[nautilus-actions] Fix relative ordering of displayed toolbars



commit dfa8a7650757d4adb3c41ba28b6059f1a37a624f
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jan 17 12:43:54 2010 +0100

    Fix relative ordering of displayed toolbars

 ChangeLog                                 |   16 ++-
 TODO                                      |    5 -
 nautilus-actions/nact/Makefile.am         |    2 +
 nautilus-actions/nact/nact-main-menubar.c |  136 +++-------------
 nautilus-actions/nact/nact-main-toolbar.c |  258 +++++++++++++++++++++++++++++
 nautilus-actions/nact/nact-main-toolbar.h |   56 ++++++
 6 files changed, 351 insertions(+), 122 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a67616..f847a49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,18 @@
+2009-01-17 Pierre Wieser <pwieser trychlos org>
+
+	* nautilus-actions/nact/nact-main-toolbar.c:
+	* nautilus-actions/nact/nact-main-toolbar.h: New files.
+
+	* nautilus-actions/nact/Makefile.am:
+	* nautilus-actions/nact/nact-main-menubar.c: Updated accordingly.
+
 2009-01-16 Pierre Wieser <pwieser trychlos org>
 
-	Fix cut/copy/paste dynamic.
+	* nautilus-actions/nact/nact-clipboard.c:
+	Fix primary clipboard management.
 
-	* nautilus-actions/nact/nact-clipboard.c
-	(nact_clipboard_primary_set): Copy data into a private dynamically allocated buffer.
-	(nact_clipboard_primary_get): Get data from the user_data buffer.
+	* nautilus-actions/nact/nact-main-menubar.c	(on_update_sensitivities):
+	Fix cut/copy/duplicate/delete sensitivity when selection is	multiple.
 
 2009-01-15 Pierre Wieser <pwieser trychlos org>
 
diff --git a/TODO b/TODO
index 058bd27..979d667 100644
--- a/TODO
+++ b/TODO
@@ -124,8 +124,3 @@
   (as a sort of 'transparent' selection)
 
 - enhancement.ui: notebook page should be labeled 'Action' or 'Menu' depending of current item
-
-- bug: toolbar position should not be absolute, but relative
-
-- bug: dnd an action with several profiles loses the profiles: only one profile
-  stays after the dnd
diff --git a/nautilus-actions/nact/Makefile.am b/nautilus-actions/nact/Makefile.am
index 02bda0a..491d779 100644
--- a/nautilus-actions/nact/Makefile.am
+++ b/nautilus-actions/nact/Makefile.am
@@ -108,6 +108,8 @@ nautilus_actions_config_tool_SOURCES = \
 	nact-main-statusbar.h										\
 	nact-main-tab.c												\
 	nact-main-tab.h												\
+	nact-main-toolbar.c											\
+	nact-main-toolbar.h											\
 	nact-main-window.c											\
 	nact-main-window.h											\
 	nact-preferences-editor.c									\
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index fb4f767..8f46afa 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -47,6 +47,7 @@
 #include "nact-iactions-list.h"
 #include "nact-clipboard.h"
 #include "nact-main-statusbar.h"
+#include "nact-main-toolbar.h"
 #include "nact-main-tab.h"
 #include "nact-main-menubar.h"
 
@@ -135,6 +136,7 @@ static void     on_view_file_toolbar_activated( GtkToggleAction *action, NactMai
 static void     on_view_edit_toolbar_activated( GtkToggleAction *action, NactMainWindow *window );
 static void     on_view_tools_toolbar_activated( GtkToggleAction *action, NactMainWindow *window );
 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 );
@@ -155,11 +157,6 @@ static void     on_menu_item_deselected( GtkMenuItem *proxy, NactMainWindow *win
 static void     on_popup_selection_done(GtkMenuShell *menushell, NactMainWindow *window );
 static void     on_proxy_connect( GtkActionGroup *action_group, GtkAction *action, GtkWidget *proxy, NactMainWindow *window );
 static void     on_proxy_disconnect( GtkActionGroup *action_group, GtkAction *action, GtkWidget *proxy, NactMainWindow *window );
-static void     on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, const gchar *pref, const gchar *path, int pos );
-static void     on_handle_finalize( gpointer data, GObject *handle );
-static void     on_attach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window );
-static void     on_detach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window );
-static void     toolbar_init( NactMainWindow *window, const gchar *pref, gboolean default_value, const gchar *item );
 
 static const GtkActionEntry entries[] = {
 
@@ -422,10 +419,7 @@ nact_main_menubar_runtime_init( NactMainWindow *window )
 	mis = g_new0( MenubarIndicatorsStruct, 1 );
 	g_object_set_data( G_OBJECT( window ), MENUBAR_PROP_INDICATORS, mis );
 
-	toolbar_init( window, MENUBAR_IPREFS_FILE_TOOLBAR, TRUE, "ViewFileToolbarItem" );
-	toolbar_init( window, MENUBAR_IPREFS_EDIT_TOOLBAR, FALSE, "ViewEditToolbarItem" );
-	toolbar_init( window, MENUBAR_IPREFS_TOOLS_TOOLBAR, FALSE, "ViewToolsToolbarItem" );
-	toolbar_init( window, MENUBAR_IPREFS_HELP_TOOLBAR, TRUE, "ViewHelpToolbarItem" );
+	nact_main_toolbar_init( window, action_group );
 }
 
 /**
@@ -1343,25 +1337,41 @@ on_collapse_all_activated( GtkAction *gtk_action, NactMainWindow *window )
 static void
 on_view_file_toolbar_activated( GtkToggleAction *action, NactMainWindow *window )
 {
-	on_view_toolbar_activated( action, window, MENUBAR_IPREFS_FILE_TOOLBAR, "/ui/FileToolbar", MENUBAR_FILE_TOOLBAR_POS );
+	/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_FILE_TOOLBAR, "/ui/FileToolbar", MENUBAR_FILE_TOOLBAR_POS );*/
+	on_view_toolbar_activated( action, window, MAIN_TOOLBAR_FILE_ID );
 }
 
 static void
 on_view_edit_toolbar_activated( GtkToggleAction *action, NactMainWindow *window )
 {
-	on_view_toolbar_activated( action, window, MENUBAR_IPREFS_EDIT_TOOLBAR, "/ui/EditToolbar", MENUBAR_EDIT_TOOLBAR_POS );
+	/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_EDIT_TOOLBAR, "/ui/EditToolbar", MENUBAR_EDIT_TOOLBAR_POS );*/
+	on_view_toolbar_activated( action, window, MAIN_TOOLBAR_EDIT_ID );
 }
 
 static void
 on_view_tools_toolbar_activated( GtkToggleAction *action, NactMainWindow *window )
 {
-	on_view_toolbar_activated( action, window, MENUBAR_IPREFS_TOOLS_TOOLBAR, "/ui/ToolsToolbar", MENUBAR_TOOLS_TOOLBAR_POS );
+	/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_TOOLS_TOOLBAR, "/ui/ToolsToolbar", MENUBAR_TOOLS_TOOLBAR_POS );*/
+	on_view_toolbar_activated( action, window, MAIN_TOOLBAR_TOOLS_ID );
 }
 
 static void
 on_view_help_toolbar_activated( GtkToggleAction *action, NactMainWindow *window )
 {
-	on_view_toolbar_activated( action, window, MENUBAR_IPREFS_HELP_TOOLBAR, "/ui/HelpToolbar", MENUBAR_HELP_TOOLBAR_POS );
+	/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_HELP_TOOLBAR, "/ui/HelpToolbar", MENUBAR_HELP_TOOLBAR_POS );*/
+	on_view_toolbar_activated( action, window, MAIN_TOOLBAR_HELP_ID );
+}
+
+static void
+on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, int toolbar_id )
+{
+	gboolean is_active;
+	GtkUIManager *ui_manager;
+
+	is_active = gtk_toggle_action_get_active( action );
+	ui_manager = ( GtkUIManager * ) g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_UI_MANAGER );
+
+	nact_main_toolbar_activate( window, toolbar_id, ui_manager, is_active );
 }
 
 static void
@@ -1550,103 +1560,3 @@ on_proxy_disconnect( GtkActionGroup *action_group, GtkAction *action, GtkWidget
 {
 	/* signal handlers will be automagically disconnected on BaseWindow::dispose */
 }
-
-static void
-on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, const gchar *pref, const gchar *path, int pos )
-{
-	static const gchar *thisfn = "nact_main_menubar_on_view_toolbar_activated";
-	NactApplication *application;
-	NAPivot *pivot;
-	gboolean is_active;
-	GtkUIManager *ui_manager;
-	GtkWidget *hbox, *toolbar, *handle;
-	gulong attach_id, detach_id;
-
-	is_active = gtk_toggle_action_get_active( action );
-
-	ui_manager = ( GtkUIManager * ) g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_UI_MANAGER );
-	toolbar = gtk_ui_manager_get_widget( ui_manager, path );
-	g_debug( "%s: toolbar=%p, path=%s, ref=%d", thisfn, ( void * ) toolbar, path, G_OBJECT( toolbar )->ref_count );
-	hbox = base_window_get_widget( BASE_WINDOW( window ), "ToolbarHBox" );
-
-	if( is_active ){
-
-		handle = gtk_handle_box_new();
-		gtk_handle_box_set_snap_edge( GTK_HANDLE_BOX( handle ), GTK_POS_LEFT );
-		g_object_set_data( G_OBJECT( toolbar ), "nact-main-menubar-handle", handle );
-		attach_id = g_signal_connect( handle, "child-attached", (GCallback ) on_attach_toolbar, window );
-		g_object_set_data( G_OBJECT( handle ), "nact-handle-attach-id", ( gpointer ) attach_id );
-		detach_id = g_signal_connect( handle, "child-detached", (GCallback ) on_detach_toolbar, window );
-		g_object_set_data( G_OBJECT( handle ), "nact-handle-detach-id", ( gpointer ) detach_id );
-		g_object_weak_ref( G_OBJECT( handle ), ( GWeakNotify ) on_handle_finalize, NULL );
-		gtk_container_add( GTK_CONTAINER( handle ), toolbar );
-		gtk_container_add( GTK_CONTAINER( hbox ), handle );
-		gtk_box_reorder_child( GTK_BOX( hbox ), handle, pos );
-		gtk_widget_show_all( handle );
-		g_debug( "%s: ref=%d", thisfn, G_OBJECT( toolbar )->ref_count );
-
-	} else {
-		handle = ( GtkWidget * ) g_object_get_data( G_OBJECT( toolbar ), "nact-main-menubar-handle" );
-		detach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "nact-handle-detach-id" );
-		g_signal_handler_disconnect( handle, detach_id );
-		attach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "nact-handle-attach-id" );
-		g_signal_handler_disconnect( handle, attach_id );
-		gtk_container_remove( GTK_CONTAINER( handle ), toolbar );
-		gtk_container_remove( GTK_CONTAINER( hbox ), handle );
-		g_debug( "%s: ref=%d", thisfn, G_OBJECT( toolbar )->ref_count );
-	}
-
-	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
-	pivot = nact_application_get_pivot( application );
-	na_iprefs_write_bool( NA_IPREFS( pivot ), pref, is_active );
-}
-
-static void
-on_handle_finalize( gpointer data, GObject *handle )
-{
-	g_debug( "nact_main_menubar_on_handle_finalize: handle=%p", ( void * ) handle );
-}
-
-static void
-on_attach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window )
-{
-	static const gchar *thisfn = "nact_main_menubar_on_attach_toolbar";
-
-	g_debug( "%s: handle=%p, toolbar=%p, window=%p", thisfn, ( void * ) handle, ( void * ) toolbar, ( void * ) window );
-
-	gtk_toolbar_set_show_arrow( toolbar, TRUE );
-}
-
-static void
-on_detach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window )
-{
-	static const gchar *thisfn = "nact_main_menubar_on_detach_toolbar";
-
-	g_debug( "%s: handle=%p, toolbar=%p, window=%p", thisfn, ( void * ) handle, ( void * ) toolbar, ( void * ) window );
-
-	gtk_toolbar_set_show_arrow( toolbar, FALSE );
-}
-
-/*
- * this set the initial state of the toggle options in View > Toolbars menu
- * when an option is activated, this will trigger the on_view_toolbar_activated()
- * which will actually display the toolbar
- */
-static void
-toolbar_init( NactMainWindow *window, const gchar *pref, gboolean default_value, const gchar *item )
-{
-	NactApplication *application;
-	NAPivot *pivot;
-	gboolean is_active;
-	GtkActionGroup *group;
-	GtkToggleAction *action;
-
-	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
-	pivot = nact_application_get_pivot( application );
-	is_active = na_iprefs_read_bool( NA_IPREFS( pivot ), pref, default_value );
-	if( is_active ){
-		group = g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_ACTIONS_GROUP );
-		action = GTK_TOGGLE_ACTION( gtk_action_group_get_action( group, item ));
-		gtk_toggle_action_set_active( action, TRUE );
-	}
-}
diff --git a/nautilus-actions/nact/nact-main-toolbar.c b/nautilus-actions/nact/nact-main-toolbar.c
new file mode 100644
index 0000000..c511c58
--- /dev/null
+++ b/nautilus-actions/nact/nact-main-toolbar.c
@@ -0,0 +1,258 @@
+/*
+ * 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 <runtime/na-iprefs.h>
+
+#include "nact-application.h"
+#include "nact-main-toolbar.h"
+
+typedef struct {
+	int      id;
+	gchar   *prefs_key;
+	gboolean displayed_per_default;
+	gchar   *ui_item;
+	gchar   *ui_path;
+}
+	ToolbarProps;
+
+static ToolbarProps toolbar_props[] = {
+		{ MAIN_TOOLBAR_FILE_ID , "main-file-toolbar" ,  TRUE, "ViewFileToolbarItem" , "/ui/FileToolbar" },
+		{ MAIN_TOOLBAR_EDIT_ID , "main-edit-toolbar" , FALSE, "ViewEditToolbarItem" , "/ui/EditToolbar" },
+		{ MAIN_TOOLBAR_TOOLS_ID, "main-tools-toolbar", FALSE, "ViewToolsToolbarItem", "/ui/ToolsToolbar" },
+		{ MAIN_TOOLBAR_HELP_ID , "main-help-toolbar" ,  TRUE, "ViewHelpToolbarItem" , "/ui/HelpToolbar" }
+};
+
+/* defines the relative position of the main toolbars
+ * that is: they are listed here in the order they should be displayed
+ */
+static int toolbar_pos[] = {
+		MAIN_TOOLBAR_FILE_ID,
+		MAIN_TOOLBAR_EDIT_ID,
+		MAIN_TOOLBAR_TOOLS_ID,
+		MAIN_TOOLBAR_HELP_ID
+};
+
+static void          init_toolbar( NactMainWindow *window, GtkActionGroup *group, int toolbar_id );
+static void          reorder_toolbars( GtkHBox *hbox, int toolbar_id, GtkWidget *handle );
+static void          on_handle_finalize( gpointer data, GObject *handle );
+static void          on_attach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window );
+static void          on_detach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window );
+static ToolbarProps *get_toolbar_properties( int toolbar_id );
+
+/**
+ * nact_main_toolbar_init:
+ * @window: this #NactMainWindow window.
+ *
+ * Setup the initial display of the standard main toolbars.
+ *
+ * This actually only setup the initial state of the toggle options in
+ * View > Toolbars menu; when an option is activated, this will trigger
+ * the 'on_view_toolbar_activated()' which will actually display the
+ * toolbar.
+ */
+void
+nact_main_toolbar_init( NactMainWindow *window, GtkActionGroup *group )
+{
+	static const gchar *thisfn = "nact_main_toolbar_init";
+	int i;
+
+	g_debug( "%s: window=%p, group=%p", thisfn, ( void * ) window, ( void * ) group );
+
+	for( i = 0 ; i < G_N_ELEMENTS( toolbar_pos ) ; ++i ){
+		init_toolbar( window, group, toolbar_pos[i] );
+	}
+}
+
+static void
+init_toolbar( NactMainWindow *window, GtkActionGroup *group, int toolbar_id )
+{
+	NactApplication *application;
+	NAPivot *pivot;
+	ToolbarProps *props;
+	gboolean is_active;
+	GtkToggleAction *action;
+
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+	pivot = nact_application_get_pivot( application );
+	props = get_toolbar_properties( toolbar_id );
+	if( props ){
+		is_active = na_iprefs_read_bool( NA_IPREFS( pivot ), props->prefs_key, props->displayed_per_default );
+		if( is_active ){
+			action = GTK_TOGGLE_ACTION( gtk_action_group_get_action( group, props->ui_item ));
+			gtk_toggle_action_set_active( action, TRUE );
+		}
+	}
+}
+
+/**
+ * nact_main_toolbar_activate:
+ * @window: this #NactMainWindow.
+ * @toolbar_id: the id of the activated toolbar.
+ * @ui_manager: the #GtkUIManager.
+ * @is_active: whether this toolbar is activated or not.
+ *
+ * Activate or desactivate the toolbar.
+ */
+void
+nact_main_toolbar_activate( NactMainWindow *window, int toolbar_id, GtkUIManager *ui_manager, gboolean is_active )
+{
+	static const gchar *thisfn = "nact_main_toolbar_activate";
+	ToolbarProps *props;
+	GtkWidget *toolbar, *hbox, *handle;
+	gulong attach_id, detach_id;
+	NactApplication *application;
+	NAPivot *pivot;
+
+	props = get_toolbar_properties( toolbar_id );
+	if( !props ){
+		return;
+	}
+
+	toolbar = gtk_ui_manager_get_widget( ui_manager, props->ui_path );
+	g_debug( "%s: toolbar=%p, path=%s, ref=%d", thisfn, ( void * ) toolbar, props->ui_path, G_OBJECT( toolbar )->ref_count );
+	hbox = base_window_get_widget( BASE_WINDOW( window ), "ToolbarHBox" );
+
+	if( is_active ){
+		handle = gtk_handle_box_new();
+		gtk_handle_box_set_snap_edge( GTK_HANDLE_BOX( handle ), GTK_POS_LEFT );
+		g_object_set_data( G_OBJECT( toolbar ), "nact-main-toolbar-handle", handle );
+		attach_id = g_signal_connect( handle, "child-attached", (GCallback ) on_attach_toolbar, window );
+		g_object_set_data( G_OBJECT( handle ), "nact-handle-attach-id", ( gpointer ) attach_id );
+		detach_id = g_signal_connect( handle, "child-detached", (GCallback ) on_detach_toolbar, window );
+		g_object_set_data( G_OBJECT( handle ), "nact-handle-detach-id", ( gpointer ) detach_id );
+		g_object_weak_ref( G_OBJECT( handle ), ( GWeakNotify ) on_handle_finalize, NULL );
+		gtk_container_add( GTK_CONTAINER( handle ), toolbar );
+		gtk_container_add( GTK_CONTAINER( hbox ), handle );
+		reorder_toolbars( GTK_HBOX( hbox ), toolbar_id, handle );
+		gtk_widget_show_all( handle );
+		g_debug( "%s: ref=%d", thisfn, G_OBJECT( toolbar )->ref_count );
+
+	} else {
+		handle = ( GtkWidget * ) g_object_get_data( G_OBJECT( toolbar ), "nact-main-toolbar-handle" );
+		detach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "nact-handle-detach-id" );
+		g_signal_handler_disconnect( handle, detach_id );
+		attach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "nact-handle-attach-id" );
+		g_signal_handler_disconnect( handle, attach_id );
+		gtk_container_remove( GTK_CONTAINER( handle ), toolbar );
+		gtk_container_remove( GTK_CONTAINER( hbox ), handle );
+		g_debug( "%s: ref=%d", thisfn, G_OBJECT( toolbar )->ref_count );
+	}
+
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+	pivot = nact_application_get_pivot( application );
+	na_iprefs_write_bool( NA_IPREFS( pivot ), props->prefs_key, is_active );
+}
+
+/*
+ * reposition the newly activated toolbar in handle
+ * so that the relative positions of toolbars are respected in hbox
+ */
+static void
+reorder_toolbars( GtkHBox *hbox, int toolbar_id, GtkWidget *handle )
+{
+	int this_canonic_rel_pos;
+	int i;
+	GList *children, *ic;
+	int pos;
+	int canonic_pos;
+
+	this_canonic_rel_pos = 0;
+	for( i = 0 ; i < G_N_ELEMENTS( toolbar_pos ); ++ i ){
+		if( toolbar_pos[i] == toolbar_id ){
+			this_canonic_rel_pos = i;
+			break;
+		}
+	}
+	g_object_set_data( G_OBJECT( handle ), "toolbar-canonic-pos", GINT_TO_POINTER( this_canonic_rel_pos ));
+
+	pos = 0;
+	children = gtk_container_get_children( GTK_CONTAINER( hbox ));
+	for( ic = children ; ic ; ic = ic->next ){
+		canonic_pos = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( ic->data ), "toolbar-canonic-pos" ));
+		if( canonic_pos >= this_canonic_rel_pos ){
+			break;
+		}
+		pos += 1;
+	}
+
+	gtk_box_reorder_child( GTK_BOX( hbox ), handle, pos );
+}
+
+static void
+on_handle_finalize( gpointer data, GObject *handle )
+{
+	g_debug( "nact_main_toolbar_on_handle_finalize: handle=%p", ( void * ) handle );
+}
+
+static void
+on_attach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window )
+{
+	static const gchar *thisfn = "nact_main_toolbar_on_attach_toolbar";
+
+	g_debug( "%s: handle=%p, toolbar=%p, window=%p", thisfn, ( void * ) handle, ( void * ) toolbar, ( void * ) window );
+
+	gtk_toolbar_set_show_arrow( toolbar, TRUE );
+}
+
+static void
+on_detach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window )
+{
+	static const gchar *thisfn = "nact_main_toolbar_on_detach_toolbar";
+
+	g_debug( "%s: handle=%p, toolbar=%p, window=%p", thisfn, ( void * ) handle, ( void * ) toolbar, ( void * ) window );
+
+	gtk_toolbar_set_show_arrow( toolbar, FALSE );
+}
+
+static ToolbarProps *
+get_toolbar_properties( int toolbar_id )
+{
+	static const gchar *thisfn = "nact_main_toolbar_get_toolbar_properties";
+	ToolbarProps *props;
+	int i;
+
+	props = NULL;
+
+	for( i = 0 ; i < G_N_ELEMENTS( toolbar_props ) && props == NULL ; ++i ){
+		if( toolbar_props[i].id == toolbar_id ){
+			props = &toolbar_props[i];
+		}
+	}
+
+	if( !props ){
+		g_warning( "%s: unable to find toolbar properties for id=%d", thisfn, toolbar_id );
+	}
+
+	return( props );
+}
diff --git a/nautilus-actions/nact/nact-main-toolbar.h b/nautilus-actions/nact/nact-main-toolbar.h
new file mode 100644
index 0000000..3a2a9d9
--- /dev/null
+++ b/nautilus-actions/nact/nact-main-toolbar.h
@@ -0,0 +1,56 @@
+/*
+ * 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_MAIN_TOOLBAR_H__
+#define __NACT_MAIN_TOOLBAR_H__
+
+/**
+ * SECTION: nact_main_toolbar
+ * @short_description: Main toolbar management.
+ * @include: nact/nact-main-toolbar.h
+ */
+
+#include "nact-main-window.h"
+
+G_BEGIN_DECLS
+
+enum {
+	MAIN_TOOLBAR_FILE_ID = 1,
+	MAIN_TOOLBAR_EDIT_ID,
+	MAIN_TOOLBAR_TOOLS_ID,
+	MAIN_TOOLBAR_HELP_ID,
+};
+
+void nact_main_toolbar_init( NactMainWindow *window, GtkActionGroup *group );
+void nact_main_toolbar_activate( NactMainWindow *window, int toolbar_id, GtkUIManager *manager, gboolean active );
+
+G_END_DECLS
+
+#endif /* __NACT_MAIN_TOOLBAR_H__ */



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