void fl_set_working_dir(const gchar *dir) { gchar *aux; if (dir == NULL || strcmp(working_dir->str, dir) == 0) return; /* set the new working_dir */ g_string_assign(working_dir, dir); expand_dir(working_dir); aux = str_filename_to_utf8(working_dir->str, NULL); if (aux == NULL) { /* if we can't convert to UTF-8, leave it as is (let Gtk do the complaining...) */ g_string_assign(working_dir_utf8, dir); } else { g_string_assign(working_dir_utf8, aux); free(aux); } gtk_entry_set_text(ent_wd, working_dir_utf8->str); /* update the directory mru list */ mru_add(dir_mru, working_dir_utf8->str); gtk_combo_box_text_remove_all(combo_wd); g_list_foreach(GLIST(dir_mru->list), glist_2_combo, combo_wd); if (check_working_dir()) load_file_list(); else clear_file_list(); }
void mru_set_first(MRU_t *mru, const gchar *filename) { GList *link = mru_find_link(mru, filename); if (link) mru->list = g_list_prepend(g_list_remove_link(mru->list, link), link->data); else mru_add(mru, filename); }
void fl_set_working_dir_utf8(const gchar *dir) { gchar *aux; if (dir == NULL || strcmp(working_dir_utf8->str, dir) == 0) return; /* set the new working_dir */ g_string_assign(working_dir_utf8, dir); aux = str_filename_from_utf8(working_dir_utf8->str, NULL); if (aux == NULL) { /* if we can't convert from UTF-8, leave it as is (loading from the filesystem will just fail) */ g_string_assign(working_dir, dir); } else { g_string_assign(working_dir, aux); free(aux); } if (expand_dir(working_dir)) { // need to reflect back to utf aux = str_filename_to_utf8(working_dir->str, NULL); if (aux != NULL) g_string_assign(working_dir_utf8, aux); free(aux); } gtk_entry_set_text(ent_wd, working_dir_utf8->str); /* update the directory mru list */ mru_add(dir_mru, working_dir_utf8->str); gtk_combo_box_text_remove_all(combo_wd); g_list_foreach(GLIST(dir_mru->list), glist_2_combo, combo_wd); if (check_working_dir()) load_file_list(); else clear_file_list(); }