[gimp] app: add signal GimpDisplayShell::rotated and use it to update the menu



commit 3972da5256dbc2005dcea1507743b9536f742cd7
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 21 03:15:22 2013 +0200

    app: add signal GimpDisplayShell::rotated and use it to update the menu

 app/display/gimpdisplayshell-rotate.c |  2 +-
 app/display/gimpdisplayshell.c        | 36 +++++++++++++++++++++++++++++++++++
 app/display/gimpdisplayshell.h        |  2 ++
 app/display/gimpimagewindow.c         | 19 ++++++++++++++++++
 4 files changed, 58 insertions(+), 1 deletion(-)
---
diff --git a/app/display/gimpdisplayshell-rotate.c b/app/display/gimpdisplayshell-rotate.c
index 49b4006..6150069 100644
--- a/app/display/gimpdisplayshell-rotate.c
+++ b/app/display/gimpdisplayshell-rotate.c
@@ -58,7 +58,7 @@ gimp_display_shell_rotate_to (GimpDisplayShell *shell,
 
   shell->rotate_angle = value;
 
-  gimp_display_shell_rotate_update_transform (shell);
+  gimp_display_shell_rotated (shell);
   gimp_display_shell_expose_full (shell);
 }
 
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index c6c6aab..b1e9a79 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -107,6 +107,7 @@ enum
 {
   SCALED,
   SCROLLED,
+  ROTATED,
   RECONNECT,
   LAST_SIGNAL
 };
@@ -146,6 +147,7 @@ static void      gimp_display_shell_screen_changed (GtkWidget        *widget,
 static gboolean  gimp_display_shell_popup_menu     (GtkWidget        *widget);
 
 static void      gimp_display_shell_real_scaled    (GimpDisplayShell *shell);
+static void      gimp_display_shell_real_rotated   (GimpDisplayShell *shell);
 
 static const guint8 * gimp_display_shell_get_icc_profile
                                                    (GimpColorManaged *managed,
@@ -215,6 +217,15 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
                   gimp_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
+  display_shell_signals[ROTATED] =
+    g_signal_new ("rotated",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpDisplayShellClass, rotated),
+                  NULL, NULL,
+                  gimp_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
   display_shell_signals[RECONNECT] =
     g_signal_new ("reconnect",
                   G_TYPE_FROM_CLASS (klass),
@@ -236,6 +247,7 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
 
   klass->scaled                    = gimp_display_shell_real_scaled;
   klass->scrolled                  = NULL;
+  klass->rotated                   = gimp_display_shell_real_rotated;
   klass->reconnect                 = NULL;
 
   g_object_class_install_property (object_class, PROP_POPUP_MANAGER,
@@ -1010,6 +1022,20 @@ gimp_display_shell_real_scaled (GimpDisplayShell *shell)
     gimp_ui_manager_update (shell->popup_manager, shell->display);
 }
 
+static void
+gimp_display_shell_real_rotated (GimpDisplayShell *shell)
+{
+  GimpContext *user_context;
+
+  if (! shell->display)
+    return;
+
+  user_context = gimp_get_user_context (shell->display->gimp);
+
+  if (shell->display == gimp_context_get_display (user_context))
+    gimp_ui_manager_update (shell->popup_manager, shell->display);
+}
+
 static const guint8 *
 gimp_display_shell_get_icc_profile (GimpColorManaged *managed,
                                     gsize            *len)
@@ -1474,6 +1500,16 @@ gimp_display_shell_scrolled (GimpDisplayShell *shell)
 }
 
 void
+gimp_display_shell_rotated (GimpDisplayShell *shell)
+{
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  gimp_display_shell_rotate_update_transform (shell);
+
+  g_signal_emit (shell, display_shell_signals[ROTATED], 0);
+}
+
+void
 gimp_display_shell_set_unit (GimpDisplayShell *shell,
                              GimpUnit          unit)
 {
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 4038aba..8c8db4d 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -199,6 +199,7 @@ struct _GimpDisplayShellClass
 
   void (* scaled)    (GimpDisplayShell *shell);
   void (* scrolled)  (GimpDisplayShell *shell);
+  void (* rotated)   (GimpDisplayShell *shell);
   void (* reconnect) (GimpDisplayShell *shell);
 };
 
@@ -242,6 +243,7 @@ void              gimp_display_shell_scale_changed (GimpDisplayShell   *shell);
 
 void              gimp_display_shell_scaled        (GimpDisplayShell   *shell);
 void              gimp_display_shell_scrolled      (GimpDisplayShell   *shell);
+void              gimp_display_shell_rotated       (GimpDisplayShell   *shell);
 
 void              gimp_display_shell_set_unit      (GimpDisplayShell   *shell,
                                                     GimpUnit            unit);
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 0d4991e..658ca05 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -209,6 +209,8 @@ static void      gimp_image_window_image_notify        (GimpDisplay         *dis
                                                         GimpImageWindow     *window);
 static void      gimp_image_window_shell_scaled        (GimpDisplayShell    *shell,
                                                         GimpImageWindow     *window);
+static void      gimp_image_window_shell_rotated       (GimpDisplayShell    *shell,
+                                                        GimpImageWindow     *window);
 static void      gimp_image_window_shell_title_notify  (GimpDisplayShell    *shell,
                                                         const GParamSpec    *pspec,
                                                         GimpImageWindow     *window);
@@ -1638,6 +1640,9 @@ gimp_image_window_switch_page (GtkNotebook     *notebook,
   g_signal_connect (private->active_shell, "scaled",
                     G_CALLBACK (gimp_image_window_shell_scaled),
                     window);
+  g_signal_connect (private->active_shell, "rotated",
+                    G_CALLBACK (gimp_image_window_shell_rotated),
+                    window);
   g_signal_connect (private->active_shell, "notify::title",
                     G_CALLBACK (gimp_image_window_shell_title_notify),
                     window);
@@ -1697,6 +1702,9 @@ gimp_image_window_disconnect_from_active_shell (GimpImageWindow *window)
                                         gimp_image_window_shell_scaled,
                                         window);
   g_signal_handlers_disconnect_by_func (private->active_shell,
+                                        gimp_image_window_shell_rotated,
+                                        window);
+  g_signal_handlers_disconnect_by_func (private->active_shell,
                                         gimp_image_window_shell_title_notify,
                                         window);
   g_signal_handlers_disconnect_by_func (private->active_shell,
@@ -1885,6 +1893,17 @@ gimp_image_window_shell_scaled (GimpDisplayShell *shell,
 }
 
 static void
+gimp_image_window_shell_rotated (GimpDisplayShell *shell,
+                                 GimpImageWindow  *window)
+{
+  GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
+
+  /* update the <Image>/View/Rotate menu */
+  gimp_ui_manager_update (private->menubar_manager,
+                          shell->display);
+}
+
+static void
 gimp_image_window_shell_title_notify (GimpDisplayShell *shell,
                                       const GParamSpec *pspec,
                                       GimpImageWindow  *window)


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