[gimp] app: add gimp_prop_icon_picker_new()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_prop_icon_picker_new()
- Date: Tue, 22 Mar 2011 21:10:10 +0000 (UTC)
commit fa9453eea13b8117607b162f1c3034b6fffb4599
Author: Michael Natterer <mitch gimp org>
Date: Tue Mar 22 15:20:03 2011 +0100
app: add gimp_prop_icon_picker_new()
and use it in GimpTemplateEditor instead of handling the icon picker
manually.
app/widgets/gimppropwidgets.c | 99 ++++++++++++++++++++++++++++++++++++++
app/widgets/gimppropwidgets.h | 3 +
app/widgets/gimptemplateeditor.c | 43 ++--------------
3 files changed, 108 insertions(+), 37 deletions(-)
---
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index 668329e..416797d 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -39,6 +39,7 @@
#include "gimpcolorpanel.h"
#include "gimpdnd.h"
+#include "gimpiconpicker.h"
#include "gimplanguagecombobox.h"
#include "gimplanguageentry.h"
#include "gimpscalebutton.h"
@@ -1292,6 +1293,104 @@ gimp_prop_language_entry_notify (GObject *config,
}
+/*****************/
+/* icon picker */
+/*****************/
+
+static void gimp_prop_icon_picker_callback (GtkWidget *picker,
+ GParamSpec *param_spec,
+ GObject *config);
+static void gimp_prop_icon_picker_notify (GObject *config,
+ GParamSpec *param_spec,
+ GtkWidget *picker);
+
+GtkWidget *
+gimp_prop_icon_picker_new (GObject *config,
+ const gchar *property_name,
+ Gimp *gimp)
+{
+ GParamSpec *param_spec;
+ GtkWidget *picker;
+ gchar *value;
+
+ param_spec = check_param_spec_w (config, property_name,
+ G_TYPE_PARAM_STRING, G_STRFUNC);
+ if (! param_spec)
+ return NULL;
+
+ g_object_get (config,
+ property_name, &value,
+ NULL);
+
+ picker = gimp_icon_picker_new (gimp);
+ gimp_icon_picker_set_stock_id (GIMP_ICON_PICKER (picker), value);
+ g_free (value);
+
+ set_param_spec (G_OBJECT (picker), picker, param_spec);
+
+ g_signal_connect (picker, "notify::stock-id",
+ G_CALLBACK (gimp_prop_icon_picker_callback),
+ config);
+
+ connect_notify (config, property_name,
+ G_CALLBACK (gimp_prop_icon_picker_notify),
+ picker);
+
+ return picker;
+}
+
+static void
+gimp_prop_icon_picker_callback (GtkWidget *picker,
+ GParamSpec *unuded_param_spec,
+ GObject *config)
+{
+ GParamSpec *param_spec;
+ const gchar *value;
+
+ param_spec = get_param_spec (G_OBJECT (picker));
+ if (! param_spec)
+ return;
+
+ value = gimp_icon_picker_get_stock_id (GIMP_ICON_PICKER (picker));
+
+ g_signal_handlers_block_by_func (config,
+ gimp_prop_icon_picker_notify,
+ picker);
+
+ g_object_set (config,
+ param_spec->name, value,
+ NULL);
+
+ g_signal_handlers_unblock_by_func (config,
+ gimp_prop_icon_picker_notify,
+ picker);
+}
+
+static void
+gimp_prop_icon_picker_notify (GObject *config,
+ GParamSpec *param_spec,
+ GtkWidget *picker)
+{
+ gchar *value;
+
+ g_object_get (config,
+ param_spec->name, &value,
+ NULL);
+
+ g_signal_handlers_block_by_func (picker,
+ gimp_prop_icon_picker_callback,
+ config);
+
+ gimp_icon_picker_set_stock_id (GIMP_ICON_PICKER (picker), value);
+
+ g_free (value);
+
+ g_signal_handlers_unblock_by_func (picker,
+ gimp_prop_icon_picker_callback,
+ config);
+}
+
+
/***********/
/* table */
/***********/
diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h
index 0654f0a..168a210 100644
--- a/app/widgets/gimppropwidgets.h
+++ b/app/widgets/gimppropwidgets.h
@@ -95,6 +95,9 @@ GtkWidget * gimp_prop_language_combo_box_new (GObject *config,
GtkWidget * gimp_prop_language_entry_new (GObject *config,
const gchar *property_name);
+GtkWidget * gimp_prop_icon_picker_new (GObject *config,
+ const gchar *property_name,
+ Gimp *gimp);
/* A view on all of an object's properties */
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 1bcb528..dcf0c11 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -31,7 +31,7 @@
#include "core/gimp.h"
#include "core/gimptemplate.h"
-#include "gimpiconpicker.h"
+#include "gimppropwidgets.h"
#include "gimptemplateeditor.h"
#include "gimp-intl.h"
@@ -54,8 +54,6 @@ struct _GimpTemplateEditorPrivate
{
GimpTemplate *template;
- GtkWidget *icon_picker;
-
GtkWidget *aspect_button;
gboolean block_aspect;
@@ -89,9 +87,6 @@ static void gimp_template_editor_aspect_callback (GtkWidget *widget,
static void gimp_template_editor_template_notify (GimpTemplate *template,
GParamSpec *param_spec,
GimpTemplateEditor *editor);
-static void gimp_template_editor_icon_changed (GimpIconPicker *picker,
- const GParamSpec *pspec,
- GimpTemplateEditor *editor);
G_DEFINE_TYPE (GimpTemplateEditor, gimp_template_editor, GTK_TYPE_BOX)
@@ -502,6 +497,7 @@ gimp_template_editor_new (GimpTemplate *template,
{
GtkWidget *table;
GtkWidget *entry;
+ GtkWidget *icon_picker;
const gchar *stock_id;
table = gtk_table_new (2, 2, FALSE);
@@ -519,17 +515,12 @@ gimp_template_editor_new (GimpTemplate *template,
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (private->template));
- private->icon_picker = gimp_icon_picker_new (gimp);
- gimp_icon_picker_set_stock_id (GIMP_ICON_PICKER (private->icon_picker),
- stock_id);
-
- g_signal_connect (private->icon_picker, "notify::stock-id",
- G_CALLBACK (gimp_template_editor_icon_changed),
- editor);
-
+ icon_picker = gimp_prop_icon_picker_new (G_OBJECT (private->template),
+ "stock-id",
+ gimp);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("_Icon:"), 1.0, 0.5,
- private->icon_picker, 1, TRUE);
+ icon_picker, 1, TRUE);
}
return GTK_WIDGET (editor);
@@ -698,26 +689,4 @@ gimp_template_editor_template_notify (GimpTemplate *template,
gtk_label_set_text (GTK_LABEL (private->more_label), text);
g_free (text);
-
- if (private->icon_picker)
- {
- const gchar *stock_id;
-
- stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (template));
-
- gimp_icon_picker_set_stock_id (GIMP_ICON_PICKER (private->icon_picker),
- stock_id);
- }
-}
-
-static void
-gimp_template_editor_icon_changed (GimpIconPicker *picker,
- const GParamSpec *pspec,
- GimpTemplateEditor *editor)
-{
- GimpTemplateEditorPrivate *private = GET_PRIVATE (editor);
-
- g_object_set (private->template,
- "stock-id", gimp_icon_picker_get_stock_id (picker),
- NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]