[nautilus-actions] Add src/nact/nact-main-menubar-tools.{c,h} files



commit 234da1b588318cafdbd5b5150f13d829b728a923
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Mar 1 20:50:54 2010 +0100

    Add src/nact/nact-main-menubar-tools.{c,h} files

 ChangeLog                               |    3 +
 src/nact/Makefile.am                    |    2 +
 src/nact/nact-main-menubar-maintainer.c |    4 --
 src/nact/nact-main-menubar-tools.c      |   90 +++++++++++++++++++++++++++++++
 src/nact/nact-main-menubar-tools.h      |   53 ++++++++++++++++++
 src/nact/nact-main-menubar.c            |   56 +++-----------------
 src/nact/nact-main-menubar.h            |   23 ++++++++
 7 files changed, 178 insertions(+), 53 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 62a4410..52ada21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-03-01 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-main-menubar-tools.c:
+	* src/nact/nact-main-menubar-tools.h: New files.
+
 	* src/nact/nact-main-menubar-maintainer.c:
 	* src/nact/nact-main-menubar-maintainer.h: New files.
 
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 05d0fcc..ba64a1c 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -110,6 +110,8 @@ nautilus_actions_config_tool_SOURCES = \
 	nact-main-menubar-help.h							\
 	nact-main-menubar-maintainer.c						\
 	nact-main-menubar-maintainer.h						\
+	nact-main-menubar-tools.c							\
+	nact-main-menubar-tools.h							\
 	nact-main-statusbar.c								\
 	nact-main-statusbar.h								\
 	nact-main-tab.c										\
diff --git a/src/nact/nact-main-menubar-maintainer.c b/src/nact/nact-main-menubar-maintainer.c
index 87de15d..df1e175 100644
--- a/src/nact/nact-main-menubar-maintainer.c
+++ b/src/nact/nact-main-menubar-maintainer.c
@@ -49,10 +49,6 @@
 void
 nact_main_menubar_maintainer_on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 {
-	/* TODO: help temporarily disabled */
-	nact_main_menubar_enable_item( window, "HelpItem", FALSE );
-
-	/* about always enabled */
 }
 
 /**
diff --git a/src/nact/nact-main-menubar-tools.c b/src/nact/nact-main-menubar-tools.c
new file mode 100644
index 0000000..c97a45c
--- /dev/null
+++ b/src/nact/nact-main-menubar-tools.c
@@ -0,0 +1,90 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Frederic Ruaudel <grumz grumz net>
+ *   Rodrigo Moya <rodrigo gnome-db org>
+ *   Pierre Wieser <pwieser trychlos org>
+ *   ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "nact-assistant-export.h"
+#include "nact-assistant-import.h"
+#include "nact-main-menubar.h"
+#include "nact-main-menubar-tools.h"
+
+/**
+ * nact_main_menubar_tools_on_update_sensitivities:
+ * @window: the #NactMainWindow main application window.
+ * @user_data: user data ?
+ *
+ * Update sensitivities on the Tools menu.
+ */
+void
+nact_main_menubar_tools_on_update_sensitivities( NactMainWindow *window, gpointer user_data )
+{
+	static const gchar *thisfn = "nact_main_menubar_tools_on_update_sensitivities";
+	MenubarIndicatorsStruct *mis;
+	gboolean has_writable_providers;
+
+	mis = ( MenubarIndicatorsStruct * ) g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_INDICATORS );
+
+	has_writable_providers = nact_window_has_writable_providers( NACT_WINDOW( window ));
+	g_debug( "%s: has_writable_providers=%s", thisfn, has_writable_providers ? "True":"False" );
+
+	/* import item enabled if at least one writable provider */
+	nact_main_menubar_enable_item( window, "ImportItem", has_writable_providers );
+
+	/* export item enabled if IActionsList store contains actions */
+	nact_main_menubar_enable_item( window, "ExportItem", mis->have_exportables );
+}
+
+/**
+ * nact_main_menubar_tools_on_import:
+ * @action: the #GtkAction of the item.
+ * @window: the #NactMainWindow main application window.
+ *
+ * Triggers the "Tools/Import assitant" item.
+ */
+void
+nact_main_menubar_tools_on_import( GtkAction *action, NactMainWindow *window )
+{
+	nact_assistant_import_run( BASE_WINDOW( window ));
+}
+
+/**
+ * nact_main_menubar_tools_on_export:
+ * @action: the #GtkAction of the item.
+ * @window: the #NactMainWindow main application window.
+ *
+ * Triggers the "Tools/Export assistant" item.
+ */
+void
+nact_main_menubar_tools_on_export( GtkAction *action, NactMainWindow *window )
+{
+	nact_assistant_export_run( BASE_WINDOW( window ));
+}
diff --git a/src/nact/nact-main-menubar-tools.h b/src/nact/nact-main-menubar-tools.h
new file mode 100644
index 0000000..660807b
--- /dev/null
+++ b/src/nact/nact-main-menubar-tools.h
@@ -0,0 +1,53 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Frederic Ruaudel <grumz grumz net>
+ *   Rodrigo Moya <rodrigo gnome-db org>
+ *   Pierre Wieser <pwieser trychlos org>
+ *   ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_MAIN_MENUBAR_TOOLS_H__
+#define __NACT_MAIN_MENUBAR_TOOLS_H__
+
+/**
+ * SECTION: nact_main_menubar
+ * @short_description: Main menubar Tools menu management.
+ * @include: nact/nact-main-menubar-tools.h
+ */
+
+#include <gtk/gtk.h>
+
+#include "nact-main-window.h"
+
+G_BEGIN_DECLS
+
+void nact_main_menubar_tools_on_update_sensitivities( NactMainWindow *window, gpointer user_data );
+
+void nact_main_menubar_tools_on_import( GtkAction *action, NactMainWindow *window );
+void nact_main_menubar_tools_on_export( GtkAction *action, NactMainWindow *window );
+
+G_END_DECLS
+
+#endif /* __NACT_NACT_MENUBAR_TOOLS_H__ */
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index a70d80f..7be9ddb 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -37,14 +37,11 @@
 #include <api/na-object-api.h>
 
 #include <core/na-factory-object.h>
-#include <core/na-iabout.h>
 #include <core/na-iprefs.h>
 #include <core/na-ipivot-consumer.h>
 #include <core/na-io-provider.h>
 
 #include "nact-application.h"
-#include "nact-assistant-export.h"
-#include "nact-assistant-import.h"
 #include "nact-preferences-editor.h"
 #include "nact-iactions-list.h"
 #include "nact-clipboard.h"
@@ -52,6 +49,7 @@
 #include "nact-main-toolbar.h"
 #include "nact-main-tab.h"
 #include "nact-main-menubar.h"
+#include "nact-main-menubar-tools.h"
 #include "nact-main-menubar-maintainer.h"
 #include "nact-main-menubar-help.h"
 
@@ -85,29 +83,6 @@ enum {
 #define MENUBAR_PROP_ITEM_ACTION			"nact-menubar-item-action"
 #endif
 
-/* this structure is updated each time the user interacts in the
- * interface ; it is then used to update action sensitivities
- */
-typedef struct {
-	gint     selected_menus;
-	gint     selected_actions;
-	gint     selected_profiles;
-	gint     clipboard_menus;
-	gint     clipboard_actions;
-	gint     clipboard_profiles;
-	gint     list_menus;
-	gint     list_actions;
-	gint     list_profiles;
-	gboolean is_modified;
-	gboolean have_exportables;
-	gboolean treeview_has_focus;
-	gboolean level_zero_order_changed;
-	gulong   popup_handler;
-}
-	MenubarIndicatorsStruct;
-
-#define MENUBAR_PROP_INDICATORS			"nact-menubar-indicators"
-
 static void     on_iactions_list_count_updated( NactMainWindow *window, gint menus, gint actions, gint profiles );
 static void     on_iactions_list_selection_changed( NactMainWindow *window, GList *selected );
 static void     on_iactions_list_focus_in( NactMainWindow *window, gpointer user_data );
@@ -142,9 +117,6 @@ static void     on_view_tools_toolbar_activated( GtkToggleAction *action, NactMa
 static void     on_view_help_toolbar_activated( GtkToggleAction *action, NactMainWindow *window );
 static void     on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, int toolbar_id );
 
-static void     on_import_activated( GtkAction *action, NactMainWindow *window );
-static void     on_export_activated( GtkAction *action, NactMainWindow *window );
-
 static gboolean on_delete_event( GtkWidget *toplevel, GdkEvent *event, NactMainWindow *window );
 static void     on_destroy_callback( gpointer data );
 static void     on_menu_item_selected( GtkMenuItem *proxy, NactMainWindow *window );
@@ -223,14 +195,16 @@ static const GtkActionEntry entries[] = {
 				/* i18n: tooltip displayed in the status bar when selecting the Collapse all item */
 				N_( "Entirely collapse the items hierarchy" ),
 				G_CALLBACK( on_collapse_all_activated ) },
+
 		{ "ImportItem" , GTK_STOCK_CONVERT, N_( "_Import assistant..." ), "",
 				/* i18n: tooltip displayed in the status bar when selecting the Import item */
 				N_( "Import one or more actions from external (XML) files into your configuration" ),
-				G_CALLBACK( on_import_activated ) },
+				G_CALLBACK( nact_main_menubar_tools_on_import ) },
 		{ "ExportItem", NULL, N_( "E_xport assistant..." ), NULL,
 				/* i18n: tooltip displayed in the status bar when selecting the Export item */
 				N_( "Export one or more actions from your configuration to external XML files" ),
-				G_CALLBACK( on_export_activated ) },
+				G_CALLBACK( nact_main_menubar_tools_on_export ) },
+
 		{ "DumpSelectionItem", NULL, N_( "_Dump the selection" ), NULL,
 				/* i18n: tooltip displayed in the status bar when selecting the Dump selection item */
 				N_( "Recursively dump selected items" ),
@@ -247,6 +221,7 @@ static const GtkActionEntry entries[] = {
 				/* i18n: tooltip displayed in the status bar when selecting the DumpClipboard item */
 				N_( "Dump the content of the clipboard object" ),
 				G_CALLBACK( nact_main_menubar_maintainer_on_dump_clipboard ) },
+
 		{ "HelpItem" , GTK_STOCK_HELP, NULL, NULL,
 				/* i18n: tooltip displayed in the status bar when selecting the Help item */
 				N_( "Display help about this program" ),
@@ -817,12 +792,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	nact_main_menubar_enable_item( window, "ExpandAllItem", count_list > 0 );
 	nact_main_menubar_enable_item( window, "CollapseAllItem", count_list > 0 );
 
-	/* import item enabled if at least one writable provider */
-	nact_main_menubar_enable_item( window, "ImportItem", has_writable_providers );
-
-	/* export item enabled if IActionsList store contains actions */
-	nact_main_menubar_enable_item( window, "ExportItem", mis->have_exportables );
-
+	nact_main_menubar_tools_on_update_sensitivities( window, user_data );
 	nact_main_menubar_maintainer_on_update_sensitivities( window, user_data );
 	nact_main_menubar_help_on_update_sensitivities( window, user_data );
 
@@ -1439,18 +1409,6 @@ on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, int
 	nact_main_toolbar_activate( window, toolbar_id, ui_manager, is_active );
 }
 
-static void
-on_import_activated( GtkAction *gtk_action, NactMainWindow *window )
-{
-	nact_assistant_import_run( BASE_WINDOW( window ));
-}
-
-static void
-on_export_activated( GtkAction *gtk_action, NactMainWindow *window )
-{
-	nact_assistant_export_run( BASE_WINDOW( window ));
-}
-
 /**
  * nact_main_menubar_enable_item:
  * @window: the #NactMainWindow main application window.
diff --git a/src/nact/nact-main-menubar.h b/src/nact/nact-main-menubar.h
index d706ac4..11e5064 100644
--- a/src/nact/nact-main-menubar.h
+++ b/src/nact/nact-main-menubar.h
@@ -45,6 +45,29 @@
 
 G_BEGIN_DECLS
 
+/* this structure is updated each time the user interacts in the
+ * interface ; it is then used to update action sensitivities
+ */
+typedef struct {
+	gint     selected_menus;
+	gint     selected_actions;
+	gint     selected_profiles;
+	gint     clipboard_menus;
+	gint     clipboard_actions;
+	gint     clipboard_profiles;
+	gint     list_menus;
+	gint     list_actions;
+	gint     list_profiles;
+	gboolean is_modified;
+	gboolean have_exportables;
+	gboolean treeview_has_focus;
+	gboolean level_zero_order_changed;
+	gulong   popup_handler;
+}
+	MenubarIndicatorsStruct;
+
+#define MENUBAR_PROP_INDICATORS			"nact-menubar-indicators"
+
 void     nact_main_menubar_runtime_init( NactMainWindow *window );
 void     nact_main_menubar_dispose( NactMainWindow *window );
 gboolean nact_main_menubar_is_pasted_object_relabeled( NAObject *object, NAPivot *pivot );



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