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



commit 777ac383e4410c5194d13d7aa78260f8ec71e3a9
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Mar 1 20:15:33 2010 +0100

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

 ChangeLog                         |    7 +++
 TODO                              |    6 ---
 src/nact/Makefile.am              |    2 +
 src/nact/nact-main-menubar-help.c |   79 +++++++++++++++++++++++++++++++++++++
 src/nact/nact-main-menubar-help.h |   53 +++++++++++++++++++++++++
 src/nact/nact-main-menubar.c      |   67 +++++++++++++------------------
 src/nact/nact-main-menubar.h      |    2 +
 7 files changed, 172 insertions(+), 44 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 94da997..a1cb748 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-03-01 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-main-menubar-help.c:
+	* src/nact/nact-main-menubar-help.h: New files.
+
+	* src/nact/Makefile.am:
+	* src/nact/nact-main-menubar.c:
+	* src/nact/nact-main-menubar.h: Updated accordingly.
+
 	* src/core/na-updater.c:
 	* src/core/na-updater.h (na_updater_append_item): New function.
 
diff --git a/TODO b/TODO
index 5974cfe..3ac4bed 100644
--- a/TODO
+++ b/TODO
@@ -162,10 +162,4 @@
   but path is defined as string in this same spec
   and icon may be a path -> so what to do with this ?
 
-- segfaults on reload
-
-- check adding/removing profile on desktop/gconf/xml import/export
-
 - shouldn't be able to copy an action into an action !
-
-- na_object_reset_last_allocated ??
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 4bbfda2..7d37358 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -106,6 +106,8 @@ nautilus_actions_config_tool_SOURCES = \
 	nact-main.c											\
 	nact-main-menubar.c									\
 	nact-main-menubar.h									\
+	nact-main-menubar-help.c							\
+	nact-main-menubar-help.h							\
 	nact-main-statusbar.c								\
 	nact-main-statusbar.h								\
 	nact-main-tab.c										\
diff --git a/src/nact/nact-main-menubar-help.c b/src/nact/nact-main-menubar-help.c
new file mode 100644
index 0000000..00a713c
--- /dev/null
+++ b/src/nact/nact-main-menubar-help.c
@@ -0,0 +1,79 @@
+/*
+ * 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 <core/na-iabout.h>
+
+#include "nact-main-menubar.h"
+#include "nact-main-menubar-help.h"
+
+/**
+ * nact_main_menubar_help_on_update_sensitivities:
+ * @window: the #NactMainWindow main application window.
+ * @user_data: user data ?
+ *
+ * Update sensitivities on the Help menu.
+ */
+void
+nact_main_menubar_help_on_update_sensitivities( NactMainWindow *window, gpointer user_data )
+{
+	/* TODO: help temporarily disabled */
+	nact_main_menubar_enable_item( window, "HelpItem", FALSE );
+
+	/* about always enabled */
+}
+
+/**
+ * nact_main_menubar_help_on_help:
+ * @action: the #GtkAction of the item.
+ * @window: the #NactMainWindow main application window.
+ *
+ * Triggers the Help item.
+ */
+void
+nact_main_menubar_help_on_help( GtkAction *action, NactMainWindow *window )
+{
+}
+
+/**
+ * nact_main_menubar_help_on_about:
+ * @action: the #GtkAction of the item.
+ * @window: the #NactMainWindow main application window.
+ *
+ * Triggers the About item.
+ */
+void
+nact_main_menubar_help_on_about( GtkAction *action, NactMainWindow *window )
+{
+	na_iabout_display( NA_IABOUT( window ));
+}
diff --git a/src/nact/nact-main-menubar-help.h b/src/nact/nact-main-menubar-help.h
new file mode 100644
index 0000000..76b1c3f
--- /dev/null
+++ b/src/nact/nact-main-menubar-help.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_HELP_H__
+#define __NACT_MAIN_MENUBAR_HELP_H__
+
+/**
+ * SECTION: nact_main_menubar
+ * @short_description: Main menubar Help menu management.
+ * @include: nact/nact-main-menubar-help.h
+ */
+
+#include <gtk/gtk.h>
+
+#include "nact-main-window.h"
+
+G_BEGIN_DECLS
+
+void nact_main_menubar_help_on_update_sensitivities( NactMainWindow *window, gpointer user_data );
+
+void nact_main_menubar_help_on_help( GtkAction *gtk_action, NactMainWindow *window );
+void nact_main_menubar_help_on_about( GtkAction *gtk_action, NactMainWindow *window );
+
+G_END_DECLS
+
+#endif /* __NACT_NACT_MENUBAR_HELP_H__ */
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index a6c6e1f..65c73f4 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -52,6 +52,7 @@
 #include "nact-main-toolbar.h"
 #include "nact-main-tab.h"
 #include "nact-main-menubar.h"
+#include "nact-main-menubar-help.h"
 
 #define MENUBAR_PROP_STATUS_CONTEXT			"nact-menubar-status-context"
 #define MENUBAR_PROP_MAIN_STATUS_CONTEXT	"nact-menubar-main-status-context"
@@ -148,10 +149,6 @@ static void     on_brief_tree_store_dump_activated( GtkAction *action, NactMainW
 static void     on_list_modified_items_activated( GtkAction *action, NactMainWindow *window );
 static void     on_dump_clipboard_activated( GtkAction *action, NactMainWindow *window );
 
-static void     on_help_activated( GtkAction *action, NactMainWindow *window );
-static void     on_about_activated( GtkAction *action, NactMainWindow *window );
-
-static void     enable_item( NactMainWindow *window, const gchar *name, gboolean enabled );
 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 );
@@ -257,11 +254,11 @@ static const GtkActionEntry entries[] = {
 		{ "HelpItem" , GTK_STOCK_HELP, NULL, NULL,
 				/* i18n: tooltip displayed in the status bar when selecting the Help item */
 				N_( "Display help about this program" ),
-				G_CALLBACK( on_help_activated ) },
+				G_CALLBACK( nact_main_menubar_help_on_help ) },
 		{ "AboutItem", GTK_STOCK_ABOUT, NULL, NULL,
 				/* i18n: tooltip displayed in the status bar when selecting the About item */
 				N_( "Display informations about this program" ),
-				G_CALLBACK( on_about_activated ) },
+				G_CALLBACK( nact_main_menubar_help_on_about ) },
 };
 
 static const GtkToggleActionEntry toolbar_entries[] = {
@@ -515,7 +512,7 @@ on_iactions_list_count_updated( NactMainWindow *window, gint menus, gint actions
 	mis->have_exportables = ( mis->list_actions > 0 );
 
 	/* i18n: note the space at the beginning of the sentence */
-	status = g_strdup_printf( _( " %d menus, %d actions, %d profiles are currently displayed" ), menus, actions, profiles );
+	status = g_strdup_printf( _( " %d menus, %d actions, %d profiles are currently loaded" ), menus, actions, profiles );
 	nact_main_statusbar_display_status( window, MENUBAR_PROP_MAIN_STATUS_CONTEXT, status );
 	g_free( status );
 
@@ -654,8 +651,8 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	 * we must have at least one writable provider
 	 */
 	new_item_enabled = is_first_parent_writable && has_writable_providers;
-	enable_item( window, "NewMenuItem", new_item_enabled );
-	enable_item( window, "NewActionItem", new_item_enabled );
+	nact_main_menubar_enable_item( window, "NewMenuItem", new_item_enabled );
+	nact_main_menubar_enable_item( window, "NewActionItem", new_item_enabled );
 
 	/* new profile enabled if selection is relative to only one writable action
 	 * i.e. contains profile(s) of the same action, or only contains one action
@@ -687,7 +684,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 			}
 		}
 	}
-	enable_item( window, "NewProfileItem",
+	nact_main_menubar_enable_item( window, "NewProfileItem",
 			new_profile_enabled &&
 			selected_action != NULL &&
 			nact_window_is_item_writable( NACT_WINDOW( window ), NA_OBJECT_ITEM( selected_action ), NULL ));
@@ -695,7 +692,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	/* save enabled if at least one item has been modified
 	 * or level-zero has been resorted and is writable
 	 */
-	enable_item( window, "SaveItem",
+	nact_main_menubar_enable_item( window, "SaveItem",
 			has_modified_items || ( mis->level_zero_order_changed && is_level_zero_writable ));
 
 	/* quit always enabled */
@@ -719,12 +716,12 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 		}
 	}
 	cut_enabled &= are_parents_writable;
-	enable_item( window, "CutItem", cut_enabled );
+	nact_main_menubar_enable_item( window, "CutItem", cut_enabled );
 
 	/* copy only requires a non-empty selection */
 	copy_enabled = mis->treeview_has_focus || mis->popup_handler;
 	copy_enabled &= count_selected > 0;
-	enable_item( window, "CopyItem", copy_enabled );
+	nact_main_menubar_enable_item( window, "CopyItem", copy_enabled );
 
 	/* paste enabled if
 	 * - clipboard is not empty
@@ -764,7 +761,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 			paste_enabled &= is_level_zero_writable;
 		}
 	}
-	enable_item( window, "PasteItem", paste_enabled );
+	nact_main_menubar_enable_item( window, "PasteItem", paste_enabled );
 
 	/* paste into enabled if
 	 * - clipboard is not empty
@@ -801,7 +798,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 			paste_enabled &= is_level_zero_writable;
 		}
 	}
-	enable_item( window, "PasteIntoItem", paste_into_enabled );
+	nact_main_menubar_enable_item( window, "PasteIntoItem", paste_into_enabled );
 
 	/* duplicate items will be duplicated besides each one
 	 * selection must be non-empty
@@ -809,11 +806,11 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	 * -> so this is the same than cut
 	 */
 	duplicate_enabled = cut_enabled;
-	enable_item( window, "DuplicateItem", duplicate_enabled );
+	nact_main_menubar_enable_item( window, "DuplicateItem", duplicate_enabled );
 
 	/* delete is same that cut */
 	delete_enabled = cut_enabled;
-	enable_item( window, "DeleteItem", delete_enabled );
+	nact_main_menubar_enable_item( window, "DeleteItem", delete_enabled );
 
 	/* reload items always enabled */
 
@@ -821,19 +818,16 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 
 	/* expand all/collapse all requires at least one item in the list */
 	count_list = mis->list_menus + mis->list_actions + mis->list_profiles;
-	enable_item( window, "ExpandAllItem", count_list > 0 );
-	enable_item( window, "CollapseAllItem", count_list > 0 );
+	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 */
-	enable_item( window, "ImportItem", has_writable_providers );
+	nact_main_menubar_enable_item( window, "ImportItem", has_writable_providers );
 
 	/* export item enabled if IActionsList store contains actions */
-	enable_item( window, "ExportItem", mis->have_exportables );
-
-	/* TODO: help temporarily disabled */
-	enable_item( window, "HelpItem", FALSE );
+	nact_main_menubar_enable_item( window, "ExportItem", mis->have_exportables );
 
-	/* about always enabled */
+	nact_main_menubar_help_on_update_sensitivities( window, user_data );
 
 	na_object_unref_selected_items( selected_items );
 }
@@ -1491,19 +1485,16 @@ on_dump_clipboard_activated( GtkAction *action, NactMainWindow *window )
 	nact_clipboard_dump( nact_main_window_get_clipboard( window ));
 }
 
-static void
-on_help_activated( GtkAction *gtk_action, NactMainWindow *window )
-{
-}
-
-static void
-on_about_activated( GtkAction *gtk_action, NactMainWindow *window )
-{
-	na_iabout_display( NA_IABOUT( window ));
-}
-
-static void
-enable_item( NactMainWindow *window, const gchar *name, gboolean enabled )
+/**
+ * nact_main_menubar_enable_item:
+ * @window: the #NactMainWindow main application window.
+ * @name: the name of the item in a menu.
+ * @enabled: whether this item should be enabled or not.
+ *
+ * Enable/disable an item in an menu.
+ */
+void
+nact_main_menubar_enable_item( NactMainWindow *window, const gchar *name, gboolean enabled )
 {
 	GtkActionGroup *group;
 	GtkAction *action;
diff --git a/src/nact/nact-main-menubar.h b/src/nact/nact-main-menubar.h
index cdc601c..d706ac4 100644
--- a/src/nact/nact-main-menubar.h
+++ b/src/nact/nact-main-menubar.h
@@ -51,6 +51,8 @@ gboolean nact_main_menubar_is_pasted_object_relabeled( NAObject *object, NAPivot
 void     nact_main_menubar_open_popup( NactMainWindow *window, GdkEventButton *event );
 void     nact_main_menubar_save_items( NactMainWindow *window );
 
+void     nact_main_menubar_enable_item( NactMainWindow *window, const gchar *name, gboolean enabled );
+
 G_END_DECLS
 
 #endif /* __NACT_NACT_MENUBAR_H__ */



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