static void clist_click_column(GtkCList *clist, gint column, gpointer data) { if (ui_layout.sortcol == column) { ui_layout.sortdir = -(ui_layout.sortdir); } else { ui_layout.sortcol = column; ui_layout.sortdir = 1; } gtk_clist_set_sort_column(clist, ui_layout.sortcol); gtk_clist_set_sort_type(clist, ui_layout.sortdir == 1 ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING); if (column == 1) { gtk_clist_set_compare_func(clist, statuscmp); } else { /* Just use the default compare function for the rest of the * columns */ gtk_clist_set_compare_func(clist, NULL); } gtk_clist_sort(clist); }
void on_clist_dbg_property_click_column(GtkCList *clist, gint column, gpointer unused_udata) { gboolean do_sort = FALSE; (void) unused_udata; g_assert(column >= 0 && column < num_dbg_cols); switch ((enum dbg_cols) column) { case dbg_col_saved: gtk_clist_set_compare_func(clist, dbg_property_cmp_saved); dbg_property_cmp_saved_inverted = !dbg_property_cmp_saved_inverted; do_sort = TRUE; break; case dbg_col_type: gtk_clist_set_compare_func(clist, dbg_property_cmp_type); dbg_property_cmp_type_inverted = !dbg_property_cmp_type_inverted; do_sort = TRUE; break; case dbg_col_name: gtk_clist_set_compare_func(clist, dbg_property_cmp_name); dbg_property_cmp_name_inverted = !dbg_property_cmp_name_inverted; do_sort = TRUE; break; case dbg_col_value: /* Don't sort by values */ break; case num_dbg_cols: g_assert_not_reached(); } if (do_sort) gtk_clist_sort(clist); }
/* Public functions */ G_GNUC_COLD void upload_stats_gui_init(void) { enum c_us i; for (i = 0; i < c_us_num; i++) { gboolean justify_left = FALSE; switch (i) { case c_us_filename: justify_left = TRUE; break; case c_us_size: justify_left = FALSE; break; case c_us_attempts: justify_left = FALSE; break; case c_us_complete: justify_left = FALSE; break; case c_us_norm: justify_left = FALSE; break; case c_us_rtime: justify_left = TRUE; break; case c_us_dtime: justify_left = TRUE; break; case c_us_num: g_assert_not_reached(); } gtk_clist_set_column_justification(clist_ul_stats(), i, justify_left ? GTK_JUSTIFY_LEFT : GTK_JUSTIFY_RIGHT); } clist_restore_widths(clist_ul_stats(), PROP_UL_STATS_COL_WIDTHS); gtk_clist_set_compare_func(clist_ul_stats(), compare_ul_norm); }
/*********************************************************************** * Create * ***********************************************************************/ GtkWidget *widget_table_create( AttributeSet *Attr, tag_attr *attr, gint Type) { GList *element; GtkWidget *widget; gchar *value; gint column; gint sort_function; list_t *sliced; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif #if !GTK_CHECK_VERSION(3,0,0) /* gtk3: Deprecated in gtk2 and now gone */ if (attributeset_is_avail(Attr, ATTR_LABEL)) { sliced = linecutter(g_strdup(attributeset_get_first( &element, Attr, ATTR_LABEL)), '|'); widget = gtk_clist_new_with_titles(sliced->n_lines, sliced->line); if (sliced) list_t_free(sliced); /* Free linecutter memory */ } else { widget = gtk_clist_new(1); /* 1 column */ } if (attr) { /* Get sort-function (custom) */ if ((value = get_tag_attribute(attr, "sort-function"))) { sort_function = atoi(value); if (sort_function == 1) { gtk_clist_set_compare_func(GTK_CLIST(widget), widget_table_natcmp); } else if (sort_function == 2) { gtk_clist_set_compare_func(GTK_CLIST(widget), widget_table_natcasecmp); } } /* Get sort-type (auto-sort will require this preset) */ if ((value = get_tag_attribute(attr, "sort-type"))) { gtk_clist_set_sort_type(GTK_CLIST(widget), atoi(value)); } /* Get sort-column (custom) */ if ((value = get_tag_attribute(attr, "sort-column"))) { gtk_clist_set_sort_column(GTK_CLIST(widget), atoi(value)); } /* Get auto-sort (custom) */ if ((value = get_tag_attribute(attr, "auto-sort")) && ((strcasecmp(value, "true") == 0) || (strcasecmp(value, "yes") == 0) || (atoi(value) == 1))) { gtk_clist_set_auto_sort(GTK_CLIST(widget), TRUE); } else { gtk_clist_set_auto_sort(GTK_CLIST(widget), FALSE); } /* Get column-header-active (custom) */ if ((value = get_tag_attribute(attr, "column-header-active"))) { sliced = linecutter(g_strdup(value), '|'); for (column = 0; column < sliced->n_lines; column++) { if ((strcasecmp(sliced->line[column], "true") == 0) || (strcasecmp(sliced->line[column], "yes") == 0) || (atoi(sliced->line[column]) == 1)) { gtk_clist_column_title_active(GTK_CLIST(widget), column); } else { gtk_clist_column_title_passive(GTK_CLIST(widget), column); } } if (sliced) list_t_free(sliced); /* Free linecutter memory */ } /* Get column-visible (custom) */ if ((value = get_tag_attribute(attr, "column-visible"))) { sliced = linecutter(g_strdup(value), '|'); for (column = 0; column < sliced->n_lines; column++) { if ((strcasecmp(sliced->line[column], "true") == 0) || (strcasecmp(sliced->line[column], "yes") == 0) || (atoi(sliced->line[column]) == 1)) { gtk_clist_set_column_visibility(GTK_CLIST(widget), column, TRUE); } else { gtk_clist_set_column_visibility(GTK_CLIST(widget), column, FALSE); } } if (sliced) list_t_free(sliced); /* Free linecutter memory */ } } #else fprintf(stderr, "%s(): The table (GtkCList) widget has been removed from GTK+ 3 and tree is recommended as a replacement.\n", __func__); exit(EXIT_FAILURE); #endif #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif return widget; }