[gimp] app: Make dock actions like "Show Image Selection" work



commit c39b8758d57356f74b85e5da88a55a85c3a06f01
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Sep 27 17:12:18 2009 +0200

    app: Make dock actions like "Show Image Selection" work
    
    Take into account that the toplevel is not a dock any longer but a
    dock window.

 app/actions/dock-commands.c |   51 +++++++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/app/actions/dock-commands.c b/app/actions/dock-commands.c
index 7510f3a..2f4fbb4 100644
--- a/app/actions/dock-commands.c
+++ b/app/actions/dock-commands.c
@@ -23,44 +23,63 @@
 
 #include "actions-types.h"
 
+#include "widgets/gimpdockwindow.h"
 #include "widgets/gimpmenudock.h"
 
 #include "actions.h"
 #include "dock-commands.h"
 
 
+static GimpMenuDock *
+dock_commands_get_menudock_from_widget (GtkWidget *widget)
+{
+  GtkWidget    *toplevel  = gtk_widget_get_toplevel (widget);
+  GimpMenuDock *menu_dock = NULL;
+
+  if (GIMP_IS_DOCK_WINDOW (toplevel))
+    {
+      GimpDock *dock = gimp_dock_window_get_dock (GIMP_DOCK_WINDOW (toplevel));
+
+      if (GIMP_IS_MENU_DOCK (dock))
+        menu_dock = GIMP_MENU_DOCK (dock);
+    }
+
+  return menu_dock;
+}
+
+
 /*  public functions  */
 
 void
 dock_toggle_image_menu_cmd_callback (GtkAction *action,
                                      gpointer   data)
 {
-  GtkWidget *widget;
-  gboolean   active;
+  GtkWidget    *widget    = NULL;
+  GimpMenuDock *menu_dock = NULL;
   return_if_no_widget (widget, data);
 
-  if (! GTK_WIDGET_TOPLEVEL (widget))
-    widget = gtk_widget_get_toplevel (widget);
+  menu_dock = dock_commands_get_menudock_from_widget (widget);
 
-  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-
-  if (GIMP_IS_MENU_DOCK (widget))
-    gimp_menu_dock_set_show_image_menu (GIMP_MENU_DOCK (widget), active);
+  if (menu_dock)
+    {
+      gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+      gimp_menu_dock_set_show_image_menu (menu_dock, active);
+    }
 }
 
 void
 dock_toggle_auto_cmd_callback (GtkAction *action,
                                gpointer   data)
 {
-  GtkWidget *widget;
-  gboolean   active;
+  GtkWidget    *widget    = NULL;
+  GimpMenuDock *menu_dock = NULL;
   return_if_no_widget (widget, data);
 
-  if (! GTK_WIDGET_TOPLEVEL (widget))
-    widget = gtk_widget_get_toplevel (widget);
-
-  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  menu_dock = dock_commands_get_menudock_from_widget (widget);
 
-  if (GIMP_IS_MENU_DOCK (widget))
-    gimp_menu_dock_set_auto_follow_active (GIMP_MENU_DOCK (widget), active);
+  if (menu_dock)
+    {
+      gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+      gimp_menu_dock_set_auto_follow_active (menu_dock, active);
+    }
 }



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