[nautilus-actions] A try to use GtkAction, but tooltips are not shown
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] A try to use GtkAction, but tooltips are not shown
- Date: Sun, 23 Aug 2009 17:31:13 +0000 (UTC)
commit bda18418ab2a8b63f75c92901ebad769494f0373
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Aug 19 21:04:56 2009 +0200
A try to use GtkAction, but tooltips are not shown
src/nact/Makefile.am | 5 +-
src/nact/nact-imenubar.c | 150 +++++++++++++++++++------
src/nact/nact-istatusbar.c | 143 +++++++++++++++++++++++
src/nact/nact-istatusbar.h | 69 +++++++++++
src/nact/nact-main-window.h | 2 +
src/nact/nautilus-actions-config-tool.actions | 27 +++++
6 files changed, 360 insertions(+), 36 deletions(-)
---
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 01a2d8e..7f75b9f 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -85,7 +85,10 @@ nautilus_actions_config_tool_LDADD = \
$(NAUTILUS_ACTIONS_LIBS) \
$(NULL)
-pkgdata_DATA = nautilus-actions-config-tool.ui
+pkgdata_DATA = \
+ nautilus-actions-config-tool.actions \
+ nautilus-actions-config-tool.ui \
+ $(NULL)
@INTLTOOL_DESKTOP_RULE@
diff --git a/src/nact/nact-imenubar.c b/src/nact/nact-imenubar.c
index 3b0a131..d954226 100644
--- a/src/nact/nact-imenubar.c
+++ b/src/nact/nact-imenubar.c
@@ -49,8 +49,6 @@
struct NactIMenubarInterfacePrivate {
};
-/* menubar properties, set on the main window
- */
#define PROP_IMENUBAR_STATUS_CONTEXT "nact-imenubar-status-context"
#define PROP_IMENUBAR_DELETED_ACTIONS "nact-imenubar-deleted-actions"
#define PROP_IMENUBAR_NEW_PROFILE_ITEM "nact-imenubar-new-profile-item"
@@ -130,6 +128,48 @@ static void set_delete_item( NactWindow *window, GtkWidget *item );
static GtkWidget *get_export_item( NactWindow *window );
static void set_export_item( NactWindow *window, GtkWidget *item );
+static const GtkActionEntry entries[] = {
+
+ { "FileMenu", NULL, N_( "_File" ) },
+ { "EditMenu", NULL, N_( "_Edit" ) },
+ { "ToolsMenu", NULL, N_( "_Tools" ) },
+ { "HelpMenu", NULL, N_( "_Help" ) },
+
+ { "NewActionItem", GTK_STOCK_NEW, N_( "_New action" ), "<Ctrl>N",
+ N_( "Define a new action." ),
+ G_CALLBACK( on_new_action_activated ) },
+ { "NewProfileItem", NULL, N_( "_New _profile" ), "<Ctrl>P",
+ N_( "Define a new profile attached to the current action." ),
+ G_CALLBACK( on_new_profile_activated ) },
+ { "SaveItem", GTK_STOCK_SAVE, NULL, NULL,
+ N_( "Record all the modified actions. Invalid actions will be silently ignored." ),
+ G_CALLBACK( on_save_activated ) },
+ { "QuitItem", GTK_STOCK_QUIT, NULL, NULL,
+ N_( "Quit the application." ),
+ G_CALLBACK( on_quit_activated ) },
+ { "DuplicateItem" , GTK_STOCK_COPY, N_( "D_uplicate" ), "",
+ N_( "Create a copy of the selected action or profile." ),
+ G_CALLBACK( on_duplicate_activated ) },
+ { "DeleteItem", GTK_STOCK_DELETE, NULL, "Delete",
+ N_( "Remove the selected action or profile from your configuration." ),
+ G_CALLBACK( on_delete_activated ) },
+ { "ReloadActionsItem", NULL, N_( "_Reload the list of actions" ), "<Ctrl>R",
+ N_( "Cancel your current modifications and reload the list of actions." ),
+ G_CALLBACK( on_reload_activated ) },
+ { "ImportItem" , GTK_STOCK_CONVERT, N_( "_Import assistant..." ), "",
+ N_( "Import one or more actions from external (XML) files into your configuration." ),
+ G_CALLBACK( on_import_activated ) },
+ { "ExportItem", NULL, N_( "E_xport assistant..." ), NULL,
+ N_( "Export one or more actions from your configuration to external XML files." ),
+ G_CALLBACK( on_export_activated ) },
+ { "HelpItem" , GTK_STOCK_HELP, NULL, NULL,
+ N_( "Display help about this program." ),
+ G_CALLBACK( on_help_activated ) },
+ { "AboutItem", GTK_STOCK_ABOUT, NULL, NULL,
+ N_( "Display informations about this program." ),
+ G_CALLBACK( on_about_activated ) },
+};
+
GType
nact_imenubar_get_type( void )
{
@@ -206,42 +246,82 @@ interface_base_finalize( NactIMenubarInterface *klass )
void
nact_imenubar_init( NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_imenubar_init";
+
g_assert( NACT_IS_MAIN_WINDOW( window ));
g_assert( NACT_IS_IMENUBAR( window ));
- /*static const gchar *menubar[] =
- "<ui>"
- " <menubar>"
- " <menu action=\"FileMenu\">"
- " <menuitem action=\"NewActionItem\" />"
- " <menuitem action=\"NewProfileItem\" />"
- " <menuitem action=\"SaveItem\" />"
- " <menuitem action=\"QuitItem\" />"
- " </menu>"
- " <menu action=\"EditMenu\">"
- " <menuitem action=\"DuplicateItem\" />"
- " <menuitem action=\"DeleteItem\" />"
- " <menuitem action=\"ReloadActionsItem\" />"
- " </menu>"
- " <menu action=\"ToolsMenu\">"
- " <menuitem action=\"ImportItem\" />"
- " <menuitem action=\"ExportItem\" />"
- " </menu>"
- " <menu action=\"HelpMenu\">"
- " <menuitem action=\"HelpItem\" />"
- " <menuitem action=\"AboutItem\" />"
- " </menu>"
- " </menubar>"
- "</ui>";*/
-
- GtkWidget *vbox = base_window_get_widget( BASE_WINDOW( window ), "MenubarVBox" );
- GtkWidget *menubar= gtk_menu_bar_new();
- gtk_container_add( GTK_CONTAINER( vbox ), menubar );
-
- create_file_menu( window, GTK_MENU_BAR( menubar ));
- create_edit_menu( window, GTK_MENU_BAR( menubar ));
- create_tools_menu( window, GTK_MENU_BAR( menubar ));
- create_help_menu( window, GTK_MENU_BAR( menubar ));
+ if( FALSE ){
+ GtkWidget *vbox = base_window_get_widget( BASE_WINDOW( window ), "MenubarVBox" );
+ GtkWidget *menubar= gtk_menu_bar_new();
+ gtk_container_add( GTK_CONTAINER( vbox ), menubar );
+
+ create_file_menu( window, GTK_MENU_BAR( menubar ));
+ create_edit_menu( window, GTK_MENU_BAR( menubar ));
+ create_tools_menu( window, GTK_MENU_BAR( menubar ));
+ create_help_menu( window, GTK_MENU_BAR( menubar ));
+ }
+
+ GtkActionGroup *action_group = gtk_action_group_new( "MenubarActions" );
+ gtk_action_group_set_translation_domain( action_group, GETTEXT_PACKAGE );
+ gtk_action_group_add_actions( action_group, entries, G_N_ELEMENTS( entries ), window );
+
+ GtkUIManager *ui_manager = gtk_ui_manager_new();
+ gtk_ui_manager_insert_action_group( ui_manager, action_group, 0 );
+ g_object_unref( action_group );
+
+ GError *error = NULL;
+ guint merge_id = gtk_ui_manager_add_ui_from_file( ui_manager, GLADEDIR "/nautilus-actions-config-tool.actions", &error );
+ if( merge_id == 0 || error ){
+ g_warning( "%s: error=%s", thisfn, error->message );
+ g_error_free( error );
+ }
+
+ GtkWindow *wnd = base_window_get_toplevel_dialog( BASE_WINDOW( window ));
+ GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group( ui_manager );
+ gtk_window_add_accel_group( wnd, accel_group );
+
+ GtkAction *action = gtk_ui_manager_get_action( ui_manager, "/ui/MainMenubar/FileMenu/NewActionItem" );
+ const gchar *tooltip = gtk_action_get_tooltip( action );
+ g_debug( "%s: tooltip=%s", thisfn, tooltip );
+
+ GList *action_groups = gtk_ui_manager_get_action_groups( ui_manager );
+ GList *ig;
+ for( ig = action_groups ; ig ; ig = ig->next ){
+ GtkActionGroup *group = GTK_ACTION_GROUP( ig->data );
+ const gchar *group_name = gtk_action_group_get_name( group );
+ GList *actions = gtk_action_group_list_actions( group );
+ GList *ia;
+ for( ia = actions ; ia ; ia = ia->next ){
+ GtkAction *action = GTK_ACTION( ia->data );
+ const gchar *action_name = gtk_action_get_name( action );
+ gchar *path = g_build_path( "/", "ui", group_name, action_name, NULL );
+ GtkWidget *widget = gtk_ui_manager_get_widget( ui_manager, path );
+ g_free( path );
+ g_debug( "%s: group_name=%s, action_name=%s, widget=%p", thisfn, group_name, action_name, widget );
+ signal_connect( window, widget, NULL, G_CALLBACK( on_new_profile_selected ));
+ }
+ g_list_free( actions );
+ }
+ /*int i;
+ for( i = 0 ; i < G_N_ELEMENTS( entries ) ; ++i ){
+ gchar *path = g_build_path( "/", "ui", "MainMenubar", entries[i].name, NULL );
+ GtkWidget *widget = gtk_ui_manager_get_widget( ui_manager, path );
+ g_debug( "%s: i=%d, widget=%p", thisfn, i, widget );
+ signal_connect( window, widget, NULL, G_CALLBACK( on_new_profile_selected ));
+ g_free( path );
+ }*/
+
+ GtkWidget *menubar = gtk_ui_manager_get_widget( ui_manager, "/ui/MainMenubar" );
+ GtkWidget *vbox = base_window_get_widget( BASE_WINDOW( window ), "MenuBarVBox" );
+ gtk_box_pack_start( GTK_BOX( vbox ), menubar, FALSE, FALSE, 0 );
+
+ GtkWidget *status_bar = v_get_status_bar( NACT_WINDOW( window ));
+ if( status_bar ){
+ g_assert( GTK_IS_STATUSBAR( status_bar ));
+ guint context = gtk_statusbar_get_context_id( GTK_STATUSBAR( status_bar ), "nact-imenubar" );
+ set_status_context( window, context );
+ }
}
/**
diff --git a/src/nact/nact-istatusbar.c b/src/nact/nact-istatusbar.c
new file mode 100644
index 0000000..2ea1138
--- /dev/null
+++ b/src/nact/nact-istatusbar.c
@@ -0,0 +1,143 @@
+/*
+ * 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 "nact-istatusbar.h"
+
+/* private interface data
+ */
+struct NactIStatusbarInterfacePrivate {
+};
+
+static GType register_type( void );
+static void interface_base_init( NactIStatusbarInterface *klass );
+static void interface_base_finalize( NactIStatusbarInterface *klass );
+
+static GtkStatusbar *v_get_status_bar( NactWindow *window );
+
+GType
+nact_istatusbar_get_type( void )
+{
+ static GType iface_type = 0;
+
+ if( !iface_type ){
+ iface_type = register_type();
+ }
+
+ return( iface_type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "nact_istatusbar_register_type";
+ g_debug( "%s", thisfn );
+
+ static const GTypeInfo info = {
+ sizeof( NactIStatusbarInterface ),
+ ( GBaseInitFunc ) interface_base_init,
+ ( GBaseFinalizeFunc ) interface_base_finalize,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ GType type = g_type_register_static( G_TYPE_INTERFACE, "NactIStatusbar", &info, 0 );
+
+ g_type_interface_add_prerequisite( type, NACT_WINDOW_TYPE );
+
+ return( type );
+}
+
+static void
+interface_base_init( NactIStatusbarInterface *klass )
+{
+ static const gchar *thisfn = "nact_istatusbar_interface_base_init";
+ static gboolean initialized = FALSE;
+
+ if( !initialized ){
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ klass->private = g_new0( NactIStatusbarInterfacePrivate, 1 );
+
+ initialized = TRUE;
+ }
+}
+
+static void
+interface_base_finalize( NactIStatusbarInterface *klass )
+{
+ static const gchar *thisfn = "nact_istatusbar_interface_base_finalize";
+ static gboolean finalized = FALSE ;
+
+ if( !finalized ){
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ g_free( klass->private );
+
+ finalized = TRUE;
+ }
+}
+
+void
+nact_istatusbar_display_status( NactWindow *window, const gchar *context, const gchar *status )
+{
+ GtkStatusbar *bar = v_get_status_bar( window );
+ if( bar ){
+ guint context_id = gtk_statusbar_get_context_id( bar, context );
+ gtk_statusbar_push( bar, context_id, status );
+ }
+}
+
+void
+nact_istatusbar_hide_status( NactWindow *window, const gchar *context )
+{
+ GtkStatusbar *bar = v_get_status_bar( window );
+ if( bar ){
+ guint context_id = gtk_statusbar_get_context_id( bar, context );
+ gtk_statusbar_pop( bar, context_id );
+ }
+}
+
+static GtkStatusbar *
+v_get_status_bar( NactWindow *window )
+{
+ if( NACT_ISTATUSBAR_GET_INTERFACE( window )->get_statusbar ){
+ return( NACT_ISTATUSBAR_GET_INTERFACE( window )->get_statusbar( window ));
+ }
+
+ return( NULL );
+}
diff --git a/src/nact/nact-istatusbar.h b/src/nact/nact-istatusbar.h
new file mode 100644
index 0000000..6ff654a
--- /dev/null
+++ b/src/nact/nact-istatusbar.h
@@ -0,0 +1,69 @@
+/*
+ * 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 __NACT_ISTATUSBAR_H__
+#define __NACT_ISTATUSBAR_H__
+
+/*
+ * NactIActionTab interface definition.
+ *
+ * This interface implements the "Nautilus Menu Item" box.
+ */
+
+#include "nact-window.h"
+
+G_BEGIN_DECLS
+
+#define NACT_ISTATUSBAR_TYPE ( nact_istatusbar_get_type())
+#define NACT_ISTATUSBAR( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_ISTATUSBAR_TYPE, NactIStatusbar ))
+#define NACT_IS_ISTATUSBAR( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_ISTATUSBAR_TYPE ))
+#define NACT_ISTATUSBAR_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NACT_ISTATUSBAR_TYPE, NactIStatusbarInterface ))
+
+typedef struct NactIStatusbar NactIStatusbar;
+
+typedef struct NactIStatusbarInterfacePrivate NactIStatusbarInterfacePrivate;
+
+typedef struct {
+ GTypeInterface parent;
+ NactIStatusbarInterfacePrivate *private;
+
+ /* api */
+ GtkStatusbar * ( *get_statusbar )( NactWindow *window );
+}
+ NactIStatusbarInterface;
+
+GType nact_istatusbar_get_type( void );
+
+void nact_istatusbar_display_status( NactWindow *window, const gchar *context, const gchar *status );
+void nact_istatusbar_hide_status( NactWindow *window, const gchar *context );
+
+G_END_DECLS
+
+#endif /* __NACT_ISTATUSBAR_H__ */
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index 77cbd45..308db6e 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -72,6 +72,8 @@ GSList *nact_main_window_get_actions( const NactMainWindow *window );
gboolean nact_main_window_action_exists( const NactMainWindow *window, const gchar *uuid );
GtkStatusbar *nact_main_window_get_statusbar( const NactMainWindow *window );
+GtkStatusbar *nact_main_window_get_statusbar( const NactMainWindow *window );
+
enum {
ACTION_TAB = 0,
COMMAND_TAB,
diff --git a/src/nact/nautilus-actions-config-tool.actions b/src/nact/nautilus-actions-config-tool.actions
new file mode 100644
index 0000000..013d41a
--- /dev/null
+++ b/src/nact/nautilus-actions-config-tool.actions
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<ui>
+ <menubar name="MainMenubar">
+ <menu action="FileMenu">
+ <menuitem action="NewActionItem" />
+ <menuitem action="NewProfileItem" />
+ <menuitem action="SaveItem" />
+ <separator />
+ <menuitem action="QuitItem" />
+ </menu>
+ <menu action="EditMenu">
+ <menuitem action="DuplicateItem" />
+ <menuitem action="DeleteItem" />
+ <separator />
+ <menuitem action="ReloadActionsItem" />
+ </menu>
+ <menu action="ToolsMenu">
+ <menuitem action="ImportItem" />
+ <menuitem action="ExportItem" />
+ </menu>
+ <menu action="HelpMenu">
+ <menuitem action="HelpItem" />
+ <separator />
+ <menuitem action="AboutItem" />
+ </menu>
+ </menubar>
+</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]