[gimp] libgimpwidgets: turn GimpDialog's "parent" into a property



commit c469dbb206c9b1dea260e9a0b2a682040519edf4
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 20 12:44:03 2011 +0100

    libgimpwidgets: turn GimpDialog's "parent" into a property
    
    and remove the parent peoperty from GimpViewableDialog.

 app/widgets/gimpviewabledialog.c |   32 +++++++----------------
 libgimpwidgets/gimpdialog.c      |   50 +++++++++++++++++++++++++++----------
 2 files changed, 46 insertions(+), 36 deletions(-)
---
diff --git a/app/widgets/gimpviewabledialog.c b/app/widgets/gimpviewabledialog.c
index e96e14c..4e5443b 100644
--- a/app/widgets/gimpviewabledialog.c
+++ b/app/widgets/gimpviewabledialog.c
@@ -44,8 +44,7 @@ enum
   PROP_VIEWABLE,
   PROP_CONTEXT,
   PROP_STOCK_ID,
-  PROP_DESC,
-  PROP_PARENT
+  PROP_DESC
 };
 
 
@@ -82,25 +81,23 @@ gimp_viewable_dialog_class_init (GimpViewableDialogClass *klass)
                                    g_param_spec_object ("viewable", NULL, NULL,
                                                         GIMP_TYPE_VIEWABLE,
                                                         GIMP_PARAM_READWRITE));
+
   g_object_class_install_property (object_class, PROP_CONTEXT,
                                    g_param_spec_object ("context", NULL, NULL,
                                                         GIMP_TYPE_CONTEXT,
                                                         GIMP_PARAM_READWRITE));
+
   g_object_class_install_property (object_class, PROP_STOCK_ID,
                                    g_param_spec_string ("stock-id", NULL, NULL,
                                                         NULL,
                                                         GIMP_PARAM_WRITABLE |
                                                         G_PARAM_CONSTRUCT_ONLY));
+
   g_object_class_install_property (object_class, PROP_DESC,
                                    g_param_spec_string ("description", NULL, NULL,
                                                         NULL,
                                                         GIMP_PARAM_WRITABLE |
                                                         G_PARAM_CONSTRUCT));
-  g_object_class_install_property (object_class, PROP_PARENT,
-                                   g_param_spec_object ("parent", NULL, NULL,
-                                                        GTK_TYPE_WIDGET,
-                                                        GIMP_PARAM_WRITABLE |
-                                                        G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
@@ -177,6 +174,7 @@ gimp_viewable_dialog_set_property (GObject      *object,
                                          g_value_get_object (value),
                                          dialog->context);
       break;
+
     case PROP_CONTEXT:
       gimp_viewable_dialog_set_viewable (dialog,
                                          dialog->view ?
@@ -184,30 +182,18 @@ gimp_viewable_dialog_set_property (GObject      *object,
                                          NULL,
                                          g_value_get_object (value));
       break;
+
     case PROP_STOCK_ID:
       gtk_image_set_from_stock (GTK_IMAGE (dialog->icon),
                                 g_value_get_string (value),
                                 GTK_ICON_SIZE_LARGE_TOOLBAR);
       break;
+
     case PROP_DESC:
       gtk_label_set_text (GTK_LABEL (dialog->desc_label),
                           g_value_get_string (value));
       break;
-    case PROP_PARENT:
-      {
-        GtkWidget *parent = g_value_get_object (value);
-
-        if (parent)
-          {
-            if (GTK_IS_WINDOW (parent))
-              gtk_window_set_transient_for (GTK_WINDOW (dialog),
-                                            GTK_WINDOW (parent));
-            else
-              gtk_window_set_screen (GTK_WINDOW (dialog),
-                                     gtk_widget_get_screen (parent));
-          }
-      }
-      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -229,9 +215,11 @@ gimp_viewable_dialog_get_property (GObject    *object,
                           dialog->view ?
                           GIMP_VIEW (dialog->view)->viewable : NULL);
       break;
+
     case PROP_CONTEXT:
       g_value_set_object (value, dialog->context);
       break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
diff --git a/libgimpwidgets/gimpdialog.c b/libgimpwidgets/gimpdialog.c
index 5c8e4bd..f94859c 100644
--- a/libgimpwidgets/gimpdialog.c
+++ b/libgimpwidgets/gimpdialog.c
@@ -44,7 +44,8 @@ enum
 {
   PROP_0,
   PROP_HELP_FUNC,
-  PROP_HELP_ID
+  PROP_HELP_ID,
+  PROP_PARENT
 };
 
 
@@ -95,7 +96,7 @@ gimp_dialog_class_init (GimpDialogClass *klass)
   dialog_class->close        = gimp_dialog_close;
 
   /**
-   * GimpDialog::help-func:
+   * GimpDialog:help-func:
    *
    * Since: GIMP 2.2
    **/
@@ -105,7 +106,7 @@ gimp_dialog_class_init (GimpDialogClass *klass)
                                                          G_PARAM_CONSTRUCT_ONLY));
 
   /**
-   * GimpDialog::help-id:
+   * GimpDialog:help-id:
    *
    * Since: GIMP 2.2
    **/
@@ -114,6 +115,17 @@ gimp_dialog_class_init (GimpDialogClass *klass)
                                                         NULL,
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));
+
+  /**
+   * GimpDialog:parent:
+   *
+   * Since: GIMP 2.8
+   **/
+  g_object_class_install_property (object_class, PROP_PARENT,
+                                   g_param_spec_object ("parent", NULL, NULL,
+                                                        GTK_TYPE_WIDGET,
+                                                        GIMP_PARAM_WRITABLE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
@@ -193,11 +205,29 @@ gimp_dialog_set_property (GObject      *object,
       g_object_set_data (object, "gimp-dialog-help-func",
                          g_value_get_pointer (value));
       break;
+
     case PROP_HELP_ID:
       g_object_set_data_full (object, "gimp-dialog-help-id",
                               g_value_dup_string (value),
                               (GDestroyNotify) g_free);
       break;
+
+    case PROP_PARENT:
+      {
+        GtkWidget *parent = g_value_get_object (value);
+
+        if (parent)
+          {
+            if (GTK_IS_WINDOW (parent))
+              gtk_window_set_transient_for (GTK_WINDOW (object),
+                                            GTK_WINDOW (parent));
+            else
+              gtk_window_set_screen (GTK_WINDOW (object),
+                                     gtk_widget_get_screen (parent));
+          }
+      }
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -216,10 +246,12 @@ gimp_dialog_get_property (GObject    *object,
       g_value_set_pointer (value, g_object_get_data (object,
                                                      "gimp-dialog-help-func"));
       break;
+
     case PROP_HELP_ID:
       g_value_set_string (value, g_object_get_data (object,
                                                     "gimp-dialog-help-id"));
       break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -391,21 +423,11 @@ gimp_dialog_new_valist (const gchar    *title,
                          "modal",     (flags & GTK_DIALOG_MODAL),
                          "help-func", help_func,
                          "help-id",   help_id,
+                         "parent",    parent,
                          NULL);
 
   if (parent)
     {
-      if (GTK_IS_WINDOW (parent))
-        {
-          gtk_window_set_transient_for (GTK_WINDOW (dialog),
-                                        GTK_WINDOW (parent));
-        }
-      else
-        {
-          gtk_window_set_screen (GTK_WINDOW (dialog),
-                                 gtk_widget_get_screen (parent));
-        }
-
       if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
         g_signal_connect_object (parent, "destroy",
                                  G_CALLBACK (gimp_dialog_close),



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