[nautilus-actions] Add About Nautilus Actions item to Nautilus context menu



commit e44afdb0b020f6a640b356680126f516dd7295e2
Author: Pierre Wieser <pwieser trychlos org>
Date:   Fri Aug 21 14:05:30 2009 +0200

    Add About Nautilus Actions item to Nautilus context menu
    
    I would like insert a separator before About item, but this is not possible for now.

 ChangeLog                     |   18 ++++++
 src/common/Makefile.am        |    2 +
 src/common/na-about.c         |  124 +++++++++++++++++++++++++++++++++++++++++
 src/common/na-about.h         |   50 ++++++++++++++++
 src/nact/nact-application.c   |    4 +-
 src/nact/nact-imenubar.c      |   58 +------------------
 src/plugin/nautilus-actions.c |   35 +++++++++++-
 7 files changed, 234 insertions(+), 57 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 96f3dd9..8d041d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2009-08-21 Pierre Wieser <pwieser trychlos org>
+
+	Add About Nautilus Actions item in Nautilus context menu.
+
+	* src/common/na-about.c:
+	* src/common/na-about.h: New files.
+
+	* src/common/Makefile.am: Updated accordingly.
+
+	* src/nact/nact-application.c:
+	Call na_about_get_icon_name() to get application default icon.
+
+	* src/nact/nact-imenubar.c:
+	Call na_about_display() to display About dialog box.
+
+	* src/plugin/nautilus-actions.c:
+	Add About Nautilus Actions item in Nautilus context menu.
+
 2009-08-20 Pierre Wieser <pwieser trychlos org>
 
 	Display actions as a submenu.
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index f801450..e40fa0b 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -35,6 +35,8 @@ AM_CPPFLAGS += \
 	$(NULL)
 
 libnact_la_SOURCES = \
+	na-about.c									\
+	na-about.h									\
 	na-action.c									\
 	na-action.h									\
 	na-action-class.h							\
diff --git a/src/common/na-about.c b/src/common/na-about.c
new file mode 100644
index 0000000..903c71b
--- /dev/null
+++ b/src/common/na-about.c
@@ -0,0 +1,124 @@
+/*
+ * 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 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 <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "na-about.h"
+
+/* TODO: make the website url and the mail addresses clickables
+ */
+/**
+ * na_about_display:
+ * @window: the toplevel window which will be the parent of the
+ * displayed dialog, or NULL.
+ *
+ * Displays the About dialog.
+ */
+void
+na_about_display( GObject *toplevel )
+{
+	static const gchar *thisfn = "na_about_display";
+	g_debug( "%s: toplevel=%p", thisfn, toplevel );
+
+	gchar *icon_name = na_about_get_icon_name();
+
+	static const gchar *artists[] = {
+		N_( "Ulisse Perusin <uli peru gmail com>" ),
+		NULL
+	};
+
+	static const gchar *authors[] = {
+		N_( "Frederic Ruaudel <grumz grumz net>" ),
+		N_( "Rodrigo Moya <rodrigo gnome-db org>" ),
+		N_( "Pierre Wieser <pwieser trychlos org>" ),
+		NULL
+	};
+
+	static const gchar *documenters[] = {
+		NULL
+	};
+
+	static gchar *license[] = {
+		N_( "Nautilus Actions Configuration Tool 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." ),
+		N_( "Nautilus Actions Configuration Tool 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." ),
+		N_( "You should have received a copy of the GNU General Public License along "
+			"with Nautilus Actions Configuration Tool ; if not, write to the Free "
+			"Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
+			"MA 02110-1301, USA." ),
+		NULL
+	};
+	gchar *license_i18n = g_strjoinv( "\n\n", license );
+
+	/*GtkWindow *toplevel = base_window_get_toplevel_dialog( BASE_WINDOW( window ));*/
+	if( toplevel ){
+		if( !GTK_IS_WINDOW( toplevel )){
+			toplevel = NULL;
+		}
+	}
+
+	gtk_show_about_dialog( GTK_WINDOW( toplevel ),
+			"artists", artists,
+			"authors", authors,
+			"comments", _( "A graphical interface to create and edit your Nautilus actions." ),
+			"copyright", _( "Copyright \xc2\xa9 2005-2007 Frederic Ruaudel <grumz grumz net>\nCopyright \xc2\xa9 2009 Pierre Wieser <pwieser trychlos org>" ),
+			"documenters", documenters,
+			"translator-credits", _( "The GNOME Translation Project <gnome-i18n gnome org>" ),
+			"license", license_i18n,
+			"wrap-license", TRUE,
+			"logo-icon-name", icon_name,
+			"version", PACKAGE_VERSION,
+			"website", "http://www.nautilus-actions.org";,
+			NULL );
+
+	g_free( license_i18n );
+	g_free( icon_name );
+}
+
+/**
+ * na_about_get_icon_name:
+ *
+ * Returns the name of the default icon for the application.
+ */
+gchar *
+na_about_get_icon_name( void )
+{
+	return( g_strdup( PACKAGE ));
+}
diff --git a/src/common/na-about.h b/src/common/na-about.h
new file mode 100644
index 0000000..063f315
--- /dev/null
+++ b/src/common/na-about.h
@@ -0,0 +1,50 @@
+/*
+ * 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 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 __NA_ABOUT_H__
+#define __NA_ABOUT_H__
+
+/**
+ * SECTION: na_about
+ * @short_description: Display the About dialog.
+ * @include: common/na-about.h
+ */
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+void   na_about_display( GObject *toplevel );
+
+gchar *na_about_get_icon_name( void );
+
+G_END_DECLS
+
+#endif /* __NA_ABOUT_H__ */
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index b43f5a6..d2cf12b 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -35,6 +35,8 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include <common/na-about.h>
+
 #include "nact-application.h"
 #include "nact-main-window.h"
 
@@ -324,7 +326,7 @@ appli_get_icon_name( BaseApplication *application )
 	static const gchar *thisfn = "nact_application_appli_get_icon_name";
 	g_debug( "%s: application=%p", thisfn, application );
 
-	return( g_strdup( PACKAGE ));
+	return( na_about_get_icon_name());
 }
 
 static gchar *
diff --git a/src/nact/nact-imenubar.c b/src/nact/nact-imenubar.c
index fc7dd54..f23e3b0 100644
--- a/src/nact/nact-imenubar.c
+++ b/src/nact/nact-imenubar.c
@@ -34,6 +34,8 @@
 
 #include <glib/gi18n.h>
 
+#include <common/na-about.h>
+
 #include "nact-application.h"
 #include "nact-assistant-export.h"
 #include "nact-assistant-import.h"
@@ -839,63 +841,9 @@ on_about_activated( GtkMenuItem *item, NactWindow *window )
 	static const gchar *thisfn = "nact_imenubar_on_about_activated";
 	g_debug( "%s: item=%p, window=%p", thisfn, item, window );
 
-	BaseApplication *appli;
-	g_object_get( G_OBJECT( window ), PROP_WINDOW_APPLICATION_STR, &appli, NULL );
-	gchar *icon_name = base_application_get_icon_name( appli );
-
-	static const gchar *artists[] = {
-		N_( "Ulisse Perusin <uli peru gmail com>" ),
-		NULL
-	};
-
-	static const gchar *authors[] = {
-		N_( "Frederic Ruaudel <grumz grumz net>" ),
-		N_( "Rodrigo Moya <rodrigo gnome-db org>" ),
-		N_( "Pierre Wieser <pwieser trychlos org>" ),
-		NULL
-	};
-
-	static const gchar *documenters[] = {
-		NULL
-	};
-
-	static gchar *license[] = {
-		N_( "Nautilus Actions Configuration Tool 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." ),
-		N_( "Nautilus Actions Configuration Tool 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." ),
-		N_( "You should have received a copy of the GNU General Public License along "
-			"with Nautilus Actions Configuration Tool ; if not, write to the Free "
-			"Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
-			"MA 02110-1301, USA." ),
-		NULL
-	};
-	gchar *license_i18n = g_strjoinv( "\n\n", license );
-
 	GtkWindow *toplevel = base_window_get_toplevel_dialog( BASE_WINDOW( window ));
 
-	gtk_show_about_dialog( toplevel,
-			"artists", artists,
-			"authors", authors,
-			"comments", _( "A graphical interface to create and edit your Nautilus actions." ),
-			"copyright", _( "Copyright \xc2\xa9 2005-2007 Frederic Ruaudel <grumz grumz net>\nCopyright \xc2\xa9 2009 Pierre Wieser <pwieser trychlos org>" ),
-			"documenters", documenters,
-			"translator-credits", _( "The GNOME Translation Project <gnome-i18n gnome org>" ),
-			"license", license_i18n,
-			"wrap-license", TRUE,
-			"logo-icon-name", icon_name,
-			"version", PACKAGE_VERSION,
-			"website", "http://www.nautilus-actions.org";,
-			NULL );
-
-	g_free( license_i18n );
-	g_free( icon_name );
-
-	/*nact_iactions_list_set_focus( NACT_WINDOW( wndmain ));*/
+	na_about_display( G_OBJECT( toplevel ));
 }
 
 static void
diff --git a/src/plugin/nautilus-actions.c b/src/plugin/nautilus-actions.c
index 50b1612..5e3c088 100644
--- a/src/plugin/nautilus-actions.c
+++ b/src/plugin/nautilus-actions.c
@@ -38,6 +38,7 @@
 #include <libnautilus-extension/nautilus-file-info.h>
 #include <libnautilus-extension/nautilus-menu-provider.h>
 
+#include <common/na-about.h>
 #include <common/na-action.h>
 #include <common/na-action-profile.h>
 #include <common/na-pivot.h>
@@ -73,6 +74,7 @@ static GList            *get_background_items( NautilusMenuProvider *provider, G
 static GList            *get_file_items( NautilusMenuProvider *provider, GtkWidget *window, GList *files );
 static NautilusMenuItem *create_menu_item( NAAction *action, NAActionProfile *profile, GList *files );
 static NautilusMenuItem *create_sub_menu( NautilusMenu **menu );
+static void              add_post_submenu( NautilusMenu *menu );
 static void              execute_action( NautilusMenuItem *item, NAActionProfile *profile );
 static void              actions_changed_handler( NAIPivotConsumer *instance, gpointer user_data );
 
@@ -337,6 +339,9 @@ get_file_items( NautilusMenuProvider *provider, GtkWidget *window, GList *files
 				}
 			}
 		}
+		if( have_submenu ){
+			add_post_submenu( menu );
+		}
 	}
 
 	return( items );
@@ -388,20 +393,48 @@ create_sub_menu( NautilusMenu **menu )
 {
 	NautilusMenuItem *item;
 
+	gchar *icon_name = na_about_get_icon_name();
+
 	item = nautilus_menu_item_new( "NautilusActionsExtensions",
 			_( "Nautilus-Actions extensions" ),
 			_( "A submenu which embeds the currently available Nautilus-Actions extensions" ),
-			PACKAGE );
+			icon_name );
 
 	if( menu ){
 		*menu = nautilus_menu_new();
 		nautilus_menu_item_set_submenu( item, *menu );
 	}
 
+	g_free( icon_name );
+
 	return( item );
 }
 
 static void
+add_post_submenu( NautilusMenu *menu )
+{
+	gchar *icon_name = na_about_get_icon_name();
+
+	NautilusMenuItem *item = nautilus_menu_item_new(
+			"AboutNautilusActions",
+			_( "About Nautilus Actions" ),
+			_( "Display information about Nautilus Actions" ),
+			icon_name );
+
+	g_signal_connect_data( item,
+				"activate",
+				G_CALLBACK( na_about_display ),
+				NULL,
+				NULL,
+				0
+	);
+
+	nautilus_menu_append_item( menu, item );
+
+	g_free( icon_name );
+}
+
+static void
 execute_action( NautilusMenuItem *item, NAActionProfile *profile )
 {
 	static const gchar *thisfn = "nautilus_actions_execute_action";



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