gboolean addressbook_foldersel_selection( AddressIndex *addrIndex, AddressBookFile **book, ItemFolder **folder, const gchar* path) { FolderPathMatch folder_path_match = { NULL, FALSE, 0, NULL }; gboolean retVal = FALSE; addressbook_foldersel_cancelled = FALSE; if ( ! addressbook_foldersel_dlg.window ) addressbook_foldersel_create(); gtk_widget_grab_focus(addressbook_foldersel_dlg.ok_btn); gtk_widget_show(addressbook_foldersel_dlg.window); manage_window_set_transient(GTK_WINDOW(addressbook_foldersel_dlg.window)); gtk_window_set_modal(GTK_WINDOW(addressbook_foldersel_dlg.window), TRUE); addressbook_foldersel_dlg.fiSelected = NULL; /* split the folder path we've received, we'll try to match this path, subpath by subpath against the book/folder structure in order to select the folder that corresponds to what we received */ if ( path != NULL ) { if ( g_utf8_collate(path, _("Any")) == 0 || strcasecmp(path, "Any") ==0 || *path == '\0' ) /* consider "Any" (both translated or untranslated forms) and "" as valid addressbook roots */ folder_path_match.matched = TRUE; else folder_path_match.folder_path = g_strsplit( path, "/", 256 ); } addressbook_foldersel_load_data( addrIndex, &folder_path_match ); if ( folder_path_match.folder_path != NULL && folder_path_match.matched == FALSE) g_warning("addressbook_foldersel_load_data: couldn't match book/folder path '%s'", path); g_strfreev( folder_path_match.folder_path ); if ( folder_path_match.node != NULL) gtk_cmctree_select( GTK_CMCTREE( addressbook_foldersel_dlg.tree_folder ), GTK_CMCTREE_NODE( folder_path_match.node ) ); else gtk_cmclist_select_row( GTK_CMCLIST( addressbook_foldersel_dlg.tree_folder ), 0, 0 ); gtk_widget_show(addressbook_foldersel_dlg.window); gtk_main(); gtk_widget_hide( addressbook_foldersel_dlg.window ); gtk_window_set_modal(GTK_WINDOW(addressbook_foldersel_dlg.window), FALSE); if ( ! addressbook_foldersel_cancelled ) { *book = NULL; *folder = NULL; if ( addressbook_foldersel_dlg.fiSelected ) { *book = addressbook_foldersel_dlg.fiSelected->book; *folder = addressbook_foldersel_dlg.fiSelected->folder; retVal = TRUE; } } gtk_cmclist_clear( GTK_CMCLIST( addressbook_foldersel_dlg.tree_folder ) ); return retVal; }
static void grouplist_dialog_set_list(const gchar *pattern, gboolean refresh) { static GdkCursor *watch_cursor = NULL; GSList *cur; GtkCMCTreeNode *node; GPatternSpec *pspec; GdkWindow *window; if (locked) return; locked = TRUE; if (!pattern || *pattern == '\0') pattern = "*"; if (!watch_cursor) watch_cursor = gdk_cursor_new(GDK_WATCH); window = gtk_widget_get_window(dialog); gdk_window_set_cursor(window, watch_cursor); main_window_cursor_wait(mainwindow_get_mainwindow()); GTK_EVENTS_FLUSH(); if (refresh) { ack = TRUE; grouplist_clear(); recv_set_ui_func(grouplist_recv_func, NULL); group_list = news_get_group_list(news_folder); group_list = g_slist_reverse(group_list); recv_set_ui_func(NULL, NULL); if (group_list == NULL && ack == TRUE) { alertpanel_error(_("Can't retrieve newsgroup list.")); locked = FALSE; gdk_window_set_cursor(window, NULL); main_window_cursor_normal(mainwindow_get_mainwindow()); return; } } else gtk_cmclist_clear(GTK_CMCLIST(ctree)); gtk_entry_set_text(GTK_ENTRY(entry), pattern); grouplist_hash_init(); gtk_cmclist_freeze(GTK_CMCLIST(ctree)); pspec = g_pattern_spec_new(pattern); for (cur = group_list; cur != NULL ; cur = cur->next) { NewsGroupInfo *ginfo = (NewsGroupInfo *)cur->data; if (g_pattern_match_string(pspec, ginfo->name)) { node = grouplist_create_branch(ginfo, pattern); if (g_slist_find_custom(subscribed, ginfo->name, (GCompareFunc)g_ascii_strcasecmp) != NULL) gtk_cmctree_select(GTK_CMCTREE(ctree), node); } } for (cur = subscribed; cur; cur = g_slist_next(cur)) grouplist_expand_upwards(GTK_CMCTREE(ctree), (gchar *)cur->data); g_pattern_spec_free(pspec); gtk_cmclist_thaw(GTK_CMCLIST(ctree)); grouplist_hash_done(); gtk_label_set_text(GTK_LABEL(status_label), _("Done.")); gdk_window_set_cursor(window, NULL); main_window_cursor_normal(mainwindow_get_mainwindow()); locked = FALSE; }