From 60ca4baeb62c3d00fdfc89a7fe224e5b38490975 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 24 Jun 2008 08:42:49 +0000 Subject: [PATCH] made the model column enum public and namespaced it. 2008-06-24 Michael Natterer * app/widgets/gimpcontainercombobox.[ch]: made the model column enum public and namespaced it. * app/widgets/gimpsettingsbox.c: use the enum value instead of a magic number. * app/widgets/gimpsettingseditor.c: add a separator between recently used settings and favorites. svn path=/trunk/; revision=25979 --- ChangeLog | 11 +++++++++++ app/widgets/gimpcontainercombobox.c | 26 +++++++++++--------------- app/widgets/gimpcontainercombobox.h | 8 ++++++++ app/widgets/gimpsettingsbox.c | 6 +----- app/widgets/gimpsettingseditor.c | 24 ++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45ac041135..19dcb29f31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-06-24 Michael Natterer + + * app/widgets/gimpcontainercombobox.[ch]: made the model column + enum public and namespaced it. + + * app/widgets/gimpsettingsbox.c: use the enum value instead of a + magic number. + + * app/widgets/gimpsettingseditor.c: add a separator between + recently used settings and favorites. + 2008-06-23 Martin Nordholts * app/tools/gimpfreeselecttool.c diff --git a/app/widgets/gimpcontainercombobox.c b/app/widgets/gimpcontainercombobox.c index 8c3bdc46f1..ec1e71548e 100644 --- a/app/widgets/gimpcontainercombobox.c +++ b/app/widgets/gimpcontainercombobox.c @@ -43,12 +43,6 @@ enum PROP_ELLIPSIZE = GIMP_CONTAINER_VIEW_PROP_LAST + 1 }; -enum -{ - COLUMN_RENDERER, - COLUMN_NAME, - NUM_COLUMNS -}; static void gimp_container_combo_box_view_iface_init (GimpContainerViewInterface *iface); @@ -144,7 +138,7 @@ gimp_container_combo_box_init (GimpContainerComboBox *combo_box) GtkCellLayout *layout; GtkCellRenderer *cell; - store = gtk_list_store_new (NUM_COLUMNS, + store = gtk_list_store_new (GIMP_CONTAINER_COMBO_BOX_N_COLUMNS, GIMP_TYPE_VIEW_RENDERER, G_TYPE_STRING); @@ -157,7 +151,8 @@ gimp_container_combo_box_init (GimpContainerComboBox *combo_box) cell = gimp_cell_renderer_viewable_new (); gtk_cell_layout_pack_start (layout, cell, FALSE); gtk_cell_layout_set_attributes (layout, cell, - "renderer", COLUMN_RENDERER, + "renderer", + GIMP_CONTAINER_COMBO_BOX_COLUMN_RENDERER, NULL); combo_box->viewable_renderer = cell; @@ -165,7 +160,8 @@ gimp_container_combo_box_init (GimpContainerComboBox *combo_box) cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (layout, cell, TRUE); gtk_cell_layout_set_attributes (layout, cell, - "text", COLUMN_NAME, + "text", + GIMP_CONTAINER_COMBO_BOX_COLUMN_NAME, NULL); combo_box->text_renderer = cell; @@ -277,8 +273,8 @@ gimp_container_combo_box_set (GimpContainerComboBox *combo_box, view); gtk_list_store_set (GTK_LIST_STORE (model), iter, - COLUMN_RENDERER, renderer, - COLUMN_NAME, name, + GIMP_CONTAINER_COMBO_BOX_COLUMN_RENDERER, renderer, + GIMP_CONTAINER_COMBO_BOX_COLUMN_NAME, name, -1); g_object_unref (renderer); @@ -308,7 +304,7 @@ gimp_container_combo_box_set_context (GimpContainerView *view, GimpViewRenderer *renderer; gtk_tree_model_get (model, &iter, - COLUMN_RENDERER, &renderer, + GIMP_CONTAINER_COMBO_BOX_COLUMN_RENDERER, &renderer, -1); gimp_view_renderer_set_context (renderer, context); @@ -429,7 +425,7 @@ gimp_container_combo_box_rename_item (GimpContainerView *view, gchar *name = gimp_viewable_get_description (viewable, NULL); gtk_list_store_set (GTK_LIST_STORE (model), iter, - COLUMN_NAME, name, + GIMP_CONTAINER_COMBO_BOX_COLUMN_NAME, name, -1); g_free (name); @@ -494,7 +490,7 @@ gimp_container_combo_box_set_view_size (GimpContainerView *view) GimpViewRenderer *renderer; gtk_tree_model_get (model, &iter, - COLUMN_RENDERER, &renderer, + GIMP_CONTAINER_COMBO_BOX_COLUMN_RENDERER, &renderer, -1); gimp_view_renderer_set_size (renderer, view_size, border_width); @@ -516,7 +512,7 @@ gimp_container_combo_box_changed (GtkComboBox *combo_box, GimpViewRenderer *renderer; gtk_tree_model_get (gtk_combo_box_get_model (combo_box), &iter, - COLUMN_RENDERER, &renderer, + GIMP_CONTAINER_COMBO_BOX_COLUMN_RENDERER, &renderer, -1); gimp_container_view_item_selected (view, renderer->viewable); diff --git a/app/widgets/gimpcontainercombobox.h b/app/widgets/gimpcontainercombobox.h index e8ccc0929b..b35e4823d1 100644 --- a/app/widgets/gimpcontainercombobox.h +++ b/app/widgets/gimpcontainercombobox.h @@ -23,6 +23,14 @@ #define __GIMP_CONTAINER_COMBO_BOX_H__ +enum +{ + GIMP_CONTAINER_COMBO_BOX_COLUMN_RENDERER, + GIMP_CONTAINER_COMBO_BOX_COLUMN_NAME, + GIMP_CONTAINER_COMBO_BOX_N_COLUMNS +}; + + #define GIMP_TYPE_CONTAINER_COMBO_BOX (gimp_container_combo_box_get_type ()) #define GIMP_CONTAINER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTAINER_COMBO_BOX, GimpContainerComboBox)) #define GIMP_CONTAINER_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER_COMBO_BOX, GimpContainerComboBoxClass)) diff --git a/app/widgets/gimpsettingsbox.c b/app/widgets/gimpsettingsbox.c index a044d2da58..8cf5861fb7 100644 --- a/app/widgets/gimpsettingsbox.c +++ b/app/widgets/gimpsettingsbox.c @@ -459,13 +459,9 @@ gimp_settings_box_row_separator_func (GtkTreeModel *model, { gchar *name = NULL; -#ifdef __GNUC__ -#warning FIXME: dont use magic model column -#endif gtk_tree_model_get (model, iter, - 1, &name, + GIMP_CONTAINER_COMBO_BOX_COLUMN_NAME, &name, -1); - g_free (name); return name == NULL; diff --git a/app/widgets/gimpsettingseditor.c b/app/widgets/gimpsettingseditor.c index d88b49b31f..78678c53f4 100644 --- a/app/widgets/gimpsettingseditor.c +++ b/app/widgets/gimpsettingseditor.c @@ -63,6 +63,11 @@ static void gimp_settings_editor_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static gboolean + gimp_settings_editor_row_separator_func (GtkTreeModel *model, + GtkTreeIter *iter, + gpointer data); + G_DEFINE_TYPE (GimpSettingsEditor, gimp_settings_editor, GTK_TYPE_VBOX) @@ -127,6 +132,9 @@ gimp_settings_editor_constructor (GType type, view = gimp_container_tree_view_new (editor->container, gimp_get_user_context (editor->gimp), 16, 0); + gtk_tree_view_set_row_separator_func (GIMP_CONTAINER_TREE_VIEW (view)->view, + gimp_settings_editor_row_separator_func, + view, NULL); gtk_container_add (GTK_CONTAINER (editor), view); gtk_widget_show (view); @@ -209,6 +217,22 @@ gimp_settings_editor_get_property (GObject *object, } } +static gboolean +gimp_settings_editor_row_separator_func (GtkTreeModel *model, + GtkTreeIter *iter, + gpointer data) +{ + GimpContainerTreeView *view = GIMP_CONTAINER_TREE_VIEW (data); + gchar *name = NULL; + + gtk_tree_model_get (model, iter, + view->model_column_name, &name, + -1); + g_free (name); + + return name == NULL; +} + /* public functions */