[gedit] TabLabel: update_close_button_sensitivity()



commit e3b2e1451f4e7b367382e538371f3c8f77846ba4
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Feb 21 17:39:29 2015 +0100

    TabLabel: update_close_button_sensitivity()
    
    The close button sensitivity was updated at two different places in two
    different ways (some states checking were missing in one). So put the
    common code in a function.

 gedit/gedit-tab-label.c |   48 ++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)
---
diff --git a/gedit/gedit-tab-label.c b/gedit/gedit-tab-label.c
index 3c9708e..c26f065 100644
--- a/gedit/gedit-tab-label.c
+++ b/gedit/gedit-tab-label.c
@@ -143,22 +143,32 @@ sync_name (GeditTab      *tab,
 }
 
 static void
-sync_state (GeditTab      *tab,
-           GParamSpec    *pspec,
-           GeditTabLabel *tab_label)
+update_close_button_sensitivity (GeditTabLabel *tab_label)
 {
-       GeditTabState  state;
-
-       g_return_if_fail (tab == tab_label->priv->tab);
-
-       state = gedit_tab_get_state (tab);
+       GeditTabState state = gedit_tab_get_state (tab_label->priv->tab);
 
        gtk_widget_set_sensitive (tab_label->priv->close_button,
                                  tab_label->priv->close_button_sensitive &&
                                  (state != GEDIT_TAB_STATE_CLOSING) &&
                                  (state != GEDIT_TAB_STATE_SAVING)  &&
                                  (state != GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
+                                 (state != GEDIT_TAB_STATE_PRINTING) &&
+                                 (state != GEDIT_TAB_STATE_PRINT_PREVIEWING) &&
                                  (state != GEDIT_TAB_STATE_SAVING_ERROR));
+}
+
+static void
+sync_state (GeditTab      *tab,
+           GParamSpec    *pspec,
+           GeditTabLabel *tab_label)
+{
+       GeditTabState state;
+
+       g_return_if_fail (tab == tab_label->priv->tab);
+
+       update_close_button_sensitivity (tab_label);
+
+       state = gedit_tab_get_state (tab);
 
        if ((state == GEDIT_TAB_STATE_LOADING)   ||
            (state == GEDIT_TAB_STATE_SAVING)    ||
@@ -284,27 +294,15 @@ void
 gedit_tab_label_set_close_button_sensitive (GeditTabLabel *tab_label,
                                            gboolean       sensitive)
 {
-       GeditTabState state;
-
        g_return_if_fail (GEDIT_IS_TAB_LABEL (tab_label));
 
        sensitive = (sensitive != FALSE);
 
-       if (sensitive == tab_label->priv->close_button_sensitive)
-               return;
-
-       tab_label->priv->close_button_sensitive = sensitive;
-
-       state = gedit_tab_get_state (tab_label->priv->tab);
-
-       gtk_widget_set_sensitive (tab_label->priv->close_button,
-                                 tab_label->priv->close_button_sensitive &&
-                                 (state != GEDIT_TAB_STATE_CLOSING) &&
-                                 (state != GEDIT_TAB_STATE_SAVING)  &&
-                                 (state != GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
-                                 (state != GEDIT_TAB_STATE_PRINTING) &&
-                                 (state != GEDIT_TAB_STATE_PRINT_PREVIEWING) &&
-                                 (state != GEDIT_TAB_STATE_SAVING_ERROR));
+       if (tab_label->priv->close_button_sensitive != sensitive)
+       {
+               tab_label->priv->close_button_sensitive = sensitive;
+               update_close_button_sensitivity (tab_label);
+       }
 }
 
 GeditTab *


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