37 #include <glib/gi18n.h> 38 #include <gdk/gdkkeysyms.h> 46 #include "gnc-cell-renderer-text-view.h" 49 #include "dialog-utils.h" 54 #define STATE_KEY "state-key" 57 #define STATE_KEY_SORT_COLUMN "sort_column" 58 #define STATE_KEY_SORT_ORDER "sort_order" 59 #define STATE_KEY_COLUMN_ORDER "column_order" 64 #define STATE_KEY_SUFF_VISIBLE "visible" 65 #define STATE_KEY_SUFF_WIDTH "width" 71 PROP_SHOW_COLUMN_MENU,
77 static QofLogModule log_module = GNC_MOD_GUI;
80 static void gnc_tree_view_constructed (GObject *
object);
81 static void gnc_tree_view_finalize (GObject *
object);
82 static void gnc_tree_view_destroy (GtkWidget *widget);
83 static void gnc_tree_view_set_property (GObject *
object,
87 static void gnc_tree_view_get_property (GObject *
object,
91 static gboolean gnc_tree_view_drop_ok_cb (GtkTreeView *view,
92 GtkTreeViewColumn *column,
93 GtkTreeViewColumn *prev_column,
94 GtkTreeViewColumn *next_column,
96 static void gnc_tree_view_build_column_menu (GncTreeView *view);
97 static void gnc_tree_view_select_column_cb (GtkTreeViewColumn *column,
99 static gchar *gnc_tree_view_get_sort_order (GncTreeView *view);
100 static gchar *gnc_tree_view_get_sort_column (GncTreeView *view);
101 static gchar **gnc_tree_view_get_column_order (GncTreeView *view,
109 GtkTreeViewColumn *column_menu_column;
110 GtkWidget *column_menu;
111 gboolean show_column_menu;
112 GtkWidget *column_menu_icon_box;
115 GtkTreeModel *sort_model;
118 GFunc editing_started_cb;
119 GFunc editing_finished_cb;
120 gpointer editing_cb_data;
123 gchar *state_section;
124 gboolean seen_state_visibility;
125 gulong columns_changed_cb_id;
126 gulong sort_column_changed_cb_id;
127 gulong size_allocate_cb_id;
131 G_ADD_PRIVATE(GncTreeView))
133 #define GNC_TREE_VIEW_GET_PRIVATE(o) \ 134 ((GncTreeViewPrivate*)gnc_tree_view_get_instance_private((GncTreeView*)o)) 154 gnc_tree_view_class_init (GncTreeViewClass *klass)
156 GObjectClass *gobject_class;
157 GtkWidgetClass *gtkwidget_class;
159 gobject_class = G_OBJECT_CLASS(klass);
160 gtkwidget_class = GTK_WIDGET_CLASS(klass);
162 gobject_class->set_property = gnc_tree_view_set_property;
163 gobject_class->get_property = gnc_tree_view_get_property;
165 g_object_class_install_property (gobject_class,
167 g_param_spec_string (
"state-section",
169 "The section name in the saved state to use for (re)storing the treeview's visual state (visible columns, sort order,...",
172 g_object_class_install_property (gobject_class,
173 PROP_SHOW_COLUMN_MENU,
174 g_param_spec_boolean (
"show-column-menu",
176 "Show the column menu so user can change what columns are visible.",
181 gobject_class->constructed = gnc_tree_view_constructed;
182 gobject_class->finalize = gnc_tree_view_finalize;
185 gtkwidget_class->destroy = gnc_tree_view_destroy;
189 gnc_tree_view_update_grid_lines (gpointer prefs, gchar* pref, gpointer user_data)
191 GncTreeView *view = user_data;
192 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(view), gnc_tree_view_get_grid_lines_pref ());
196 gnc_tree_view_select_column_icon_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
198 GncTreeView *view = user_data;
200 GtkStyleContext *stylectxt = gtk_widget_get_style_context (widget);
204 if (event->button != 1)
207 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
209 gtk_style_context_get_padding (stylectxt, GTK_STATE_FLAG_NORMAL, &padding);
211 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
213 if (event->x < (gtk_widget_get_allocated_width (priv->column_menu_icon_box) + padding.left))
214 gnc_tree_view_select_column_cb (priv->column_menu_column, view);
218 if (event->x > (gtk_widget_get_allocated_width (widget) -
219 (gtk_widget_get_allocated_width (priv->column_menu_icon_box) + padding.right)))
220 gnc_tree_view_select_column_cb (priv->column_menu_column, view);
235 gnc_tree_view_init (GncTreeView *view)
238 GtkTreeViewColumn *column;
239 GtkWidget *sep, *icon;
241 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
242 priv->column_menu = NULL;
243 priv->show_column_menu = FALSE;
244 priv->sort_model = NULL;
245 priv->state_section = NULL;
246 priv->seen_state_visibility = FALSE;
247 priv->columns_changed_cb_id = 0;
248 priv->sort_column_changed_cb_id = 0;
249 priv->size_allocate_cb_id = 0;
252 gtk_widget_set_name (GTK_WIDGET(view),
"gnc-id-tree-view");
255 gtk_tree_view_set_column_drag_function (GTK_TREE_VIEW(view),
256 gnc_tree_view_drop_ok_cb, NULL, NULL);
259 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(view), gnc_tree_view_get_grid_lines_pref ());
261 gnc_tree_view_update_grid_lines, view);
263 gnc_tree_view_update_grid_lines, view);
268 icon = gtk_image_new_from_icon_name (
"pan-down-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
270 priv->column_menu_icon_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
271 gtk_box_set_homogeneous (GTK_BOX(priv->column_menu_icon_box), FALSE);
273 gtk_widget_set_margin_start (GTK_WIDGET(icon), 5);
275 gtk_box_pack_end (GTK_BOX(priv->column_menu_icon_box), icon, FALSE, FALSE, 0);
277 sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
278 gtk_box_pack_end (GTK_BOX(priv->column_menu_icon_box), sep, FALSE, FALSE, 0);
280 gtk_widget_show_all (priv->column_menu_icon_box);
284 g_object_set (G_OBJECT(column),
286 "widget", priv->column_menu_icon_box,
291 priv->column_menu_column = column;
295 GtkWidget *mybox = gtk_widget_get_parent (icon);
296 GtkWidget *walign = gtk_widget_get_parent (mybox);
297 GtkWidget *box = gtk_widget_get_parent (walign);
298 GtkWidget *button = gtk_widget_get_parent (box);
300 if (!GTK_IS_BUTTON(button))
303 g_signal_connect (G_OBJECT(column),
"clicked",
304 G_CALLBACK(gnc_tree_view_select_column_cb),
312 gtk_widget_set_events (button, GDK_BUTTON_PRESS_MASK);
314 g_signal_connect (G_OBJECT(button),
"button_press_event",
315 G_CALLBACK(gnc_tree_view_select_column_icon_cb),
319 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
329 gnc_tree_view_constructed (GObject *obj)
333 G_OBJECT_CLASS (gnc_tree_view_parent_class)->constructed (obj);
347 gnc_tree_view_finalize (GObject *
object)
349 ENTER(
"view %p",
object);
350 g_return_if_fail (
object != NULL);
351 g_return_if_fail (GNC_IS_TREE_VIEW(
object));
355 G_OBJECT_CLASS(gnc_tree_view_parent_class)->finalize (
object);
371 gnc_tree_view_destroy (GtkWidget *widget)
376 ENTER(
"view %p", widget);
377 g_return_if_fail (widget != NULL);
378 g_return_if_fail (GNC_IS_TREE_VIEW(widget));
380 view = GNC_TREE_VIEW(widget);
383 gnc_tree_view_update_grid_lines, view);
385 gnc_tree_view_update_grid_lines, view);
387 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
389 if (priv->state_section)
393 g_free (priv->state_section);
394 priv->state_section = NULL;
396 if (priv->column_menu)
398 DEBUG(
"removing column selection menu");
399 g_object_unref (priv->column_menu);
400 priv->column_menu = NULL;
403 GTK_WIDGET_CLASS(gnc_tree_view_parent_class)->destroy (widget);
424 gnc_tree_view_get_property (GObject *
object,
429 GncTreeView *view = GNC_TREE_VIEW(
object);
432 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
435 case PROP_STATE_SECTION:
436 g_value_set_string (value, priv->state_section);
438 case PROP_SHOW_COLUMN_MENU:
439 g_value_set_boolean (value, priv->show_column_menu);
442 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
457 gnc_tree_view_set_property (GObject *
object,
462 GncTreeView *view = GNC_TREE_VIEW(
object);
466 case PROP_STATE_SECTION:
469 case PROP_SHOW_COLUMN_MENU:
473 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
501 static GtkTreeViewColumn *
502 view_column_find_by_model_id (GncTreeView *view,
505 GtkTreeViewColumn *column, *found = NULL;
506 GList *column_list, *tmp;
510 column_list = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
511 for (tmp = column_list; tmp; tmp = g_list_next (tmp))
514 id = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), MODEL_COLUMN));
520 g_list_free (column_list);
540 GtkTreeViewColumn *column, *found = NULL;
541 GList *column_list, *tmp;
545 column_list = gtk_tree_view_get_columns(GTK_TREE_VIEW(view));
546 for (tmp = column_list; tmp; tmp = g_list_next (tmp))
549 name = g_object_get_data (G_OBJECT(column), PREF_NAME);
550 if (!name || (strcmp(name, wanted) != 0))
555 g_list_free (column_list);
596 gnc_tree_view_drop_ok_cb (GtkTreeView *view,
597 GtkTreeViewColumn *column,
598 GtkTreeViewColumn *prev_column,
599 GtkTreeViewColumn *next_column,
602 const gchar *pref_name;
607 if (prev_column == NULL)
612 if (next_column == NULL)
620 pref_name = g_object_get_data (G_OBJECT(prev_column), PREF_NAME);
657 gnc_tree_view_column_visible (GncTreeView *view,
658 GtkTreeViewColumn *column,
659 const gchar *pref_name)
663 const gchar *col_name = pref_name;
665 ENTER(
"column %p, name %s", column, pref_name ? pref_name :
"(null)");
666 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
669 if (g_object_get_data (G_OBJECT(column), ALWAYS_VISIBLE))
671 LEAVE(
"1, first column");
674 col_name = g_object_get_data (G_OBJECT(column), PREF_NAME);
675 DEBUG(
"col_name is %s", col_name ? col_name :
"(null)");
680 LEAVE(
"1, no pref name");
685 if (priv->state_section)
688 gchar *key = g_strdup_printf (
"%s_%s", col_name, STATE_KEY_SUFF_VISIBLE);
690 if (g_key_file_has_key (state_file, priv->state_section, key, NULL))
692 visible = g_key_file_get_boolean (state_file, priv->state_section, key, NULL);
694 LEAVE(
"%d, state defined visibility", visible);
701 (g_object_get_data (G_OBJECT(column), DEFAULT_VISIBLE) != NULL) : FALSE;
702 LEAVE(
"defaults says %d", visible);
717 gnc_tree_view_update_visibility (GtkTreeViewColumn *column,
722 g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN(column));
723 g_return_if_fail (GNC_IS_TREE_VIEW(view));
726 visible = gnc_tree_view_column_visible (view, column, NULL);
727 gtk_tree_view_column_set_visible (column, visible);
728 LEAVE(
"made %s", visible ?
"visible" :
"invisible");
742 gnc_tree_view_get_sort_order (GncTreeView *view)
744 GtkTreeModel *s_model;
747 gchar *order_str = NULL;
749 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
753 if (!gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(s_model),
757 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(s_model),
759 order_str = g_strdup (order == GTK_SORT_ASCENDING ?
"ascending" :
"descending");
760 DEBUG(
"current sort_order is %s", order_str);
774 gnc_tree_view_get_sort_column (GncTreeView *view)
776 GtkTreeModel *s_model;
777 GtkTreeViewColumn *column;
782 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
786 if (!gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(s_model),
790 column = view_column_find_by_model_id (view, current);
794 name = g_object_get_data (G_OBJECT(column), PREF_NAME);
795 DEBUG(
"current sort column is %s", name ? name :
"(NULL)");
796 return g_strdup (name);
812 gnc_tree_view_get_column_order (GncTreeView *view,
818 gchar *col_names = NULL;
819 gchar **col_str_list;
824 columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
825 for (tmp = columns; tmp; tmp = g_list_next(tmp))
827 GtkTreeViewColumn *column = tmp->data;
828 const gchar *name = g_object_get_data (G_OBJECT(column), PREF_NAME);
830 col_names = g_strdup (name);
833 gchar *col_names_prev = col_names;
834 col_names = g_strjoin (
";", col_names_prev, name, NULL);
835 g_free (col_names_prev);
840 col_str_list = g_strsplit (col_names,
";", 0);
843 g_list_free (columns);
846 LEAVE(
"column order get");
862 gnc_tree_view_set_sort_order (GncTreeView *view,
865 GtkTreeModel *s_model;
866 GtkSortType order = GTK_SORT_ASCENDING;
869 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
872 if (g_strcmp0 (name,
"descending") == 0)
873 order = GTK_SORT_DESCENDING;
874 if (!gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(s_model),
876 current = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
877 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(s_model),
879 DEBUG(
"sort_order set to %s", order == GTK_SORT_ASCENDING ?
"ascending" :
"descending");
891 gnc_tree_view_set_sort_column (GncTreeView *view,
894 GtkTreeModel *s_model;
895 GtkTreeViewColumn *column;
897 gint model_column, current;
899 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
906 gtk_tree_sortable_set_sort_column_id (
907 GTK_TREE_SORTABLE(s_model), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
913 GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), MODEL_COLUMN));
914 if (model_column == GNC_TREE_VIEW_COLUMN_DATA_NONE)
917 if (!gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE(s_model),
919 order = GTK_SORT_ASCENDING;
921 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(s_model),
922 model_column, order);
923 DEBUG(
"sort column set to %s", name);
939 gnc_tree_view_set_column_order (GncTreeView *view,
940 gchar **column_names,
943 GtkTreeViewColumn *column, *prev;
951 for (idx = 0; idx < length; idx++)
953 const gchar *name = column_names [idx];
957 columns = g_slist_append (columns, column);
961 for (prev = NULL, tmp = columns; tmp; tmp = g_slist_next (tmp))
964 gtk_tree_view_move_column_after (GTK_TREE_VIEW(view), column, prev);
969 g_slist_free (columns);
970 LEAVE(
"column order set");
987 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
988 if (!priv->state_section)
990 LEAVE(
"no state section");
994 g_key_file_remove_group (state_file, priv->state_section, NULL);
995 g_free (priv->state_section);
996 priv->state_section = NULL;
1009 const gchar *section)
1012 GKeyFile *state_file;
1014 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1016 ENTER(
"view %p, section %s", view, section);
1018 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1021 if (priv->state_section)
1026 LEAVE(
"cleared state section");
1031 priv->state_section = g_strdup (section);
1034 if (g_key_file_has_group (state_file, priv->state_section))
1036 gsize num_keys, idx;
1037 gchar **keys = g_key_file_get_keys (state_file, priv->state_section, &num_keys, NULL);
1038 for (idx = 0; idx < num_keys; idx++)
1040 gchar *key = keys[idx];
1041 if (g_strcmp0 (key, STATE_KEY_SORT_COLUMN) == 0)
1043 gchar *name = g_key_file_get_string (state_file, priv->state_section,
1045 gnc_tree_view_set_sort_column (view, name);
1048 else if (g_strcmp0 (key, STATE_KEY_SORT_ORDER) == 0)
1050 gchar *name = g_key_file_get_string (state_file, priv->state_section,
1052 gnc_tree_view_set_sort_order (view, name);
1055 else if (g_strcmp0 (key, STATE_KEY_COLUMN_ORDER) == 0)
1058 gchar **columns = g_key_file_get_string_list (state_file, priv->state_section,
1059 key, &length, NULL);
1060 gnc_tree_view_set_column_order (view, columns, length);
1061 g_strfreev (columns);
1067 gboolean known = FALSE;
1068 gchar *column_name = g_strdup (key);
1069 gchar *type_name = g_strrstr (column_name,
"_");
1071 if (type_name != NULL)
1073 *type_name++ =
'\0';
1075 if (g_strcmp0 (type_name, STATE_KEY_SUFF_VISIBLE) == 0)
1081 if (!g_object_get_data (G_OBJECT (column), ALWAYS_VISIBLE))
1083 gtk_tree_view_column_set_visible (column,
1084 g_key_file_get_boolean (state_file, priv->state_section, key, NULL));
1088 else if (g_strcmp0 (type_name, STATE_KEY_SUFF_WIDTH) == 0)
1090 gint width = g_key_file_get_integer (state_file, priv->state_section, key, NULL);
1095 if (width && (width != gtk_tree_view_column_get_width (column)))
1097 gtk_tree_view_column_set_fixed_width (column, width);
1102 DEBUG (
"Ignored key %s", key);
1104 g_free (column_name);
1112 gnc_tree_view_build_column_menu (view);
1113 LEAVE (
"set state section");
1127 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1129 priv = GNC_TREE_VIEW_GET_PRIVATE (view);
1130 return priv->state_section;
1137 ENTER(
"view %p", view);
1138 g_return_if_fail (view != NULL);
1139 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1141 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1143 if (priv->state_section)
1146 GList *column_list, *tmp;
1149 gchar *sort_column = gnc_tree_view_get_sort_column (view);
1150 gchar *sort_order = gnc_tree_view_get_sort_order (view);
1151 gchar **col_order = gnc_tree_view_get_column_order (view, &num_cols);
1154 if (sort_column && (g_strcmp0 (sort_column,
"name") != 0))
1155 g_key_file_set_string (state_file, priv->state_section, STATE_KEY_SORT_COLUMN, sort_column);
1156 else if (g_key_file_has_key (state_file, priv->state_section, STATE_KEY_SORT_COLUMN, NULL))
1157 g_key_file_remove_key (state_file, priv->state_section, STATE_KEY_SORT_COLUMN, NULL);
1158 g_free (sort_column);
1162 if (g_strcmp0 (sort_order,
"descending") == 0)
1163 g_key_file_set_string (state_file, priv->state_section, STATE_KEY_SORT_ORDER, sort_order);
1164 else if (g_key_file_has_key (state_file, priv->state_section, STATE_KEY_SORT_ORDER, NULL))
1165 g_key_file_remove_key (state_file, priv->state_section, STATE_KEY_SORT_ORDER, NULL);
1166 g_free (sort_order);
1168 if (col_order && (num_cols > 0))
1169 g_key_file_set_string_list (state_file, priv->state_section, STATE_KEY_COLUMN_ORDER,
1170 (
const gchar**) col_order, num_cols);
1171 else if (g_key_file_has_key (state_file, priv->state_section, STATE_KEY_COLUMN_ORDER, NULL))
1172 g_key_file_remove_key (state_file, priv->state_section, STATE_KEY_COLUMN_ORDER, NULL);
1174 g_strfreev (col_order);
1178 column_list = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1179 for (tmp = column_list; tmp; tmp = g_list_next (tmp))
1181 GtkTreeViewColumn *column = tmp->data;
1183 const gchar *name = g_object_get_data (G_OBJECT(column), PREF_NAME);
1187 if (!g_object_get_data (G_OBJECT(column), ALWAYS_VISIBLE))
1189 key = g_strjoin (
"_", name, STATE_KEY_SUFF_VISIBLE, NULL);
1190 g_key_file_set_boolean (state_file, priv->state_section, key,
1191 gtk_tree_view_column_get_visible (column));
1195 key = g_strjoin (
"_", name, STATE_KEY_SUFF_WIDTH, NULL);
1196 if (g_object_get_data (G_OBJECT(column),
"default-width") &&
1197 (GPOINTER_TO_INT((g_object_get_data (G_OBJECT(column),
"default-width")))
1198 != gtk_tree_view_column_get_width (column)))
1200 g_key_file_set_integer (state_file, priv->state_section, key,
1201 gtk_tree_view_column_get_width (column));
1203 else if (g_key_file_has_key (state_file, priv->state_section, key, NULL))
1204 g_key_file_remove_key (state_file, priv->state_section, key, NULL);
1207 g_list_free (column_list);
1239 gnc_tree_view_create_menu_item (GtkTreeViewColumn *column,
1244 const gchar *column_name, *pref_name;
1249 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1250 if (!priv->state_section)
1256 pref_name = g_object_get_data (G_OBJECT(column), PREF_NAME);
1264 if (!priv->column_menu)
1266 priv->column_menu = gtk_menu_new();
1267 g_object_ref_sink (priv->column_menu);
1271 column_name = g_object_get_data (G_OBJECT(column), REAL_TITLE);
1273 column_name = gtk_tree_view_column_get_title (column);
1274 widget = gtk_check_menu_item_new_with_label (column_name);
1275 gtk_menu_shell_append (GTK_MENU_SHELL(priv->column_menu), widget);
1278 if (g_object_get_data (G_OBJECT(column), ALWAYS_VISIBLE))
1280 g_object_set_data (G_OBJECT(widget), ALWAYS_VISIBLE, GINT_TO_POINTER(1));
1281 gtk_widget_set_sensitive (widget, FALSE);
1284 binding = g_object_bind_property (G_OBJECT(widget),
"active", G_OBJECT(column),
"visible", 0);
1285 g_object_set_data (G_OBJECT(widget),
"column-binding", binding);
1288 key = g_strdup_printf (
"%s_%s", pref_name, STATE_KEY_SUFF_VISIBLE);
1289 g_object_set_data_full (G_OBJECT(widget), STATE_KEY, key, g_free);
1294 column_menu_sort (GtkTreeViewColumn *columna, GtkTreeViewColumn *columnb)
1296 const gchar *column_namea = g_object_get_data (G_OBJECT(columna), REAL_TITLE);
1297 const gchar *column_nameb = g_object_get_data (G_OBJECT(columnb), REAL_TITLE);
1300 column_namea = gtk_tree_view_column_get_title (columna);
1303 column_nameb = gtk_tree_view_column_get_title (columnb);
1320 gnc_tree_view_build_column_menu (GncTreeView *view)
1325 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1327 ENTER(
"view %p", view);
1328 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1331 if (priv->column_menu)
1333 g_object_unref (priv->column_menu);
1334 priv->column_menu = NULL;
1337 if (priv->show_column_menu && priv->state_section)
1340 if (priv->column_menu_column)
1341 gtk_tree_view_column_set_visible (priv->column_menu_column, TRUE);
1344 column_list = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1345 column_list = g_list_sort (column_list, (GCompareFunc)column_menu_sort);
1346 g_list_foreach (column_list, (GFunc)gnc_tree_view_create_menu_item, view);
1347 g_list_free (column_list);
1352 if (priv->column_menu_column)
1353 gtk_tree_view_column_set_visible (priv->column_menu_column, FALSE);
1355 LEAVE(
"menu: show %d, section %s", priv->show_column_menu,
1356 priv->state_section ? priv->state_section :
"(null)");
1369 gnc_tree_view_update_column_menu_item (GtkCheckMenuItem *checkmenuitem,
1374 g_return_if_fail (GTK_IS_CHECK_MENU_ITEM(checkmenuitem));
1375 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1377 if (g_object_get_data (G_OBJECT(checkmenuitem), ALWAYS_VISIBLE))
1383 GBinding *binding = g_object_get_data (G_OBJECT(checkmenuitem),
"column-binding");
1384 GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(g_binding_get_target (binding));
1386 visible = gtk_tree_view_column_get_visible (column);
1388 gtk_check_menu_item_set_active (checkmenuitem, visible);
1404 gnc_tree_view_select_column_cb (GtkTreeViewColumn *column,
1410 g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN(column));
1411 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1413 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1414 menu = priv->column_menu;
1419 gtk_container_foreach (GTK_CONTAINER(menu),
1420 (GtkCallback)gnc_tree_view_update_column_menu_item,
1424 gtk_widget_show_all (menu);
1427 gtk_menu_popup_at_pointer (GTK_MENU(priv->column_menu), NULL);
1432 gchar *first_column_name,
1435 GtkTreeViewColumn *column;
1436 GList *columns, *tmp;
1437 gchar *name, *pref_name;
1440 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1442 va_start (args, first_column_name);
1443 name = first_column_name;
1446 columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1447 for (tmp = columns; tmp; tmp = g_list_next (tmp))
1450 pref_name = g_object_get_data (G_OBJECT(column), PREF_NAME);
1451 if (pref_name != NULL)
1452 gtk_tree_view_column_set_expand (column, FALSE);
1454 g_list_free(columns);
1457 while (name != NULL)
1462 gtk_tree_view_column_set_expand (column, TRUE);
1464 name = va_arg (args, gchar*);
1475 update_control_cell_renderers_background (GncTreeView *view, GtkTreeViewColumn *col,
1476 gint column, GtkTreeCellDataFunc func )
1479 GtkCellRenderer *cell;
1482 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(col));
1485 for (node = renderers; node; node = node->next)
1489 gtk_tree_view_column_add_attribute (col, cell,
"cell-background", column);
1491 gtk_tree_view_column_set_cell_data_func (col, cell, func, view, NULL);
1493 g_list_free (renderers);
1504 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1506 ENTER(
"view %p, column %d, func %p", view, column, func);
1507 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1509 update_control_cell_renderers_background (view, priv->column_menu_column, column, func);
1522 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1524 ENTER(
"view %p, sort_model %p", view, s_model);
1525 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1527 priv->sort_model = s_model;
1544 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1546 ENTER(
"view %p, show menu %d", view, visible);
1547 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1548 priv->show_column_menu = visible;
1549 gnc_tree_view_build_column_menu (view);
1564 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), FALSE);
1566 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1567 return (priv->show_column_menu);
1577 gnc_tree_view_count_visible_columns (GncTreeView *view)
1579 GList *columns, *node;
1582 columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1583 for (node = columns; node; node = node->next)
1585 GtkTreeViewColumn *col = GTK_TREE_VIEW_COLUMN(node->data);
1587 if (g_object_get_data (G_OBJECT(col), DEFAULT_VISIBLE) ||
1588 g_object_get_data (G_OBJECT(col), ALWAYS_VISIBLE))
1591 g_list_free (columns);
1599 GtkTreeViewColumn *column;
1601 gboolean hide_menu_column;
1603 g_return_if_fail (GNC_IS_TREE_VIEW(view));
1608 columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(view));
1609 g_list_foreach (columns, (GFunc)gnc_tree_view_update_visibility, view);
1610 g_list_free (columns);
1612 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1613 if (priv->state_section)
1614 priv->seen_state_visibility = TRUE;
1618 hide_menu_column = (gnc_tree_view_count_visible_columns (view) == 1);
1619 column = gtk_tree_view_get_column (GTK_TREE_VIEW(view), 0);
1620 gtk_tree_view_column_set_expand (column, hide_menu_column);
1621 gtk_tree_view_column_set_visible (priv->column_menu_column, !hide_menu_column);
1657 gnc_tree_view_column_properties (GncTreeView *view,
1658 GtkTreeViewColumn *column,
1659 const gchar *pref_name,
1663 GtkTreeIterCompareFunc column_sort_fn)
1666 GtkTreeModel *s_model;
1672 g_object_set_data (G_OBJECT(column), PREF_NAME, (gpointer)pref_name);
1673 if (data_column == 0)
1674 g_object_set_data (G_OBJECT(column), ALWAYS_VISIBLE, GINT_TO_POINTER(1));
1675 g_object_set_data (G_OBJECT(column), MODEL_COLUMN,
1676 GINT_TO_POINTER(data_column));
1679 visible = gnc_tree_view_column_visible (view, NULL, pref_name);
1682 g_object_set (G_OBJECT(column),
1684 "resizable", resizable && pref_name != NULL,
1685 "reorderable", pref_name != NULL,
1689 if (default_width == 0)
1692 g_object_set (G_OBJECT(column),
1693 "sizing", GTK_TREE_VIEW_COLUMN_AUTOSIZE,
1703 width = default_width + 10;
1708 g_object_set (G_OBJECT(column),
1709 "sizing", GTK_TREE_VIEW_COLUMN_FIXED,
1710 "fixed-width", width,
1717 g_object_set_data (G_OBJECT(column),
1718 "default-width", GINT_TO_POINTER(width));
1721 s_model = gtk_tree_view_get_model (GTK_TREE_VIEW(view));
1722 if (GTK_IS_TREE_SORTABLE(s_model))
1724 gtk_tree_view_column_set_sort_column_id (column, data_column);
1727 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE(s_model),
1728 data_column, column_sort_fn,
1729 GINT_TO_POINTER(data_column),
1735 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
1736 if (priv->sort_model != NULL)
1738 gtk_tree_view_column_set_sort_column_id (column, data_column);
1741 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE(priv->sort_model),
1742 data_column, column_sort_fn,
1751 gnc_tree_view_create_menu_item (column, view);
1767 const gchar *column_title,
1768 const gchar *column_short_title,
1769 const gchar *pref_name,
1770 gint model_data_column,
1771 gint model_visibility_column,
1772 GtkTreeIterCompareFunc column_sort_fn,
1773 renderer_toggled toggle_edited_cb)
1775 GtkTreeViewColumn *column;
1776 GtkCellRenderer *renderer;
1778 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1780 renderer = gtk_cell_renderer_toggle_new ();
1781 if (!toggle_edited_cb)
1783 gtk_cell_renderer_toggle_set_activatable (GTK_CELL_RENDERER_TOGGLE(renderer), FALSE);
1786 gtk_tree_view_column_new_with_attributes (column_short_title,
1788 "active", model_data_column,
1792 g_object_set_data_full (G_OBJECT(column), REAL_TITLE,
1793 g_strdup(column_title), g_free);
1794 if (toggle_edited_cb)
1795 g_signal_connect (G_OBJECT(renderer),
"toggled",
1796 G_CALLBACK(toggle_edited_cb), view);
1798 if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
1799 gtk_tree_view_column_add_attribute (column, renderer,
1800 "visible", model_visibility_column);
1803 gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
1804 0, FALSE, column_sort_fn);
1809 gtk_widget_set_tooltip_text (gtk_tree_view_column_get_button (column), column_title);
1815 renderer_editing_canceled_cb (GtkCellRenderer *renderer, gpointer user_data)
1817 GncTreeView *view = user_data;
1819 if (priv->editing_finished_cb)
1820 (priv->editing_finished_cb)(view, priv->editing_cb_data);
1824 renderer_editing_started_cb (GtkCellRenderer *renderer,
1825 GtkCellEditable *editable, gchar *path, gpointer user_data)
1827 GncTreeView *view = user_data;
1829 if (priv->editing_started_cb)
1830 (priv->editing_started_cb)(view, priv->editing_cb_data);
1834 renderer_edited_cb (GtkCellRendererText *renderer, gchar *path,
1835 gchar *new_text, gpointer user_data)
1837 GncTreeView *view = user_data;
1839 if (priv->editing_finished_cb)
1840 (priv->editing_finished_cb)(view, priv->editing_cb_data);
1844 static GtkTreeViewColumn *
1845 add_text_column_variant (GncTreeView *view, GtkCellRenderer *renderer,
1846 const gchar *column_title,
1847 const gchar *pref_name,
1848 const gchar *icon_name,
1849 const gchar *sizing_text,
1850 gint model_data_column,
1851 gint model_visibility_column,
1852 GtkTreeIterCompareFunc column_sort_fn)
1854 GtkTreeViewColumn *column;
1855 PangoLayout* layout;
1856 int default_width, title_width;
1858 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1860 column = gtk_tree_view_column_new ();
1861 gtk_tree_view_column_set_title (column, column_title);
1866 GtkCellRenderer *renderer_pix = gtk_cell_renderer_pixbuf_new ();
1867 g_object_set (renderer_pix,
"icon-name", icon_name, NULL);
1868 gtk_tree_view_column_pack_start (column, renderer_pix, FALSE);
1872 gtk_tree_view_column_pack_start (column, renderer, TRUE);
1875 g_signal_connect (G_OBJECT(renderer),
"editing-canceled",
1876 (GCallback)renderer_editing_canceled_cb, view);
1878 g_signal_connect (G_OBJECT(renderer),
"editing-started",
1879 (GCallback)renderer_editing_started_cb, view);
1881 g_signal_connect (G_OBJECT(renderer),
"edited",
1882 (GCallback)renderer_edited_cb, view);
1885 if (model_data_column != GNC_TREE_VIEW_COLUMN_DATA_NONE)
1886 gtk_tree_view_column_add_attribute (column, renderer,
1887 "text", model_data_column);
1888 if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
1889 gtk_tree_view_column_add_attribute (column, renderer,
1890 "visible", model_visibility_column);
1893 layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), column_title);
1894 pango_layout_get_pixel_size (layout, &title_width, NULL);
1895 g_object_unref (layout);
1896 layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), sizing_text);
1897 pango_layout_get_pixel_size (layout, &default_width, NULL);
1898 g_object_unref (layout);
1899 default_width = MAX(default_width, title_width);
1901 default_width += 10;
1902 gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
1903 default_width, TRUE, column_sort_fn);
1920 const gchar *column_title,
1921 const gchar *pref_name,
1922 const gchar *icon_name,
1923 const gchar *sizing_text,
1924 gint model_data_column,
1925 gint model_visibility_column,
1926 GtkTreeIterCompareFunc column_sort_fn)
1928 GtkCellRenderer *renderer;
1930 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1932 renderer = gtk_cell_renderer_text_new ();
1934 return add_text_column_variant (view, renderer,
1935 column_title, pref_name,
1936 icon_name, sizing_text,
1938 model_visibility_column,
1952 const gchar *column_title,
1953 const gchar *pref_name,
1954 const gchar *icon_name,
1955 const gchar *sizing_text,
1956 gint model_data_column,
1957 gint model_visibility_column,
1958 GtkTreeIterCompareFunc column_sort_fn)
1960 GtkCellRenderer *renderer;
1962 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1964 renderer = gnc_cell_renderer_text_view_new ();
1966 return add_text_column_variant (view, renderer,
1967 column_title, pref_name,
1968 icon_name, sizing_text,
1970 model_visibility_column,
1984 const gchar *column_title,
1985 const gchar *pref_name,
1986 const gchar *sizing_text,
1987 gint model_data_column,
1988 gint model_visibility_column,
1989 GtkTreeIterCompareFunc column_sort_fn)
1991 GtkTreeViewColumn *column;
1992 PangoLayout* layout;
1993 int default_width, title_width;
1994 GtkCellRenderer *renderer;
1996 g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
1998 renderer = gtk_cell_renderer_pixbuf_new ();
2000 column = gtk_tree_view_column_new ();
2001 gtk_tree_view_column_set_title (column, column_title);
2004 gtk_tree_view_column_pack_start (column, renderer, TRUE);
2007 if (model_data_column != GNC_TREE_VIEW_COLUMN_DATA_NONE)
2008 gtk_tree_view_column_add_attribute (column, renderer,
2009 "icon-name", model_data_column);
2010 if (model_visibility_column != GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS)
2011 gtk_tree_view_column_add_attribute (column, renderer,
2012 "visible", model_visibility_column);
2015 layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), column_title);
2016 pango_layout_get_pixel_size (layout, &title_width, NULL);
2017 g_object_unref (layout);
2018 layout = gtk_widget_create_pango_layout (GTK_WIDGET(view), sizing_text);
2019 pango_layout_get_pixel_size (layout, &default_width, NULL);
2020 g_object_unref (layout);
2021 default_width = MAX(default_width, title_width);
2023 default_width += 10;
2024 gnc_tree_view_column_properties (view, column, pref_name, model_data_column,
2025 default_width, TRUE, column_sort_fn);
2035 GtkCellRenderer *cr = NULL;
2037 g_return_val_if_fail (GTK_TREE_VIEW_COLUMN(column), NULL);
2040 renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(column));
2041 if (g_list_length (renderers) > 0)
2042 cr = GTK_CELL_RENDERER(renderers->data);
2043 g_list_free (renderers);
2060 const gchar *column_title,
2061 const gchar *pref_name,
2062 const gchar *sizing_text,
2063 gint model_data_column,
2064 gint model_color_column,
2065 gint model_visibility_column,
2066 GtkTreeIterCompareFunc column_sort_fn)
2068 GtkTreeViewColumn *column;
2069 GtkCellRenderer *renderer;
2070 gfloat alignment = 1.0;
2073 NULL, sizing_text, model_data_column,
2074 model_visibility_column,
2080 if (gtk_widget_get_direction (GTK_WIDGET(view)) == GTK_TEXT_DIR_RTL)
2083 g_object_set (G_OBJECT(column),
"alignment", alignment, NULL);
2084 g_object_set (G_OBJECT(renderer),
"xalign", alignment, NULL);
2087 if (model_color_column != GNC_TREE_VIEW_COLUMN_COLOR_NONE)
2088 gtk_tree_view_column_add_attribute (column, renderer,
2089 "foreground", model_color_column);
2104 GtkTreeViewColumn *column)
2106 int n = gtk_tree_view_get_n_columns (GTK_TREE_VIEW(view));
2111 return gtk_tree_view_insert_column (GTK_TREE_VIEW(view), column, n);
2115 get_column_next_to (GtkTreeView *tv, GtkTreeViewColumn **col, gboolean backward)
2118 GtkTreeViewColumn *c = NULL;
2120 gboolean wrapped = FALSE;
2122 cols = gtk_tree_view_get_columns (tv);
2123 g_return_val_if_fail (cols != NULL, FALSE);
2125 node = g_list_find (cols, *col);
2126 g_return_val_if_fail (node, FALSE);
2129 node = backward ? node->prev : node->next;
2133 node = backward ? g_list_last (cols) : cols;
2135 c = GTK_TREE_VIEW_COLUMN (node->data);
2136 if (c && gtk_tree_view_column_get_visible (c))
2138 if (c == *col)
break;
2148 gnc_tree_view_path_is_valid (GncTreeView *view, GtkTreePath *path)
2150 GtkTreeView *tv = GTK_TREE_VIEW(view);
2151 GtkTreeModel *s_model;
2154 s_model = gtk_tree_view_get_model (tv);
2155 return gtk_tree_model_get_iter (s_model, &iter, path);
2159 gnc_tree_view_keynav (GncTreeView *view, GtkTreeViewColumn **col,
2160 GtkTreePath *path, GdkEventKey *event)
2162 GtkTreeView *tv = GTK_TREE_VIEW(view);
2166 if (event->type != GDK_KEY_PRESS)
return;
2168 switch (event->keyval)
2171 case GDK_KEY_ISO_Left_Tab:
2172 case GDK_KEY_KP_Tab:
2173 shifted =
event->state & GDK_SHIFT_MASK;
2174 if (get_column_next_to (tv, col, shifted))
2177 depth = gtk_tree_path_get_depth (path);
2180 if (!gtk_tree_path_prev (path) && depth > 1)
2182 gtk_tree_path_up (path);
2185 else if (gtk_tree_view_row_expanded (tv, path))
2187 gtk_tree_path_down (path);
2191 gtk_tree_path_next (path);
2192 if (!gnc_tree_view_path_is_valid (view, path) && depth > 2)
2194 gtk_tree_path_prev (path);
2195 gtk_tree_path_up (path);
2196 gtk_tree_path_next (path);
2198 if (!gnc_tree_view_path_is_valid (view, path) && depth > 1)
2200 gtk_tree_path_prev (path);
2201 gtk_tree_path_up (path);
2202 gtk_tree_path_next (path);
2208 case GDK_KEY_Return:
2209 case GDK_KEY_KP_Enter:
2210 if (gtk_tree_view_row_expanded (tv, path))
2212 gtk_tree_path_down (path);
2216 depth = gtk_tree_path_get_depth (path);
2217 gtk_tree_path_next (path);
2218 if (!gnc_tree_view_path_is_valid (view, path) && depth > 1)
2220 gtk_tree_path_prev (path);
2221 gtk_tree_path_up (path);
2222 gtk_tree_path_next (path);
2235 if (!view && !editing_started_cb)
2238 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
2240 priv->editing_started_cb = editing_started_cb;
2241 priv->editing_cb_data = editing_cb_data;
2249 if (!view && !editing_finished_cb)
2252 priv = GNC_TREE_VIEW_GET_PRIVATE(view);
2254 priv->editing_finished_cb = editing_finished_cb;
2255 priv->editing_cb_data = editing_cb_data;
void gnc_tree_view_set_sort_user_data(GncTreeView *view, GtkTreeModel *s_model)
This allows the columns to be setup without the model connected.
Functions to load, save and get gui state.
void gnc_tree_view_expand_columns(GncTreeView *view, gchar *first_column_name,...)
This function set the columns that will be allocated the free space in the view.
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
int safe_utf8_collate(const char *da, const char *db)
Collate two UTF-8 strings.
void gnc_tree_view_set_editing_started_cb(GncTreeView *view, GFunc editing_started_cb, gpointer editing_cb_data)
Setup a callback for when the user starts editing so appropriate actions can be taken like disable th...
void gnc_gobject_tracking_forget(GObject *object)
Tell gnucash to remember this object in the database.
common utilities for manipulating a GtkTreeView within gnucash
#define DEBUG(format, args...)
Print a debugging message.
gboolean gnc_tree_view_get_show_column_menu(GncTreeView *view)
This function is called to get the current value of the "show-column-menu" property.
void gnc_tree_view_remove_state_information(GncTreeView *view)
Completely wipe the treeview's state information (column visibility, width, sorting order...
void gnc_tree_view_set_show_column_menu(GncTreeView *view, gboolean visible)
This function is called to set the "show-column-menu" property on this view.
GtkTreeViewColumn * gnc_tree_view_add_numeric_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_color_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new numeric column to a GncTreeView base view.
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
Find a tree column given the "pref name" used with saved state.
#define ENTER(format, args...)
Print a function entry debugging message.
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
G_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_APPLICATION_WINDOW, G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init)) static guint main_window_signals[LAST_SIGNAL]
A holding place for all the signals generated by the main window code.
gint gnc_tree_view_append_column(GncTreeView *view, GtkTreeViewColumn *column)
Add a column to a view based upon a GncTreeView.
void gnc_gobject_tracking_remember(GObject *object)
Tell gnucash to remember this object in the database.
GtkTreeViewColumn * gnc_tree_view_add_pix_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new pixbuf view column to a GncTreeView base view.
GtkTreeViewColumn * gnc_tree_view_add_toggle_column(GncTreeView *view, const gchar *column_title, const gchar *column_short_title, const gchar *pref_name, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn, renderer_toggled toggle_edited_cb)
This function adds a new toggle column to a GncTreeView base view.
void gnc_tree_view_set_editing_finished_cb(GncTreeView *view, GFunc editing_finished_cb, gpointer editing_cb_data)
Setup a callback for when the user finishes editing so appropriate actions can be taken like enable t...
GtkCellRenderer * gnc_tree_view_column_get_renderer(GtkTreeViewColumn *column)
Return the "main" cell renderer from a GtkTreeViewColumn added to a GncTreeView my one of the conveni...
GtkTreeViewColumn * gnc_tree_view_add_text_view_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text view column to a GncTreeView base view.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
void gnc_tree_view_save_state(GncTreeView *view)
This function is called to write the treeview's state information (column visibility, width, sorting order,..) to the state file.
void gnc_tree_view_set_control_column_background(GncTreeView *view, gint column, GtkTreeCellDataFunc func)
This function links the cell backgrounds of the two control columns to a column in the model that has...
Gnome specific utility functions.
All type declarations for the whole Gnucash engine.
const gchar * gnc_tree_view_get_state_section(GncTreeView *view)
Get the name of the state section this tree view is associated with.
Generic api to store and retrieve preferences.
void gnc_tree_view_set_state_section(GncTreeView *view, const gchar *section)
Set up or remove an association between a saved state section and the display of a view...
GtkTreeViewColumn * gnc_tree_view_add_text_column(GncTreeView *view, const gchar *column_title, const gchar *pref_name, const gchar *icon_name, const gchar *sizing_text, gint model_data_column, gint model_visibility_column, GtkTreeIterCompareFunc column_sort_fn)
This function adds a new text column to a GncTreeView base view.
#define LEAVE(format, args...)
Print a function exit debugging message.
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.