[nautilus-actions] Enable/disable sort buttons depending of items list count



commit e13ed1f8ae1ee5b7769f7bd0cae4c3eb066face7
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Jun 17 20:02:33 2010 +0200

    Enable/disable sort buttons depending of items list count

 ChangeLog                       |    7 +++++++
 src/nact/nact-iproperties-tab.c |    2 +-
 src/nact/nact-main-menubar.c    |    5 ++++-
 src/nact/nact-sort-buttons.c    |   25 ++++++++++++++++++++++++-
 src/nact/nact-sort-buttons.h    |    1 +
 5 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bd13a08..f476d54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-06-17 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-sort-buttons.c:
+	* src/nact/nact-sort-buttons.h (nact_sort_buttons_enable_buttons):
+	New function.
+
+	* src/nact/nact-main-menubar.c (on_iactions_list_count_updated):
+	Enable/disable sort buttons depending of items list count.
+
 	* src/api/na-object-api.h
 	(na_object_get_shortcut, na_object_set_shortcut): New macros.
 
diff --git a/src/nact/nact-iproperties-tab.c b/src/nact/nact-iproperties-tab.c
index 8fbd874..3d59cc9 100644
--- a/src/nact/nact-iproperties-tab.c
+++ b/src/nact/nact-iproperties-tab.c
@@ -194,7 +194,7 @@ nact_iproperties_tab_runtime_init_toplevel( NactIPropertiesTab *instance )
 		button = base_window_get_widget( BASE_WINDOW( instance ), "SuggestedShortcutButton" );
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
-				G_OBJECT( buffer ),
+				G_OBJECT( button ),
 				"clicked",
 				G_CALLBACK( on_shortcut_clicked ));
 
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 36e1ac5..365129d 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -55,6 +55,7 @@
 #include "nact-main-menubar-tools.h"
 #include "nact-main-menubar-maintainer.h"
 #include "nact-main-menubar-help.h"
+#include "nact-sort-buttons.h"
 
 #define MENUBAR_PROP_STATUS_CONTEXT			"nact-menubar-status-context"
 #define MENUBAR_PROP_MAIN_STATUS_CONTEXT	"nact-menubar-main-status-context"
@@ -445,7 +446,9 @@ on_iactions_list_count_updated( NactMainWindow *window, gint menus, gint actions
 	mis->list_menus = menus;
 	mis->list_actions = actions;
 	mis->list_profiles = profiles;
-	mis->have_exportables = ( mis->list_actions > 0 );
+	mis->have_exportables = ( mis->list_menus + mis->list_actions > 0 );
+
+	nact_sort_buttons_enable_buttons( window, mis->list_menus + mis->list_actions > 0 );
 
 	/* i18n: note the space at the beginning of the sentence */
 	status = g_strdup_printf( _( " %d menu(s), %d action(s), %d profile(s) are currently loaded" ), menus, actions, profiles );
diff --git a/src/nact/nact-sort-buttons.c b/src/nact/nact-sort-buttons.c
index 55749ad..7967e8c 100644
--- a/src/nact/nact-sort-buttons.c
+++ b/src/nact/nact-sort-buttons.c
@@ -47,6 +47,7 @@ typedef struct {
 
 static gboolean st_set_sort_order = FALSE;
 static gboolean st_in_toggle      = FALSE;
+static gboolean st_enable_buttons = FALSE;
 static gint     st_last_active    = -1;
 
 static void enable_buttons( NactMainWindow *window );
@@ -133,6 +134,28 @@ nact_sort_buttons_all_widgets_showed( NactMainWindow *window )
 }
 
 /**
+ * nact_sort_buttons_enable_buttons:
+ * @window: the #NactMainWindow.
+ * @enable: whether we wish enable or disable these sort buttons.
+ *
+ * Enable or disable the sort buttons, while keeping relevant with
+ * writability status of the various stages.
+ *
+ * This function may be called when application wishes enable or disable
+ * the sort buttons, typically when there is no record to sort.
+ */
+void
+nact_sort_buttons_enable_buttons( NactMainWindow *window, gboolean enable )
+{
+	static const gchar *thisfn = "nact_sort_buttons_enable_buttons";
+
+	g_debug( "%s: window=%p, enable=%s", thisfn, ( void * ) window, enable ? "True":"False" );
+
+	st_enable_buttons = enable;
+	enable_buttons( window );
+}
+
+/**
  * nact_sort_buttons_dispose:
  * @window: the #NactMainWindow.
  *
@@ -195,7 +218,7 @@ enable_buttons( NactMainWindow *window )
 	i = 0;
 	while( st_toggle_group[i].btn_name ){
 		button = base_window_get_widget( BASE_WINDOW( window ), st_toggle_group[i].btn_name );
-		gtk_widget_set_sensitive( button, writable );
+		gtk_widget_set_sensitive( button, writable && st_enable_buttons );
 		i += 1;
 	}
 }
diff --git a/src/nact/nact-sort-buttons.h b/src/nact/nact-sort-buttons.h
index d810a11..31e449a 100644
--- a/src/nact/nact-sort-buttons.h
+++ b/src/nact/nact-sort-buttons.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
 void  nact_sort_buttons_initial_load                 ( NactMainWindow *window );
 void  nact_sort_buttons_runtime_init                 ( NactMainWindow *window );
 void  nact_sort_buttons_all_widgets_showed           ( NactMainWindow *window );
+void  nact_sort_buttons_enable_buttons               ( NactMainWindow *window, gboolean enable );
 void  nact_sort_buttons_dispose                      ( NactMainWindow *window );
 void  nact_sort_buttons_display_order_change         ( NactMainWindow *window, guint order_mode );
 void  nact_sort_buttons_level_zero_writability_change( NactMainWindow *window );



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