[nautilus-actions] Define NactBuilder new class
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define NactBuilder new class
- Date: Sat, 26 Sep 2009 22:50:06 +0000 (UTC)
commit 367a58c72f5a8ad2b883a4ca04570b09cab3f55e
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Sep 26 15:32:01 2009 +0200
Define NactBuilder new class
NactBuilder let any window to has its own GtkBuilder, possibly with its own XML UI definition.
ChangeLog | 34 +++
src/nact/Makefile.am | 2 +
src/nact/base-application.c | 240 +++++------------------
src/nact/base-application.h | 29 ++--
src/nact/base-assistant.c | 41 +----
src/nact/base-builder.c | 273 +++++++++++++++++++++++++
src/nact/base-builder.h | 83 ++++++++
src/nact/base-iprefs.c | 4 +-
src/nact/base-window-class.h | 73 ++++---
src/nact/base-window.c | 394 +++++++++++++++++++-----------------
src/nact/base-window.h | 6 +-
src/nact/nact-assistant-export.c | 23 ++-
src/nact/nact-assistant-import.c | 6 +-
src/nact/nact-iactions-list.c | 200 ++++++++----------
src/nact/nact-iactions-list.h | 19 ++-
src/nact/nact-icommand-tab.c | 4 +-
src/nact/nact-main-menubar.c | 8 +-
src/nact/nact-main-window.c | 4 +-
src/nact/nact-preferences-editor.c | 4 +-
src/nact/nact-tree-model.c | 14 +-
20 files changed, 853 insertions(+), 608 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0f485d3..f94d77b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2009-09-26 Pierre Wieser <pwieser trychlos org>
+
+ * src/nact/base-builder.c:
+ * src/nact/base-builder.h: New files.
+
+ * src/nact/Makefile.am: Updated accordingly.
+
+ * src/nact/base-application.c:
+ * src/nact/base-application.h:
+ Embeds a NactBuilder object.
+ base_application_get_toplevel(), base_application_get_widget(),
+ base_application_search_for_widget(): Removed functions.
+
+ * src/nact/base-assistant.c:
+ Remove embedded GtkBuilder object.
+
+ * src/nact/base-window-class.h (get_ui_filename):
+ New virtual function.
+ base_window_get_toplevel_window(): Renamed to
+ base_window_get_toplevel().
+
+ * src/nact/base-iprefs.c:
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-preferences-editor.c: Use base_window_get_toplevel().
+
+ * src/nact/base-window.c:
+ * src/nact/base-window.h: Two new properties
+ HAS_OWN_BUILDER and XML_UI_FILENAME.
+
+ * nact/nact-assistant-export.c:
+ * nact/nact-assistant-import.c: Use new properties.
+
+ * src/nact/nact-iactions-list.c: Define management mode.
+
2009-09-25 Pierre Wieser <pwieser trychlos org>
* data/nautilus-actions.schemas.in:
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 3e18f5f..cf4bdbb 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -44,6 +44,8 @@ nautilus_actions_config_tool_SOURCES = \
base-application-class.h \
base-assistant.c \
base-assistant.h \
+ base-builder.c \
+ base-builder.h \
base-dialog.c \
base-dialog.h \
base-iprefs.c \
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index 8b07a2b..c504ce5 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -49,16 +49,16 @@ struct BaseApplicationClassPrivate {
/* private instance data
*/
struct BaseApplicationPrivate {
- gboolean dispose_has_run;
- int argc;
- gpointer argv;
- gboolean is_gtk_initialized;
- UniqueApp *unique_app_handle;
- int exit_code;
- gchar *exit_message1;
- gchar *exit_message2;
- GtkBuilder *ui_xml;
- BaseWindow *main_window;
+ gboolean dispose_has_run;
+ int argc;
+ gpointer argv;
+ gboolean is_gtk_initialized;
+ UniqueApp *unique_app_handle;
+ int exit_code;
+ gchar *exit_message1;
+ gchar *exit_message2;
+ BaseBuilder *builder;
+ BaseWindow *main_window;
};
/* instance properties
@@ -71,7 +71,7 @@ enum {
BASE_APPLICATION_PROP_EXIT_CODE_ID,
BASE_APPLICATION_PROP_EXIT_MESSAGE1_ID,
BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID,
- BASE_APPLICATION_PROP_UI_XML_ID,
+ BASE_APPLICATION_PROP_BUILDER_ID,
BASE_APPLICATION_PROP_MAIN_WINDOW_ID
};
@@ -107,11 +107,8 @@ static gboolean application_do_initialize_application( BaseApplication *ap
static gboolean check_for_unique_app( BaseApplication *application );
/*static UniqueResponse on_unique_message_received( UniqueApp *app, UniqueCommand command, UniqueMessageData *message, guint time, gpointer user_data );*/
static gint display_dlg( BaseApplication *application, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *first, const gchar *second );
-static GtkWidget *recursive_search_for_child( BaseApplication *application, GtkWindow *toplevel, const gchar *name );
-static GtkWidget *search_for_child_widget( GtkContainer *container, const gchar *name );
static void display_error_message( BaseApplication *application );
-static void set_get_toplevel_error( BaseApplication *application, const gchar *name );
static void set_initialize_i18n_error( BaseApplication *application );
static void set_initialize_gtk_error( BaseApplication *application );
static void set_initialize_unique_app_error( BaseApplication *application );
@@ -226,11 +223,11 @@ class_init( BaseApplicationClass *klass )
g_object_class_install_property( object_class, BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID, spec );
spec = g_param_spec_pointer(
- BASE_APPLICATION_PROP_UI_XML,
+ BASE_APPLICATION_PROP_BUILDER,
"UI object pointer",
"A reference to the UI definition from GtkBuilder",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_APPLICATION_PROP_UI_XML_ID, spec );
+ g_object_class_install_property( object_class, BASE_APPLICATION_PROP_BUILDER_ID, spec );
spec = g_param_spec_pointer(
BASE_APPLICATION_PROP_MAIN_WINDOW,
@@ -313,8 +310,8 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_string( value, self->private->exit_message2 );
break;
- case BASE_APPLICATION_PROP_UI_XML_ID:
- g_value_set_pointer( value, self->private->ui_xml );
+ case BASE_APPLICATION_PROP_BUILDER_ID:
+ g_value_set_pointer( value, self->private->builder );
break;
case BASE_APPLICATION_PROP_MAIN_WINDOW_ID:
@@ -369,8 +366,8 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->exit_message2 = g_value_dup_string( value );
break;
- case BASE_APPLICATION_PROP_UI_XML_ID:
- self->private->ui_xml = g_value_get_pointer( value );
+ case BASE_APPLICATION_PROP_BUILDER_ID:
+ self->private->builder = g_value_get_pointer( value );
break;
case BASE_APPLICATION_PROP_MAIN_WINDOW_ID:
@@ -402,8 +399,8 @@ instance_dispose( GObject *application )
g_object_unref( self->private->unique_app_handle );
}
- if( GTK_IS_BUILDER( self->private->ui_xml )){
- g_object_unref( self->private->ui_xml );
+ if( GTK_IS_BUILDER( self->private->builder )){
+ g_object_unref( self->private->builder );
}
/* chain up to the parent class */
@@ -499,6 +496,28 @@ base_application_get_application_name( BaseApplication *application )
}
/**
+ * base_application_get_builder:
+ * @application: this #BaseApplication instance.
+ *
+ * Returns: the default #BaseBuilder object for the application.
+ */
+BaseBuilder *
+base_application_get_builder( BaseApplication *application )
+{
+ /*static const gchar *thisfn = "base_application_get_application_name";
+ g_debug( "%s: application=%p", thisfn, application );*/
+ BaseBuilder *builder = NULL;
+
+ g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
+
+ if( !application->private->dispose_has_run ){
+ builder = application->private->builder;
+ }
+
+ return( builder );
+}
+
+/**
* base_application_get_icon_name:
* @application: this #BaseApplication instance.
*
@@ -625,110 +644,6 @@ base_application_get_main_window( BaseApplication *application )
}
/**
- * base_application_get_toplevel:
- * @application: this #BaseApplication instance.
- * @name: the name of the searched toplevel window.
- *
- * This function provides a pointer to the toplevel dialog associated
- * with the specified #BaseWindow.
- *
- * Returns: a pointer to the named dialog, or NULL.
- * This pointer is owned by GtkBuilder instance, and must not be
- * g_free() nor g_object_unref() by the caller.
- */
-GtkWindow *
-base_application_get_toplevel( BaseApplication *application, const gchar *name )
-{
- /*static const gchar *thisfn = "base_application_get_dialog";
- g_debug( "%s: application=%p, name=%s", thisfn, application, name );*/
- GtkWindow *toplevel = NULL;
-
- g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- g_return_val_if_fail( name, NULL );
- g_return_val_if_fail( strlen( name ), NULL );
-
- if( !application->private->dispose_has_run ){
-
- toplevel = GTK_WINDOW( gtk_builder_get_object( application->private->ui_xml, name ));
-
- if( !toplevel ){
- set_get_toplevel_error( application, name );
-
- } else {
- g_assert( GTK_IS_WINDOW( toplevel ));
- }
- }
-
- return( toplevel );
-}
-
-/**
- * base_application_get_widget:
- * @application: this #BaseApplication instance.
- * @window: a #BaseWindow-derived document.
- * @name: the name of the searched widget.
- *
- * Returns a pointer to the named widget which is a child of the
- * toplevel #GtkWindow associated with @window.
- *
- * Returns: a pointer to the searched widget, or NULL.
- * This pointer is owned by GtkBuilder instance, and must not be
- * g_free() nor g_object_unref() by the caller.
- */
-GtkWidget *
-base_application_get_widget( BaseApplication *application, BaseWindow *window, const gchar *name )
-{
- /*static const gchar *thisfn = "base_application_get_widget";
- g_debug( "%s: application=%p, name=%s", thisfn, application, name );*/
- GtkWindow *toplevel;
- GtkWidget *widget = NULL;
-
- g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
- g_return_val_if_fail( name, NULL );
- g_return_val_if_fail( strlen( name ), NULL );
-
- if( !application->private->dispose_has_run ){
-
- toplevel = base_window_get_toplevel_window( window );
- widget = base_application_search_for_widget( application, toplevel, name );
- }
-
- return( widget );
-}
-
-/**
- * base_application_search_for_widget:
- * @application: this #BaseApplication instance.
- * @window: a #GtkWindow toplevel dialog.
- * @name: the name of the searched widget.
- *
- * Returns a pointer to the named widget which is a child of @window.
- *
- * Returns: a pointer to the searched widget, or NULL.
- * This pointer is owned by GtkBuilder instance, and must not be
- * g_free() nor g_object_unref() by the caller.
- */
-GtkWidget *
-base_application_search_for_widget( BaseApplication *application, GtkWindow *window, const gchar *name )
-{
- /*static const gchar *thisfn = "base_application_get_widget";
- g_debug( "%s: application=%p, name=%s", thisfn, application, name );*/
- GtkWidget *widget = NULL;
-
- if( !application->private->dispose_has_run ){
-
- widget = recursive_search_for_child( application, window, name );
-
- if( widget ){
- g_assert( GTK_IS_WIDGET( widget ));
- }
- }
-
- return( widget );
-}
-
-/**
* base_application_error_dlg:
* @application: this #BaseApplication instance.
* @type:
@@ -911,7 +826,7 @@ application_do_run( BaseApplication *application )
if( base_window_init( application->private->main_window )){
- wnd = base_window_get_toplevel_window( application->private->main_window );
+ wnd = base_window_get_toplevel( application->private->main_window );
g_assert( wnd );
g_assert( GTK_IS_WINDOW( wnd ));
@@ -1028,7 +943,6 @@ application_do_initialize_ui( BaseApplication *application )
gboolean ret = TRUE;
GError *error = NULL;
gchar *name;
- guint retint;
g_debug( "%s: application=%p", thisfn, ( void * ) application );
@@ -1039,12 +953,13 @@ application_do_initialize_ui( BaseApplication *application )
set_initialize_ui_get_fname_error( application );
} else {
- application->private->ui_xml = gtk_builder_new();
- retint = gtk_builder_add_from_file( application->private->ui_xml, name, &error );
- if( error || retint == 0 ){
+ application->private->builder = base_builder_new();
+ if( !base_builder_add_from_file( application->private->builder, name, &error )){
ret = FALSE;
set_initialize_ui_add_xml_error( application, name, error );
- g_error_free( error );
+ if( error ){
+ g_error_free( error );
+ }
}
}
@@ -1159,46 +1074,6 @@ display_dlg( BaseApplication *application, GtkMessageType type_message, GtkButto
return( result );
}
-static GtkWidget *
-recursive_search_for_child( BaseApplication *application, GtkWindow *toplevel, const gchar *name )
-{
- return( search_for_child_widget( GTK_CONTAINER( toplevel ) , name ));
-}
-
-static GtkWidget *
-search_for_child_widget( GtkContainer *container, const gchar *name )
-{
- /*static const gchar *thisfn = "base_application_search_for_child_widget";
- g_debug( "%s: container=%p, name=%s", thisfn, container, name );*/
-
- GList *children = gtk_container_get_children( container );
- GList *ic;
- GtkWidget *found = NULL;
- GtkWidget *child;
-
- for( ic = children ; ic ; ic = ic->next ){
- if( GTK_IS_WIDGET( ic->data )){
- child = GTK_WIDGET( ic->data );
- if( child->name && strlen( child->name )){
- /*g_debug( "%s: child=%s", thisfn, child->name );*/
- if( !g_ascii_strcasecmp( name, child->name )){
- found = child;
- break;
-
- } else if( GTK_IS_CONTAINER( child )){
- found = search_for_child_widget( GTK_CONTAINER( child ), name );
- if( found ){
- break;
- }
- }
- }
- }
- }
-
- g_list_free( children );
- return( found );
-}
-
static void
display_error_message( BaseApplication *application )
{
@@ -1221,25 +1096,6 @@ display_error_message( BaseApplication *application )
}
static void
-set_get_toplevel_error( BaseApplication *application, const gchar *toplevel_name )
-{
- gchar *fname, *msg;
-
- application->private->exit_code = BASE_APPLICATION_ERROR_TOPLEVEL_LOAD;
-
- fname = base_application_get_ui_filename( application );
-
- msg = g_strdup_printf(
- /* i18n: unable to load <dialog_name> dialog from XML definition in <filename> */
- _( "Unable to load %s dialog from XML definition in %s." ), toplevel_name, fname );
-
- base_application_error_dlg( application, GTK_MESSAGE_ERROR, msg, NULL );
-
- g_free( msg );
- g_free( fname );
-}
-
-static void
set_initialize_i18n_error( BaseApplication *application )
{
application->private->exit_code = BASE_APPLICATION_ERROR_I18N;
@@ -1284,7 +1140,7 @@ set_initialize_ui_add_xml_error( BaseApplication *application, const gchar *file
/* i18n: Unable to load the XML definition from <filename> */
g_strdup_printf( _( "Unable to load the XML definition from %s." ), filename );
- if( error->message ){
+ if( error && error->message ){
application->private->exit_message2 = g_strdup( error->message );
}
}
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index dae5b1e..6bb5c75 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -40,6 +40,7 @@
#include <gtk/gtk.h>
#include "base-application-class.h"
+#include "base-builder.h"
#include "base-window-class.h"
G_BEGIN_DECLS
@@ -51,7 +52,6 @@ enum {
BASE_APPLICATION_ERROR_UNIQUE_APP, /* another instance is running */
BASE_APPLICATION_ERROR_UI_FNAME, /* empty XML filename */
BASE_APPLICATION_ERROR_UI_LOAD, /* unable to load the XML definition of the UI */
- BASE_APPLICATION_ERROR_TOPLEVEL_LOAD, /* unable to load a toplevel from the XML definition */
BASE_APPLICATION_ERROR_DEFAULT_ICON /* unable to set default icon */
};
@@ -100,10 +100,10 @@ enum {
#define BASE_APPLICATION_PROP_EXIT_MESSAGE2 "base-application-exit-message2"
/**
- * @BASE_APPLICATION_PROP_UI_XML: the GtkBuilder object allocated to handle
- * the user interface XML definition. Rather for internal use.
+ * @BASE_APPLICATION_PROP_BUILDER: the #BaseBuilder object allocated to
+ * handle the user interface XML definition. Rather for internal use.
*/
-#define BASE_APPLICATION_PROP_UI_XML "base-application-ui-xml"
+#define BASE_APPLICATION_PROP_BUILDER "base-application-builder"
/**
* @BASE_APPLICATION_PROP_MAIN_WINDOW: as its name says: a pointer to the
@@ -111,19 +111,16 @@ enum {
*/
#define BASE_APPLICATION_PROP_MAIN_WINDOW "base-application-main-window"
-int base_application_run( BaseApplication *application );
-gchar *base_application_get_application_name( BaseApplication *application );
-gchar *base_application_get_icon_name( BaseApplication *application );
-gchar *base_application_get_unique_app_name( BaseApplication *application );
-gchar *base_application_get_ui_filename( BaseApplication *application );
-BaseWindow *base_application_get_main_window( BaseApplication *application );
+int base_application_run( BaseApplication *application );
+gchar *base_application_get_application_name( BaseApplication *application );
+gchar *base_application_get_icon_name( BaseApplication *application );
+gchar *base_application_get_unique_app_name( BaseApplication *application );
+gchar *base_application_get_ui_filename( BaseApplication *application );
+BaseBuilder *base_application_get_builder( BaseApplication *application );
+BaseWindow *base_application_get_main_window( BaseApplication *application );
-GtkWindow *base_application_get_toplevel( BaseApplication *application, const gchar *name );
-GtkWidget *base_application_get_widget( BaseApplication *application, BaseWindow *window, const gchar *name );
-GtkWidget *base_application_search_for_widget( BaseApplication *application, GtkWindow *window, const gchar *name );
-
-void base_application_error_dlg( BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second );
-gboolean base_application_yesno_dlg( BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second );
+void base_application_error_dlg( BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second );
+gboolean base_application_yesno_dlg( BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second );
G_END_DECLS
diff --git a/src/nact/base-assistant.c b/src/nact/base-assistant.c
index a5ded4d..4000a4f 100644
--- a/src/nact/base-assistant.c
+++ b/src/nact/base-assistant.c
@@ -49,7 +49,6 @@ struct BaseAssistantClassPrivate {
*/
struct BaseAssistantPrivate {
gboolean dispose_has_run;
- GtkBuilder *builder;
gboolean cancel_on_escape;
gboolean warn_on_escape;
gboolean warn_on_cancel;
@@ -75,8 +74,6 @@ static void instance_set_property( GObject *object, guint property_id, con
static void instance_dispose( GObject *application );
static void instance_finalize( GObject *application );
-static GtkWindow *base_get_window( BaseWindow *window, const gchar *name );
-
static void v_assistant_apply( GtkAssistant *assistant, BaseAssistant *window );
static void v_assistant_cancel( GtkAssistant *assistant, BaseAssistant *window );
static void v_assistant_close( GtkAssistant *assistant, BaseAssistant *window );
@@ -138,7 +135,6 @@ class_init( BaseAssistantClass *klass )
static const gchar *thisfn = "base_assistant_class_init";
GObjectClass *object_class;
GParamSpec *spec;
- BaseWindowClass *base_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -173,9 +169,6 @@ class_init( BaseAssistantClass *klass )
klass->private = g_new0( BaseAssistantClassPrivate, 1 );
- base_class = BASE_WINDOW_CLASS( klass );
- base_class->get_window = base_get_window;
-
klass->apply = assistant_do_apply;
klass->cancel = assistant_do_cancel;
klass->close = assistant_do_close;
@@ -289,8 +282,6 @@ instance_dispose( GObject *window )
self->private->dispose_has_run = TRUE;
- g_object_unref( self->private->builder );
-
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( window );
@@ -316,34 +307,6 @@ instance_finalize( GObject *window )
}
}
-/*
- * cf. http://bugzilla.gnome.org/show_bug.cgi?id=589746 against Gtk+ 2.16
- * a GtkFileChooserWidget embedded in a GtkAssistant is not displayed
- * when run more than once
- *
- * as a work-around, reload the XML ui each time we run an assistant !
- */
-static GtkWindow *
-base_get_window( BaseWindow *window, const gchar *name )
-{
- BaseApplication *appli;
- gchar *fname;
- GtkWindow *dialog;
-
- g_return_val_if_fail( BASE_IS_ASSISTANT( window ), NULL );
-
- BASE_ASSISTANT( window )->private->builder = gtk_builder_new();
-
- appli = base_window_get_application( window );
- fname = base_application_get_ui_filename( appli );
- gtk_builder_add_from_file( BASE_ASSISTANT( window )->private->builder, fname, NULL );
- g_free( fname );
-
- dialog = GTK_WINDOW( gtk_builder_get_object( BASE_ASSISTANT( window )->private->builder, name ));
-
- return( dialog );
-}
-
/**
* base_assistant_set_cancel_on_esc:
* @window: this #BaseAssistant instance.
@@ -527,7 +490,7 @@ on_runtime_init( BaseAssistant *window, gpointer user_data )
if( !window->private->dispose_has_run ){
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( window ));
g_assert( GTK_IS_ASSISTANT( toplevel ));
base_window_signal_connect(
@@ -578,7 +541,7 @@ on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseAssistant *assi
assistant->private->cancel_on_escape ){
assistant->private->escape_key_pressed = TRUE;
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( assistant ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( assistant ));
g_signal_emit_by_name( toplevel, "cancel", toplevel );
stop = TRUE;
}
diff --git a/src/nact/base-builder.c b/src/nact/base-builder.c
new file mode 100644
index 0000000..24a39b3
--- /dev/null
+++ b/src/nact/base-builder.c
@@ -0,0 +1,273 @@
+/*
+ * 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 <common/na-utils.h>
+
+#include "base-builder.h"
+
+/* private class data
+ */
+struct BaseBuilderClassPrivate {
+ void *empty; /* so that gcc -pedantic is happy */
+};
+
+/* private instance data
+ */
+struct BaseBuilderPrivate {
+ gboolean dispose_has_run;
+ GSList *fnames;
+};
+
+static GtkBuilderClass *st_parent_class = NULL;
+
+static GType register_type( void );
+static void class_init( BaseBuilderClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *application );
+static void instance_finalize( GObject *application );
+
+static gboolean already_loaded( BaseBuilder *builder, const gchar *filename );
+
+GType
+base_builder_get_type( void )
+{
+ static GType type = 0;
+
+ if( !type ){
+ type = register_type();
+ }
+
+ return( type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "base_builder_register_type";
+ GType type;
+
+ static GTypeInfo info = {
+ sizeof( BaseBuilderClass ),
+ ( GBaseInitFunc ) NULL,
+ ( GBaseFinalizeFunc ) NULL,
+ ( GClassInitFunc ) class_init,
+ NULL,
+ NULL,
+ sizeof( BaseBuilder ),
+ 0,
+ ( GInstanceInitFunc ) instance_init
+ };
+
+ g_debug( "%s", thisfn );
+
+ type = g_type_register_static( GTK_TYPE_BUILDER, "BaseBuilder", &info, 0 );
+
+ return( type );
+}
+
+static void
+class_init( BaseBuilderClass *klass )
+{
+ static const gchar *thisfn = "base_builder_class_init";
+ GObjectClass *object_class;
+
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ st_parent_class = g_type_class_peek_parent( klass );
+
+ object_class = G_OBJECT_CLASS( klass );
+ object_class->dispose = instance_dispose;
+ object_class->finalize = instance_finalize;
+
+ klass->private = g_new0( BaseBuilderClassPrivate, 1 );
+}
+
+static void
+instance_init( GTypeInstance *instance, gpointer klass )
+{
+ static const gchar *thisfn = "base_builder_instance_init";
+ BaseBuilder *self;
+
+ g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
+
+ g_return_if_fail( BASE_IS_BUILDER( instance ));
+ self = BASE_BUILDER( instance );
+
+ self->private = g_new0( BaseBuilderPrivate, 1 );
+
+ self->private->dispose_has_run = FALSE;
+}
+
+static void
+instance_dispose( GObject *window )
+{
+ static const gchar *thisfn = "base_builder_instance_dispose";
+ BaseBuilder *self;
+
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
+ g_return_if_fail( BASE_IS_BUILDER( window ));
+ self = BASE_BUILDER( window );
+
+ if( !self->private->dispose_has_run ){
+
+ self->private->dispose_has_run = TRUE;
+
+ /* chain up to the parent class */
+ if( G_OBJECT_CLASS( st_parent_class )->dispose ){
+ G_OBJECT_CLASS( st_parent_class )->dispose( window );
+ }
+ }
+}
+
+static void
+instance_finalize( GObject *window )
+{
+ static const gchar *thisfn = "base_builder_instance_finalize";
+ BaseBuilder *self;
+
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
+ g_return_if_fail( BASE_IS_BUILDER( window ));
+ self = BASE_BUILDER( window );
+
+ na_utils_free_string_list( self->private->fnames );
+
+ g_free( self->private );
+
+ /* chain call to parent class */
+ if( G_OBJECT_CLASS( st_parent_class )->finalize ){
+ G_OBJECT_CLASS( st_parent_class )->finalize( window );
+ }
+}
+
+/**
+ * base_builder_new:
+ *
+ * Returns: a newly allocated #BaseBuilder object.
+ */
+BaseBuilder *
+base_builder_new( void )
+{
+ BaseBuilder *builder;
+
+ builder = g_object_new( BASE_BUILDER_TYPE, NULL );
+
+ return( builder );
+}
+
+/**
+ * base_builder_add_from_file:
+ * @builder: this #BaseBuilder object.
+ * @filename: the filename to load.
+ * @error: a #GError whilch will be allocated if an error occurs.
+ *
+ * Loads the file into the GtkBuilder, taking care of not loading it
+ * twice.
+ *
+ * Returns: %TRUE if filename has been successfully loaded, or were
+ * already loaded, %FALSE else.
+ */
+gboolean
+base_builder_add_from_file( BaseBuilder *builder, const gchar *filename, GError **error )
+{
+ static const gchar *thisfn = "base_builder_add_from_file";
+ gboolean ret = FALSE;
+ guint retint;
+
+ g_return_val_if_fail( BASE_IS_BUILDER( builder ), FALSE );
+
+ if( !builder->private->dispose_has_run ){
+
+ if( already_loaded( builder, filename )){
+ g_debug( "%s: %s already loaded", thisfn, filename );
+ ret = TRUE;
+
+ } else {
+ retint = gtk_builder_add_from_file( GTK_BUILDER( builder ), filename, error );
+ if( retint > 0 && !( *error )){
+ builder->private->fnames = g_slist_prepend( builder->private->fnames, g_strdup( filename ));
+ ret = TRUE;
+ }
+ }
+ }
+
+ return( ret );
+}
+
+/**
+ * base_builder_load_named_toplevel:
+ * @builder: this #BaseBuilder object.
+ * @name: the name of the searched toplevel window.
+ *
+ * This function provides a pointer to the toplevel dialog associated
+ * with the specified #BaseWindow.
+ *
+ * Returns: a pointer to the named dialog, or NULL.
+ * This pointer is owned by GtkBuilder instance, and must not be
+ * g_free() nor g_object_unref() by the caller.
+ */
+GtkWindow *
+base_builder_load_named_toplevel( BaseBuilder *builder, const gchar *name )
+{
+ GtkWindow *toplevel = NULL;
+
+ g_return_val_if_fail( BASE_IS_BUILDER( builder ), NULL );
+ g_return_val_if_fail( name, NULL );
+ g_return_val_if_fail( g_utf8_strlen( name, -1 ), NULL );
+
+ if( !builder->private->dispose_has_run ){
+
+ toplevel = GTK_WINDOW( gtk_builder_get_object( GTK_BUILDER( builder ), name ));
+
+ if( toplevel ){
+ g_return_val_if_fail( GTK_IS_WINDOW( toplevel ), NULL );
+ }
+ }
+
+ return( toplevel );
+}
+
+static gboolean
+already_loaded( BaseBuilder *builder, const gchar *filename )
+{
+ gboolean loaded = FALSE;
+ GSList *it;
+
+ for( it = builder->private->fnames ; it && !loaded ; it = it->next ){
+ if( !g_utf8_collate(( const gchar * ) it->data, filename )){
+ loaded = TRUE;
+ }
+ }
+
+ return( loaded );
+}
diff --git a/src/nact/base-builder.h b/src/nact/base-builder.h
new file mode 100644
index 0000000..c65e632
--- /dev/null
+++ b/src/nact/base-builder.h
@@ -0,0 +1,83 @@
+/*
+ * 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 __BASE_BUILDER_H__
+#define __BASE_BUILDER_H__
+
+/**
+ * SECTION: base_builder
+ * @short_description: #BaseBuilder class definition.
+ * @include: nact/base-builder.h
+ *
+ * This class is derived from GtkBuilder class. It adds to it a list
+ * of already loaded files to be sure to not load them twice.
+ *
+ * #Basebuilder class is embedded as a convenience object in
+ * #BaseApplication and, possibly, in #BaseWindow instances.
+ */
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define BASE_BUILDER_TYPE ( base_builder_get_type())
+#define BASE_BUILDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, BASE_BUILDER_TYPE, BaseBuilder ))
+#define BASE_BUILDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, BASE_BUILDER_TYPE, BaseBuilderClass ))
+#define BASE_IS_BUILDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, BASE_BUILDER_TYPE ))
+#define BASE_IS_BUILDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), BASE_BUILDER_TYPE ))
+#define BASE_BUILDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), BASE_BUILDER_TYPE, BaseBuilderClass ))
+
+typedef struct BaseBuilderPrivate BaseBuilderPrivate;
+
+typedef struct {
+ GtkBuilder parent;
+ BaseBuilderPrivate *private;
+}
+ BaseBuilder;
+
+typedef struct BaseBuilderClassPrivate BaseBuilderClassPrivate;
+
+typedef struct {
+ GtkBuilderClass parent;
+ BaseBuilderClassPrivate *private;
+}
+ BaseBuilderClass;
+
+GType base_builder_get_type( void );
+
+BaseBuilder *base_builder_new( void );
+
+gboolean base_builder_add_from_file( BaseBuilder *builder, const gchar *filename, GError **error );
+
+GtkWindow *base_builder_load_named_toplevel( BaseBuilder *builder, const gchar *name );
+
+G_END_DECLS
+
+#endif /* __BASE_BUILDER_H__ */
diff --git a/src/nact/base-iprefs.c b/src/nact/base-iprefs.c
index 03e6706..033ae0e 100644
--- a/src/nact/base-iprefs.c
+++ b/src/nact/base-iprefs.c
@@ -202,7 +202,7 @@ base_iprefs_position_window( BaseWindow *window )
key = v_iprefs_get_window_id( window );
if( key ){
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( window ));
base_iprefs_position_named_window( window, toplevel, key );
g_free( key );
}
@@ -277,7 +277,7 @@ base_iprefs_save_window_position( BaseWindow *window )
key = v_iprefs_get_window_id( window );
if( key ){
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( window ));
base_iprefs_save_named_window_position( window, toplevel, key );
g_free( key );
}
diff --git a/src/nact/base-window-class.h b/src/nact/base-window-class.h
index f71faed..b6c78b6 100644
--- a/src/nact/base-window-class.h
+++ b/src/nact/base-window-class.h
@@ -39,6 +39,34 @@
* This is a base class which encapsulates a Gtk+ windows.
* It works together with the BaseApplication class to run a Gtk+
* application.
+ *
+ * Note that two properties of #BaseApplication may be overriden on a
+ * per-#BaseWindow basis. These are :
+ *
+ * - the #GtkBuilder UI manager
+ * the application has one global UI manager, but each window may
+ * have its own, provided that it is willing to reallocate a new
+ * one each time the window is opened.
+ *
+ * Cf. http://bugzilla.gnome.org/show_bug.cgi?id=589746 against
+ * Gtk+ 2.16 : a GtkFileChooserWidget embedded in a GtkAssistant is
+ * not displayed when run more than once. As a work-around, reload
+ * the XML ui each time we run an assistant !
+ *
+ * - the filename which handled the window XML definition
+ * the application provides with one global default file, but each
+ * window may decide to provide its own.
+ *
+ * Cf. http://bugzilla.gnome.org/show_bug.cgi?id=579345 against
+ * GtkBuilder : duplicate ids are no more allowed in a file. But we
+ * require this ability to have the same widget definition
+ * (ActionsList) in main window and export assistant.
+ * As a work-around, we have XML definition of export assistant in
+ * its own file.
+ * Another work-around could have be to let the IActionsList
+ * interface asks from the actual widget name to its implementor...
+ *
+ * Having its own XML UI definition implies having its own builder.
*/
#include <gtk/gtk.h>
@@ -104,12 +132,6 @@ typedef struct {
gboolean ( *delete_event ) ( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
/**
- * get_application:
- * @window: this #BaseWindow instance.
- */
- BaseApplication * ( *get_application ) ( BaseWindow *window );
-
- /**
* window_get_toplevel_name:
* @window: this #BaseWindow instance.
*
@@ -118,42 +140,31 @@ typedef struct {
gchar * ( *get_toplevel_name ) ( BaseWindow *window );
/**
- * get_toplevel_window:
+ * get_iprefs_window_id:
* @window: this #BaseWindow instance.
*
- * Returns the toplevel #GtkWindow associated with this #BaseWindow
- * instance.
- */
- GtkWindow * ( *get_toplevel_window ) ( BaseWindow *window );
-
- /**
- * get_window:
- * @window: this #BaseWindow instance.
+ * Asks the derived class for the string which must be used to
+ * store last size and position of the window in GConf preferences.
*
- * Returns the named GtkWindow.
+ * This delegates to #BaseWindow-derived classes the NactIPrefs
+ * interface virtual function.
*/
- GtkWindow * ( *get_window ) ( BaseWindow *window, const gchar *name );
+ gchar * ( *get_iprefs_window_id ) ( BaseWindow *window );
/**
- * get_widget:
+ * get_ui_filename:
* @window: this #BaseWindow instance.
*
- * Returns the named #GtkWidget searched as a descendant of the
- * #GtkWindow toplevel associated to this #Basewindow instance.
- */
- GtkWidget * ( *get_widget ) ( BaseWindow *window, const gchar *name );
-
- /**
- * get_iprefs_window_id:
- * @window: this #BaseWindow instance.
+ * Asks the derived class for the filename of the XML definition of
+ * the user interface for this window. This XML definition must be
+ * suitable in order to be loaded via GtkBuilder.
*
- * Asks the derived class for the string which must be used to
- * store last size and position of the window in GConf preferences.
+ * Defaults to application UI filename.
*
- * This delegates to #BaseWindow-derived classes the NactIPrefs
- * interface virtual function.
+ * Returns: the filename of the XML definition, to be g_free() by
+ * the caller.
*/
- gchar * ( *get_iprefs_window_id ) ( BaseWindow *window );
+ gchar * ( *get_ui_filename ) ( BaseWindow *window );
}
BaseWindowClass;
diff --git a/src/nact/base-window.c b/src/nact/base-window.c
index 836e686..3e28e57 100644
--- a/src/nact/base-window.c
+++ b/src/nact/base-window.c
@@ -58,6 +58,9 @@ struct BaseWindowPrivate {
gboolean initialized;
GSList *signals;
gboolean save_window_position;
+ gboolean has_own_builder;
+ BaseBuilder *builder;
+ gchar *ui_filename;
};
/* connected signal, to be disconnected at NactWindow dispose
@@ -76,7 +79,9 @@ enum {
BASE_WINDOW_PROP_TOPLEVEL_NAME_ID,
BASE_WINDOW_PROP_TOPLEVEL_WIDGET_ID,
BASE_WINDOW_PROP_INITIALIZED_ID,
- BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID
+ BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID,
+ BASE_WINDOW_PROP_HAS_OWN_BUILDER_ID,
+ BASE_WINDOW_PROP_XML_UI_FILENAME_ID
};
/* signals defined in BaseWindow, to be used in all derived classes
@@ -107,11 +112,9 @@ static void v_initial_load_toplevel( BaseWindow *window, gpointer us
static void v_runtime_init_toplevel( BaseWindow *window, gpointer user_data );
static void v_all_widgets_showed( BaseWindow *window, gpointer user_data );
static gboolean v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
-static BaseApplication *v_get_application( BaseWindow *window );
-static GtkWindow *v_get_toplevel_window( BaseWindow *window );
-static GtkWindow *v_get_window( BaseWindow *window, const gchar *name );
-static GtkWidget *v_get_widget( BaseWindow *window, const gchar *name );
+static gchar *v_get_toplevel_name( BaseWindow *window );
static gchar *v_get_iprefs_window_id( BaseWindow *window );
+static gchar *v_get_ui_filename( BaseWindow *window );
static void on_runtime_init_toplevel( BaseWindow *window, gpointer user_data );
@@ -120,15 +123,14 @@ static void window_do_runtime_init_toplevel( BaseWindow *window, gpo
static void window_do_all_widgets_showed( BaseWindow *window, gpointer user_data );
static gboolean window_do_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
static gboolean window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
-static BaseApplication *window_do_get_application( BaseWindow *window );
-static gchar *window_do_get_toplevel_name( BaseWindow *window );
-static GtkWindow *window_do_get_toplevel_window( BaseWindow *window );
-static GtkWindow *window_do_get_window( BaseWindow *window, const gchar *name );
-static GtkWidget *window_do_get_widget( BaseWindow *window, const gchar *name );
static gboolean is_main_window( BaseWindow *window );
static gboolean is_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel );
+static GtkWindow *load_named_toplevel( BaseWindow *window, const gchar *name );
+static GtkWidget *search_for_widget( GtkWindow *toplevel, const gchar *name );
+static GtkWidget *search_for_child_widget( GtkContainer *container, const gchar *name );
static void set_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel, gboolean init );
+static void setup_builder( BaseWindow *window );
GType
base_window_get_type( void )
@@ -234,6 +236,20 @@ class_init( BaseWindowClass *klass )
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID, spec );
+ spec = g_param_spec_boolean(
+ BASE_WINDOW_PROP_HAS_OWN_BUILDER,
+ "Does this have its own GtkBuilder",
+ "Whether this BaseWindow reallocates a new GtkBuilder each time it is opened", FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, BASE_WINDOW_PROP_HAS_OWN_BUILDER_ID, spec );
+
+ spec = g_param_spec_string(
+ BASE_WINDOW_PROP_XML_UI_FILENAME,
+ "Specific XML UI filename",
+ "The filename which contains the XML UI definition", "",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, BASE_WINDOW_PROP_XML_UI_FILENAME_ID, spec );
+
klass->private = g_new0( BaseWindowClassPrivate, 1 );
klass->initial_load_toplevel = window_do_initial_load_toplevel;
@@ -241,12 +257,9 @@ class_init( BaseWindowClass *klass )
klass->all_widgets_showed = window_do_all_widgets_showed;
klass->dialog_response = window_do_dialog_response;
klass->delete_event = window_do_delete_event;
- klass->get_application = window_do_get_application;
klass->get_toplevel_name = NULL;
- klass->get_toplevel_window = window_do_get_toplevel_window;
- klass->get_window = window_do_get_window;
- klass->get_widget = window_do_get_widget;
klass->get_iprefs_window_id = NULL;
+ klass->get_ui_filename = NULL;
/**
* nact-signal-base-window-initial-load:
@@ -379,6 +392,14 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_boolean( value, self->private->save_window_position );
break;
+ case BASE_WINDOW_PROP_HAS_OWN_BUILDER_ID:
+ g_value_set_boolean( value, self->private->has_own_builder );
+ break;
+
+ case BASE_WINDOW_PROP_XML_UI_FILENAME_ID:
+ g_value_set_string( value, self->private->ui_filename );
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -422,6 +443,15 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->save_window_position = g_value_get_boolean( value );
break;
+ case BASE_WINDOW_PROP_HAS_OWN_BUILDER_ID:
+ self->private->has_own_builder = g_value_get_boolean( value );
+ break;
+
+ case BASE_WINDOW_PROP_XML_UI_FILENAME_ID:
+ g_free( self->private->ui_filename );
+ self->private->ui_filename = g_value_dup_string( value );
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -477,6 +507,12 @@ instance_dispose( GObject *window )
self->private->dispose_has_run = TRUE;
+ /* release the Gtkbuilder, if any
+ */
+ if( self->private->builder ){
+ g_object_unref( self->private->builder );
+ }
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( window );
@@ -495,6 +531,7 @@ instance_finalize( GObject *window )
self = BASE_WINDOW( window );
g_free( self->private->toplevel_name );
+ g_free( self->private->ui_filename );
g_free( self->private );
@@ -549,10 +586,12 @@ base_window_init( BaseWindow *window )
g_assert( window->private->application );
g_assert( BASE_IS_APPLICATION( window->private->application ));
- dialog_name = window_do_get_toplevel_name( window );
+ setup_builder( window );
+
+ dialog_name = v_get_toplevel_name( window );
g_assert( dialog_name && strlen( dialog_name ));
- toplevel = base_window_get_toplevel( window, dialog_name );
+ toplevel = load_named_toplevel( window, dialog_name );
window->private->toplevel_window = toplevel;
if( toplevel ){
@@ -595,38 +634,40 @@ base_window_run( BaseWindow *window )
base_window_init( window );
}
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
+ this_dialog = GTK_WIDGET( window->private->toplevel_window );
+ if( this_dialog ){
- g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_RUNTIME_INIT, NULL );
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
- this_dialog = GTK_WIDGET( window->private->toplevel_window );
+ g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_RUNTIME_INIT, NULL );
- gtk_widget_show_all( this_dialog );
+ gtk_widget_show_all( this_dialog );
- g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED, NULL );
+ g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED, NULL );
- if( is_main_window( window )){
+ if( is_main_window( window )){
- if( GTK_IS_DIALOG( this_dialog )){
- g_signal_connect( G_OBJECT( this_dialog ), "response", G_CALLBACK( v_dialog_response ), window );
- } else {
- g_signal_connect( G_OBJECT( this_dialog ), "delete-event", G_CALLBACK( on_delete_event ), window );
- }
+ if( GTK_IS_DIALOG( this_dialog )){
+ g_signal_connect( G_OBJECT( this_dialog ), "response", G_CALLBACK( v_dialog_response ), window );
+ } else {
+ g_signal_connect( G_OBJECT( this_dialog ), "delete-event", G_CALLBACK( on_delete_event ), window );
+ }
- g_debug( "%s: application=%p, starting gtk_main", thisfn, ( void * ) window->private->application );
- gtk_main();
+ g_debug( "%s: application=%p, starting gtk_main", thisfn, ( void * ) window->private->application );
+ gtk_main();
- } else if( GTK_IS_ASSISTANT( this_dialog )){
- g_debug( "%s: starting gtk_main", thisfn );
- gtk_main();
+ } else if( GTK_IS_ASSISTANT( this_dialog )){
+ g_debug( "%s: starting gtk_main", thisfn );
+ gtk_main();
- } else {
- g_assert( GTK_IS_DIALOG( this_dialog ));
- g_debug( "%s: starting gtk_dialog_run", thisfn );
- do {
- code = gtk_dialog_run( GTK_DIALOG( this_dialog ));
+ } else {
+ g_assert( GTK_IS_DIALOG( this_dialog ));
+ g_debug( "%s: starting gtk_dialog_run", thisfn );
+ do {
+ code = gtk_dialog_run( GTK_DIALOG( this_dialog ));
+ }
+ while( !v_dialog_response( GTK_DIALOG( this_dialog ), code, window ));
}
- while( !v_dialog_response( GTK_DIALOG( this_dialog ), code, window ));
}
}
}
@@ -649,30 +690,34 @@ base_window_get_application( BaseWindow *window )
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
if( !window->private->dispose_has_run ){
- application = v_get_application( window );
+ application = window->private->application;
}
return( application );
}
/**
- * base_window_get_toplevel_window:
- * @window: this #BaseWindow instance..
+ * base_window_get_named_toplevel:
+ * @window: this #BaseWindow instance.
+ * @name: the name of the searched GtkWindow.
*
- * Returns the top-level GtkWindow attached to this BaseWindow object.
+ * Returns: the named top-level GtkWindow.
+ *
+ * This is just a convenience function to be able to open quickly a
+ * window (e.g. Legend dialog).
*
* The caller may close the window by g_object_unref()-ing the returned
* #GtkWindow.
*/
GtkWindow *
-base_window_get_toplevel_window( BaseWindow *window )
+base_window_get_named_toplevel( BaseWindow *window, const gchar *name )
{
GtkWindow *toplevel = NULL;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
if( !window->private->dispose_has_run ){
- toplevel = v_get_toplevel_window( window );
+ toplevel = load_named_toplevel( window, name );
}
return( toplevel );
@@ -680,23 +725,22 @@ base_window_get_toplevel_window( BaseWindow *window )
/**
* base_window_get_toplevel:
- * @window: this #BaseWindow instance.
- * @name: the name of the searched GtkWindow.
+ * @window: this #BaseWindow instance..
*
- * Returns: the named top-level GtkWindow.
+ * Returns the top-level GtkWindow attached to this BaseWindow object.
*
* The caller may close the window by g_object_unref()-ing the returned
* #GtkWindow.
*/
GtkWindow *
-base_window_get_toplevel( BaseWindow *window, const gchar *name )
+base_window_get_toplevel( BaseWindow *window )
{
GtkWindow *toplevel = NULL;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
if( !window->private->dispose_has_run ){
- toplevel = v_get_window( window, name );
+ toplevel = window->private->toplevel_window;
}
return( toplevel );
@@ -704,23 +748,27 @@ base_window_get_toplevel( BaseWindow *window, const gchar *name )
/**
* base_window_get_widget:
- * @window: this BaseWindow object.
+ * @window: this #BaseWindow instance.
* @name: the name of the searched child.
*
- * Returns: the GtkWidget which is a child of this parent.
+ * Returns a pointer to the named widget which is a child of the
+ * toplevel #GtkWindow associated with @window.
*
- * The returned #GtkWidget is owned by the #GtkBuilder UI. It should
- * not be g_free nor g_object_unref() by the caller.
+ * Returns: a pointer to the searched widget, or NULL.
+ * This pointer is owned by GtkBuilder instance, and must not be
+ * g_free() nor g_object_unref() by the caller.
*/
GtkWidget *
base_window_get_widget( BaseWindow *window, const gchar *name )
{
+ GtkWindow *toplevel;
GtkWidget *widget = NULL;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
if( !window->private->dispose_has_run ){
- widget = v_get_widget( window, name );
+ toplevel = window->private->toplevel_window;
+ widget = search_for_widget( toplevel, name );
}
return( widget );
@@ -841,93 +889,64 @@ v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
return( stop );
}
-static BaseApplication *
-v_get_application( BaseWindow *window )
+static gchar *
+v_get_toplevel_name( BaseWindow *window )
{
- BaseApplication *application = NULL;
+ gchar *name = NULL;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
- if( !window->private->dispose_has_run ){
-
- if( BASE_WINDOW_GET_CLASS( window )->get_application ){
- application = BASE_WINDOW_GET_CLASS( window )->get_application( window );
+ g_object_get( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, &name, NULL );
- } else {
- application = window_do_get_application( window );
+ if( !name || !strlen( name )){
+ if( BASE_WINDOW_GET_CLASS( window )->get_toplevel_name ){
+ name = BASE_WINDOW_GET_CLASS( window )->get_toplevel_name( window );
+ if( name && strlen( name )){
+ g_object_set( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, name, NULL );
+ }
}
}
- return( application );
-}
-
-static GtkWindow *
-v_get_toplevel_window( BaseWindow *window )
-{
- g_assert( BASE_IS_WINDOW( window ));
-
- if( BASE_WINDOW_GET_CLASS( window )->get_toplevel_window ){
- return( BASE_WINDOW_GET_CLASS( window )->get_toplevel_window( window ));
- }
-
- return( window_do_get_toplevel_window( window ));
+ return( name );
}
-static GtkWindow *
-v_get_window( BaseWindow *window, const gchar *name )
+static gchar *
+v_get_iprefs_window_id( BaseWindow *window )
{
- GtkWindow *toplevel = NULL;
+ gchar *id = NULL;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
if( !window->private->dispose_has_run ){
- if( BASE_WINDOW_GET_CLASS( window )->get_window ){
- toplevel = BASE_WINDOW_GET_CLASS( window )->get_window( window, name );
-
- } else {
- toplevel = window_do_get_window( window, name );
+ if( BASE_WINDOW_GET_CLASS( window )->get_iprefs_window_id ){
+ id = BASE_WINDOW_GET_CLASS( window )->get_iprefs_window_id( window );
}
}
- return( toplevel );
+ return( id );
}
-static GtkWidget *
-v_get_widget( BaseWindow *window, const gchar *name )
+static gchar *
+v_get_ui_filename( BaseWindow *window )
{
- GtkWidget *widget = NULL;
+ gchar *filename = NULL;
+ BaseApplication *application;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
if( !window->private->dispose_has_run ){
- if( BASE_WINDOW_GET_CLASS( window )->get_widget ){
- widget = BASE_WINDOW_GET_CLASS( window )->get_widget( window, name );
+ if( BASE_WINDOW_GET_CLASS( window )->get_ui_filename ){
+ filename = BASE_WINDOW_GET_CLASS( window )->get_ui_filename( window );
} else {
- widget = window_do_get_widget( window, name );
- }
- }
-
- return( widget );
-}
-
-static gchar *
-v_get_iprefs_window_id( BaseWindow *window )
-{
- gchar *id = NULL;
-
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
-
- if( !window->private->dispose_has_run ){
-
- if( BASE_WINDOW_GET_CLASS( window )->get_iprefs_window_id ){
- id = BASE_WINDOW_GET_CLASS( window )->get_iprefs_window_id( window );
+ application = base_window_get_application( window );
+ filename = base_application_get_ui_filename( application );
}
}
- return( id );
+ return( filename );
}
static void
@@ -944,7 +963,7 @@ on_runtime_init_toplevel( BaseWindow *window, gpointer user_data )
if( window->private->parent ){
g_assert( BASE_IS_WINDOW( window->private->parent ));
- parent_toplevel = base_window_get_toplevel_window( BASE_WINDOW( window->private->parent ));
+ parent_toplevel = base_window_get_toplevel( BASE_WINDOW( window->private->parent ));
gtk_window_set_transient_for( window->private->toplevel_window, parent_toplevel );
}
@@ -1023,121 +1042,134 @@ window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event
return( FALSE );
}
-static BaseApplication *
-window_do_get_application( BaseWindow *window )
-{
- BaseApplication *application = NULL;
-
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
-
- if( !window->private->dispose_has_run ){
- application = window->private->application;
- }
-
- return( application );
-}
-
-static gchar *
-window_do_get_toplevel_name( BaseWindow *window )
+static gboolean
+is_main_window( BaseWindow *window )
{
- gchar *name = NULL;
+ gboolean is_main = FALSE;
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
if( !window->private->dispose_has_run ){
- g_object_get( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, &name, NULL );
+ BaseApplication *appli = window->private->application;
+ BaseWindow *main_window = BASE_WINDOW( base_application_get_main_window( appli ));
- if( !name || !strlen( name )){
- name = BASE_WINDOW_GET_CLASS( window )->get_toplevel_name( window );
- if( name && strlen( name )){
- g_object_set( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, name, NULL );
- }
- }
+ is_main = ( main_window->private->toplevel_window == window->private->toplevel_window );
}
- return( name );
+ return( is_main );
}
-static GtkWindow *
-window_do_get_toplevel_window( BaseWindow *window )
+static gboolean
+is_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel )
{
- GtkWindow *toplevel = NULL;
-
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+ gboolean initialized;
- if( !window->private->dispose_has_run ){
- toplevel = window->private->toplevel_window;
- }
+ initialized = GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toplevel ), "base-window-toplevel-initialized" ));
- return( toplevel );
+ return( initialized );
}
static GtkWindow *
-window_do_get_window( BaseWindow *window, const gchar *name )
+load_named_toplevel( BaseWindow *window, const gchar *name )
{
GtkWindow *toplevel = NULL;
+ BaseApplication *application;
+ BaseBuilder *builder;
+ gchar *msg;
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+ if( window->private->builder ){
+ g_return_val_if_fail( BASE_IS_BUILDER( window->private->builder ), NULL );
+ toplevel = base_builder_load_named_toplevel( window->private->builder, name );
+ }
- if( !window->private->dispose_has_run ){
- toplevel = base_application_get_toplevel( window->private->application, name );
+ if( !toplevel ){
+ application = base_window_get_application( window );
+ builder = base_application_get_builder( application );
+ toplevel = base_builder_load_named_toplevel( builder, name );
+ }
+
+ if( !toplevel ){
+ msg = g_strdup_printf( _( "Unable to load %s XML definition." ), name );
+ base_application_error_dlg( window->private->application, GTK_MESSAGE_ERROR, msg, NULL );
+ g_free( msg );
}
return( toplevel );
}
static GtkWidget *
-window_do_get_widget( BaseWindow *window, const gchar *name )
+search_for_widget( GtkWindow *toplevel, const gchar *name )
{
GtkWidget *widget = NULL;
- g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+ widget = search_for_child_widget( GTK_CONTAINER( toplevel ) , name );
- if( !window->private->dispose_has_run ){
- widget = base_application_get_widget( window->private->application, window, name );
- }
+ g_return_val_if_fail( GTK_IS_WIDGET( widget ) || !widget, NULL );
return( widget );
}
-static gboolean
-is_main_window( BaseWindow *window )
+static GtkWidget *
+search_for_child_widget( GtkContainer *container, const gchar *name )
{
- gboolean is_main = FALSE;
-
- g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
-
- if( !window->private->dispose_has_run ){
-
- BaseApplication *appli = window->private->application;
-
- BaseWindow *main_window = BASE_WINDOW( base_application_get_main_window( appli ));
-
- GtkWidget *main_dialog = GTK_WIDGET( base_window_get_toplevel_window( main_window ));
-
- GtkWidget *this_dialog = GTK_WIDGET( window->private->toplevel_window );
-
- is_main = ( main_dialog == this_dialog );
+ GList *children = gtk_container_get_children( container );
+ GList *ic;
+ GtkWidget *found = NULL;
+ GtkWidget *child;
+
+ for( ic = children ; ic ; ic = ic->next ){
+ if( GTK_IS_WIDGET( ic->data )){
+ child = GTK_WIDGET( ic->data );
+ if( child->name && strlen( child->name )){
+ /*g_debug( "%s: child=%s", thisfn, child->name );*/
+ if( !g_ascii_strcasecmp( name, child->name )){
+ found = child;
+ break;
+
+ } else if( GTK_IS_CONTAINER( child )){
+ found = search_for_child_widget( GTK_CONTAINER( child ), name );
+ if( found ){
+ break;
+ }
+ }
+ }
+ }
}
- return( is_main );
+ g_list_free( children );
+ return( found );
}
-static gboolean
-is_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel )
+static void
+set_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel, gboolean initialized )
{
- gboolean initialized;
-
- initialized = GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toplevel ), "base-window-toplevel-initialized" ));
-
- return( initialized );
+ g_object_set_data( G_OBJECT( toplevel ), "base-window-toplevel-initialized", GUINT_TO_POINTER( initialized ));
}
+/*
+ * setup the builder of the window as a new one, or use the global one
+ */
static void
-set_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel, gboolean initialized )
+setup_builder( BaseWindow *window )
{
- g_object_set_data( G_OBJECT( toplevel ), "base-window-toplevel-initialized", GUINT_TO_POINTER( initialized ));
+ static const gchar *thisfn = "base_window_setup_builder";
+ gchar *fname;
+ GError *error = NULL;
+
+ if( window->private->has_own_builder ){
+
+ window->private->builder = base_builder_new();
+
+ fname = v_get_ui_filename( window );
+ g_return_if_fail( fname && strlen( fname ));
+
+ if( !base_builder_add_from_file( window->private->builder, fname, &error )){
+ g_warning( "%s: unable to load %s UI XML definition: %s", thisfn, fname, error->message );
+ g_error_free( error );
+ }
+ g_free( fname );
+ }
}
void
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index 6c5734d..80ffa2d 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -56,6 +56,8 @@ G_BEGIN_DECLS
#define BASE_WINDOW_PROP_TOPLEVEL_WIDGET "base-window-toplevel-widget"
#define BASE_WINDOW_PROP_INITIALIZED "base-window-is-initialized"
#define BASE_WINDOW_PROP_SAVE_WINDOW_POSITION "base-window-save-window-position"
+#define BASE_WINDOW_PROP_HAS_OWN_BUILDER "base-window-has-own-builder"
+#define BASE_WINDOW_PROP_XML_UI_FILENAME "base-window-xml-ui-filename"
/* signals defined in this class
*
@@ -75,9 +77,9 @@ G_BEGIN_DECLS
gboolean base_window_init( BaseWindow *window );
void base_window_run( BaseWindow *window );
-GtkWindow *base_window_get_toplevel_window( BaseWindow *window );
BaseApplication *base_window_get_application( BaseWindow *window );
-GtkWindow *base_window_get_toplevel( BaseWindow *window, const gchar *name );
+GtkWindow *base_window_get_named_toplevel( BaseWindow *window, const gchar *name );
+GtkWindow *base_window_get_toplevel( BaseWindow *window );
GtkWidget *base_window_get_widget( BaseWindow *window, const gchar *name );
void base_window_set_save_window_position( BaseWindow *window, gboolean save );
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 759b793..06d17d4 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -103,6 +103,7 @@ static NactAssistantExport *assist_new( BaseApplication *application );
static gchar *window_get_iprefs_window_id( BaseWindow *window );
static gchar *window_get_toplevel_name( BaseWindow *dialog );
+static gchar *window_get_ui_filename( BaseWindow *dialog );
static void on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data );
static void on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data );
@@ -213,8 +214,9 @@ class_init( NactAssistantExportClass *klass )
klass->private = g_new0( NactAssistantExportClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->get_toplevel_name = window_get_toplevel_name;
base_class->get_iprefs_window_id = window_get_iprefs_window_id;
+ base_class->get_toplevel_name = window_get_toplevel_name;
+ base_class->get_ui_filename = window_get_ui_filename;
assist_class = BASE_ASSISTANT_CLASS( klass );
assist_class->apply = assistant_apply;
@@ -332,6 +334,7 @@ nact_assistant_export_run( BaseWindow *main_window )
assist = assist_new( appli );
g_object_set( G_OBJECT( assist ), BASE_WINDOW_PROP_PARENT, main_window, NULL );
+ g_object_set( G_OBJECT( assist ), BASE_WINDOW_PROP_HAS_OWN_BUILDER, TRUE, NULL );
assist->private->main_window = NACT_MAIN_WINDOW( main_window );
@@ -350,6 +353,12 @@ window_get_toplevel_name( BaseWindow *dialog )
return( g_strdup( "ExportAssistant" ));
}
+static gchar *
+window_get_ui_filename( BaseWindow *dialog )
+{
+ return( g_strdup( PKGDATADIR "/nact-assistant-export.ui" ));
+}
+
static void
on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data )
{
@@ -359,7 +368,7 @@ on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data )
g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
g_assert( NACT_IS_ASSISTANT_EXPORT( dialog ));
- assistant = GTK_ASSISTANT( base_window_get_toplevel_window( BASE_WINDOW( dialog )));
+ assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( dialog )));
assist_initial_load_intro( dialog, assistant );
assist_initial_load_actions_list( dialog, assistant );
@@ -381,7 +390,7 @@ on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data )
g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
g_assert( NACT_IS_ASSISTANT_EXPORT( dialog ));
- assistant = GTK_ASSISTANT( base_window_get_toplevel_window( BASE_WINDOW( dialog )));
+ assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( dialog )));
assist_runtime_init_intro( dialog, assistant );
assist_runtime_init_actions_list( dialog, assistant );
@@ -492,9 +501,9 @@ static void
assist_initial_load_actions_list( NactAssistantExport *window, GtkAssistant *assistant )
{
g_assert( NACT_IS_IACTIONS_LIST( window ));
+
+ nact_iactions_list_set_management_mode( NACT_IACTIONS_LIST( window ), IACTIONS_LIST_MANAGEMENT_MODE_EXPORT );
nact_iactions_list_initial_load_toplevel( NACT_IACTIONS_LIST( window ));
- nact_iactions_list_set_multiple_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
- nact_iactions_list_set_only_actions_mode( NACT_IACTIONS_LIST( window ), TRUE );
}
static void
@@ -528,7 +537,7 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
GtkWidget *content;
g_assert( NACT_IS_ASSISTANT_EXPORT( instance ));
- assistant = GTK_ASSISTANT( base_window_get_toplevel_window( BASE_WINDOW( instance )));
+ assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( instance )));
pos = gtk_assistant_get_current_page( assistant );
if( pos == ASSIST_PAGE_ACTIONS_SELECTION ){
@@ -599,7 +608,7 @@ on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data )
g_debug( "%s: chooser=%p, user_data=%p", thisfn, ( void * ) chooser, ( void * ) user_data );
g_assert( NACT_IS_ASSISTANT_EXPORT( user_data ));
- assistant = GTK_ASSISTANT( base_window_get_toplevel_window( BASE_WINDOW( user_data )));
+ assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( user_data )));
pos = gtk_assistant_get_current_page( assistant );
if( pos == ASSIST_PAGE_FOLDER_SELECTION ){
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index ef5ae8d..07df74d 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -267,8 +267,8 @@ nact_assistant_import_run( BaseWindow *main_window )
appli = BASE_APPLICATION( base_window_get_application( main_window ));
assist = assist_new( appli );
-
g_object_set( G_OBJECT( assist ), BASE_WINDOW_PROP_PARENT, main_window, NULL );
+ g_object_set( G_OBJECT( assist ), BASE_WINDOW_PROP_HAS_OWN_BUILDER, TRUE, NULL );
base_window_run( BASE_WINDOW( assist ));
@@ -301,7 +301,7 @@ on_runtime_init_dialog( NactAssistantImport *dialog, gpointer user_data )
base_assistant_set_cancel_on_esc( BASE_ASSISTANT( dialog ), TRUE );
base_assistant_set_warn_on_esc( BASE_ASSISTANT( dialog ), TRUE );
- assistant = GTK_ASSISTANT( base_window_get_toplevel_window( BASE_WINDOW( dialog )));
+ assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( dialog )));
runtime_init_intro( dialog, assistant );
runtime_init_file_selector( dialog, assistant );
@@ -366,7 +366,7 @@ on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data )
GtkWidget *content;
g_assert( NACT_IS_ASSISTANT_IMPORT( user_data ));
- assistant = GTK_ASSISTANT( base_window_get_toplevel_window( BASE_WINDOW( user_data )));
+ assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( user_data )));
pos = gtk_assistant_get_current_page( assistant );
if( pos == ASSIST_PAGE_FILES_SELECTION ){
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 97102f6..709dafc 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -103,12 +103,10 @@ typedef struct {
}
IdToObjectIter;
-/* data set against GObject
+/* data set against GObject's instance
*/
#define SELECTION_CHANGED_SIGNAL_MODE "nact-iactions-list-selection-changed-signal-mode"
-#define SHOW_ONLY_ACTIONS_MODE "nact-iactions-list-show-only-actions-mode"
-#define HAVE_DND_MODE "nact-iactions-list-dnd-mode"
-#define FILTER_SELECTION_MODE "nact-iactions-list-filter-selection-mode"
+#define MANAGEMENT_MODE "nact-iactions-list-management-mode"
static gint st_signals[ LAST_SIGNAL ] = { 0 };
static gboolean st_initialized = FALSE;
@@ -133,6 +131,8 @@ static gboolean has_exportable_iter( NactTreeModel *model, GtkTreePath *path
static gboolean has_modified_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, gboolean *has_modified );
static gboolean have_dnd_mode( NactIActionsList *instance );
static gboolean have_filter_selection_mode( NactIActionsList *instance );
+static gboolean have_only_actions( NactIActionsList *instance );
+static gboolean is_iduplicable_proxy( NactIActionsList *instance );
static gboolean is_selection_changed_authorized( NactIActionsList *instance );
static void iter_on_selection( NactIActionsList *instance, FnIterOnSelection fn_iter, gpointer user_data );
static GtkTreePath *object_to_path( NactIActionsList *instance, NactTreeModel *model, NAObject *object );
@@ -282,7 +282,7 @@ interface_base_finalize( NactIActionsListInterface *klass )
/**
* nact_iactions_list_initial_load_toplevel:
- * @window: this #NactIActionsList *instance.
+ * @instance: this #NactIActionsList *instance.
*
* Allocates and initializes the ActionsList widget.
*
@@ -291,6 +291,9 @@ interface_base_finalize( NactIActionsListInterface *klass )
* implements EggTreeMultiDragSourceIface
* is derived from GtkTreeModelFilter
* GtkTreeModelFilter is built on top of GtkTreeStore
+ *
+ * Please note that management mode for the list should have been set
+ * before calling this function.
*/
void
nact_iactions_list_initial_load_toplevel( NactIActionsList *instance )
@@ -312,9 +315,6 @@ nact_iactions_list_initial_load_toplevel( NactIActionsList *instance )
label = base_window_get_widget( BASE_WINDOW( instance ), "ActionsListLabel" );
gtk_label_set_mnemonic_widget( GTK_LABEL( label ), GTK_WIDGET( treeview ));
- nact_iactions_list_set_dnd_mode( instance, FALSE );
- nact_iactions_list_set_multiple_selection_mode( instance, FALSE );
- nact_iactions_list_set_only_actions_mode( instance, FALSE );
set_selection_changed_mode( instance, FALSE );
nact_tree_model_initial_load( BASE_WINDOW( instance ), treeview );
@@ -353,6 +353,7 @@ nact_iactions_list_runtime_init_toplevel( NactIActionsList *instance, GList *ite
NactTreeModel *model;
gboolean have_dnd;
gboolean have_filter_selection;
+ gboolean is_proxy;
GtkTreeSelection *selection;
g_debug( "%s: instance=%p, items=%p (%d items)",
@@ -417,9 +418,12 @@ nact_iactions_list_runtime_init_toplevel( NactIActionsList *instance, GList *ite
/* records NactIActionsList as a proxy for edition status modification
*/
- na_iduplicable_register_consumer( G_OBJECT( instance ));
- g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_MODIFIED_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
- g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_VALID_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
+ is_proxy = is_iduplicable_proxy( instance );
+ if( is_proxy ){
+ na_iduplicable_register_consumer( G_OBJECT( instance ));
+ g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_MODIFIED_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
+ g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_VALID_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
+ }
/* fill the model after having connected the signals
* so that callbacks are triggered at last
@@ -537,7 +541,7 @@ nact_iactions_list_fill( NactIActionsList *instance, GList *items )
treeview = get_actions_list_treeview( instance );
model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- only_actions = nact_iactions_list_is_only_actions_mode( instance );
+ only_actions = have_only_actions( instance );
set_selection_changed_mode( instance, FALSE );
nact_tree_model_fill( model, items, only_actions );
@@ -617,6 +621,26 @@ nact_iactions_list_get_items( NactIActionsList *instance )
}
/**
+ * nact_iactions_list_get_management_mode:
+ * @instance: this #NactIActionsList instance.
+ *
+ * Returns: the current management mode of the list.
+ */
+gint
+nact_iactions_list_get_management_mode( NactIActionsList *instance )
+{
+ gint mode = 0;
+
+ g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), 0 );
+
+ if( st_initialized && !st_finalized ){
+ mode = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), MANAGEMENT_MODE ));
+ }
+
+ return( mode );
+}
+
+/**
* nact_iactions_list_get_selected_items:
* @window: this #NactIActionsList instance.
*
@@ -908,119 +932,37 @@ nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item
}
/**
- * nact_iactions_list_is_only_actions_mode:
- * @window: this #NactIActionsList instance.
- *
- * Returns %TRUE if only actions should be displayed in the treeview.
- */
-gboolean
-nact_iactions_list_is_only_actions_mode( NactIActionsList *instance )
-{
- gboolean mode = FALSE;
-
- g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), FALSE );
-
- if( st_initialized && !st_finalized ){
- mode = ( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), SHOW_ONLY_ACTIONS_MODE ));
- }
-
- return( mode );
-}
-
-/**
- * nact_iactions_list_set_dnd_mode:
- * @window: this #NactIActionsList instance.
- * @have_dnd: whether the treeview implements drag and drop ?
- *
- * When set to %TRUE, the corresponding tree model will implement the
- * GtkTreeDragSource and the GtkTreeDragDest interfaces.
- *
- * This property defaults to %FALSE.
- */
-void
-nact_iactions_list_set_dnd_mode( NactIActionsList *instance, gboolean have_dnd )
-{
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- if( st_initialized && !st_finalized ){
- g_object_set_data( G_OBJECT( instance ), HAVE_DND_MODE, GINT_TO_POINTER( have_dnd ));
- }
-}
-
-/**
- * nact_iactions_list_set_filter_selection_mode:
- * @window: this #NactIActionsList instance.
- * @filter: whether the filter selection function must be installed ?
- *
- * If %FALSE, user is able to select any item.
- * If %TRUE, a filter selection function is installed, and the selection
- * can only contains :
- * - either only profiles
- * - or actions or menus.
- *
- * This property defaults to %FALSE.
- */
-void
-nact_iactions_list_set_filter_selection_mode( NactIActionsList *instance, gboolean filter )
-{
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- if( st_initialized && !st_finalized ){
- g_object_set_data( G_OBJECT( instance ), FILTER_SELECTION_MODE, GINT_TO_POINTER( filter ));
- }
-}
-
-/**
- * nact_iactions_list_set_multiple_selection_mode:
- * @window: this #NactIActionsList instance.
- * @multiple: whether the treeview does support multiple selection ?
+ * nact_iactions_list_set_management_mode:
+ * @instance: this #NactIActionsList instance.
+ * @mode: management mode.
*
- * If %FALSE, only one item can selected at same time. Set to %TRUE to
- * be able to have multiple items simultaneously selected.
+ * Set the management mode for this @instance.
*
- * This property defaults to %FALSE.
+ * For the two known modes (edition mode, export mode), we also allow
+ * multiple selection in the list.
*/
void
-nact_iactions_list_set_multiple_selection_mode( NactIActionsList *instance, gboolean multiple )
+nact_iactions_list_set_management_mode( NactIActionsList *instance, gint mode )
{
GtkTreeView *treeview;
GtkTreeSelection *selection;
+ gboolean multiple;
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
if( st_initialized && !st_finalized ){
+ g_object_set_data( G_OBJECT( instance ), MANAGEMENT_MODE, GINT_TO_POINTER( mode ));
+
+ multiple = ( mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION ||
+ mode == IACTIONS_LIST_MANAGEMENT_MODE_EXPORT );
+
treeview = get_actions_list_treeview( instance );
selection = gtk_tree_view_get_selection( treeview );
gtk_tree_selection_set_mode( selection, multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE );
}
}
-/**
- * nact_iactions_list_set_only_actions_mode:
- * @window: this #NactIActionsList instance.
- * @only_actions: whether the treeview must only display actions ?
- *
- * When @only_actions is %TRUE, then the treeview will only display the
- * list of actions in alphabetical order of their label. In this mode,
- * the actual value of the 'Display in alphabetical order' preference
- * is ignored.
- *
- * If @only_actions is %FALSE, the the treeview display all the tree
- * of menus, submenus, actions and profiles.
- *
- * This property defaults to %FALSE.
- */
-void
-nact_iactions_list_set_only_actions_mode( NactIActionsList *instance, gboolean only_actions )
-{
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- if( st_initialized && !st_finalized ){
- g_object_set_data( G_OBJECT( instance ), SHOW_ONLY_ACTIONS_MODE, GINT_TO_POINTER( only_actions ));
- }
-}
-
/*
* Collapse / expand if actions has more than one profile
*/
@@ -1299,13 +1241,49 @@ has_modified_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, gb
static gboolean
have_dnd_mode( NactIActionsList *instance )
{
- return(( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), HAVE_DND_MODE )));
+ gint mode;
+ gboolean have_dnd;
+
+ mode = nact_iactions_list_get_management_mode( instance );
+ have_dnd = ( mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION );
+
+ return( have_dnd );
}
static gboolean
have_filter_selection_mode( NactIActionsList *instance )
{
- return(( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), FILTER_SELECTION_MODE )));
+ gint mode;
+ gboolean have_filter;
+
+ mode = nact_iactions_list_get_management_mode( instance );
+ have_filter = ( mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION );
+
+ return( have_filter );
+}
+
+static gboolean
+have_only_actions( NactIActionsList *instance )
+{
+ gint mode;
+ gboolean only_actions;
+
+ mode = nact_iactions_list_get_management_mode( instance );
+ only_actions = ( mode == IACTIONS_LIST_MANAGEMENT_MODE_EXPORT );
+
+ return( only_actions );
+}
+
+static gboolean
+is_iduplicable_proxy( NactIActionsList *instance )
+{
+ gint mode;
+ gboolean is_proxy;
+
+ mode = nact_iactions_list_get_management_mode( instance );
+ is_proxy = ( mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION );
+
+ return( is_proxy );
}
static gboolean
@@ -1404,8 +1382,8 @@ on_edition_status_changed( NactIActionsList *instance, NAIDuplicable *object )
if( is_selection_changed_authorized( instance )){
- g_debug( "nact_iactions_list_on_edition_status_changed: instance=%p (%s), object=%p (%s)",
- ( void * ) instance, G_OBJECT_TYPE_NAME( instance ),
+ g_debug( "nact_iactions_list_on_edition_status_changed: instance=%p, object=%p (%s)",
+ ( void * ) instance,
( void * ) object, G_OBJECT_TYPE_NAME( object ));
g_return_if_fail( NA_IS_OBJECT( object ));
diff --git a/src/nact/nact-iactions-list.h b/src/nact/nact-iactions-list.h
index d534c5d..f1e4628 100644
--- a/src/nact/nact-iactions-list.h
+++ b/src/nact/nact-iactions-list.h
@@ -35,6 +35,9 @@
* SECTION: nact_iactions_list
* @short_description: #NactIActionsList interface definition.
* @include: nact/nact-iactions-list.h
+ *
+ * This same interface is used in the main window (edition mode, default),
+ * and in the export assistant (export mode).
*/
#include <common/na-object-class.h>
@@ -75,6 +78,15 @@ typedef struct {
#define IACTIONS_LIST_SIGNAL_SELECTION_CHANGED "nact-iactions-list-selection-changed"
#define IACTIONS_LIST_SIGNAL_ITEM_UPDATED "nact-iactions-list-item-updated"
+/* management modes
+ * - edition: dnd, filter, multiple selection, item updated signal
+ * - export: multiple selection
+ */
+enum {
+ IACTIONS_LIST_MANAGEMENT_MODE_EDITION = 1,
+ IACTIONS_LIST_MANAGEMENT_MODE_EXPORT
+};
+
GType nact_iactions_list_get_type( void );
void nact_iactions_list_initial_load_toplevel( NactIActionsList *instance );
@@ -86,16 +98,13 @@ void nact_iactions_list_delete_selection( NactIActionsList *instance );
void nact_iactions_list_fill( NactIActionsList *instance, GList *items );
NAObject *nact_iactions_list_get_item( NactIActionsList *instance, const gchar *uuid );
GList *nact_iactions_list_get_items( NactIActionsList *instance );
+gint nact_iactions_list_get_management_mode( NactIActionsList *instance );
GList *nact_iactions_list_get_selected_items( NactIActionsList *instance );
gboolean nact_iactions_list_has_exportable( NactIActionsList *instance );
gboolean nact_iactions_list_has_modified_items( NactIActionsList *instance );
void nact_iactions_list_insert_items( NactIActionsList *instance, GList *items, NAObject *sibling );
gboolean nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item );
-gboolean nact_iactions_list_is_only_actions_mode( NactIActionsList *instance );
-void nact_iactions_list_set_dnd_mode( NactIActionsList *instance, gboolean have_dnd );
-void nact_iactions_list_set_filter_selection_mode( NactIActionsList *instance, gboolean filter );
-void nact_iactions_list_set_multiple_selection_mode( NactIActionsList *instance, gboolean multiple );
-void nact_iactions_list_set_only_actions_mode( NactIActionsList *instance, gboolean only_actions );
+void nact_iactions_list_set_management_mode( NactIActionsList *instance, gint mode );
void nact_iactions_list_toggle_collapse( NactIActionsList *instance, const NAObject *item );
G_END_DECLS
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index 719cb06..2e19847 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -389,7 +389,7 @@ get_legend_button( NactICommandTab *instance )
static GtkWindow *
get_legend_dialog( NactICommandTab *instance )
{
- return( base_window_get_toplevel( BASE_WINDOW( instance ), "LegendDialog" ));
+ return( base_window_get_named_toplevel( BASE_WINDOW( instance ), "LegendDialog" ));
}
static GtkWidget *
@@ -445,7 +445,7 @@ legend_dialog_show( NactICommandTab *instance )
legend_dialog = get_legend_dialog( instance );
gtk_window_set_deletable( legend_dialog, FALSE );
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( instance ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( instance ));
gtk_window_set_transient_for( GTK_WINDOW( legend_dialog ), toplevel );
base_iprefs_position_named_window( BASE_WINDOW( instance ), legend_dialog, IPREFS_LEGEND_DIALOG );
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 2af523e..ec79c71 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -188,7 +188,6 @@ nact_main_menubar_runtime_init( NactMainWindow *window )
GtkUIManager *ui_manager;
GError *error = NULL;
guint merge_id;
- GtkWindow *wnd;
GtkAccelGroup *accel_group;
GtkWidget *menubar, *vbox;
GtkWindow *toplevel;
@@ -232,15 +231,14 @@ nact_main_menubar_runtime_init( NactMainWindow *window )
g_error_free( error );
}
- wnd = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( window ));
accel_group = gtk_ui_manager_get_accel_group( ui_manager );
- gtk_window_add_accel_group( wnd, accel_group );
+ gtk_window_add_accel_group( toplevel, accel_group );
menubar = gtk_ui_manager_get_widget( ui_manager, "/ui/MainMenubar" );
vbox = base_window_get_widget( BASE_WINDOW( window ), "MenubarVBox" );
gtk_box_pack_start( GTK_BOX( vbox ), menubar, FALSE, FALSE, 0 );
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
base_window_signal_connect(
BASE_WINDOW( window ),
G_OBJECT( toplevel ),
@@ -633,7 +631,7 @@ on_about_activated( GtkAction *gtk_action, NactMainWindow *window )
{
GtkWindow *toplevel;
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ toplevel = base_window_get_toplevel( BASE_WINDOW( window ));
na_about_display( G_OBJECT( toplevel ));
}
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index a9ffb3b..edc2022 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -778,10 +778,8 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
gtk_paned_set_position( GTK_PANED( pane ), pos );
}
+ nact_iactions_list_set_management_mode( NACT_IACTIONS_LIST( window ), IACTIONS_LIST_MANAGEMENT_MODE_EDITION );
nact_iactions_list_initial_load_toplevel( NACT_IACTIONS_LIST( window ));
- nact_iactions_list_set_filter_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
- nact_iactions_list_set_multiple_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
- nact_iactions_list_set_dnd_mode( NACT_IACTIONS_LIST( window ), TRUE );
nact_iaction_tab_initial_load_toplevel( NACT_IACTION_TAB( window ));
nact_icommand_tab_initial_load_toplevel( NACT_ICOMMAND_TAB( window ));
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 828017e..f2d6211 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -381,7 +381,7 @@ on_add_about_toggled( GtkToggleButton *button, NactPreferencesEditor *editor )
static void
on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor )
{
- GtkWindow *toplevel = base_window_get_toplevel_window( BASE_WINDOW( editor ));
+ GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_CLOSE );
}
@@ -389,7 +389,7 @@ on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor )
static void
on_ok_clicked( GtkButton *button, NactPreferencesEditor *editor )
{
- GtkWindow *toplevel = base_window_get_toplevel_window( BASE_WINDOW( editor ));
+ GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_OK );
}
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 5f732b4..045c579 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -79,6 +79,7 @@ struct NactTreeModelPrivate {
BaseWindow *window;
GtkTreeView *treeview;
gboolean have_dnd;
+ gboolean only_actions;
gchar *drag_dest_uri;
GList *drag_items;
};
@@ -190,7 +191,7 @@ static void on_drag_end( GtkWidget *widget, GdkDragContext *context, B
static void on_drag_data_received( GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, GtkSelectionData *data, guint info, guint time, BaseWindow *window );*/
static gint sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, BaseWindow *window );
-static gboolean filter_visible( GtkTreeModel *model, GtkTreeIter *iter, NactIActionsList *window );
+static gboolean filter_visible( GtkTreeModel *store, GtkTreeIter *iter, NactTreeModel *model );
static char *get_xds_atom_value( GdkDragContext *context );
GType
@@ -390,7 +391,7 @@ tree_model_new( BaseWindow *window, GtkTreeView *treeview )
model = g_object_new( NACT_TREE_MODEL_TYPE, "child-model", ts_model, NULL );
gtk_tree_model_filter_set_visible_func(
- GTK_TREE_MODEL_FILTER( model ), ( GtkTreeModelFilterVisibleFunc ) filter_visible, window, NULL );
+ GTK_TREE_MODEL_FILTER( model ), ( GtkTreeModelFilterVisibleFunc ) filter_visible, model, NULL );
model->private->window = window;
model->private->treeview = treeview;
@@ -593,10 +594,9 @@ nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean only_actions)
if( !model->private->dispose_has_run ){
+ model->private->only_actions = only_actions;
ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
-
gtk_tree_store_clear( ts_model );
-
fill_tree_store( ts_model, model->private->treeview, items, only_actions, NULL );
}
}
@@ -1449,7 +1449,7 @@ sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, BaseWind
}
static gboolean
-filter_visible( GtkTreeModel *model, GtkTreeIter *iter, NactIActionsList *window )
+filter_visible( GtkTreeModel *store, GtkTreeIter *iter, NactTreeModel *model )
{
/*static const gchar *thisfn = "nact_tree_model_filter_visible";*/
NAObject *object;
@@ -1461,7 +1461,7 @@ filter_visible( GtkTreeModel *model, GtkTreeIter *iter, NactIActionsList *window
/*g_debug( "%s at %p", G_OBJECT_TYPE_NAME( model ), ( void * ) model );*/
/* is a GtkTreeStore */
- gtk_tree_model_get( model, iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ gtk_tree_model_get( store, iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
if( object ){
/*na_object_dump( object );*/
@@ -1471,7 +1471,7 @@ filter_visible( GtkTreeModel *model, GtkTreeIter *iter, NactIActionsList *window
return( TRUE );
}
- only_actions = nact_iactions_list_is_only_actions_mode( window );
+ only_actions = NACT_TREE_MODEL( model )->private->only_actions;
if( !only_actions ){
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]