/** * Callback function to toggle selected LDIF field. * \param clist List to update. * \param event Event object. * \param data Data. */ static gboolean imp_ldif_field_list_toggle( GtkCMCList *clist, GdkEventButton *event, gpointer data ) { Ldif_FieldRec *rec; gboolean toggle = FALSE; if( ! event ) return FALSE; if( impldif_dlg.rowIndSelect < 0 ) return FALSE; if( event->button == 1 ) { /* If single click in select column */ if( event->type == GDK_BUTTON_PRESS ) { gint x = event->x; gint y = event->y; gint row, col; if (!gtk_cmclist_get_selection_info( clist, x, y, &row, &col )) return FALSE; if( col != FIELD_COL_SELECT ) return FALSE; if( row > impldif_dlg.rowCount ) return FALSE; /* Set row */ impldif_dlg.rowIndSelect = row; toggle = TRUE; } /* If double click anywhere in row */ else if( event->type == GDK_2BUTTON_PRESS ) { toggle = TRUE; } } /* Toggle field selection */ if( toggle ) { rec = gtk_cmclist_get_row_data( clist, impldif_dlg.rowIndSelect ); if( rec ) { ldif_field_toggle( rec ); imp_ldif_update_row( clist ); } } return FALSE; }
/* clist/ctree clear old selection on click (gtk2 only) * - intercept all button clicks (always return TRUE) * - only allow left button single click * - handle click on expander * - update "subscribed" list and un-/select row */ static gboolean button_press_cb(GtkCMCTree *ctree, GdkEventButton *button, gpointer data) { gint row, col; GtkCMCTreeNode *node; NewsGroupInfo *ginfo; GSList *list; if (button->type != GDK_BUTTON_PRESS) return TRUE; if (button->button != 1) return TRUE; if (button->window != GTK_CMCLIST(ctree)->clist_window) return TRUE; if (!gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree), button->x, button->y, &row, &col)) return TRUE; node = gtk_cmctree_node_nth(ctree, row); if (!node) return TRUE; if (gtk_cmctree_is_hot_spot(ctree, button->x, button->y)) { gtk_cmctree_toggle_expansion(ctree, node); return TRUE; } ginfo = gtk_cmctree_node_get_row_data(ctree, node); if (!ginfo) return TRUE; list = g_slist_find_custom(subscribed, ginfo->name, (GCompareFunc)g_ascii_strcasecmp); if (list) { g_free(list->data); subscribed = g_slist_remove(subscribed, list->data); gtk_cmclist_unselect_row(GTK_CMCLIST(ctree), row, 0); } else { subscribed = g_slist_append(subscribed, g_strdup(ginfo->name)); gtk_cmclist_select_row(GTK_CMCLIST(ctree), row, 0); } return TRUE; }