[nautilus-actions] Whole refactoring of BaseWindow, BaseAssistant and BaseDialog
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Whole refactoring of BaseWindow, BaseAssistant and BaseDialog
- Date: Fri, 28 Jan 2011 00:00:21 +0000 (UTC)
commit 69a5dc3dfb5321b5fa98326c26ff4d3270e773f1
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 28 00:59:53 2011 +0100
Whole refactoring of BaseWindow, BaseAssistant and BaseDialog
ChangeLog | 37 +++
src/nact/base-application.c | 2 +
src/nact/base-application.h | 2 +
src/nact/base-assistant.c | 453 +++++++++++++--------------------
src/nact/base-assistant.h | 65 ++----
src/nact/base-dialog.c | 90 ++++++-
src/nact/base-dialog.h | 26 ++-
src/nact/base-iprefs.c | 14 +-
src/nact/base-iprefs.h | 12 +-
src/nact/base-window.c | 256 +++++++++----------
src/nact/base-window.h | 52 ++--
src/nact/nact-add-capability-dialog.c | 183 +++++---------
src/nact/nact-add-scheme-dialog.c | 145 ++++-------
src/nact/nact-assistant-export.c | 177 +++++++-------
src/nact/nact-assistant-import.c | 87 +++----
src/nact/nact-confirm-logout.c | 132 ++--------
src/nact/nact-export-ask.c | 191 +++++---------
src/nact/nact-icon-chooser.c | 227 ++++++++---------
src/nact/nact-main-window.c | 147 ++++-------
src/nact/nact-preferences-editor.c | 303 ++++++++++-------------
20 files changed, 1128 insertions(+), 1473 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 08f1bde..fa05446 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2011-01-28 Pierre Wieser <pwieser trychlos org>
+
+ Whole refactoring of BaseWindow / BaseAssistant / BaseDialog
+
+ * src/nact/base-application.c:
+ * src/nact/base-application.h: Add new exit codes.
+
+ * src/nact/base-assistant.c:
+ * src/nact/base-assistant.h:
+ Remove 'warn-on-cancel' unused property.
+ (base_assistant_set_cancel_on_esc, base_assistant_set_warn_on_esc):
+ Remove unused functions.
+ Implement run() virtual method.
+
+ * src/nact/base-dialog.c:
+ * src/nact/base-dialog.h:
+ Implement run() virtual method.
+ Define new cancel() and ok() virtual methods.
+
+ * src/nact/base-iprefs.c:
+ * src/nact/base-iprefs.h (iprefs_get_window_id): Renamed as get_wsp_id().
+
+ * src/nact/base-window.c:
+ * src/nact/base-window.h
+ (dialog_response, delete_event): Remove no more used virtual methods.
+ (run): Define new virtual method.
+
+ * src/nact/nact-add-capability-dialog.c:
+ * src/nact/nact-add-scheme-dialog.c:
+ * src/nact/nact-assistant-export.c:
+ * src/nact/nact-assistant-import.c:
+ * src/nact/nact-confirm-logout.c:
+ * src/nact/nact-export-ask.c:
+ * src/nact/nact-icon-chooser.c:
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-preferences-editor.c: Updated accordingly.
+
2011-01-26 Pierre Wieser <pwieser trychlos org>
* src/nact/nact-providers-list.c:
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index 7e5455f..876600a 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -471,8 +471,10 @@ base_application_run( BaseApplication *application )
g_debug( "%s: invoking base_window_run", thisfn );
code = base_window_run( application->private->main_window );
+
} else {
g_debug( "%s: base_window_init has returned FALSE", thisfn );
+ code = BASE_EXIT_CODE_INIT_FAIL;
}
}
}
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index 32452cc..f4a9c2d 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -164,6 +164,8 @@ typedef enum {
BASE_EXIT_CODE_ARGS,
BASE_EXIT_CODE_UNIQUE_APP,
BASE_EXIT_CODE_MAIN_WINDOW,
+ BASE_EXIT_CODE_INIT_FAIL,
+ BASE_EXIT_CODE_PROGRAM,
/*
* BaseApplication -derived class may use program return codes
* starting with this value
diff --git a/src/nact/base-assistant.c b/src/nact/base-assistant.c
index 25ee9fa..11ae686 100644
--- a/src/nact/base-assistant.c
+++ b/src/nact/base-assistant.c
@@ -49,9 +49,14 @@ struct _BaseAssistantClassPrivate {
*/
struct _BaseAssistantPrivate {
gboolean dispose_has_run;
- gboolean cancel_on_escape;
+
+ /* properties
+ */
+ gboolean quit_on_escape;
gboolean warn_on_escape;
- gboolean warn_on_cancel;
+
+ /* internals
+ */
gboolean apply_has_run;
gboolean escape_key_pressed;
};
@@ -59,38 +64,38 @@ struct _BaseAssistantPrivate {
/* instance properties
*/
enum {
- BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID = 1,
- BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID,
- BASE_ASSISTANT_PROP_WARN_ON_CANCEL_ID
+ BASE_PROP_0,
+
+ BASE_PROP_QUIT_ON_ESCAPE_ID,
+ BASE_PROP_WARN_ON_ESCAPE_ID,
+
+ BASE_PROP_N_PROPERTIES
};
static BaseWindowClass *st_parent_class = NULL;
-static GType register_type( void );
-static void class_init( BaseAssistantClass *klass );
-static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
-static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
-static void instance_dispose( GObject *application );
-static void instance_finalize( GObject *application );
-
-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 );
-static void v_assistant_prepare( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window );
-
-static void on_apply_message( GtkAssistant *assistant, BaseAssistant *window );
-static void on_cancel_message( GtkAssistant *assistant, BaseAssistant *window );
-static void on_close_message( GtkAssistant *assistant, BaseAssistant *window );
-static void on_prepare_message( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window );
-
-static void on_initial_load( BaseAssistant *window, gpointer user_data );
-static void on_runtime_init( BaseAssistant *window, gpointer user_data );
-static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseAssistant *assistant );
-static void assistant_do_apply( BaseAssistant *window, GtkAssistant *assistant );
-static void assistant_do_cancel( BaseAssistant *window, GtkAssistant *assistant );
-static void assistant_do_close( BaseAssistant *window, GtkAssistant *assistant );
-static void assistant_do_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
+static GType register_type( void );
+static void class_init( BaseAssistantClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
+static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
+static void instance_dispose( GObject *application );
+static void instance_finalize( GObject *application );
+
+static void on_initialize_base_window( BaseAssistant *window );
+static int do_run( BaseWindow *window, GtkWindow *toplevel );
+static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseAssistant *assistant );
+
+static void on_prepare( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window );
+static void v_assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
+static void do_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
+static void on_apply( GtkAssistant *assistant, BaseAssistant *window );
+static void v_assistant_apply( BaseAssistant *window, GtkAssistant *assistant );
+static void do_apply( BaseAssistant *window, GtkAssistant *assistant );
+
+static void on_cancel( GtkAssistant *assistant, BaseAssistant *window );
+static void on_close( GtkAssistant *assistant, BaseAssistant *window );
+static void do_close( BaseAssistant *window, GtkAssistant *assistant );
GType
base_assistant_get_type( void )
@@ -134,7 +139,7 @@ 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 );
@@ -146,33 +151,28 @@ class_init( BaseAssistantClass *klass )
object_class->get_property = instance_get_property;
object_class->set_property = instance_set_property;
- spec = g_param_spec_boolean(
- BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE,
- "Cancel on Escape",
- "Does the assistant should 'Cancel' when the user hits Escape ?", FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID, spec );
-
- spec = g_param_spec_boolean(
- BASE_ASSISTANT_PROP_WARN_ON_ESCAPE,
- "Warn on Escape",
- "Does the user should confirm when exiting the assistant via Escape ?", FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID, spec );
-
- spec = g_param_spec_boolean(
- BASE_ASSISTANT_PROP_WARN_ON_CANCEL,
- "Warn on cancel",
- "Does the user should confirm when exiting the assistant via Cancel ?", FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_ASSISTANT_PROP_WARN_ON_CANCEL_ID, spec );
+ g_object_class_install_property( object_class, BASE_PROP_QUIT_ON_ESCAPE_ID,
+ g_param_spec_boolean(
+ BASE_PROP_QUIT_ON_ESCAPE,
+ _( "Quit on Escape" ),
+ _( "Does the assistant should 'Quit' when the user hits the Escape key ?" ),
+ FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, BASE_PROP_WARN_ON_ESCAPE_ID,
+ g_param_spec_boolean(
+ BASE_PROP_WARN_ON_ESCAPE,
+ _( "Warn on Escape" ),
+ _( "Does the user should confirm when quitting the assistant on Escape key ?" ),
+ FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ base_class = BASE_WINDOW_CLASS( klass );
+ base_class->run = do_run;
klass->private = g_new0( BaseAssistantClassPrivate, 1 );
-
- klass->apply = assistant_do_apply;
- klass->cancel = assistant_do_cancel;
- klass->close = assistant_do_close;
- klass->prepare = assistant_do_prepare;
+ klass->apply = do_apply;
+ klass->prepare = do_prepare;
}
static void
@@ -181,32 +181,23 @@ instance_init( GTypeInstance *instance, gpointer klass )
static const gchar *thisfn = "base_assistant_instance_init";
BaseAssistant *self;
+ g_return_if_fail( BASE_IS_ASSISTANT( instance ));
+
g_debug( "%s: instance=%p (%s), klass=%p",
thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
- g_return_if_fail( BASE_IS_ASSISTANT( instance ));
self = BASE_ASSISTANT( instance );
self->private = g_new0( BaseAssistantPrivate, 1 );
self->private->dispose_has_run = FALSE;
- self->private->cancel_on_escape = FALSE;
+ self->private->quit_on_escape = FALSE;
self->private->warn_on_escape = FALSE;
- self->private->warn_on_cancel = FALSE;
self->private->apply_has_run = FALSE;
self->private->escape_key_pressed = FALSE;
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_initial_load ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_runtime_init ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_initialize_base_window ));
}
static void
@@ -215,23 +206,20 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
BaseAssistant *self;
g_return_if_fail( BASE_IS_ASSISTANT( object ));
+
self = BASE_ASSISTANT( object );
if( !self->private->dispose_has_run ){
switch( property_id ){
- case BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID:
- g_value_set_boolean( value, self->private->cancel_on_escape );
+ case BASE_PROP_QUIT_ON_ESCAPE_ID:
+ g_value_set_boolean( value, self->private->quit_on_escape );
break;
- case BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID:
+ case BASE_PROP_WARN_ON_ESCAPE_ID:
g_value_set_boolean( value, self->private->warn_on_escape );
break;
- case BASE_ASSISTANT_PROP_WARN_ON_CANCEL_ID:
- g_value_set_boolean( value, self->private->warn_on_cancel );
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -244,24 +232,21 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
{
BaseAssistant *self;
- g_assert( BASE_IS_ASSISTANT( object ));
+ g_return_if_fail( BASE_IS_ASSISTANT( object ));
+
self = BASE_ASSISTANT( object );
if( !self->private->dispose_has_run ){
switch( property_id ){
- case BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID:
- self->private->cancel_on_escape = g_value_get_boolean( value );
+ case BASE_PROP_QUIT_ON_ESCAPE_ID:
+ self->private->quit_on_escape = g_value_get_boolean( value );
break;
- case BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID:
+ case BASE_PROP_WARN_ON_ESCAPE_ID:
self->private->warn_on_escape = g_value_get_boolean( value );
break;
- case BASE_ASSISTANT_PROP_WARN_ON_CANCEL_ID:
- self->private->warn_on_cancel = g_value_get_boolean( value );
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -275,11 +260,12 @@ instance_dispose( GObject *window )
static const gchar *thisfn = "base_assistant_instance_dispose";
BaseAssistant *self;
- g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
g_return_if_fail( BASE_IS_ASSISTANT( window ));
+
self = BASE_ASSISTANT( window );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
self->private->dispose_has_run = TRUE;
@@ -296,8 +282,10 @@ instance_finalize( GObject *window )
static const gchar *thisfn = "base_assistant_instance_finalize";
BaseAssistant *self;
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
g_return_if_fail( BASE_IS_ASSISTANT( window ));
+
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
+
self = BASE_ASSISTANT( window );
g_free( self->private );
@@ -308,152 +296,104 @@ instance_finalize( GObject *window )
}
}
-/**
- * base_assistant_set_cancel_on_esc:
- * @window: this #BaseAssistant instance.
- * @cancel: whether hitting 'Escape' key triggers the 'Cancel' action.
- *
- * Set 'cancel on escape' property.
- */
-void
-base_assistant_set_cancel_on_esc( BaseAssistant *window, gboolean cancel )
+static void
+on_initialize_base_window( BaseAssistant *window )
{
+ static const gchar *thisfn = "base_assistant_on_initialize_base_window";
+ GtkWindow *toplevel;
+
g_return_if_fail( BASE_IS_ASSISTANT( window ));
- g_object_set( G_OBJECT( window ), BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE, cancel, NULL );
-}
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
-/**
- * base_assistant_set_warn_on_esc:
- * @window: this #BaseAssistant instance.
- * @warn: whether the 'Cancel' action, when triggered by 'Escape' key,
- * should emit a warning.
- *
- * Set 'warn on escape' property.
- */
-void
-base_assistant_set_warn_on_esc( BaseAssistant *window, gboolean warn )
-{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
+ if( !window->private->dispose_has_run ){
- g_object_set( G_OBJECT( window ), BASE_ASSISTANT_PROP_WARN_ON_ESCAPE, warn, NULL );
-}
+ toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window ));
+ g_return_if_fail( GTK_IS_ASSISTANT( toplevel ));
-/**
- * base_assistant_set_warn_on_cancel:
- * @window: this #BaseAssistant instance.
- * @warn: whether the 'Cancel' action should emit a warning.
- *
- * Set 'warn on close' property.
- */
-void
-base_assistant_set_warn_on_cancel( BaseAssistant *window, gboolean warn )
-{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( toplevel ), "key-press-event", G_CALLBACK( on_key_pressed_event ));
- g_object_set( G_OBJECT( window ), BASE_ASSISTANT_PROP_WARN_ON_CANCEL, warn, NULL );
-}
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( toplevel ), "apply", G_CALLBACK( on_apply ));
-static void
-v_assistant_apply( GtkAssistant *assistant, BaseAssistant *window )
-{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( toplevel ), "cancel", G_CALLBACK( on_cancel ));
- if( BASE_ASSISTANT_GET_CLASS( window )->apply ){
- BASE_ASSISTANT_GET_CLASS( window )->apply( window, assistant );
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( toplevel ), "close", G_CALLBACK( on_close ));
- } else {
- assistant_do_apply( window, assistant );
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( toplevel ), "prepare", G_CALLBACK( on_prepare ));
}
-
- window->private->apply_has_run = TRUE;
}
-static void
-v_assistant_cancel( GtkAssistant *assistant, BaseAssistant *window )
+static int
+do_run( BaseWindow *window, GtkWindow *toplevel )
{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
+ static const gchar *thisfn = "base_assistant_do_run";
+ int code;
- if( BASE_ASSISTANT_GET_CLASS( window )->cancel ){
- BASE_ASSISTANT_GET_CLASS( window )->cancel( window, assistant );
+ g_return_val_if_fail( BASE_IS_ASSISTANT( window ), BASE_EXIT_CODE_PROGRAM );
+ g_return_val_if_fail( GTK_IS_ASSISTANT( toplevel ), BASE_EXIT_CODE_PROGRAM );
- } else {
- assistant_do_cancel( window, assistant );
+ code = BASE_EXIT_CODE_INIT_FAIL;
+
+ if( !BASE_ASSISTANT( window )->private->dispose_has_run ){
+ g_debug( "%s: window=%p (%s), toplevel=%p (%s), starting gtk_main",
+ thisfn,
+ ( void * ) window, G_OBJECT_TYPE_NAME( window ),
+ ( void * ) toplevel, G_OBJECT_TYPE_NAME( toplevel ));
+ gtk_main();
+ code = BASE_EXIT_CODE_OK;
}
+
+ return( code );
}
-static void
-v_assistant_close( GtkAssistant *assistant, BaseAssistant *window )
+static gboolean
+on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseAssistant *assistant )
{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
-
- if( BASE_ASSISTANT_GET_CLASS( window )->close ){
- BASE_ASSISTANT_GET_CLASS( window )->close( window, assistant );
+ gboolean stop = FALSE;
+ GtkWindow *toplevel;
- } else {
- assistant_do_close( window, assistant );
- }
-}
+ g_return_val_if_fail( BASE_IS_ASSISTANT( assistant ), FALSE );
-static void
-v_assistant_prepare( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window )
-{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
+ if( !assistant->private->dispose_has_run ){
- if( BASE_ASSISTANT_GET_CLASS( window )->prepare ){
- BASE_ASSISTANT_GET_CLASS( window )->prepare( window, assistant, page );
+ if( event->keyval == NACT_KEY_Escape && assistant->private->quit_on_escape ){
- } else {
- assistant_do_prepare( window, assistant, page );
+ assistant->private->escape_key_pressed = TRUE;
+ toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( assistant ));
+ g_signal_emit_by_name( toplevel, "cancel", toplevel );
+ stop = TRUE;
+ }
}
+
+ return( stop );
}
/*
* starting with Gtk+ 2.18, this work-around will become useless
- * so message handlers could safely be the v_xxx functions
+ * so message handlers could safely be the v_xxx functions themselves
*/
static void
-on_apply_message( GtkAssistant *assistant, BaseAssistant *window )
-{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
-
- if( !window->private->apply_has_run ){
- v_assistant_apply( assistant, window );
- }
-}
-
-static void
-on_cancel_message( GtkAssistant *assistant, BaseAssistant *window )
+on_prepare( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window )
{
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
-
- v_assistant_cancel( assistant, window );
-}
+ static const gchar *thisfn = "base_assistant_on_prepare";
+ GtkAssistantPageType type;
-static void
-on_close_message( GtkAssistant *assistant, BaseAssistant *window )
-{
g_return_if_fail( BASE_IS_ASSISTANT( window ));
- v_assistant_close( assistant, window );
-}
-
-static void
-on_prepare_message( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window )
-{
- static const gchar *thisfn = "base_assistant_on_prepare_message";
- GtkAssistantPageType type;
-
g_debug( "%s: assistant=%p, page=%p, window=%p",
thisfn, ( void * ) assistant, ( void * ) page, ( void * ) window );
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
type = gtk_assistant_get_page_type( assistant, page );
switch( type ){
case GTK_ASSISTANT_PAGE_SUMMARY:
if( !window->private->apply_has_run ){
- v_assistant_apply( assistant, window );
+ v_assistant_apply( window, assistant );
}
break;
@@ -461,146 +401,103 @@ on_prepare_message( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *win
break;
}
- v_assistant_prepare( assistant, page, window );
+ v_assistant_prepare( window, assistant, page );
}
static void
-on_initial_load( BaseAssistant *window, gpointer user_data )
+v_assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page )
{
- static const gchar *thisfn = "base_assistant_on_initial_load";
-
- g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
g_return_if_fail( BASE_IS_ASSISTANT( window ));
- if( !window->private->dispose_has_run ){
-
- base_assistant_set_cancel_on_esc( window, FALSE );
- base_assistant_set_warn_on_esc( window, FALSE );
- base_assistant_set_warn_on_cancel( window, FALSE );
+ if( BASE_ASSISTANT_GET_CLASS( window )->prepare ){
+ BASE_ASSISTANT_GET_CLASS( window )->prepare( window, assistant, page );
}
}
static void
-on_runtime_init( BaseAssistant *window, gpointer user_data )
+do_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page )
{
- static const gchar *thisfn = "base_assistant_on_runtime_init";
- GtkWindow *toplevel;
+ static const gchar *thisfn = "base_assistant_do_prepare";
- g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_return_if_fail( BASE_IS_ASSISTANT( window ));
+ g_debug( "%s: window=%p, assistant=%p, page=%p",
+ thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
+}
- if( !window->private->dispose_has_run ){
+static void
+on_apply( GtkAssistant *assistant, BaseAssistant *window )
+{
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
- toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window ));
- g_assert( GTK_IS_ASSISTANT( toplevel ));
-
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( toplevel ),
- "key-press-event",
- G_CALLBACK( on_key_pressed_event ));
-
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( toplevel ),
- "apply",
- G_CALLBACK( on_apply_message ));
-
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( toplevel ),
- "cancel",
- G_CALLBACK( on_cancel_message ));
-
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( toplevel ),
- "close",
- G_CALLBACK( on_close_message ));
-
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( toplevel ),
- "prepare",
- G_CALLBACK( on_prepare_message ));
+ if( !window->private->apply_has_run ){
+ v_assistant_apply( window, assistant );
}
}
-static gboolean
-on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseAssistant *assistant )
+static void
+v_assistant_apply( BaseAssistant *window, GtkAssistant *assistant )
{
- /*static const gchar *thisfn = "base_assistant_on_key_pressed_event";
- g_debug( "%s: widget=%p, event=%p, user_data=%p", thisfn, widget, event, user_data );*/
- gboolean stop = FALSE;
- GtkWindow *toplevel;
-
- g_return_val_if_fail( BASE_IS_ASSISTANT( assistant ), FALSE );
-
- if( !assistant->private->dispose_has_run ){
-
- if( event->keyval == NACT_KEY_Escape &&
- assistant->private->cancel_on_escape ){
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
- assistant->private->escape_key_pressed = TRUE;
- toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( assistant ));
- g_signal_emit_by_name( toplevel, "cancel", toplevel );
- stop = TRUE;
- }
+ if( BASE_ASSISTANT_GET_CLASS( window )->apply ){
+ BASE_ASSISTANT_GET_CLASS( window )->apply( window, assistant );
}
- return( stop );
+ window->private->apply_has_run = TRUE;
}
static void
-assistant_do_apply( BaseAssistant *window, GtkAssistant *assistant )
+do_apply( BaseAssistant *window, GtkAssistant *assistant )
{
- static const gchar *thisfn = "base_assistant_assistant_do_apply";
+ static const gchar *thisfn = "base_assistant_do_apply";
g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) window, ( void * ) assistant );
}
/*
- * the 'Cancel' button is clicked
+ * either the 'Cancel' button has been clicked
+ * or the 'cancel' message has been emitted on the toplevel GtkAssistant
+ * due to the 'Escape' key being pressed and 'quit-on-cancel' property
+ * is true
*/
static void
-assistant_do_cancel( BaseAssistant *window, GtkAssistant *assistant )
+on_cancel( GtkAssistant *assistant, BaseAssistant *window )
{
- static const gchar *thisfn = "base_assistant_assistant_do_cancel";
+ static const gchar *thisfn = "base_assistant_on_cancel";
gboolean ok = TRUE;
- gchar *first;
+ gchar *msg;
+
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) window, ( void * ) assistant );
- if( window->private->warn_on_cancel ||
- ( window->private->warn_on_escape && window->private->escape_key_pressed )){
+ if( window->private->warn_on_escape && window->private->escape_key_pressed ){
- first = g_strdup( _( "Are you sure you want to quit this assistant ?" ));
- ok = base_window_display_yesno_dlg( BASE_WINDOW( window ), first, NULL );
- g_free( first );
+ msg = g_strdup( _( "Are you sure you want to quit this assistant ?" ));
+ ok = base_window_display_yesno_dlg( BASE_WINDOW( window ), msg, NULL );
+ g_free( msg );
}
window->private->escape_key_pressed = FALSE;
if( ok ){
- assistant_do_close( window, assistant );
+ do_close( window, assistant );
}
}
static void
-assistant_do_close( BaseAssistant *window, GtkAssistant *assistant )
+on_close( GtkAssistant *assistant, BaseAssistant *window )
{
- static const gchar *thisfn = "base_assistant_assistant_do_close";
-
- g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) window, ( void * ) assistant );
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
- g_object_unref( window );
+ do_close( window, assistant );
}
static void
-assistant_do_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page )
+do_close( BaseAssistant *window, GtkAssistant *assistant )
{
- static const gchar *thisfn = "base_assistant_assistant_do_prepare";
+ static const gchar *thisfn = "base_assistant_do_close";
- g_debug( "%s: window=%p, assistant=%p, page=%p",
- thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
+ g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) window, ( void * ) assistant );
+
+ g_object_unref( window );
}
diff --git a/src/nact/base-assistant.h b/src/nact/base-assistant.h
index f39ef5e..226444c 100644
--- a/src/nact/base-assistant.h
+++ b/src/nact/base-assistant.h
@@ -69,6 +69,13 @@ typedef struct {
typedef struct _BaseAssistantClassPrivate BaseAssistantClassPrivate;
+/**
+ * BaseAssistantClass:
+ * @apply: apply the result of the assistant.
+ * @prepare: prepare a page to be displayed.
+ *
+ * This defines the virtual method a derived class may, should or must implement.
+ */
typedef struct {
/*< private >*/
BaseWindowClass parent;
@@ -77,66 +84,36 @@ typedef struct {
/*< public >*/
/**
* apply:
- * @window: this #BaseAssistance instance.
+ * @window: this #BaseAssistant instance.
+ * @assistant: the #GtkAssistant toplevel.
+ *
+ * Invoked when the user has clicked on the 'Apply' button.
*/
void ( *apply ) ( BaseAssistant *window, GtkAssistant *assistant );
/**
- * cancel:
- * @window: this #BaseAssistance instance.
- */
- void ( *cancel ) ( BaseAssistant *window, GtkAssistant *assistant );
-
- /**
- * close:
- * @window: this #BaseAssistance instance.
- */
- void ( *close ) ( BaseAssistant *window, GtkAssistant *assistant );
-
- /**
* prepare:
* @window: this #BaseAssistance instance.
+ * @assistant: the #GtkAssistant toplevel.
+ *
+ * Invoked when the Gtk+ runtime is preparing a page.
+ *
+ * The #BaseAssistant class makes sure that the apply() method has
+ * been triggered before preparing the 'Summary' page.
*/
void ( *prepare )( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
}
BaseAssistantClass;
/**
- * %BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE:
- *
- * Does the assistant cancel its execution when the user hits the
- * 'Escape' key ?
- *
- * Defaults to %FALSE.
- */
-#define BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE "base-assistant-cancel-on-escape"
-
-/**
- * %BASE_ASSISTANT_PROP_WARN_ON_ESCAPE:
- *
- * Does the user be warned when he/she quits the assistant by hitting
- * the 'Escape' key ? This is only used when previous property
- * %BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE is set to %TRUE.
- *
- * Defaults to %FALSE.
+ * Properties defined by the BaseAssistant class.
+ * They should be provided at object instanciation time.
*/
-#define BASE_ASSISTANT_PROP_WARN_ON_ESCAPE "base-assistant-warn-on-escape"
-
-/**
- * %BASE_ASSISTANT_PROP_WARN_ON_CANCEL:
- *
- * Does the user be warned when he/she cancels the assistant ?
- *
- * Defaults to %FALSE.
- */
-#define BASE_ASSISTANT_PROP_WARN_ON_CANCEL "base-assistant-warn-on-cancel"
+#define BASE_PROP_QUIT_ON_ESCAPE "base-assistant-quit-on-escape"
+#define BASE_PROP_WARN_ON_ESCAPE "base-assistant-warn-on-escape"
GType base_assistant_get_type( void );
-void base_assistant_set_cancel_on_esc( BaseAssistant *window, gboolean cancel );
-void base_assistant_set_warn_on_esc( BaseAssistant *window, gboolean warn_esc );
-void base_assistant_set_warn_on_cancel( BaseAssistant *window, gboolean warn_cancel );
-
G_END_DECLS
#endif /* __BASE_ASSISTANT_H__ */
diff --git a/src/nact/base-dialog.c b/src/nact/base-dialog.c
index 9bd4e47..861dae9 100644
--- a/src/nact/base-dialog.c
+++ b/src/nact/base-dialog.c
@@ -48,11 +48,16 @@ struct _BaseDialogPrivate {
static BaseWindowClass *st_parent_class = NULL;
-static GType register_type( void );
-static void class_init( BaseDialogClass *klass );
-static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_dispose( GObject *application );
-static void instance_finalize( GObject *application );
+static GType register_type( void );
+static void class_init( BaseDialogClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *application );
+static void instance_finalize( GObject *application );
+
+static int do_run( BaseWindow *window, GtkWindow *toplevel );
+static gboolean terminate_dialog( BaseDialog *window, GtkDialog *toplevel, int *code );
+static void dialog_cancel( BaseDialog *window );
+static void dialog_ok( BaseDialog *window );
GType
base_dialog_get_type( void )
@@ -96,6 +101,7 @@ class_init( BaseDialogClass *klass )
{
static const gchar *thisfn = "base_dialog_class_init";
GObjectClass *object_class;
+ BaseWindowClass *base_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -105,6 +111,9 @@ class_init( BaseDialogClass *klass )
object_class->dispose = instance_dispose;
object_class->finalize = instance_finalize;
+ base_class = BASE_WINDOW_CLASS( klass );
+ base_class->run = do_run;
+
klass->private = g_new0( BaseDialogClassPrivate, 1 );
}
@@ -168,3 +177,74 @@ instance_finalize( GObject *window )
G_OBJECT_CLASS( st_parent_class )->finalize( window );
}
}
+
+/*
+ * returns the response ID of the dialog box
+ */
+static int
+do_run( BaseWindow *window, GtkWindow *toplevel )
+{
+ static const gchar *thisfn = "base_dialog_do_run";
+ int code;
+
+ g_return_val_if_fail( BASE_IS_DIALOG( window ), BASE_EXIT_CODE_PROGRAM );
+ g_return_val_if_fail( GTK_IS_DIALOG( toplevel ), BASE_EXIT_CODE_PROGRAM );
+
+ code = BASE_EXIT_CODE_INIT_FAIL;
+
+ if( !BASE_DIALOG( window )->private->dispose_has_run ){
+ g_debug( "%s: window=%p (%s), toplevel=%p (%s), starting gtk_dialog_run",
+ thisfn,
+ ( void * ) window, G_OBJECT_TYPE_NAME( window ),
+ ( void * ) toplevel, G_OBJECT_TYPE_NAME( toplevel ));
+ do {
+ code = gtk_dialog_run( GTK_DIALOG( toplevel ));
+ }
+ while( !terminate_dialog( BASE_DIALOG( window ), GTK_DIALOG( toplevel ), &code ));
+ }
+
+ return( code );
+}
+
+/*
+ * returns %TRUE to quit the dialog loop
+ */
+static gboolean
+terminate_dialog( BaseDialog *window, GtkDialog *toplevel, int *code )
+{
+ gboolean quit = FALSE;
+
+ switch( *code ){
+ case GTK_RESPONSE_NONE:
+ case GTK_RESPONSE_DELETE_EVENT:
+ case GTK_RESPONSE_CLOSE:
+ case GTK_RESPONSE_CANCEL:
+ dialog_cancel( window );
+ *code = GTK_RESPONSE_CANCEL;
+ quit = TRUE;
+ break;
+
+ case GTK_RESPONSE_OK:
+ dialog_ok( window );
+ quit = TRUE;
+ break;
+ }
+
+ return( quit );
+}
+
+static void
+dialog_cancel( BaseDialog *window )
+{
+ if( BASE_DIALOG_GET_CLASS( window )->cancel ){
+ BASE_DIALOG_GET_CLASS( window )->cancel( window );
+ }
+}
+
+static void
+dialog_ok( BaseDialog *window )
+{
+ if( BASE_DIALOG_GET_CLASS( window )->ok ){
+ BASE_DIALOG_GET_CLASS( window )->ok( window );
+ }
+}
diff --git a/src/nact/base-dialog.h b/src/nact/base-dialog.h
index 189ef1f..1276151 100644
--- a/src/nact/base-dialog.h
+++ b/src/nact/base-dialog.h
@@ -39,8 +39,6 @@
*
* This class is derived from BaseWindow class, and serves as a base
* class for all Nautilus-Actions dialogs.
- *
- * As of version 3.1.0, this base class does nothing.
*/
#include "base-window.h"
@@ -65,10 +63,34 @@ typedef struct {
typedef struct _BaseDialogClassPrivate BaseDialogClassPrivate;
+/**
+ * BaseDialogClass:
+ * @cancel: the dialog box is not validated.
+ * @ok: the dialog box is validated.
+ *
+ * This defines the virtual method a derived class may, should or must implement.
+ */
typedef struct {
/*< private >*/
BaseWindowClass parent;
BaseDialogClassPrivate *private;
+
+ /*< public >*/
+ /**
+ * cancel:
+ * @dialog: this #BaseDialog instance.
+ *
+ * Invoked when the dialog box is closed without having been validated.
+ */
+ void ( *cancel )( BaseDialog *dialog );
+
+ /**
+ * ok:
+ * @dialog: this #BaseDialog instance.
+ *
+ * Invoked when the dialog box is validated.
+ */
+ void ( *ok ) ( BaseDialog *dialog );
}
BaseDialogClass;
diff --git a/src/nact/base-iprefs.c b/src/nact/base-iprefs.c
index 5b2cae4..2d61428 100644
--- a/src/nact/base-iprefs.c
+++ b/src/nact/base-iprefs.c
@@ -52,7 +52,7 @@ static GType register_type( void );
static void interface_base_init( BaseIPrefsInterface *klass );
static void interface_base_finalize( BaseIPrefsInterface *klass );
-static gchar *v_iprefs_get_window_id( const BaseWindow *window );
+static gchar *get_wsp_id( const BaseWindow *window );
static NASettings *get_settings( const BaseWindow *window );
static GList *read_int_list( const BaseWindow *window, const gchar *key );
@@ -111,7 +111,7 @@ interface_base_init( BaseIPrefsInterface *klass )
klass->private = g_new0( BaseIPrefsInterfacePrivate, 1 );
- klass->iprefs_get_window_id = NULL;
+ klass->get_wsp_id = NULL;
st_initialized = TRUE;
}
@@ -151,7 +151,7 @@ base_iprefs_position_window( const BaseWindow *window )
if( st_initialized && !st_finalized ){
- key = v_iprefs_get_window_id( window );
+ key = get_wsp_id( window );
if( key ){
toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window ));
base_iprefs_position_named_window( window, toplevel, key );
@@ -229,7 +229,7 @@ base_iprefs_save_window_position( const BaseWindow *window )
if( st_initialized && !st_finalized ){
- key = v_iprefs_get_window_id( window );
+ key = get_wsp_id( window );
if( key ){
toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window ));
base_iprefs_save_named_window_position( window, toplevel, key );
@@ -271,12 +271,12 @@ base_iprefs_save_named_window_position( const BaseWindow *window, GtkWindow *top
}
static gchar *
-v_iprefs_get_window_id( const BaseWindow *window )
+get_wsp_id( const BaseWindow *window )
{
g_return_val_if_fail( BASE_IS_IPREFS( window ), NULL );
- if( BASE_IPREFS_GET_INTERFACE( window )->iprefs_get_window_id ){
- return( BASE_IPREFS_GET_INTERFACE( window )->iprefs_get_window_id( window ));
+ if( BASE_IPREFS_GET_INTERFACE( window )->get_wsp_id ){
+ return( BASE_IPREFS_GET_INTERFACE( window )->get_wsp_id( window ));
}
return( NULL );
diff --git a/src/nact/base-iprefs.h b/src/nact/base-iprefs.h
index 66ace82..5ce3c74 100644
--- a/src/nact/base-iprefs.h
+++ b/src/nact/base-iprefs.h
@@ -62,9 +62,17 @@ typedef struct {
BaseIPrefsInterfacePrivate *private;
/*< public >*/
- /* api
+ /**
+ * get_wsp_id:
+ * @window: the #BaseWindow which implements this interface.
+ *
+ * Invoked when we need the string which holds the size and position
+ * of the window in the user preferences.
+ *
+ * The implementation should returns a newly allocated ASCII string
+ * which will be g_free() by #BaseIPrefs internals.
*/
- gchar * ( *iprefs_get_window_id )( const BaseWindow *window );
+ gchar * ( *get_wsp_id )( const BaseWindow *window );
}
BaseIPrefsInterface;
diff --git a/src/nact/base-window.c b/src/nact/base-window.c
index 7cd70c4..5da97c5 100644
--- a/src/nact/base-window.c
+++ b/src/nact/base-window.c
@@ -65,9 +65,7 @@ struct _BaseWindowPrivate {
*/
GtkWindow *gtk_toplevel;
gboolean initialized;
-
GList *signals;
- gboolean save_window_position;
BaseBuilder *builder;
};
@@ -107,42 +105,39 @@ static gint st_signals[ LAST_SIGNAL ] = { 0 };
static gboolean st_debug_signal_connect = FALSE;
static BaseWindow *st_first_window = NULL;
-static GType register_type( void );
-static void class_init( BaseWindowClass *klass );
-static void iprefs_base_iface_init( BaseIPrefsInterface *iface );
-static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
-static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
-static void instance_dispose( GObject *application );
-static void instance_finalize( GObject *application );
+static GType register_type( void );
+static void class_init( BaseWindowClass *klass );
+static void iprefs_base_iface_init( BaseIPrefsInterface *iface );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
+static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
+static void instance_dispose( GObject *application );
+static void instance_finalize( GObject *application );
/* initialization process
*/
-static gboolean setup_builder( const BaseWindow *window );
-static gboolean load_gtk_toplevel( const BaseWindow *window );
-static gboolean is_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel );
-static void set_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel, gboolean init );
-static void on_initialize_gtk_toplevel_class_handler( BaseWindow *window, GtkWindow *toplevel );
-static void do_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel );
+static gboolean setup_builder( const BaseWindow *window );
+static gboolean load_gtk_toplevel( const BaseWindow *window );
+static gboolean is_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel );
+static void set_gtk_toplevel_initialized( const BaseWindow *window, GtkWindow *gtk_toplevel, gboolean init );
+static void on_initialize_gtk_toplevel_class_handler( BaseWindow *window, GtkWindow *toplevel );
+static void do_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel );
/* run
*/
-static void on_initialize_base_window_class_handler( BaseWindow *window );
-static void do_initialize_base_window( BaseWindow *window );
-static void on_all_widgets_showed_class_handler( BaseWindow *window );
-
-static gboolean is_main_window( BaseWindow *window );
-
-static gboolean on_delete_event( GtkWidget *widget, GdkEvent *event, BaseWindow *window );
-
-static gboolean v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
-static gchar *v_get_iprefs_window_id( const BaseWindow *window );
-
-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 void on_initialize_base_window_class_handler( BaseWindow *window );
+static void do_initialize_base_window( BaseWindow *window );
+static gchar *get_wsp_id( const BaseWindow *window );
+static void on_all_widgets_showed_class_handler( BaseWindow *window );
+static gboolean do_run( BaseWindow *window, GtkWindow *toplevel );
+static gboolean is_main_window( BaseWindow *window );
+static gboolean on_delete_event( GtkWidget *widget, GdkEvent *event, BaseWindow *window );
+#if 0
+static gboolean on_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
+#endif
-static void record_connected_signal( BaseWindow *window, GObject *instance, gulong handler_id );
-static gint display_dlg( const BaseWindow *parent, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *primary, const gchar *secondary );
+static void record_connected_signal( BaseWindow *window, GObject *instance, gulong handler_id );
+static gint display_dlg( const BaseWindow *parent, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *primary, const gchar *secondary );
GType
base_window_get_type( void )
@@ -247,10 +242,9 @@ class_init( BaseWindowClass *klass )
klass->initialize_gtk_toplevel = do_initialize_gtk_toplevel;
klass->initialize_base_window = do_initialize_base_window;
+ klass->get_wsp_id = NULL;
klass->all_widgets_showed = NULL;
- klass->dialog_response = window_do_dialog_response;
- klass->delete_event = window_do_delete_event;
- klass->get_iprefs_window_id = NULL;
+ klass->run = do_run;
klass->is_willing_to_quit = NULL;
/**
@@ -323,7 +317,7 @@ iprefs_base_iface_init( BaseIPrefsInterface *iface )
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
- iface->iprefs_get_window_id = v_get_iprefs_window_id;
+ iface->get_wsp_id = get_wsp_id;
}
static void
@@ -350,7 +344,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->dispose_has_run = FALSE;
self->private->signals = NULL;
- self->private->save_window_position = TRUE;
}
static void
@@ -446,9 +439,7 @@ instance_dispose( GObject *window )
g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
- if( self->private->save_window_position ){
- base_iprefs_save_window_position( self );
- }
+ base_iprefs_save_window_position( self );
/* signals must be deconnected before quitting main loop
*/
@@ -734,39 +725,49 @@ do_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel )
*
* Runs the window.
*
- * Returns: the exit code of the program is this is the main window.
+ * Returns: the exit code of the program if this is the main window,
+ * the response ID of a dialog box
*/
int
base_window_run( BaseWindow *window )
{
static const gchar *thisfn = "base_window_run";
gboolean run_ok;
- gint code;
+ int code;
- g_return_val_if_fail( BASE_IS_WINDOW( window ), BASE_EXIT_CODE_START_FAIL );
+ code = BASE_EXIT_CODE_START_FAIL;
- run_ok = FALSE;
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), code );
if( !window->private->dispose_has_run ){
run_ok = window->private->initialized;
- if( !window->private->initialized ){
+ if( !run_ok ){
run_ok = base_window_init( window );
}
- if( run_ok ){
- g_return_val_if_fail( GTK_IS_WINDOW( window->private->gtk_toplevel ), BASE_EXIT_CODE_START_FAIL );
+ if( !run_ok ){
+ code = BASE_EXIT_CODE_INIT_FAIL;
+ } else {
+ g_return_val_if_fail( GTK_IS_WINDOW( window->private->gtk_toplevel ), code );
g_debug( "%s: window=%p", thisfn, ( void * ) window );
+
+ code = BASE_EXIT_CODE_OK;
g_signal_emit_by_name( window, BASE_SIGNAL_INITIALIZE_WINDOW );
gtk_widget_show_all( GTK_WIDGET( window->private->gtk_toplevel ));
g_signal_emit_by_name( window, BASE_SIGNAL_ALL_WIDGETS_SHOWED );
+ if( BASE_WINDOW_GET_CLASS( window )->run ){
+ code = BASE_WINDOW_GET_CLASS( window )->run( window, window->private->gtk_toplevel );
+ }
+
+#if 0
if( is_main_window( window )){
if( GTK_IS_DIALOG( window->private->gtk_toplevel )){
- g_signal_connect( G_OBJECT( window->private->gtk_toplevel ), "response", G_CALLBACK( v_dialog_response ), window );
+ g_signal_connect( G_OBJECT( window->private->gtk_toplevel ), "response", G_CALLBACK( on_dialog_response ), window );
} else {
g_signal_connect( G_OBJECT( window->private->gtk_toplevel ), "delete-event", G_CALLBACK( on_delete_event ), window );
}
@@ -779,17 +780,18 @@ base_window_run( BaseWindow *window )
gtk_main();
} else {
- g_assert( GTK_IS_DIALOG( window->private->gtk_toplevel ));
+ g_return_val_if_fail( GTK_IS_DIALOG( window->private->gtk_toplevel ), code );
g_debug( "%s: starting gtk_dialog_run", thisfn );
do {
- code = gtk_dialog_run( GTK_DIALOG( window->private->gtk_toplevel ));
+ code = gtk_dialog_run( GTK_DIALOG( toplevel ));
}
- while( !v_dialog_response( GTK_DIALOG( window->private->gtk_toplevel ), code, window ));
+ while( !on_dialog_response( GTK_DIALOG( toplevel ), code, window ));
}
+#endif
}
}
- return( run_ok ? BASE_EXIT_CODE_OK : BASE_EXIT_CODE_MAIN_WINDOW );
+ return( code );
}
/*
@@ -828,6 +830,23 @@ do_initialize_base_window( BaseWindow *window )
}
}
+static gchar *
+get_wsp_id( const 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_wsp_id ){
+ id = BASE_WINDOW_GET_CLASS( window )->get_wsp_id( window );
+ }
+ }
+
+ return( id );
+}
+
static void
on_all_widgets_showed_class_handler( BaseWindow *window )
{
@@ -845,6 +864,32 @@ on_all_widgets_showed_class_handler( BaseWindow *window )
}
}
+static int
+do_run( BaseWindow *window, GtkWindow *toplevel )
+{
+ static const gchar *thisfn = "base_window_do_run";
+ int code;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), BASE_EXIT_CODE_PROGRAM );
+ g_return_val_if_fail( GTK_IS_WINDOW( toplevel ), BASE_EXIT_CODE_PROGRAM );
+
+ code = BASE_EXIT_CODE_INIT_FAIL;
+
+ if( !window->private->dispose_has_run ){
+ if( is_main_window( window )){
+ g_signal_connect( G_OBJECT( toplevel ), "delete-event", G_CALLBACK( on_delete_event ), window );
+ g_debug( "%s: window=%p (%s), toplevel=%p (%s), starting gtk_main",
+ thisfn,
+ ( void * ) window, G_OBJECT_TYPE_NAME( window ),
+ ( void * ) toplevel, G_OBJECT_TYPE_NAME( toplevel ));
+ gtk_main();
+ code = BASE_EXIT_CODE_OK;
+ }
+ }
+
+ return( code );
+}
+
static gboolean
is_main_window( BaseWindow *window )
{
@@ -860,6 +905,26 @@ is_main_window( BaseWindow *window )
return( is_main );
}
+/*
+ * handler of "delete-event" message connected on the main window Gtk toplevel
+ * our own function does nothing, and let the signal be propagated
+ * it so ends up in the default class handler for this signal
+ * which just destroys the toplevel
+ */
+static gboolean
+on_delete_event( GtkWidget *toplevel, GdkEvent *event, BaseWindow *window )
+{
+ static const gchar *thisfn = "base_window_on_delete_event";
+ static gboolean stop = FALSE;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
+
+ g_debug( "%s: toplevel=%p, event=%p, window=%p",
+ thisfn, ( void * ) toplevel, ( void * ) event, ( void * ) window );
+
+ return( stop );
+}
+
/**
* base_window_get_application:
* @window: this #BaseWindow object.
@@ -1016,37 +1081,16 @@ base_window_is_willing_to_quit( const BaseWindow *window )
}
/*
- * handler of "delete-event" message
- * let a chance to derived class to handle it
- * our own function does nothing, and let the signal be propagated.
+ * this is the handler for the 'response' message when the main window is
+ * actually a GtkDialog
+ *
+ * we default to quit the dialog loop
*/
+#if 0
static gboolean
-on_delete_event( GtkWidget *toplevel, GdkEvent *event, BaseWindow *window )
+on_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
{
- static const gchar *thisfn = "base_window_on_delete_event";
- static gboolean stop = FALSE;
-
- g_debug( "%s: toplevel=%p, event=%p, window=%p",
- thisfn, ( void * ) toplevel, ( void * ) event, ( void * ) window );
- g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
-
- if( !window->private->dispose_has_run ){
-
- if( BASE_WINDOW_GET_CLASS( window )->delete_event ){
- stop = BASE_WINDOW_GET_CLASS( window )->delete_event( window, GTK_WINDOW( toplevel ), event );
-
- } else {
- stop = window_do_delete_event( window, GTK_WINDOW( toplevel ), event );
- }
- }
-
- return( stop );
-}
-
-static gboolean
-v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
-{
- static const gchar *thisfn = "base_window_v_dialog_response";
+ static const gchar *thisfn = "base_window_on_dialog_response";
gboolean stop = FALSE;
g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
@@ -1055,64 +1099,16 @@ v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
if( !window->private->dispose_has_run ){
if( BASE_WINDOW_GET_CLASS( window )->dialog_response ){
- stop = BASE_WINDOW_GET_CLASS( window )->dialog_response( dialog, code, window );
+ stop = BASE_WINDOW_GET_CLASS( window )->dialog_response( window, dialog, code );
} else {
- stop = window_do_dialog_response( dialog, code, window );
+ stop = TRUE;
}
}
return( stop );
}
-
-static gchar *
-v_get_iprefs_window_id( const 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 );
- }
- }
-
- return( id );
-}
-
-/*
- * return TRUE to quit the dialog loop
- */
-static gboolean
-window_do_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
-{
- static const gchar *thisfn = "base_window_do_dialog_response";
-
- g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
- g_return_val_if_fail( GTK_IS_DIALOG( dialog ), FALSE );
- g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
-
- return( TRUE );
-}
-
-/*
- * return TRUE to stop other handlers from being invoked for the event.
- * note that default handler will destroy this window
- */
-static gboolean
-window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event )
-{
- static const gchar *thisfn = "base_window_do_delete_event";
-
- g_debug( "%s: window=%p, toplevel=%p, event=%p",
- thisfn, ( void * ) window, ( void * ) toplevel, ( void * ) event );
- g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
- g_return_val_if_fail( GTK_IS_WINDOW( toplevel ), FALSE );
-
- return( FALSE );
-}
+#endif
/**
* base_window_display_error_dlg:
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index cbc7182..f01dff9 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -99,10 +99,9 @@ typedef struct _BaseWindowClassPrivate BaseWindowClassPrivate;
* @initialize_gtk_toplevel: initialize the toplevel GtkWindow
* @initialize_base_window: initialize the BaseWindow
* @all_widgets_showed: all widgets have been showed
- * @dialog_response:
- * @delete_event:
- * @get_iprefs_window_id:
- * @is_willing_to_quit: asks if the window is willing to quit
+ * @run: run the dialog box loop
+ * @iprefs_get_window_id: returns the string which handles size and position preferences
+ * @is_willing_to_quit: asks if the window is willing to quit
*
* This defines the virtual method a derived class may, should or must implement.
*/
@@ -146,6 +145,20 @@ typedef struct {
void ( *initialize_base_window ) ( BaseWindow *window );
/**
+ * get_wsp_id:
+ * @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 user preferences.
+ *
+ * The returned string will be g_free() by the BaseIPrefs internals.
+ *
+ * This delegates to #BaseWindow -derived classes the BaseIPrefs
+ * interface method.
+ */
+ gchar * ( *get_wsp_id ) ( const BaseWindow *window );
+
+ /**
* all_widgets_showed:
* @window: this #BaseWindow instance.
*
@@ -158,33 +171,20 @@ typedef struct {
void ( *all_widgets_showed ) ( BaseWindow *window );
/**
- * dialog_response:
- * @window: this #BaseWindow instance.
- */
- gboolean ( *dialog_response ) ( GtkDialog *dialog, gint code, BaseWindow *window );
-
- /**
- * delete_event:
+ * run:
* @window: this #BaseWindow instance.
+ * @dialog: the toplevel #GtkWindow.
*
- * The #BaseWindow class connects to the "delete-event" signal,
- * and transforms it into a virtual function. The derived class
- * can so implement the virtual function, without having to take
- * care of the signal itself.
- */
- gboolean ( *delete_event ) ( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event );
-
- /**
- * get_iprefs_window_id:
- * @window: this #BaseWindow instance.
+ * Invoked when it is time to run the main loop for the toplevel.
*
- * Asks the derived class for the string which must be used to
- * store last size and position of the window in GConf preferences.
+ * The #BaseWindow class makes sure that the #GtkWindow toplevel and
+ * the #BaseWindow window have both been initialized.
*
- * This delegates to #BaseWindow-derived classes the BaseIPrefs
- * interface method.
+ * The #BaseWindow class defaults to do nothing.
+ *
+ * Returns: the exit code of the program if it is the main window.
*/
- gchar * ( *get_iprefs_window_id ) ( const BaseWindow *window );
+ int ( *run ) ( BaseWindow *window, GtkWindow *toplevel );
/**
* is_willing_to_quit:
diff --git a/src/nact/nact-add-capability-dialog.c b/src/nact/nact-add-capability-dialog.c
index a031d69..d914ae4 100644
--- a/src/nact/nact-add-capability-dialog.c
+++ b/src/nact/nact-add-capability-dialog.c
@@ -91,12 +91,10 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
-static NactAddCapabilityDialog *add_capability_dialog_new( BaseWindow *parent );
-
-static gchar *base_get_iprefs_window_id( const BaseWindow *window );
-static void on_base_initial_load_dialog( NactAddCapabilityDialog *editor, gpointer user_data );
-static void on_base_runtime_init_dialog( NactAddCapabilityDialog *editor, gpointer user_data );
-static void on_base_all_widgets_showed( NactAddCapabilityDialog *editor, gpointer user_data );
+static void on_base_initialize_gtk_toplevel( NactAddCapabilityDialog *editor, GtkDialog *toplevel );
+static void on_base_initialize_base_window( NactAddCapabilityDialog *editor );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
+static void on_base_all_widgets_showed( NactAddCapabilityDialog *editor );
static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactAddCapabilityDialog *editor );
static void on_cancel_clicked( GtkButton *button, NactAddCapabilityDialog *editor );
static void on_ok_clicked( GtkButton *button, NactAddCapabilityDialog *editor );
@@ -107,8 +105,7 @@ static void display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell,
static gboolean setup_values_iter( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter* iter, GSList *capabilities );
static void try_for_send_ok( NactAddCapabilityDialog *dialog );
static void send_ok( NactAddCapabilityDialog *dialog );
-static void validate_dialog( NactAddCapabilityDialog *editor );
-static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
+static void on_dialog_ok( BaseDialog *dialog );
GType
nact_add_capability_dialog_get_type( void )
@@ -153,6 +150,7 @@ class_init( NactAddCapabilityDialogClass *klass )
static const gchar *thisfn = "nact_add_capability_dialog_class_init";
GObjectClass *object_class;
BaseWindowClass *base_class;
+ BaseDialogClass *dialog_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -165,8 +163,10 @@ class_init( NactAddCapabilityDialogClass *klass )
klass->private = g_new0( NactAddCapabilityDialogClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->dialog_response = base_dialog_response;
- base_class->get_iprefs_window_id = base_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
+
+ dialog_class = BASE_DIALOG_CLASS( klass );
+ dialog_class->ok = on_dialog_ok;
}
static void
@@ -176,28 +176,21 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactAddCapabilityDialog *self;
g_return_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( instance ));
+
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
+
self = NACT_ADD_CAPABILITY_DIALOG( instance );
self->private = g_new0( NactAddCapabilityDialogPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_base_initial_load_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk_toplevel ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_ALL_WIDGETS_SHOWED, G_CALLBACK( on_base_all_widgets_showed));
self->private->dispose_has_run = FALSE;
self->private->capability = NULL;
@@ -213,10 +206,11 @@ instance_dispose( GObject *dialog )
GtkTreeSelection *selection;
g_return_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( dialog ));
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
+
self = NACT_ADD_CAPABILITY_DIALOG( dialog );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
self->private->dispose_has_run = TRUE;
@@ -240,7 +234,9 @@ instance_finalize( GObject *dialog )
NactAddCapabilityDialog *self;
g_return_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( dialog ));
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
+
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
+
self = NACT_ADD_CAPABILITY_DIALOG( dialog );
na_core_utils_slist_free( self->private->already_used );
@@ -254,22 +250,6 @@ instance_finalize( GObject *dialog )
}
}
-/*
- * Returns a newly allocated NactAddCapabilityDialog object.
- *
- * @parent: the BaseWindow parent of this dialog (usually, the main
- * toplevel window of the application).
- */
-static NactAddCapabilityDialog *
-add_capability_dialog_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_ADD_CAPABILITY_DIALOG_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
* nact_add_capability_dialog_run:
* @parent: the BaseWindow parent of this dialog
@@ -292,28 +272,28 @@ nact_add_capability_dialog_run( BaseWindow *parent, GSList *capabilities )
g_return_val_if_fail( BASE_IS_WINDOW( parent ), NULL );
- dialog = add_capability_dialog_new( parent );
- dialog->private->already_used = na_core_utils_slist_duplicate( capabilities );
+ dialog = g_object_new( NACT_ADD_CAPABILITY_DIALOG_TYPE,
+ BASE_PROP_PARENT, parent,
+ BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ NULL );
- base_window_run( BASE_WINDOW( dialog ));
+ dialog->private->already_used = na_core_utils_slist_duplicate( capabilities );
+ capability = NULL;
- capability = g_strdup( dialog->private->capability );
+ if( base_window_run( BASE_WINDOW( dialog )) == GTK_RESPONSE_OK ){
+ capability = g_strdup( dialog->private->capability );
+ }
g_object_unref( dialog );
return( capability );
}
-static gchar *
-base_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP ));
-}
-
static void
-on_base_initial_load_dialog( NactAddCapabilityDialog *dialog, gpointer user_data )
+on_base_initialize_gtk_toplevel( NactAddCapabilityDialog *dialog, GtkDialog *toplevel )
{
- static const gchar *thisfn = "nact_add_capability_dialog_on_initial_load_dialog";
+ static const gchar *thisfn = "nact_add_capability_dialog_on_base_initialize_gtk_toplevel";
GtkTreeView *listview;
GtkTreeModel *model;
GtkTreeViewColumn *column;
@@ -323,7 +303,7 @@ on_base_initial_load_dialog( NactAddCapabilityDialog *dialog, gpointer user_data
g_return_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( dialog ));
if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
+ g_debug( "%s: dialog=%p, toplevel=%p", thisfn, ( void * ) dialog, ( void * ) toplevel );
listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( dialog ), "CapabilitiesTreeView" ));
@@ -360,9 +340,9 @@ on_base_initial_load_dialog( NactAddCapabilityDialog *dialog, gpointer user_data
}
static void
-on_base_runtime_init_dialog( NactAddCapabilityDialog *dialog, gpointer user_data )
+on_base_initialize_base_window( NactAddCapabilityDialog *dialog )
{
- static const gchar *thisfn = "nact_add_capability_dialog_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_add_capability_dialog_on_base_initialize_base_window";
GtkTreeView *listview;
GtkListStore *model;
GtkTreeIter row;
@@ -371,7 +351,7 @@ on_base_runtime_init_dialog( NactAddCapabilityDialog *dialog, gpointer user_data
g_return_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( dialog ));
if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( dialog ), "CapabilitiesTreeView" ));
model = GTK_LIST_STORE( gtk_tree_view_get_model( listview ));
@@ -388,36 +368,30 @@ on_base_runtime_init_dialog( NactAddCapabilityDialog *dialog, gpointer user_data
gtk_tree_model_foreach( GTK_TREE_MODEL( model ), ( GtkTreeModelForeachFunc ) setup_values_iter, dialog->private->already_used );
/* catch double-click */
- base_window_signal_connect(
- BASE_WINDOW( dialog ),
- G_OBJECT( listview ),
- "button-press-event",
- G_CALLBACK( on_button_press_event ));
-
- base_window_signal_connect(
- BASE_WINDOW( dialog ),
- G_OBJECT( gtk_tree_view_get_selection( listview )),
- "changed",
- G_CALLBACK( on_selection_changed ));
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( dialog ),
- "CancelButton",
- "clicked",
- G_CALLBACK( on_cancel_clicked ));
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( dialog ),
- "OKButton",
- "clicked",
- G_CALLBACK( on_ok_clicked ));
+ base_window_signal_connect( BASE_WINDOW( dialog ),
+ G_OBJECT( listview ), "button-press-event", G_CALLBACK( on_button_press_event ));
+
+ base_window_signal_connect( BASE_WINDOW( dialog ),
+ G_OBJECT( gtk_tree_view_get_selection( listview )), "changed", G_CALLBACK( on_selection_changed ));
+
+ base_window_signal_connect_by_name( BASE_WINDOW( dialog ),
+ "CancelButton", "clicked", G_CALLBACK( on_cancel_clicked ));
+
+ base_window_signal_connect_by_name( BASE_WINDOW( dialog ),
+ "OKButton", "clicked", G_CALLBACK( on_ok_clicked ));
}
}
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP ));
+}
+
static void
-on_base_all_widgets_showed( NactAddCapabilityDialog *dialog, gpointer user_data )
+on_base_all_widgets_showed( NactAddCapabilityDialog *dialog )
{
- static const gchar *thisfn = "nact_add_capability_dialog_on_all_widgets_showed";
+ static const gchar *thisfn = "nact_add_capability_dialog_on_base_all_widgets_showed";
GtkTreeView *listview;
GtkTreePath *path;
GtkTreeSelection *selection;
@@ -425,8 +399,7 @@ on_base_all_widgets_showed( NactAddCapabilityDialog *dialog, gpointer user_data
g_return_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( dialog ));
if( !dialog->private->dispose_has_run ){
-
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( dialog ), "CapabilitiesTreeView" ));
path = gtk_tree_path_new_first();
@@ -566,8 +539,9 @@ send_ok( NactAddCapabilityDialog *dialog )
}
static void
-validate_dialog( NactAddCapabilityDialog *dialog )
+on_dialog_ok( BaseDialog *dialog )
{
+ NactAddCapabilityDialog *editor;
GtkTreeView *listview;
GtkTreeSelection *selection;
GtkTreeModel *model;
@@ -575,42 +549,15 @@ validate_dialog( NactAddCapabilityDialog *dialog )
GtkTreePath *path;
GtkTreeIter iter;
- listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( dialog ), "CapabilitiesTreeView" ));
+ editor = NACT_ADD_CAPABILITY_DIALOG( dialog );
+
+ listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "CapabilitiesTreeView" ));
selection = gtk_tree_view_get_selection( listview );
rows = gtk_tree_selection_get_selected_rows( selection, &model );
if( g_list_length( rows ) == 1 ){
path = ( GtkTreePath * ) rows->data;
gtk_tree_model_get_iter( model, &iter, path );
- gtk_tree_model_get( model, &iter, CAPABILITY_KEYWORD_COLUMN, &dialog->private->capability, -1 );
+ gtk_tree_model_get( model, &iter, CAPABILITY_KEYWORD_COLUMN, &editor->private->capability, -1 );
}
}
-
-static gboolean
-base_dialog_response( GtkDialog *dialog_box, gint code, BaseWindow *window )
-{
- static const gchar *thisfn = "nact_add_capability_dialog_on_dialog_response";
- NactAddCapabilityDialog *dialog;
-
- g_return_val_if_fail( NACT_IS_ADD_CAPABILITY_DIALOG( window ), FALSE );
-
- dialog = NACT_ADD_CAPABILITY_DIALOG( window );
-
- if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog_box=%p, code=%d, window=%p", thisfn, ( void * ) dialog_box, code, ( void * ) window );
-
- switch( code ){
- case GTK_RESPONSE_OK:
- validate_dialog( dialog );
-
- case GTK_RESPONSE_NONE:
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_CANCEL:
- return( TRUE );
- break;
- }
- }
-
- return( FALSE );
-}
diff --git a/src/nact/nact-add-scheme-dialog.c b/src/nact/nact-add-scheme-dialog.c
index 302edac..9b32737 100644
--- a/src/nact/nact-add-scheme-dialog.c
+++ b/src/nact/nact-add-scheme-dialog.c
@@ -66,20 +66,17 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
-static NactAddSchemeDialog *add_scheme_dialog_new( BaseWindow *parent );
-
-static gchar *base_get_iprefs_window_id( const BaseWindow *window );
-static void on_base_initial_load_dialog( NactAddSchemeDialog *editor, gpointer user_data );
-static void on_base_runtime_init_dialog( NactAddSchemeDialog *editor, gpointer user_data );
-static void on_base_all_widgets_showed( NactAddSchemeDialog *editor, gpointer user_data );
+static void on_base_initialize_gtk_toplevel( NactAddSchemeDialog *editor, GtkDialog *toplevel );
+static void on_base_initialize_base_window( NactAddSchemeDialog *editor );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
+static void on_base_all_widgets_showed( NactAddSchemeDialog *editor );
static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactAddSchemeDialog *dialog );
static void on_cancel_clicked( GtkButton *button, NactAddSchemeDialog *editor );
static void on_ok_clicked( GtkButton *button, NactAddSchemeDialog *editor );
static void on_selection_changed( const gchar *scheme, gboolean used, NactAddSchemeDialog *dialog );
static void try_for_send_ok( NactAddSchemeDialog *dialog );
static void send_ok( NactAddSchemeDialog *dialog );
-static void validate_dialog( NactAddSchemeDialog *editor );
-static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
+static void on_dialog_ok( BaseDialog *dialog );
GType
nact_add_scheme_dialog_get_type( void )
@@ -124,6 +121,7 @@ class_init( NactAddSchemeDialogClass *klass )
static const gchar *thisfn = "nact_add_scheme_dialog_class_init";
GObjectClass *object_class;
BaseWindowClass *base_class;
+ BaseDialogClass *dialog_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -136,8 +134,10 @@ class_init( NactAddSchemeDialogClass *klass )
klass->private = g_new0( NactAddSchemeDialogClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->dialog_response = base_dialog_response;
- base_class->get_iprefs_window_id = base_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
+
+ dialog_class = BASE_DIALOG_CLASS( klass );
+ dialog_class->ok = on_dialog_ok;
}
static void
@@ -147,28 +147,21 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactAddSchemeDialog *self;
g_return_if_fail( NACT_IS_ADD_SCHEME_DIALOG( instance ));
+
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
+
self = NACT_ADD_SCHEME_DIALOG( instance );
self->private = g_new0( NactAddSchemeDialogPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_base_initial_load_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk_toplevel ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_ALL_WIDGETS_SHOWED, G_CALLBACK( on_base_all_widgets_showed));
self->private->dispose_has_run = FALSE;
self->private->scheme = NULL;
@@ -184,7 +177,9 @@ instance_dispose( GObject *dialog )
GtkTreeSelection *selection;
g_return_if_fail( NACT_IS_ADD_SCHEME_DIALOG( dialog ));
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
+
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
+
self = NACT_ADD_SCHEME_DIALOG( dialog );
if( !self->private->dispose_has_run ){
@@ -211,7 +206,9 @@ instance_finalize( GObject *dialog )
NactAddSchemeDialog *self;
g_return_if_fail( NACT_IS_ADD_SCHEME_DIALOG( dialog ));
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
+
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
+
self = NACT_ADD_SCHEME_DIALOG( dialog );
na_core_utils_slist_free( self->private->already_used );
@@ -225,22 +222,6 @@ instance_finalize( GObject *dialog )
}
}
-/*
- * Returns a newly allocated NactAddSchemeDialog object.
- *
- * @parent: the BaseWindow parent of this dialog (usually, the main
- * toplevel window of the application).
- */
-static NactAddSchemeDialog *
-add_scheme_dialog_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_ADD_SCHEME_DIALOG_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
* nact_add_scheme_dialog_run:
* @parent: the BaseWindow parent of this dialog
@@ -263,34 +244,34 @@ nact_add_scheme_dialog_run( BaseWindow *parent, GSList *schemes )
g_return_val_if_fail( BASE_IS_WINDOW( parent ), NULL );
- dialog = add_scheme_dialog_new( parent );
- dialog->private->already_used = na_core_utils_slist_duplicate( schemes );
+ dialog = g_object_new( NACT_ADD_SCHEME_DIALOG_TYPE,
+ BASE_PROP_PARENT, parent,
+ BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ NULL );
- base_window_run( BASE_WINDOW( dialog ));
+ dialog->private->already_used = na_core_utils_slist_duplicate( schemes );
+ scheme = NULL;
- scheme = g_strdup( dialog->private->scheme );
+ if( base_window_run( BASE_WINDOW( dialog )) == GTK_RESPONSE_OK ){
+ scheme = g_strdup( dialog->private->scheme );
+ }
g_object_unref( dialog );
return( scheme );
}
-static gchar *
-base_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_SCHEME_ADD_SCHEME_WSP ));
-}
-
static void
-on_base_initial_load_dialog( NactAddSchemeDialog *dialog, gpointer user_data )
+on_base_initialize_gtk_toplevel( NactAddSchemeDialog *dialog, GtkDialog *toplevel )
{
- static const gchar *thisfn = "nact_add_scheme_dialog_on_initial_load_dialog";
+ static const gchar *thisfn = "nact_add_scheme_dialog_on_base_initialize_gtk_toplevel";
GtkTreeView *listview;
g_return_if_fail( NACT_IS_ADD_SCHEME_DIALOG( dialog ));
if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
+ g_debug( "%s: dialog=%p, toplevel=%p", thisfn, ( void * ) dialog, ( void * ) toplevel );
listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( dialog ), "SchemesTreeView" ));
nact_schemes_list_create_model( listview, SCHEMES_LIST_FOR_ADD_FROM_DEFAULTS );
@@ -298,15 +279,15 @@ on_base_initial_load_dialog( NactAddSchemeDialog *dialog, gpointer user_data )
}
static void
-on_base_runtime_init_dialog( NactAddSchemeDialog *dialog, gpointer user_data )
+on_base_initialize_base_window( NactAddSchemeDialog *dialog )
{
- static const gchar *thisfn = "nact_add_scheme_dialog_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_add_scheme_dialog_on_base_initialize_base_window";
GtkTreeView *listview;
g_return_if_fail( NACT_IS_ADD_SCHEME_DIALOG( dialog ));
if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( dialog ), "SchemesTreeView" ));
nact_schemes_list_init_view( listview, BASE_WINDOW( dialog ), ( pf_new_selection_cb ) on_selection_changed, ( void * ) dialog );
@@ -336,15 +317,21 @@ on_base_runtime_init_dialog( NactAddSchemeDialog *dialog, gpointer user_data )
}
}
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_SCHEME_ADD_SCHEME_WSP ));
+}
+
static void
-on_base_all_widgets_showed( NactAddSchemeDialog *dialog, gpointer user_data )
+on_base_all_widgets_showed( NactAddSchemeDialog *dialog )
{
- static const gchar *thisfn = "nact_add_scheme_dialog_on_all_widgets_showed";
+ static const gchar *thisfn = "nact_add_scheme_dialog_on_base_all_widgets_showed";
g_return_if_fail( NACT_IS_ADD_SCHEME_DIALOG( dialog ));
if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
nact_schemes_list_show_all( BASE_WINDOW( dialog ));
}
@@ -424,36 +411,8 @@ send_ok( NactAddSchemeDialog *dialog )
}
static void
-validate_dialog( NactAddSchemeDialog *dialog )
-{
- dialog->private->scheme = nact_schemes_list_get_current_scheme( BASE_WINDOW( dialog ));
-}
-
-static gboolean
-base_dialog_response( GtkDialog *dialog_box, gint code, BaseWindow *window )
+on_dialog_ok( BaseDialog *dialog )
{
- static const gchar *thisfn = "nact_add_scheme_dialog_on_dialog_response";
- NactAddSchemeDialog *dialog;
-
- g_return_val_if_fail( NACT_IS_ADD_SCHEME_DIALOG( window ), FALSE );
-
- dialog = NACT_ADD_SCHEME_DIALOG( window );
-
- if( !dialog->private->dispose_has_run ){
- g_debug( "%s: dialog_box=%p, code=%d, window=%p", thisfn, ( void * ) dialog_box, code, ( void * ) window );
-
- switch( code ){
- case GTK_RESPONSE_OK:
- validate_dialog( dialog );
-
- case GTK_RESPONSE_NONE:
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_CANCEL:
- return( TRUE );
- break;
- }
- }
-
- return( FALSE );
+ NactAddSchemeDialog *editor = NACT_ADD_SCHEME_DIALOG( dialog );
+ editor->private->scheme = nact_schemes_list_get_current_scheme( BASE_WINDOW( dialog ));
}
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 55d1fef..9a4de24 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -106,13 +106,10 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *application );
static void instance_finalize( GObject *application );
-static NactAssistantExport *assist_new( BaseWindow *parent );
-
-static gchar *window_get_iprefs_window_id( const BaseWindow *window );
-
-static void on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data );
-static void on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data );
-static void on_all_widgets_showed( NactAssistantExport *dialog );
+static void on_base_initialize_gtk_toplevel( NactAssistantExport *dialog, GtkAssistant *toplevel );
+static void on_base_initialize_base_window( NactAssistantExport *dialog );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
+static void on_base_all_widgets_showed( NactAssistantExport *dialog );
static void assist_initial_load_intro( NactAssistantExport *window, GtkAssistant *assistant );
static void assist_runtime_init_intro( NactAssistantExport *window, GtkAssistant *assistant );
@@ -207,7 +204,7 @@ class_init( NactAssistantExportClass *klass )
klass->private = g_new0( NactAssistantExportClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->get_iprefs_window_id = window_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
assist_class = BASE_ASSISTANT_CLASS( klass );
assist_class->apply = assistant_apply;
@@ -230,32 +227,25 @@ instance_init( GTypeInstance *instance, gpointer klass )
static const gchar *thisfn = "nact_assistant_export_instance_init";
NactAssistantExport *self;
+ g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( instance ));
+
g_debug( "%s: instance=%p (%s), klass=%p",
thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
- g_assert( NACT_IS_ASSISTANT_EXPORT( instance ));
+
self = NACT_ASSISTANT_EXPORT( instance );
self->private = g_new0( NactAssistantExportPrivate, 1 );
self->private->dispose_has_run = FALSE;
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_initial_load_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk_toplevel ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_all_widgets_showed ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_ALL_WIDGETS_SHOWED, G_CALLBACK( on_base_all_widgets_showed ));
}
static void
@@ -264,11 +254,12 @@ instance_dispose( GObject *window )
static const gchar *thisfn = "nact_assistant_export_instance_dispose";
NactAssistantExport *self;
- g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( window ));
+
self = NACT_ASSISTANT_EXPORT( window );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
self->private->dispose_has_run = TRUE;
@@ -287,8 +278,10 @@ instance_finalize( GObject *window )
static const gchar *thisfn = "nact_assistant_export_instance_finalize";
NactAssistantExport *self;
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( window ));
+
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
+
self = NACT_ASSISTANT_EXPORT( window );
free_results( self->private->results );
@@ -301,16 +294,6 @@ instance_finalize( GObject *window )
}
}
-static NactAssistantExport *
-assist_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_ASSISTANT_EXPORT_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
* Run the assistant.
*
@@ -319,91 +302,106 @@ assist_new( BaseWindow *parent )
void
nact_assistant_export_run( BaseWindow *main_window )
{
- NactAssistantExport *assist;
+ NactAssistantExport *assistant;
+ NactApplication *application;
+ NAUpdater *updater;
+ NASettings *settings;
+ gboolean esc_quit, esc_confirm;
- assist = assist_new( main_window );
- g_object_set( G_OBJECT( assist ), BASE_PROP_HAS_OWN_BUILDER, TRUE, NULL );
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( main_window ));
- base_window_run( BASE_WINDOW( assist ));
-}
+ application = NACT_APPLICATION( base_window_get_application( main_window ));
+ updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
-static gchar *
-window_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_EXPORT_ASSISTANT_WSP ));
+ esc_quit = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, NULL, NULL );
+ esc_confirm = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, NULL, NULL );
+
+ assistant = g_object_new( NACT_ASSISTANT_EXPORT_TYPE,
+ BASE_PROP_PARENT, main_window,
+ BASE_PROP_HAS_OWN_BUILDER, TRUE,
+ BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ BASE_PROP_QUIT_ON_ESCAPE, esc_quit,
+ BASE_PROP_WARN_ON_ESCAPE, esc_confirm,
+ NULL );
+
+ base_window_run( BASE_WINDOW( assistant ));
}
static void
-on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data )
+on_base_initialize_gtk_toplevel( NactAssistantExport *dialog, GtkAssistant *assistant )
{
- static const gchar *thisfn = "nact_assistant_export_on_initial_load_dialog";
- GtkAssistant *assistant;
+ static const gchar *thisfn = "nact_assistant_export_on_base_initialize_gtk_toplevel";
NactApplication *application;
NAUpdater *updater;
NASettings *settings;
- gboolean esc_quit, esc_confirm;
gboolean are_locked, mandatory;
g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( dialog ));
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
-
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( dialog )));
- updater = nact_application_get_updater( application );
- settings = na_pivot_get_settings( NA_PIVOT( updater ));
-
- are_locked = na_settings_get_boolean( settings, NA_IPREFS_ADMIN_PREFERENCES_LOCKED, NULL, &mandatory );
- dialog->private->preferences_locked = are_locked && mandatory;
+ if( !dialog->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p, assistant=%p", thisfn, ( void * ) dialog, ( void * ) assistant );
- assistant = GTK_ASSISTANT( base_window_get_gtk_toplevel( BASE_WINDOW( dialog )));
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( dialog )));
+ updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
- assist_initial_load_intro( dialog, assistant );
- assist_initial_load_actions_list( dialog, assistant );
- assist_initial_load_target_folder( dialog, assistant );
- assist_initial_load_format( dialog, assistant );
- assist_initial_load_confirm( dialog, assistant );
- assist_initial_load_exportdone( dialog, assistant );
+ are_locked = na_settings_get_boolean( settings, NA_IPREFS_ADMIN_PREFERENCES_LOCKED, NULL, &mandatory );
+ dialog->private->preferences_locked = are_locked && mandatory;
- esc_quit = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, NULL, NULL );
- base_assistant_set_cancel_on_esc( BASE_ASSISTANT( dialog ), esc_quit );
- esc_confirm = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, NULL, NULL );
- base_assistant_set_warn_on_esc( BASE_ASSISTANT( dialog ), esc_confirm );
+ assist_initial_load_intro( dialog, assistant );
+ assist_initial_load_actions_list( dialog, assistant );
+ assist_initial_load_target_folder( dialog, assistant );
+ assist_initial_load_format( dialog, assistant );
+ assist_initial_load_confirm( dialog, assistant );
+ assist_initial_load_exportdone( dialog, assistant );
+ }
}
static void
-on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data )
+on_base_initialize_base_window( NactAssistantExport *dialog )
{
- static const gchar *thisfn = "nact_assistant_export_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_assistant_export_on_base_initialize_base_window";
GtkAssistant *assistant;
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
- g_assert( NACT_IS_ASSISTANT_EXPORT( dialog ));
+ g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( dialog ));
- assistant = GTK_ASSISTANT( base_window_get_gtk_toplevel( BASE_WINDOW( dialog )));
+ if( !dialog->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
- base_window_signal_connect(
- BASE_WINDOW( dialog ),
- G_OBJECT( dialog ),
- IACTIONS_LIST_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_iactions_list_selection_changed ));
+ assistant = GTK_ASSISTANT( base_window_get_gtk_toplevel( BASE_WINDOW( dialog )));
- assist_runtime_init_intro( dialog, assistant );
- assist_runtime_init_actions_list( dialog, assistant );
- assist_runtime_init_target_folder( dialog, assistant );
- assist_runtime_init_format( dialog, assistant );
- assist_runtime_init_confirm( dialog, assistant );
- assist_runtime_init_exportdone( dialog, assistant );
+ base_window_signal_connect( BASE_WINDOW( dialog ),
+ G_OBJECT( dialog ), IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_iactions_list_selection_changed ));
+
+ assist_runtime_init_intro( dialog, assistant );
+ assist_runtime_init_actions_list( dialog, assistant );
+ assist_runtime_init_target_folder( dialog, assistant );
+ assist_runtime_init_format( dialog, assistant );
+ assist_runtime_init_confirm( dialog, assistant );
+ assist_runtime_init_exportdone( dialog, assistant );
+ }
+}
+
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_EXPORT_ASSISTANT_WSP ));
}
static void
-on_all_widgets_showed( NactAssistantExport *dialog )
+on_base_all_widgets_showed( NactAssistantExport *dialog )
{
- static const gchar *thisfn = "nact_assistant_export_on_all_widgets_showed";
+ static const gchar *thisfn = "nact_assistant_export_on_base_all_widgets_showed";
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( dialog ));
- nact_iactions_list_bis_select_first_row( NACT_IACTIONS_LIST( dialog ));
+ if( !dialog->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
+
+ nact_iactions_list_bis_select_first_row( NACT_IACTIONS_LIST( dialog ));
+ }
}
static void
@@ -872,8 +870,7 @@ assist_prepare_exportdone( NactAssistantExport *window, GtkAssistant *assistant,
g_object_unref( title_tag );
gtk_assistant_set_page_complete( assistant, page, TRUE );
- base_assistant_set_warn_on_cancel( BASE_ASSISTANT( window ), FALSE );
- base_assistant_set_warn_on_esc( BASE_ASSISTANT( window ), FALSE );
+ g_object_set( G_OBJECT( window ), BASE_PROP_WARN_ON_ESCAPE, FALSE, NULL );
}
static void
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 1a0ac33..53042dc 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -89,12 +89,8 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *application );
static void instance_finalize( GObject *application );
-static NactAssistantImport *assist_new( BaseWindow *parent );
-
-static gchar *window_get_iprefs_window_id( const BaseWindow *window );
-
-static void on_initial_load_dialog( NactAssistantImport *dialog, gpointer user_data );
-static void on_runtime_init_dialog( NactAssistantImport *dialog, gpointer user_data );
+static void on_base_initialize_base_window( NactAssistantImport *dialog );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
static void runtime_init_intro( NactAssistantImport *window, GtkAssistant *assistant );
static void runtime_init_file_selector( NactAssistantImport *window, GtkAssistant *assistant );
static void on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data );
@@ -167,7 +163,7 @@ class_init( NactAssistantImportClass *klass )
klass->private = g_new0( NactAssistantImportClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->get_iprefs_window_id = window_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
assist_class = BASE_ASSISTANT_CLASS( klass );
assist_class->apply = assistant_apply;
@@ -191,17 +187,8 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->results = NULL;
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_initial_load_dialog ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
self->private->dispose_has_run = FALSE;
}
@@ -236,7 +223,7 @@ instance_finalize( GObject *window )
g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( window ));
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
self = NACT_ASSISTANT_IMPORT( window );
@@ -250,17 +237,6 @@ instance_finalize( GObject *window )
}
}
-static NactAssistantImport *
-assist_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_ASSISTANT_IMPORT_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_HAS_OWN_BUILDER, TRUE,
- BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
* nact_assistant_import_run:
* @main: the #NactMainWindow parent window of this assistant.
@@ -270,51 +246,43 @@ assist_new( BaseWindow *parent )
void
nact_assistant_import_run( BaseWindow *main_window )
{
- NactAssistantImport *assist;
-
- assist = assist_new( main_window );
-
- base_window_run( BASE_WINDOW( assist ));
-}
-
-static gchar *
-window_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_IMPORT_ASSISTANT_WSP ));
-}
-
-static void
-on_initial_load_dialog( NactAssistantImport *dialog, gpointer user_data )
-{
- static const gchar *thisfn = "nact_assistant_import_on_initial_load_dialog";
+ NactAssistantImport *assistant;
NactApplication *application;
NAUpdater *updater;
NASettings *settings;
gboolean esc_quit, esc_confirm;
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
- g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( dialog ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( main_window ));
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( dialog )));
+ application = NACT_APPLICATION( base_window_get_application( main_window ));
updater = nact_application_get_updater( application );
settings = na_pivot_get_settings( NA_PIVOT( updater ));
esc_quit = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, NULL, NULL );
- base_assistant_set_cancel_on_esc( BASE_ASSISTANT( dialog ), esc_quit );
esc_confirm = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, NULL, NULL );
- base_assistant_set_warn_on_esc( BASE_ASSISTANT( dialog ), esc_confirm );
+
+ assistant = g_object_new( NACT_ASSISTANT_IMPORT_TYPE,
+ BASE_PROP_PARENT, main_window,
+ BASE_PROP_HAS_OWN_BUILDER, TRUE,
+ BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ BASE_PROP_QUIT_ON_ESCAPE, esc_quit,
+ BASE_PROP_WARN_ON_ESCAPE, esc_confirm,
+ NULL );
+
+ base_window_run( BASE_WINDOW( assistant ));
}
static void
-on_runtime_init_dialog( NactAssistantImport *dialog, gpointer user_data )
+on_base_initialize_base_window( NactAssistantImport *dialog )
{
- static const gchar *thisfn = "nact_assistant_import_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_assistant_import_on_base_initialize_base_window";
GtkAssistant *assistant;
- g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( dialog ));
if( !dialog->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
assistant = GTK_ASSISTANT( base_window_get_gtk_toplevel( BASE_WINDOW( dialog )));
@@ -324,6 +292,12 @@ on_runtime_init_dialog( NactAssistantImport *dialog, gpointer user_data )
}
}
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_IMPORT_ASSISTANT_WSP ));
+}
+
static void
runtime_init_intro( NactAssistantImport *window, GtkAssistant *assistant )
{
@@ -833,8 +807,7 @@ prepare_importdone( NactAssistantImport *window, GtkAssistant *assistant, GtkWid
na_iprefs_set_import_mode( NA_PIVOT( updater ), NA_IPREFS_IMPORT_PREFERRED_MODE, mode );
gtk_assistant_set_page_complete( assistant, page, TRUE );
- base_assistant_set_warn_on_cancel( BASE_ASSISTANT( window ), FALSE );
- base_assistant_set_warn_on_esc( BASE_ASSISTANT( window ), FALSE );
+ g_object_set( G_OBJECT( window ), BASE_PROP_WARN_ON_ESCAPE, FALSE, NULL );
}
static void
diff --git a/src/nact/nact-confirm-logout.c b/src/nact/nact-confirm-logout.c
index 7081bcd..f5112dc 100644
--- a/src/nact/nact-confirm-logout.c
+++ b/src/nact/nact-confirm-logout.c
@@ -64,16 +64,10 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
-static NactConfirmLogout *confirm_logout_new( BaseWindow *parent );
-
-static void on_base_initial_load_dialog( NactConfirmLogout *editor, gpointer user_data );
-static void on_base_runtime_init_dialog( NactConfirmLogout *editor, gpointer user_data );
-static void on_base_all_widgets_showed( NactConfirmLogout *editor, gpointer user_data );
+static void on_base_initialize_base_window( NactConfirmLogout *editor );
static void on_quit_without_saving_clicked( GtkButton *button, NactConfirmLogout *editor );
static void on_cancel_clicked( GtkButton *button, NactConfirmLogout *editor );
static void on_save_and_quit_clicked( GtkButton *button, NactConfirmLogout *editor );
-
-static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
static void close_dialog( NactConfirmLogout *editor, gboolean willing_to );
GType
@@ -118,7 +112,6 @@ class_init( NactConfirmLogoutClass *klass )
{
static const gchar *thisfn = "nact_confirm_logout_class_init";
GObjectClass *object_class;
- BaseWindowClass *base_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -129,9 +122,6 @@ class_init( NactConfirmLogoutClass *klass )
object_class->finalize = instance_finalize;
klass->private = g_new0( NactConfirmLogoutClassPrivate, 1 );
-
- base_class = BASE_WINDOW_CLASS( klass );
- base_class->dialog_response = base_dialog_response;
}
static void
@@ -147,23 +137,8 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NactConfirmLogoutPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_base_initial_load_dialog ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_dialog ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
self->private->dispose_has_run = FALSE;
}
@@ -207,21 +182,6 @@ instance_finalize( GObject *dialog )
}
}
-/*
- * Returns a newly allocated NactConfirmLogout object.
- *
- * @parent: the BaseWindow parent of this dialog (usually, the main
- * toplevel window of the application).
- */
-static NactConfirmLogout *
-confirm_logout_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_CONFIRM_LOGOUT_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
* nact_confirm_logout_run:
* @parent: the NactMainWindow parent of this dialog
@@ -233,62 +193,46 @@ gboolean
nact_confirm_logout_run( NactMainWindow *parent )
{
static const gchar *thisfn = "nact_confirm_logout_run";
- NactConfirmLogout *editor;
+ NactConfirmLogout *dialog;
gboolean willing_to;
+ g_return_val_if_fail( NACT_IS_MAIN_WINDOW( parent ), TRUE );
+
g_debug( "%s: parent=%p", thisfn, ( void * ) parent );
- g_return_val_if_fail( BASE_IS_WINDOW( parent ), TRUE );
- editor = confirm_logout_new( BASE_WINDOW( parent ));
+ dialog = g_object_new( NACT_CONFIRM_LOGOUT_TYPE,
+ BASE_PROP_PARENT, parent,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ NULL );
+
+ base_window_run( BASE_WINDOW( dialog ));
+
+ willing_to = dialog->private->willing_to_quit;
- base_window_run( BASE_WINDOW( editor ));
- willing_to = editor->private->willing_to_quit;
- g_object_unref( editor );
+ g_object_unref( dialog );
return( willing_to );
}
static void
-on_base_initial_load_dialog( NactConfirmLogout *editor, gpointer user_data )
+on_base_initialize_base_window( NactConfirmLogout *dialog )
{
- static const gchar *thisfn = "nact_confirm_logout_on_initial_load_dialog";
+ static const gchar *thisfn = "nact_confirm_logout_on_base_initialize_base_window";
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
- g_return_if_fail( NACT_IS_CONFIRM_LOGOUT( editor ));
-}
+ g_return_if_fail( NACT_IS_CONFIRM_LOGOUT( dialog ));
-static void
-on_base_runtime_init_dialog( NactConfirmLogout *editor, gpointer user_data )
-{
- static const gchar *thisfn = "nact_confirm_logout_on_runtime_init_dialog";
-
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "QuitNoSaveButton",
- "clicked",
- G_CALLBACK( on_quit_without_saving_clicked ));
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "CancelQuitButton",
- "clicked",
- G_CALLBACK( on_cancel_clicked ));
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "SaveQuitButton",
- "clicked",
- G_CALLBACK( on_save_and_quit_clicked ));
-}
+ if( !dialog->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
-static void
-on_base_all_widgets_showed( NactConfirmLogout *editor, gpointer user_data )
-{
- static const gchar *thisfn = "nact_confirm_logout_on_all_widgets_showed";
+ base_window_signal_connect_by_name( BASE_WINDOW( dialog ),
+ "QuitNoSaveButton", "clicked", G_CALLBACK( on_quit_without_saving_clicked ));
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
+ base_window_signal_connect_by_name( BASE_WINDOW( dialog ),
+ "CancelQuitButton", "clicked", G_CALLBACK( on_cancel_clicked ));
+
+ base_window_signal_connect_by_name( BASE_WINDOW( dialog ),
+ "SaveQuitButton", "clicked", G_CALLBACK( on_save_and_quit_clicked ));
+ }
}
static void
@@ -325,26 +269,6 @@ on_save_and_quit_clicked( GtkButton *button, NactConfirmLogout *editor )
close_dialog( editor, TRUE );
}
-static gboolean
-base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
-{
- static const gchar *thisfn = "nact_confirm_logout_on_dialog_response";
- NactConfirmLogout *editor;
-
- g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
- g_assert( NACT_IS_CONFIRM_LOGOUT( window ));
- editor = NACT_CONFIRM_LOGOUT( window );
-
- switch( code ){
- case GTK_RESPONSE_CLOSE:
-
- return( TRUE );
- break;
- }
-
- return( FALSE );
-}
-
static void
close_dialog( NactConfirmLogout *editor, gboolean willing_to )
{
diff --git a/src/nact/nact-export-ask.c b/src/nact/nact-export-ask.c
index 7c79605..752de87 100644
--- a/src/nact/nact-export-ask.c
+++ b/src/nact/nact-export-ask.c
@@ -74,17 +74,13 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
-static NactExportAsk *export_ask_new( BaseWindow *parent );
-
-static gchar *base_get_iprefs_window_id( const BaseWindow *window );
-static void on_base_initial_load_dialog( NactExportAsk *editor, gpointer user_data );
-static void on_base_runtime_init_dialog( NactExportAsk *editor, gpointer user_data );
-static void on_base_all_widgets_showed( NactExportAsk *editor, gpointer user_data );
+static void on_base_initialize_gtk_toplevel( NactExportAsk *editor, GtkDialog *toplevel );
+static void on_base_initialize_base_window( NactExportAsk *editor );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
static void keep_choice_on_toggled( GtkToggleButton *button, NactExportAsk *editor );
static void on_cancel_clicked( GtkButton *button, NactExportAsk *editor );
static void on_ok_clicked( GtkButton *button, NactExportAsk *editor );
static GQuark get_export_format( NactExportAsk *editor );
-static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
GType
nact_export_ask_get_type( void )
@@ -141,8 +137,7 @@ class_init( NactExportAskClass *klass )
klass->private = g_new0( NactExportAskClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->dialog_response = base_dialog_response;
- base_class->get_iprefs_window_id = base_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
}
static void
@@ -160,23 +155,11 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NactExportAskPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_base_initial_load_dialog ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk_toplevel ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
self->private->dispose_has_run = FALSE;
}
@@ -192,7 +175,6 @@ instance_dispose( GObject *dialog )
self = NACT_EXPORT_ASK( dialog );
if( !self->private->dispose_has_run ){
-
g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
self->private->dispose_has_run = TRUE;
@@ -224,21 +206,8 @@ instance_finalize( GObject *dialog )
}
}
-/*
- * Returns a newly allocated NactExportAsk object.
- */
-static NactExportAsk *
-export_ask_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_EXPORT_ASK_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
- * nact_export_ask_run:
+ * nact_export_ask_user:
* @parent: the NactAssistant parent of this dialog.
* @item: the NAObjectItem to be exported.
* @first: whether this is the first call of a serie.
@@ -261,7 +230,7 @@ export_ask_new( BaseWindow *parent )
GQuark
nact_export_ask_user( BaseWindow *parent, NAObjectItem *item, gboolean first )
{
- static const gchar *thisfn = "nact_export_ask_run";
+ static const gchar *thisfn = "nact_export_ask_user";
NactExportAsk *editor;
NactApplication *application;
NAUpdater *updater;
@@ -285,7 +254,11 @@ nact_export_ask_user( BaseWindow *parent, NAObjectItem *item, gboolean first )
if( first || !keep ){
- editor = export_ask_new( parent );
+ editor = g_object_new( NACT_EXPORT_ASK_TYPE,
+ BASE_PROP_PARENT, parent,
+ BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ NULL );
editor->private->format = format;
editor->private->format_mandatory = mandatory;
@@ -298,10 +271,8 @@ nact_export_ask_user( BaseWindow *parent, NAObjectItem *item, gboolean first )
are_locked = na_settings_get_boolean( settings, NA_IPREFS_ADMIN_PREFERENCES_LOCKED, NULL, &mandatory );
editor->private->preferences_locked = are_locked && mandatory;
- if( base_window_run( BASE_WINDOW( editor ))){
- if( editor->private->format ){
- format = editor->private->format;
- }
+ if( base_window_run( BASE_WINDOW( editor )) == GTK_RESPONSE_OK ){
+ format = get_export_format( editor );
}
g_object_unref( editor );
@@ -310,83 +281,76 @@ nact_export_ask_user( BaseWindow *parent, NAObjectItem *item, gboolean first )
return( format );
}
-static gchar *
-base_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_EXPORT_ASK_USER_WSP ));
-}
-
static void
-on_base_initial_load_dialog( NactExportAsk *editor, gpointer user_data )
+on_base_initialize_gtk_toplevel( NactExportAsk *editor, GtkDialog *toplevel )
{
- static const gchar *thisfn = "nact_export_ask_on_initial_load_dialog";
+ static const gchar *thisfn = "nact_export_ask_on_base_initialize_gtk_toplevel";
NactApplication *application;
NAUpdater *updater;
GtkWidget *container;
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
g_return_if_fail( NACT_IS_EXPORT_ASK( editor ));
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
- updater = nact_application_get_updater( application );
- container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
- nact_export_format_init_display( container, NA_PIVOT( updater ), EXPORT_FORMAT_DISPLAY_ASK, !editor->private->preferences_locked );
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p, toplevel=%p", thisfn, ( void * ) editor, ( void * ) toplevel );
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+ updater = nact_application_get_updater( application );
+ container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
+
+ nact_export_format_init_display( container,
+ NA_PIVOT( updater ), EXPORT_FORMAT_DISPLAY_ASK, !editor->private->preferences_locked );
+ }
}
static void
-on_base_runtime_init_dialog( NactExportAsk *editor, gpointer user_data )
+on_base_initialize_base_window( NactExportAsk *editor )
{
- static const gchar *thisfn = "nact_export_ask_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_export_ask_on_base_initialize_base_window";
GtkWidget *container;
gchar *item_label, *label;
GtkWidget *widget;
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
g_return_if_fail( NACT_IS_EXPORT_ASK( editor ));
- item_label = na_object_get_label( editor->private->item );
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p", thisfn, ( void * ) editor );
- if( NA_IS_OBJECT_ACTION( editor->private->item )){
- /* i18n: The action <label> is about to be exported */
- label = g_strdup_printf( _( "The action \"%s\" is about to be exported." ), item_label );
- } else {
- /* i18n: The menu <label> is about to be exported */
- label = g_strdup_printf( _( "The menu \"%s\" is about to be exported." ), item_label );
- }
+ item_label = na_object_get_label( editor->private->item );
- widget = base_window_get_widget( BASE_WINDOW( editor ), "ExportAskLabel1" );
- gtk_label_set_text( GTK_LABEL( widget ), label );
- g_free( label );
- g_free( item_label );
+ if( NA_IS_OBJECT_ACTION( editor->private->item )){
+ /* i18n: The action <label> is about to be exported */
+ label = g_strdup_printf( _( "The action \"%s\" is about to be exported." ), item_label );
+ } else {
+ /* i18n: The menu <label> is about to be exported */
+ label = g_strdup_printf( _( "The menu \"%s\" is about to be exported." ), item_label );
+ }
- container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
- nact_export_format_select( container, !editor->private->format_mandatory, editor->private->format );
-
- nact_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
- "AskKeepChoiceButton", G_CALLBACK( keep_choice_on_toggled ),
- editor->private->keep_last_choice,
- !editor->private->keep_last_choice_mandatory, !editor->private->preferences_locked );
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "CancelButton",
- "clicked",
- G_CALLBACK( on_cancel_clicked ));
-
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "OKButton",
- "clicked",
- G_CALLBACK( on_ok_clicked ));
+ widget = base_window_get_widget( BASE_WINDOW( editor ), "ExportAskLabel1" );
+ gtk_label_set_text( GTK_LABEL( widget ), label );
+ g_free( label );
+ g_free( item_label );
+
+ container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
+ nact_export_format_select( container, !editor->private->format_mandatory, editor->private->format );
+
+ nact_gtk_utils_toggle_set_initial_state( BASE_WINDOW( editor ),
+ "AskKeepChoiceButton", G_CALLBACK( keep_choice_on_toggled ),
+ editor->private->keep_last_choice,
+ !editor->private->keep_last_choice_mandatory, !editor->private->preferences_locked );
+
+ base_window_signal_connect_by_name( BASE_WINDOW( editor ),
+ "CancelButton", "clicked", G_CALLBACK( on_cancel_clicked ));
+
+ base_window_signal_connect_by_name( BASE_WINDOW( editor ),
+ "OKButton", "clicked", G_CALLBACK( on_ok_clicked ));
+ }
}
-static void
-on_base_all_widgets_showed( NactExportAsk *editor, gpointer user_data )
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
{
- static const gchar *thisfn = "nact_export_ask_on_all_widgets_showed";
-
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
- g_return_if_fail( NACT_IS_EXPORT_ASK( editor ));
+ return( g_strdup( NA_IPREFS_EXPORT_ASK_USER_WSP ));
}
static void
@@ -456,32 +420,3 @@ get_export_format( NactExportAsk *editor )
return( format_quark );
}
-
-static gboolean
-base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
-{
- static const gchar *thisfn = "nact_export_ask_on_dialog_response";
- NactExportAsk *editor;
-
- g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
- g_assert( NACT_IS_EXPORT_ASK( window ));
- editor = NACT_EXPORT_ASK( window );
-
- switch( code ){
- case GTK_RESPONSE_NONE:
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_CANCEL:
-
- editor->private->format = 0;
- return( TRUE );
- break;
-
- case GTK_RESPONSE_OK:
- editor->private->format = get_export_format( editor );
- return( TRUE );
- break;
- }
-
- return( FALSE );
-}
diff --git a/src/nact/nact-icon-chooser.c b/src/nact/nact-icon-chooser.c
index 99a21e4..54230a3 100644
--- a/src/nact/nact-icon-chooser.c
+++ b/src/nact/nact-icon-chooser.c
@@ -100,19 +100,19 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
-static NactIconChooser *icon_chooser_new( BaseWindow *parent );
-
-static gchar *base_get_iprefs_window_id( const BaseWindow *window );
-static void on_base_initial_load_dialog( NactIconChooser *editor, gpointer user_data );
+static void on_base_initialize_gtk_toplevel( NactIconChooser *editor, GtkDialog *toplevel );
static void do_initialize_themed_icons( NactIconChooser *editor );
static void do_initialize_icons_by_path( NactIconChooser *editor );
-static void on_base_runtime_init_dialog( NactIconChooser *editor, gpointer user_data );
+static void on_base_initialize_base_window( NactIconChooser *editor );
static void fillup_themed_icons( NactIconChooser *editor );
static void fillup_icons_by_path( NactIconChooser *editor );
-static void on_base_all_widgets_showed( NactIconChooser *editor, gpointer user_data );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
+static void on_base_all_widgets_showed( NactIconChooser *editor );
+
static void on_cancel_clicked( GtkButton *button, NactIconChooser *editor );
static void on_ok_clicked( GtkButton *button, NactIconChooser *editor );
-static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
+static void on_dialog_cancel( BaseDialog *dialog );
+
static void on_current_icon_changed( const NactIconChooser *editor );
static gboolean on_destroy( GtkWidget *widget, GdkEvent *event, void *foo );
static gboolean on_icon_view_button_press_event( GtkWidget *widget, GdkEventButton *event, NactIconChooser *editor );
@@ -169,6 +169,7 @@ class_init( NactIconChooserClass *klass )
static const gchar *thisfn = "nact_icon_chooser_class_init";
GObjectClass *object_class;
BaseWindowClass *base_class;
+ BaseDialogClass *dialog_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -181,8 +182,10 @@ class_init( NactIconChooserClass *klass )
klass->private = g_new0( NactIconChooserClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->dialog_response = base_dialog_response;
- base_class->get_iprefs_window_id = base_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
+
+ dialog_class = BASE_DIALOG_CLASS( klass );
+ dialog_class->cancel = on_dialog_cancel;
}
static void
@@ -200,23 +203,14 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NactIconChooserPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( self ),
- G_OBJECT( self ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_base_initial_load_dialog ));
+ base_window_signal_connect( BASE_WINDOW( self ),
+ G_OBJECT( self ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk_toplevel ));
- base_window_signal_connect(
- BASE_WINDOW( self ),
- G_OBJECT( self ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( self ),
+ G_OBJECT( self ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
- base_window_signal_connect(
- BASE_WINDOW( self ),
- G_OBJECT( self ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed));
+ base_window_signal_connect( BASE_WINDOW( self ),
+ G_OBJECT( self ), BASE_SIGNAL_ALL_WIDGETS_SHOWED, G_CALLBACK( on_base_all_widgets_showed));
self->private->dispose_has_run = FALSE;
}
@@ -234,11 +228,10 @@ instance_dispose( GObject *dialog )
g_return_if_fail( NACT_IS_ICON_CHOOSER( dialog ));
- g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
-
self = NACT_ICON_CHOOSER( dialog );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
self->private->dispose_has_run = TRUE;
@@ -265,7 +258,7 @@ instance_finalize( GObject *dialog )
g_return_if_fail( NACT_IS_ICON_CHOOSER( dialog ));
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
self = NACT_ICON_CHOOSER( dialog );
@@ -279,19 +272,6 @@ instance_finalize( GObject *dialog )
}
}
-/*
- * Returns a newly allocated NactIconChooser object.
- */
-static NactIconChooser *
-icon_chooser_new( BaseWindow *parent )
-{
- return( g_object_new( NACT_ICON_CHOOSER_TYPE,
- BASE_PROP_PARENT, parent,
- BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
- BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
-}
-
/**
* nact_icon_chooser_choose_icon:
* @parent: the #BaseWindow parent of this dialog.
@@ -316,13 +296,18 @@ nact_icon_chooser_choose_icon( BaseWindow *parent, const gchar *icon_name )
g_debug( "%s: parent=%p, icon_name=%s", thisfn, ( void * ) parent, icon_name );
- editor = icon_chooser_new( parent );
+ editor = g_object_new( NACT_ICON_CHOOSER_TYPE,
+ BASE_PROP_PARENT, parent,
+ BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
+ BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
+ NULL );
+
editor->private->main_window = parent;
editor->private->initial_icon = icon_name;
new_name = g_strdup( editor->private->initial_icon );
- if( base_window_run( BASE_WINDOW( editor ))){
+ if( base_window_run( BASE_WINDOW( editor )) == GTK_RESPONSE_OK ){
g_free( new_name );
new_name = g_strdup( editor->private->current_icon );
}
@@ -332,31 +317,27 @@ nact_icon_chooser_choose_icon( BaseWindow *parent, const gchar *icon_name )
return( new_name );
}
-static gchar *
-base_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_ICON_CHOOSER_WSP ));
-}
-
static void
-on_base_initial_load_dialog( NactIconChooser *editor, gpointer user_data )
+on_base_initialize_gtk_toplevel( NactIconChooser *editor, GtkDialog *toplevel )
{
- static const gchar *thisfn = "nact_icon_chooser_on_initial_load_dialog";
+ static const gchar *thisfn = "nact_icon_chooser_on_base_initialize_gtk_toplevel";
g_return_if_fail( NACT_IS_ICON_CHOOSER( editor ));
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
-
- /* initialize the notebook
- */
- do_initialize_themed_icons( editor );
- do_initialize_icons_by_path( editor );
-
- /* destroy event
- * there is here that we are going to release our stores
- */
- GtkDialog *dialog = GTK_DIALOG( base_window_get_gtk_toplevel( BASE_WINDOW( editor )));
- g_signal_connect( G_OBJECT( dialog ), "destroy", G_CALLBACK( on_destroy ), NULL );
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p, toplevel=%p", thisfn, ( void * ) editor, ( void * ) toplevel );
+
+ /* initialize the notebook
+ */
+ do_initialize_themed_icons( editor );
+ do_initialize_icons_by_path( editor );
+
+ /* destroy event
+ * this is here that we are going to release our stores
+ */
+ GtkDialog *dialog = GTK_DIALOG( base_window_get_gtk_toplevel( BASE_WINDOW( editor )));
+ g_signal_connect( G_OBJECT( dialog ), "destroy", G_CALLBACK( on_destroy ), NULL );
+ }
}
/*
@@ -431,9 +412,9 @@ do_initialize_icons_by_path( NactIconChooser *editor )
}
static void
-on_base_runtime_init_dialog( NactIconChooser *editor, gpointer user_data )
+on_base_initialize_base_window( NactIconChooser *editor )
{
- static const gchar *thisfn = "nact_icon_chooser_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_icon_chooser_on_base_initialize_base_window";
guint pos;
GtkWidget *paned;
NactApplication *application;
@@ -442,43 +423,43 @@ on_base_runtime_init_dialog( NactIconChooser *editor, gpointer user_data )
g_return_if_fail( NACT_IS_ICON_CHOOSER( editor ));
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
-
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
- updater = nact_application_get_updater( application );
- settings = na_pivot_get_settings( NA_PIVOT( updater ));
-
- pos = na_settings_get_uint( settings, NA_IPREFS_ICON_CHOOSER_PANED, NULL, NULL );
- if( pos ){
- paned = base_window_get_widget( BASE_WINDOW( editor ), "IconPaned" );
- gtk_paned_set_position( GTK_PANED( paned ), pos );
- }
-
- /* setup the initial icon
- */
- editor->private->current_icon = g_strdup( editor->private->initial_icon );
- on_current_icon_changed( editor );
-
- /* fillup the icon stores
- */
- fillup_themed_icons( editor );
- fillup_icons_by_path( editor );
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p", thisfn, ( void * ) editor );
- /* intercept Escape key: we do not quit on Esc.
- */
- base_window_signal_connect(
- BASE_WINDOW( editor ),
- G_OBJECT( base_window_get_gtk_toplevel( BASE_WINDOW( editor ))),
- "key-press-event",
- G_CALLBACK( on_key_pressed_event ));
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+ updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
- /* OK/Cancel buttons
- */
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ), "CancelButton", "clicked", G_CALLBACK( on_cancel_clicked ));
+ pos = na_settings_get_uint( settings, NA_IPREFS_ICON_CHOOSER_PANED, NULL, NULL );
+ if( pos ){
+ paned = base_window_get_widget( BASE_WINDOW( editor ), "IconPaned" );
+ gtk_paned_set_position( GTK_PANED( paned ), pos );
+ }
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ), "OKButton", "clicked", G_CALLBACK( on_ok_clicked ));
+ /* setup the initial icon
+ */
+ editor->private->current_icon = g_strdup( editor->private->initial_icon );
+ on_current_icon_changed( editor );
+
+ /* fillup the icon stores
+ */
+ fillup_themed_icons( editor );
+ fillup_icons_by_path( editor );
+
+ /* intercept Escape key: we do not quit on Esc.
+ */
+ base_window_signal_connect( BASE_WINDOW( editor ),
+ G_OBJECT( base_window_get_gtk_toplevel( BASE_WINDOW( editor ))),
+ "key-press-event", G_CALLBACK( on_key_pressed_event ));
+
+ /* OK/Cancel buttons
+ */
+ base_window_signal_connect_by_name(
+ BASE_WINDOW( editor ), "CancelButton", "clicked", G_CALLBACK( on_cancel_clicked ));
+
+ base_window_signal_connect_by_name(
+ BASE_WINDOW( editor ), "OKButton", "clicked", G_CALLBACK( on_ok_clicked ));
+ }
}
static void
@@ -538,6 +519,7 @@ fillup_icons_by_path( NactIconChooser *editor )
base_window_signal_connect(
BASE_WINDOW( editor ), G_OBJECT( file_chooser ), "selection-changed", G_CALLBACK( on_path_selection_changed ));
+
base_window_signal_connect(
BASE_WINDOW( editor ), G_OBJECT( file_chooser ), "update-preview", G_CALLBACK( on_path_update_preview ));
@@ -545,20 +527,28 @@ fillup_icons_by_path( NactIconChooser *editor )
BASE_WINDOW( editor ), "PathApplyButton", "clicked", G_CALLBACK( on_path_apply_button_clicked ));
}
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_ICON_CHOOSER_WSP ));
+}
+
static void
-on_base_all_widgets_showed( NactIconChooser *editor, gpointer user_data )
+on_base_all_widgets_showed( NactIconChooser *editor )
{
- static const gchar *thisfn = "nact_icon_chooser_on_all_widgets_showed";
+ static const gchar *thisfn = "nact_icon_chooser_on_base_all_widgets_showed";
GtkWidget *about_button;
g_return_if_fail( NACT_IS_ICON_CHOOSER( editor ));
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p", thisfn, ( void * ) editor );
- /* hide about button not used here
- */
- about_button = base_window_get_widget( BASE_WINDOW( editor ), "AboutButton" );
- gtk_widget_hide( about_button );
+ /* hide about button not used here
+ */
+ about_button = base_window_get_widget( BASE_WINDOW( editor ), "AboutButton" );
+ gtk_widget_hide( about_button );
+ }
}
static void
@@ -575,35 +565,22 @@ on_ok_clicked( GtkButton *button, NactIconChooser *editor )
gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_OK );
}
-static gboolean
-base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
+static void
+on_dialog_cancel( BaseDialog *dialog )
{
- static const gchar *thisfn = "nact_icon_chooser_on_dialog_response";
+ static const gchar *thisfn = "nact_icon_chooser_on_dialog_cancel";
NactIconChooser *editor;
- g_return_val_if_fail( NACT_IS_ICON_CHOOSER( window ), FALSE );
-
- g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
-
- editor = NACT_ICON_CHOOSER( window );
+ g_return_if_fail( NACT_IS_ICON_CHOOSER( dialog ));
- switch( code ){
- case GTK_RESPONSE_NONE:
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_CANCEL:
+ editor = NACT_ICON_CHOOSER( dialog );
- g_free( editor->private->current_icon );
- editor->private->current_icon = g_strdup( editor->private->initial_icon );
- return( TRUE );
- break;
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
- case GTK_RESPONSE_OK:
- return( TRUE );
- break;
+ g_free( editor->private->current_icon );
+ editor->private->current_icon = g_strdup( editor->private->initial_icon );
}
-
- return( FALSE );
}
/*
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 49817b6..69e64b1 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -156,7 +156,6 @@ static void iexecution_tab_iface_init( NactIExecutionTabInterface *iface );
static void iproperties_tab_iface_init( NactIPropertiesTabInterface *iface );
static void iabout_iface_init( NAIAboutInterface *iface );
static void ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface );
-static void iprefs_base_iface_init( BaseIPrefsInterface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
@@ -165,11 +164,12 @@ static void instance_finalize( GObject *application );
static gboolean actually_delete_item( NactMainWindow *window, NAObject *item, NAUpdater *updater, GList **not_deleted, GSList **messages );
-static gchar *base_get_iprefs_window_id( const BaseWindow *window );
-static gboolean base_is_willing_to_quit( const BaseWindow *window );
static void on_base_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel );
-static void on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data );
-static void on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data );
+static void on_base_initialize_base_window( NactMainWindow *window );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
+static void on_base_all_widgets_showed( NactMainWindow *window );
+
+static gboolean base_is_willing_to_quit( const BaseWindow *window );
static void on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data );
static void on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
@@ -304,12 +304,6 @@ register_type( void )
NULL
};
- static const GInterfaceInfo iprefs_base_iface_info = {
- ( GInterfaceInitFunc ) iprefs_base_iface_init,
- NULL,
- NULL
- };
-
g_debug( "%s", thisfn );
type = g_type_register_static( NACT_WINDOW_TYPE, "NactMainWindow", &info, 0 );
@@ -340,8 +334,6 @@ register_type( void )
g_type_add_interface_static( type, NA_IPIVOT_CONSUMER_TYPE, &ipivot_consumer_iface_info );
- g_type_add_interface_static( type, BASE_IPREFS_TYPE, &iprefs_base_iface_info );
-
return( type );
}
@@ -395,7 +387,7 @@ class_init( NactMainWindowClass *klass )
base_class = BASE_WINDOW_CLASS( klass );
base_class->initialize_gtk_toplevel = on_base_initialize_gtk_toplevel;
- base_class->get_iprefs_window_id = base_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
base_class->is_willing_to_quit = base_is_willing_to_quit;
/**
@@ -623,14 +615,6 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
}
static void
-iprefs_base_iface_init( BaseIPrefsInterface *iface )
-{
- static const gchar *thisfn = "nact_main_window_iprefs_base_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-}
-
-static void
instance_init( GTypeInstance *instance, gpointer klass )
{
static const gchar *thisfn = "nact_main_window_instance_init";
@@ -645,23 +629,14 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NactMainWindowPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_toplevel ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed ));
-
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- TAB_UPDATABLE_SIGNAL_ITEM_UPDATED,
- G_CALLBACK( on_tab_updatable_item_updated ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
+
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_ALL_WIDGETS_SHOWED, G_CALLBACK( on_base_all_widgets_showed ));
+
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, G_CALLBACK( on_tab_updatable_item_updated ));
self->private->dispose_has_run = FALSE;
@@ -750,11 +725,10 @@ instance_dispose( GObject *window )
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
-
self = NACT_MAIN_WINDOW( window );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
self->private->dispose_has_run = TRUE;
@@ -1093,35 +1067,6 @@ actually_delete_item( NactMainWindow *window, NAObject *item, NAUpdater *updater
return( delete_ok );
}
-static gchar *
-base_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_MAIN_WINDOW_WSP ));
-}
-
-static gboolean
-base_is_willing_to_quit( const BaseWindow *window )
-{
- static const gchar *thisfn = "nact_main_window_is_willing_to_quit";
- gboolean willing_to;
-
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
-
- willing_to = TRUE;
- if( nact_main_window_has_modified_items( NACT_MAIN_WINDOW( window ))){
- willing_to = nact_confirm_logout_run( NACT_MAIN_WINDOW( window ));
- }
-
- /* call parent class */
- if( willing_to ){
- if( BASE_WINDOW_CLASS( st_parent_class )->is_willing_to_quit ){
- willing_to = BASE_WINDOW_CLASS( st_parent_class )->is_willing_to_quit( window );
- }
- }
-
- return( willing_to );
-}
-
/*
* note that for this NactMainWindow, on_initial_load_toplevel and
* on_runtime_init_toplevel are equivalent, as there is only one
@@ -1181,26 +1126,23 @@ on_base_initialize_gtk_toplevel( BaseWindow *window, GtkWindow *toplevel )
}
static void
-on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
+on_base_initialize_base_window( NactMainWindow *window )
{
- static const gchar *thisfn = "nact_main_window_on_base_runtime_init_toplevel";
+ static const gchar *thisfn = "nact_main_window_on_base_initialize_base_window";
NactApplication *application;
NAUpdater *updater;
GList *tree;
gint order_mode;
- g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
if( !window->private->dispose_has_run ){
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
window->private->clipboard = nact_clipboard_new( BASE_WINDOW( window ));
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( window ),
- IACTIONS_LIST_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_iactions_list_selection_changed ));
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( window ), IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_iactions_list_selection_changed ));
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
@@ -1230,26 +1172,25 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
/* this to update the title when an item is modified
*/
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( window ),
- IACTIONS_LIST_SIGNAL_STATUS_CHANGED,
- G_CALLBACK( on_iactions_list_status_changed ));
-
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( window ),
- MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED,
- G_CALLBACK( on_main_window_level_zero_order_changed ));
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( window ), IACTIONS_LIST_SIGNAL_STATUS_CHANGED, G_CALLBACK( on_iactions_list_status_changed ));
+
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( window ), MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED, G_CALLBACK( on_main_window_level_zero_order_changed ));
}
}
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_MAIN_WINDOW_WSP ));
+}
+
static void
-on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
+on_base_all_widgets_showed( NactMainWindow *window )
{
static const gchar *thisfn = "nact_main_window_on_base_all_widgets_showed";
- g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
g_return_if_fail( NACT_IS_IACTIONS_LIST( window ));
g_return_if_fail( NACT_IS_IACTION_TAB( window ));
@@ -1263,6 +1204,7 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
g_return_if_fail( NACT_IS_IPROPERTIES_TAB( window ));
if( !window->private->dispose_has_run ){
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
raz_main_properties( window );
@@ -1284,6 +1226,29 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
}
}
+static gboolean
+base_is_willing_to_quit( const BaseWindow *window )
+{
+ static const gchar *thisfn = "nact_main_window_is_willing_to_quit";
+ gboolean willing_to;
+
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
+
+ willing_to = TRUE;
+ if( nact_main_window_has_modified_items( NACT_MAIN_WINDOW( window ))){
+ willing_to = nact_confirm_logout_run( NACT_MAIN_WINDOW( window ));
+ }
+
+ /* call parent class */
+ if( willing_to ){
+ if( BASE_WINDOW_CLASS( st_parent_class )->is_willing_to_quit ){
+ willing_to = BASE_WINDOW_CLASS( st_parent_class )->is_willing_to_quit( window );
+ }
+ }
+
+ return( willing_to );
+}
+
static void
on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data )
{
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 9eeb9dc..8fba042 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -102,12 +102,10 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *dialog );
static void instance_finalize( GObject *dialog );
-static NactPreferencesEditor *preferences_editor_new( BaseWindow *parent );
-
-static gchar *base_get_iprefs_window_id( const BaseWindow *window );
-static void on_base_initial_load_dialog( NactPreferencesEditor *editor, gpointer user_data );
-static void on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data );
-static void on_base_all_widgets_showed( NactPreferencesEditor *editor, gpointer user_data );
+static void on_base_initialize_gtk_toplevel( NactPreferencesEditor *editor, GtkDialog *toplevel );
+static void on_base_initialize_base_window( NactPreferencesEditor *editor );
+static gchar *on_base_get_wsp_id( const BaseWindow *window );
+static void on_base_all_widgets_showed( NactPreferencesEditor *editor );
static void order_mode_setup( NactPreferencesEditor *editor, NAPivot *pivot );
static void order_mode_on_alpha_asc_toggled( GtkToggleButton *togglebutton, NactPreferencesEditor *editor );
static void order_mode_on_alpha_desc_toggled( GtkToggleButton *togglebutton, NactPreferencesEditor *editor );
@@ -140,7 +138,7 @@ static void on_cancel_clicked( GtkButton *button, NactPreferencesEditor *edi
static void on_ok_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void save_preferences( NactPreferencesEditor *editor );
-static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
+static void on_dialog_ok( BaseDialog *dialog );
GType
nact_preferences_editor_get_type( void )
@@ -185,6 +183,7 @@ class_init( NactPreferencesEditorClass *klass )
static const gchar *thisfn = "nact_preferences_editor_class_init";
GObjectClass *object_class;
BaseWindowClass *base_class;
+ BaseDialogClass *dialog_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -197,8 +196,10 @@ class_init( NactPreferencesEditorClass *klass )
klass->private = g_new0( NactPreferencesEditorClassPrivate, 1 );
base_class = BASE_WINDOW_CLASS( klass );
- base_class->dialog_response = base_dialog_response;
- base_class->get_iprefs_window_id = base_get_iprefs_window_id;
+ base_class->get_wsp_id = on_base_get_wsp_id;
+
+ dialog_class = BASE_DIALOG_CLASS( klass );
+ dialog_class->ok = on_dialog_ok;
}
static void
@@ -207,29 +208,22 @@ instance_init( GTypeInstance *instance, gpointer klass )
static const gchar *thisfn = "nact_preferences_editor_instance_init";
NactPreferencesEditor *self;
- g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( instance ));
+
+ g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
+
self = NACT_PREFERENCES_EDITOR( instance );
self->private = g_new0( NactPreferencesEditorPrivate, 1 );
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_GTK,
- G_CALLBACK( on_base_initial_load_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk_toplevel ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_INITIALIZE_WINDOW,
- G_CALLBACK( on_base_runtime_init_dialog ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- BASE_SIGNAL_ALL_WIDGETS_SHOWED,
- G_CALLBACK( on_base_all_widgets_showed));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), BASE_SIGNAL_ALL_WIDGETS_SHOWED, G_CALLBACK( on_base_all_widgets_showed));
self->private->dispose_has_run = FALSE;
}
@@ -240,11 +234,12 @@ instance_dispose( GObject *dialog )
static const gchar *thisfn = "nact_preferences_editor_instance_dispose";
NactPreferencesEditor *self;
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( dialog ));
+
self = NACT_PREFERENCES_EDITOR( dialog );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
self->private->dispose_has_run = TRUE;
@@ -264,8 +259,10 @@ instance_finalize( GObject *dialog )
static const gchar *thisfn = "nact_preferences_editor_instance_finalize";
NactPreferencesEditor *self;
- g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( dialog ));
+
+ g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
+
self = NACT_PREFERENCES_EDITOR( dialog );
g_free( self->private );
@@ -276,30 +273,33 @@ instance_finalize( GObject *dialog )
}
}
-/*
- * Returns a newly allocated NactPreferencesEditor object.
+/**
+ * nact_preferences_editor_run:
+ * @parent: the BaseWindow parent of this dialog
+ * (usually the NactMainWindow).
*
- * @parent: the BaseWindow parent of this dialog (usually, the main
- * toplevel window of the application).
+ * Initializes and runs the dialog.
*/
-static NactPreferencesEditor *
-preferences_editor_new( BaseWindow *parent )
+void
+nact_preferences_editor_run( BaseWindow *parent )
{
- static const gchar *thisfn = "nact_preferences_editor_new";
+ static const gchar *thisfn = "nact_preferences_editor_run";
NactPreferencesEditor *editor;
NactApplication *application;
NAUpdater *updater;
NASettings *settings;
gboolean are_locked, mandatory;
+ GtkNotebook *notebook;
+
+ g_return_if_fail( BASE_IS_WINDOW( parent ));
g_debug( "%s: parent=%p (%s)", thisfn, ( void * ) parent, G_OBJECT_TYPE_NAME( parent ));
- editor = NACT_PREFERENCES_EDITOR(
- g_object_new( NACT_PREFERENCES_EDITOR_TYPE,
+ editor = g_object_new( NACT_PREFERENCES_EDITOR_TYPE,
BASE_PROP_PARENT, parent,
BASE_PROP_XMLUI_FILENAME, st_xmlui_filename,
BASE_PROP_TOPLEVEL_NAME, st_toplevel_name,
- NULL ));
+ NULL );
application = NACT_APPLICATION( base_window_get_application( parent ));
updater = nact_application_get_updater( application );
@@ -310,40 +310,18 @@ preferences_editor_new( BaseWindow *parent )
g_debug( "%s: are_locked=%s, mandatory=%s",
thisfn, are_locked ? "True":"False", mandatory ? "True":"False" );
- return( editor );
-}
-
-/**
- * nact_preferences_editor_run:
- * @parent: the BaseWindow parent of this dialog
- * (usually the NactMainWindow).
- *
- * Initializes and runs the dialog.
- */
-void
-nact_preferences_editor_run( BaseWindow *parent )
-{
- static const gchar *thisfn = "nact_preferences_editor_run";
- NactPreferencesEditor *editor;
-
- g_debug( "%s: parent=%p", thisfn, ( void * ) parent );
- g_return_if_fail( BASE_IS_WINDOW( parent ));
-
- editor = preferences_editor_new( parent );
-
base_window_run( BASE_WINDOW( editor ));
-}
-static gchar *
-base_get_iprefs_window_id( const BaseWindow *window )
-{
- return( g_strdup( NA_IPREFS_PREFERENCES_WSP ));
+ notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( editor ), "PreferencesNotebook" ));
+ st_last_tab = gtk_notebook_get_current_page( notebook );
+
+ g_object_unref( editor );
}
static void
-on_base_initial_load_dialog( NactPreferencesEditor *editor, gpointer user_data )
+on_base_initialize_gtk_toplevel( NactPreferencesEditor *editor, GtkDialog *toplevel )
{
- static const gchar *thisfn = "nact_preferences_editor_on_initial_load_dialog";
+ static const gchar *thisfn = "nact_preferences_editor_on_base_initialize_gtk_toplevel";
NactApplication *application;
NAUpdater *updater;
GtkWidget *container;
@@ -351,27 +329,29 @@ on_base_initial_load_dialog( NactPreferencesEditor *editor, gpointer user_data )
g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( editor ));
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p, toplevel=%p", thisfn, ( void * ) editor, ( void * ) toplevel );
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
- updater = nact_application_get_updater( application );
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+ updater = nact_application_get_updater( application );
- container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
- nact_export_format_init_display(
- container, NA_PIVOT( updater ),
- EXPORT_FORMAT_DISPLAY_PREFERENCES, !editor->private->preferences_locked );
+ container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
+ nact_export_format_init_display(
+ container, NA_PIVOT( updater ),
+ EXPORT_FORMAT_DISPLAY_PREFERENCES, !editor->private->preferences_locked );
- listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "SchemesTreeView" ));
- nact_schemes_list_create_model( listview, SCHEMES_LIST_FOR_PREFERENCES );
+ listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "SchemesTreeView" ));
+ nact_schemes_list_create_model( listview, SCHEMES_LIST_FOR_PREFERENCES );
- listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
- nact_providers_list_create_model( listview );
+ listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
+ nact_providers_list_create_model( listview );
+ }
}
static void
-on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
+on_base_initialize_base_window( NactPreferencesEditor *editor )
{
- static const gchar *thisfn = "nact_preferences_editor_on_runtime_init_dialog";
+ static const gchar *thisfn = "nact_preferences_editor_on_base_initialize_base_window";
NactApplication *application;
NAUpdater *updater;
NASettings *settings;
@@ -380,75 +360,84 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
GtkTreeView *listview;
GtkWidget *ok_button;
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
+ g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( editor ));
+
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p", thisfn, ( void * ) editor );
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
- updater = nact_application_get_updater( application );
- settings = na_pivot_get_settings( NA_PIVOT( updater ));
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+ updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ /* first tab: runtime preferences
+ */
+ order_mode_setup( editor, NA_PIVOT( updater ));
+ root_menu_setup( editor, settings );
+ about_item_setup( editor, settings );
+
+ /* second tab: ui preferences
+ */
+ relabel_menu_setup( editor, settings );
+ relabel_action_setup( editor, settings );
+ relabel_profile_setup( editor, settings );
+ esc_quit_setup( editor, settings );
+ esc_confirm_setup( editor, settings );
+ auto_save_setup( editor, settings );
+
+ /* third tab: import mode
+ */
+ import_mode_setup( editor, NA_PIVOT( updater ));
+
+ /* fourth tab: export format
+ */
+ export_format = na_iprefs_get_export_format( NA_PIVOT( updater ), NA_IPREFS_EXPORT_PREFERRED_FORMAT, &editor->private->export_format_mandatory );
+ container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
+ nact_export_format_select( container, !editor->private->export_format_mandatory, export_format );
+
+ /* fifth tab: default schemes
+ */
+ listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "SchemesTreeView" ));
+ nact_schemes_list_init_view( listview, BASE_WINDOW( editor ), NULL, NULL );
+
+ /* sixth tab: I/O providers priorities
+ */
+ listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
+ nact_providers_list_init_view( BASE_WINDOW( editor ), listview );
+
+ /* dialog buttons
+ */
+ base_window_signal_connect_by_name( BASE_WINDOW( editor ),
+ "CancelButton", "clicked", G_CALLBACK( on_cancel_clicked ));
+
+ ok_button = base_window_get_widget( BASE_WINDOW( editor ), "OKButton" );
+ base_window_signal_connect( BASE_WINDOW( editor ),
+ G_OBJECT( ok_button ), "clicked", G_CALLBACK( on_ok_clicked ));
+ nact_gtk_utils_set_editable( G_OBJECT( ok_button ), !editor->private->preferences_locked );
+ }
+}
- /* first tab: runtime preferences
- */
- order_mode_setup( editor, NA_PIVOT( updater ));
- root_menu_setup( editor, settings );
- about_item_setup( editor, settings );
-
- /* second tab: ui preferences
- */
- relabel_menu_setup( editor, settings );
- relabel_action_setup( editor, settings );
- relabel_profile_setup( editor, settings );
- esc_quit_setup( editor, settings );
- esc_confirm_setup( editor, settings );
- auto_save_setup( editor, settings );
-
- /* third tab: import mode
- */
- import_mode_setup( editor, NA_PIVOT( updater ));
-
- /* fourth tab: export format
- */
- export_format = na_iprefs_get_export_format( NA_PIVOT( updater ), NA_IPREFS_EXPORT_PREFERRED_FORMAT, &editor->private->export_format_mandatory );
- container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
- nact_export_format_select( container, !editor->private->export_format_mandatory, export_format );
-
- /* fifth tab: default schemes
- */
- listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "SchemesTreeView" ));
- nact_schemes_list_init_view( listview, BASE_WINDOW( editor ), NULL, NULL );
-
- /* sixth tab: I/O providers priorities
- */
- listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
- nact_providers_list_init_view( BASE_WINDOW( editor ), listview );
-
- /* dialog buttons
- */
- base_window_signal_connect_by_name(
- BASE_WINDOW( editor ),
- "CancelButton",
- "clicked",
- G_CALLBACK( on_cancel_clicked ));
-
- ok_button = base_window_get_widget( BASE_WINDOW( editor ), "OKButton" );
- base_window_signal_connect(
- BASE_WINDOW( editor ),
- G_OBJECT( ok_button ),
- "clicked",
- G_CALLBACK( on_ok_clicked ));
- nact_gtk_utils_set_editable( G_OBJECT( ok_button ), !editor->private->preferences_locked );
+static gchar *
+on_base_get_wsp_id( const BaseWindow *window )
+{
+ return( g_strdup( NA_IPREFS_PREFERENCES_WSP ));
}
static void
-on_base_all_widgets_showed( NactPreferencesEditor *editor, gpointer user_data )
+on_base_all_widgets_showed( NactPreferencesEditor *editor )
{
static const gchar *thisfn = "nact_preferences_editor_on_all_widgets_showed";
GtkNotebook *notebook;
- g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
- notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( editor ), "PreferencesNotebook" ));
- gtk_notebook_set_current_page( notebook, st_last_tab );
+ g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( editor ));
+
+ if( !editor->private->dispose_has_run ){
+ g_debug( "%s: editor=%p", thisfn, ( void * ) editor );
- nact_schemes_list_show_all( BASE_WINDOW( editor ));
+ notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( editor ), "PreferencesNotebook" ));
+ gtk_notebook_set_current_page( notebook, st_last_tab );
+
+ nact_schemes_list_show_all( BASE_WINDOW( editor ));
+ }
}
/*
@@ -1007,42 +996,10 @@ save_preferences( NactPreferencesEditor *editor )
}
}
-static gboolean
-base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
+static void
+on_dialog_ok( BaseDialog *dialog )
{
- static const gchar *thisfn = "nact_preferences_editor_on_dialog_response";
- NactPreferencesEditor *editor;
- gboolean stop;
- GtkNotebook *notebook;
-
- g_return_val_if_fail( NACT_IS_PREFERENCES_EDITOR( window ), FALSE );
-
- g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
-
- stop = FALSE;
- editor = NACT_PREFERENCES_EDITOR( window );
-
- switch( code ){
- case GTK_RESPONSE_NONE:
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_CANCEL:
-
- stop = TRUE;
- break;
-
- case GTK_RESPONSE_OK:
- save_preferences( editor );
- stop = TRUE;
- break;
- }
-
- if( stop ){
- notebook = GTK_NOTEBOOK( base_window_get_widget( window, "PreferencesNotebook" ));
- st_last_tab = gtk_notebook_get_current_page( notebook );
- g_object_unref( editor );
- }
-
+ g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( dialog ));
- return( stop );
+ save_preferences( NACT_PREFERENCES_EDITOR( dialog ));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]