[gimp] app: also make options_box into a GWeakRef.



commit 55083baa98f92a1ff4e8dd1c011fda5ecbe3e8c5
Author: Jehan <jehan girinstud io>
Date:   Thu Oct 5 00:11:36 2017 +0200

    app: also make options_box into a GWeakRef.
    
    While I am at it, let's spread the improvement to options_box which was
    also a weak pointer with g_object_add_weak_pointer(). Let's make it
    rather a GWeakRef for the same reason as I did options_gui.

 app/tools/gimpgegltool.c      |    8 ++++++--
 app/tools/gimpoperationtool.c |   32 ++++++++++++++++++++------------
 app/tools/gimpoperationtool.h |    2 +-
 3 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/app/tools/gimpgegltool.c b/app/tools/gimpgegltool.c
index 8ae2248..e768390 100644
--- a/app/tools/gimpgegltool.c
+++ b/app/tools/gimpgegltool.c
@@ -393,11 +393,15 @@ gimp_gegl_tool_dialog (GimpFilterTool *filter_tool)
   GtkWidget         *hbox;
   GtkWidget         *combo;
   GtkWidget         *options_gui;
+  GtkWidget         *options_box;
   GList             *opclasses;
   GList             *iter;
 
   GIMP_FILTER_TOOL_CLASS (parent_class)->dialog (filter_tool);
 
+  options_box = g_weak_ref_get (&o_tool->options_box_ref);
+  g_return_if_fail (options_box);
+
   main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool);
 
   /*  The operation combo box  */
@@ -480,8 +484,8 @@ gimp_gegl_tool_dialog (GimpFilterTool *filter_tool)
                              PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
                              -1);
   gtk_misc_set_padding (GTK_MISC (options_gui), 0, 4);
-  gtk_container_add (GTK_CONTAINER (o_tool->options_box),
-                     options_gui);
+  gtk_container_add (GTK_CONTAINER (options_box), options_gui);
+  g_object_unref (options_box);
   g_weak_ref_set (&o_tool->options_gui_ref, options_gui);
   gtk_widget_show (options_gui);
 }
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index f7bbf67..72cd56d 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -280,17 +280,16 @@ gimp_operation_tool_dialog (GimpFilterTool *filter_tool)
   GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool);
   GtkWidget         *main_vbox;
   GtkWidget         *options_gui;
+  GtkWidget         *options_box;
 
   main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool);
 
   /*  The options vbox  */
-  op_tool->options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
-  gtk_box_pack_start (GTK_BOX (main_vbox), op_tool->options_box,
+  options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+  g_weak_ref_set (&op_tool->options_box_ref, options_box);
+  gtk_box_pack_start (GTK_BOX (main_vbox), options_box,
                       TRUE, TRUE, 0);
-  gtk_widget_show (op_tool->options_box);
-
-  g_object_add_weak_pointer (G_OBJECT (op_tool->options_box),
-                             (gpointer) &op_tool->options_box);
+  gtk_widget_show (options_box);
 
   options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
   if (options_gui)
@@ -565,10 +564,12 @@ gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
 {
   GtkSizeGroup *size_group  = NULL;
   GtkWidget    *options_gui;
+  GtkWidget    *options_box;
   GList        *list;
 
   options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
-  g_return_if_fail (options_gui);
+  options_box = g_weak_ref_get (&op_tool->options_box_ref);
+  g_return_if_fail (options_gui && options_box);
 
   for (list = op_tool->aux_inputs; list; list = g_list_next (list))
     {
@@ -583,7 +584,7 @@ gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
 
       gtk_size_group_add_widget (size_group, toggle);
 
-      gtk_box_pack_start (GTK_BOX (op_tool->options_box), input->box,
+      gtk_box_pack_start (GTK_BOX (options_box), input->box,
                           FALSE, FALSE, 0);
       gtk_widget_show (input->box);
     }
@@ -591,10 +592,11 @@ gimp_operation_tool_add_gui (GimpOperationTool *op_tool)
   if (size_group)
     g_object_unref (size_group);
 
-  gtk_box_pack_start (GTK_BOX (op_tool->options_box), options_gui,
-                      TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (options_box), options_gui, TRUE, TRUE, 0);
   gtk_widget_show (options_gui);
+
   g_object_unref (options_gui);
+  g_object_unref (options_box);
 }
 
 
@@ -739,9 +741,15 @@ gimp_operation_tool_set_operation (GimpOperationTool *op_tool,
 
   if (filter_tool->config && tool->display)
     {
+      GtkWidget *options_box;
+
       gimp_operation_tool_create_gui (op_tool);
 
-      if (op_tool->options_box)
-        gimp_operation_tool_add_gui (op_tool);
+      options_box = g_weak_ref_get (&op_tool->options_box_ref);
+      if (options_box)
+        {
+          gimp_operation_tool_add_gui (op_tool);
+          g_object_unref (options_box);
+        }
     }
 }
diff --git a/app/tools/gimpoperationtool.h b/app/tools/gimpoperationtool.h
index c30143b..dd2b762 100644
--- a/app/tools/gimpoperationtool.h
+++ b/app/tools/gimpoperationtool.h
@@ -43,7 +43,7 @@ struct _GimpOperationTool
   GList          *aux_inputs;
 
   /* dialog */
-  GtkWidget      *options_box;
+  GWeakRef        options_box_ref;
   GWeakRef        options_gui_ref;
 };
 


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