[gimp] app: clean up toggle callbacks in view-commands.c



commit 84d60ad94306660f7fa9164180c5c1f75175d38c
Author: Michael Natterer <mitch gimp org>
Date:   Mon May 16 13:39:45 2016 +0200

    app: clean up toggle callbacks in view-commands.c

 app/actions/view-commands.c |  130 ++++++++++++++++++++++++++-----------------
 1 files changed, 78 insertions(+), 52 deletions(-)
---
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index d581f9b..efdd2b0 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -635,13 +635,15 @@ view_toggle_selection_cmd_callback (GtkAction *action,
                                     gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_selection (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_selection (shell, active);
+  if (active != gimp_display_shell_get_show_selection (shell))
+    {
+      gimp_display_shell_set_show_selection (shell, active);
+    }
 }
 
 void
@@ -649,13 +651,15 @@ view_toggle_layer_boundary_cmd_callback (GtkAction *action,
                                          gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_layer (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_layer (shell, active);
+  if (active != gimp_display_shell_get_show_layer (shell))
+    {
+      gimp_display_shell_set_show_layer (shell, active);
+    }
 }
 
 void
@@ -663,13 +667,15 @@ view_toggle_menubar_cmd_callback (GtkAction *action,
                                   gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_menubar (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_menubar (shell, active);
+  if (active != gimp_display_shell_get_show_menubar (shell))
+    {
+      gimp_display_shell_set_show_menubar (shell, active);
+    }
 }
 
 void
@@ -677,13 +683,15 @@ view_toggle_rulers_cmd_callback (GtkAction *action,
                                  gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_rulers (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_rulers (shell, active);
+  if (active != gimp_display_shell_get_show_rulers (shell))
+    {
+      gimp_display_shell_set_show_rulers (shell, active);
+    }
 }
 
 void
@@ -691,13 +699,15 @@ view_toggle_scrollbars_cmd_callback (GtkAction *action,
                                      gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_scrollbars (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_scrollbars (shell, active);
+  if (active != gimp_display_shell_get_show_scrollbars (shell))
+    {
+      gimp_display_shell_set_show_scrollbars (shell, active);
+    }
 }
 
 void
@@ -705,13 +715,15 @@ view_toggle_statusbar_cmd_callback (GtkAction *action,
                                     gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_statusbar (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_statusbar (shell, active);
+  if (active != gimp_display_shell_get_show_statusbar (shell))
+    {
+      gimp_display_shell_set_show_statusbar (shell, active);
+    }
 }
 
 void
@@ -719,13 +731,15 @@ view_toggle_guides_cmd_callback (GtkAction *action,
                                  gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_guides (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_guides (shell, active);
+  if (active != gimp_display_shell_get_show_guides (shell))
+    {
+      gimp_display_shell_set_show_guides (shell, active);
+    }
 }
 
 void
@@ -733,13 +747,15 @@ view_toggle_grid_cmd_callback (GtkAction *action,
                                gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_grid (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_grid (shell, active);
+  if (active != gimp_display_shell_get_show_grid (shell))
+    {
+      gimp_display_shell_set_show_grid (shell, active);
+    }
 }
 
 void
@@ -747,13 +763,15 @@ view_toggle_sample_points_cmd_callback (GtkAction *action,
                                         gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_show_sample_points (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_show_sample_points (shell, active);
+  if (active != gimp_display_shell_get_show_sample_points (shell))
+    {
+      gimp_display_shell_set_show_sample_points (shell, active);
+    }
 }
 
 void
@@ -761,13 +779,15 @@ view_snap_to_guides_cmd_callback (GtkAction *action,
                                   gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_snap_to_guides (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_snap_to_guides (shell, active);
+  if (active != gimp_display_shell_get_snap_to_guides (shell))
+    {
+      gimp_display_shell_set_snap_to_guides (shell, active);
+    }
 }
 
 void
@@ -775,13 +795,15 @@ view_snap_to_grid_cmd_callback (GtkAction *action,
                                 gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_snap_to_grid (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_snap_to_grid (shell, active);
+  if (active != gimp_display_shell_get_snap_to_grid (shell))
+    {
+      gimp_display_shell_set_snap_to_grid (shell, active);
+    }
 }
 
 void
@@ -789,13 +811,15 @@ view_snap_to_canvas_cmd_callback (GtkAction *action,
                                   gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_snap_to_canvas (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_snap_to_canvas (shell, active);
+  if (active != gimp_display_shell_get_snap_to_canvas (shell))
+    {
+      gimp_display_shell_set_snap_to_canvas (shell, active);
+    }
 }
 
 void
@@ -803,13 +827,15 @@ view_snap_to_vectors_cmd_callback (GtkAction *action,
                                    gpointer   data)
 {
   GimpDisplayShell *shell;
-  gboolean          active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+  gboolean          active;
   return_if_no_shell (shell, data);
 
-  if (active == gimp_display_shell_get_snap_to_vectors (shell))
-    return;
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
-  gimp_display_shell_set_snap_to_vectors (shell, active);
+  if (active != gimp_display_shell_get_snap_to_vectors (shell))
+    {
+      gimp_display_shell_set_snap_to_vectors (shell, active);
+    }
 }
 
 void


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