[gimp] app: make GimpOverlayDialog's title and icon-name settable after construction



commit 17bd4d2c288eabe692a8cf3ead87c14629eb97e9
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 9 01:42:09 2014 +0200

    app: make GimpOverlayDialog's title and icon-name settable after construction

 app/display/gimptoolgui.c       |   11 ++---------
 app/widgets/gimpoverlaydialog.c |   16 ++++++++++++----
 app/widgets/gimpoverlaydialog.h |    2 ++
 3 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/app/display/gimptoolgui.c b/app/display/gimptoolgui.c
index ebf902a..f7495ef 100644
--- a/app/display/gimptoolgui.c
+++ b/app/display/gimptoolgui.c
@@ -281,7 +281,7 @@ gimp_tool_gui_set_description (GimpToolGui *gui,
 
   if (private->overlay)
     {
-      /* TODO */
+      g_object_set (private->dialog, "title", description, NULL);
     }
   else
     {
@@ -308,14 +308,7 @@ gimp_tool_gui_set_icon_name (GimpToolGui *gui,
   if (! icon_name)
     icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (private->tool_info));
 
-  if (private->overlay)
-    {
-      /* TODO */
-    }
-  else
-    {
-      g_object_set (private->dialog, "icon-name", icon_name, NULL);
-    }
+  g_object_set (private->dialog, "icon-name", icon_name, NULL);
 }
 
 void
diff --git a/app/widgets/gimpoverlaydialog.c b/app/widgets/gimpoverlaydialog.c
index 3f29cb6..93a7712 100644
--- a/app/widgets/gimpoverlaydialog.c
+++ b/app/widgets/gimpoverlaydialog.c
@@ -119,14 +119,14 @@ gimp_overlay_dialog_class_init (GimpOverlayDialogClass *klass)
                                                         NULL, NULL,
                                                         NULL,
                                                         GIMP_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT_ONLY));
+                                                        G_PARAM_CONSTRUCT));
 
   g_object_class_install_property (object_class, PROP_ICON_NAME,
                                    g_param_spec_string ("icon-name",
                                                         NULL, NULL,
                                                         NULL,
                                                         GIMP_PARAM_READWRITE |
-                                                        G_PARAM_CONSTRUCT_ONLY));
+                                                        G_PARAM_CONSTRUCT));
 
   signals[RESPONSE] =
     g_signal_new ("response",
@@ -175,11 +175,12 @@ gimp_overlay_dialog_constructed (GObject *object)
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
-  image = gtk_image_new_from_icon_name (dialog->icon_name, GTK_ICON_SIZE_MENU);
+  dialog->icon_image = image = gtk_image_new_from_icon_name (dialog->icon_name,
+                                                             GTK_ICON_SIZE_MENU);
   gtk_box_pack_start (GTK_BOX (dialog->header), image, FALSE, FALSE, 0);
   gtk_widget_show (image);
 
-  label = gtk_label_new (dialog->title);
+  dialog->title_label = label = gtk_label_new (dialog->title);
   gimp_label_set_attributes (GTK_LABEL (label),
                              PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
                              -1);
@@ -254,11 +255,18 @@ gimp_overlay_dialog_set_property (GObject      *object,
   switch (property_id)
     {
     case PROP_TITLE:
+      g_free (dialog->title);
       dialog->title = g_value_dup_string (value);
+      if (dialog->title_label)
+        gtk_label_set_text (GTK_LABEL (dialog->title_label), dialog->title);
       break;
 
     case PROP_ICON_NAME:
+      g_free (dialog->icon_name);
       dialog->icon_name = g_value_dup_string (value);
+      if (dialog->icon_image)
+        gtk_image_set_from_icon_name (GTK_IMAGE (dialog->icon_image),
+                                      dialog->icon_name, GTK_ICON_SIZE_MENU);
       break;
 
     default:
diff --git a/app/widgets/gimpoverlaydialog.h b/app/widgets/gimpoverlaydialog.h
index 7a2eb24..6afa020 100644
--- a/app/widgets/gimpoverlaydialog.h
+++ b/app/widgets/gimpoverlaydialog.h
@@ -44,6 +44,8 @@ struct _GimpOverlayDialog
   gchar            *icon_name;
 
   GtkWidget        *header;
+  GtkWidget        *icon_image;
+  GtkWidget        *title_label;
   GtkWidget        *close_button;
   GtkWidget        *action_area;
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]