[nautilus-actions] Review code, usage of g_assert, test dispose_has_run
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Review code, usage of g_assert, test dispose_has_run
- Date: Sat, 26 Sep 2009 22:49:36 +0000 (UTC)
commit eb3ff0e58bc00a7d49972f2068f9977a94f9de0f
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Sep 24 19:48:52 2009 +0200
Review code, usage of g_assert, test dispose_has_run
ChangeLog | 43 +++
src/nact/base-application-class.h | 2 +-
src/nact/base-application.c | 268 +++++++++++--------
src/nact/base-application.h | 8 +-
src/nact/base-assistant.c | 191 ++++++++------
src/nact/base-dialog.c | 9 +-
src/nact/base-iprefs.c | 211 +++++++++++----
src/nact/base-window-class.h | 6 +-
src/nact/base-window.c | 522 ++++++++++++++++++++++++------------
src/nact/base-window.h | 6 +-
src/nact/nact-application.c | 52 +++--
src/nact/nact-application.h | 8 +-
src/nact/nact-assistant-export.c | 6 +-
src/nact/nact-assistant-export.h | 6 +-
src/nact/nact-assistant-import.c | 9 +-
src/nact/nact-assistant-import.h | 6 +-
src/nact/nact-iaction-tab.c | 256 ++++++++++--------
src/nact/nact-iactions-list.c | 496 ++++++++++++++++++++---------------
src/nact/nact-iactions-list.h | 6 +
src/nact/nact-iadvanced-tab.c | 281 +++++++++++---------
src/nact/nact-iadvanced-tab.h | 6 +-
src/nact/nact-icommand-tab.c | 199 ++++++++------
src/nact/nact-icommand-tab.h | 9 +-
src/nact/nact-iconditions-tab.c | 259 ++++++++++--------
src/nact/nact-iconditions-tab.h | 8 +-
src/nact/nact-main-menubar.h | 6 +-
src/nact/nact-main-statusbar.c | 2 +-
src/nact/nact-main-statusbar.h | 6 +-
src/nact/nact-main-tab.h | 8 +
src/nact/nact-main-window.c | 207 ++++++++-------
src/nact/nact-main-window.h | 6 +-
src/nact/nact-preferences-editor.c | 19 +-
src/nact/nact-preferences-editor.h | 6 +-
src/nact/nact-tree-model.c | 224 +++++++++-------
src/nact/nact-tree-model.h | 2 +
src/nact/nact-window.c | 130 ++++++----
src/nact/nact-window.h | 6 +-
src/nact/nact-xml-reader.h | 6 +-
src/plugin/nautilus-actions.c | 96 ++++----
src/plugin/nautilus-actions.h | 6 +-
40 files changed, 2167 insertions(+), 1436 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3c89faf..970e402 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2009-09-24 Pierre Wieser <pwieser trychlos org>
+
+ * src/nact/base-application-class.h:
+ * src/nact/base-application.c:
+ * src/nact/base-application.h:
+ * src/nact/base-assistant.c:
+ * src/nact/base-dialog.c:
+ * src/nact/base-iprefs.c:
+ * src/nact/base-window-class.h:
+ * src/nact/base-window.c:
+ * src/nact/base-window.h:
+ * src/nact/nact-application.c:
+ * src/nact/nact-application.h:
+ * src/nact/nact-assistant-export.c:
+ * src/nact/nact-assistant-export.h:
+ * src/nact/nact-assistant-import.c:
+ * src/nact/nact-assistant-import.h:
+ * src/nact/nact-iaction-tab.c:
+ * src/nact/nact-iactions-list.c:
+ * src/nact/nact-iactions-list.h:
+ * src/nact/nact-iadvanced-tab.c:
+ * src/nact/nact-iadvanced-tab.h:
+ * src/nact/nact-icommand-tab.c:
+ * src/nact/nact-icommand-tab.h:
+ * src/nact/nact-iconditions-tab.c:
+ * src/nact/nact-iconditions-tab.h:
+ * src/nact/nact-main-menubar.h:
+ * src/nact/nact-main-statusbar.c:
+ * src/nact/nact-main-statusbar.h:
+ * src/nact/nact-main-tab.h:
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-main-window.h:
+ * src/nact/nact-preferences-editor.c:
+ * src/nact/nact-preferences-editor.h:
+ * src/nact/nact-tree-model.c:
+ * src/nact/nact-tree-model.h:
+ * src/nact/nact-window.c:
+ * src/nact/nact-window.h:
+ * src/nact/nact-xml-reader.h:
+ * src/plugin/nautilus-actions.c:
+ * src/plugin/nautilus-actions.h:
+ Review code, usage of g_assert, test dispose_has_run.
+
2009-09-23 Pierre Wieser <pwieser trychlos org>
* data/nautilus-actions.schemas.in: Migrate misnamed keys.
diff --git a/src/nact/base-application-class.h b/src/nact/base-application-class.h
index 161b5ce..73069c2 100644
--- a/src/nact/base-application-class.h
+++ b/src/nact/base-application-class.h
@@ -34,7 +34,7 @@
/**
* SECTION: base_application
* @short_description: #BaseApplication class definition.
- * @include: nact/base-application.h
+ * @include: nact/base-application-class.h
*
* This is a pure virtual base class for Gtk+ programs.
*/
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index aa071b1..8b07a2b 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -282,46 +282,49 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_return_if_fail( BASE_IS_APPLICATION( object ));
self = BASE_APPLICATION( object );
- switch( property_id ){
- case BASE_APPLICATION_PROP_ARGC_ID:
- g_value_set_int( value, self->private->argc );
- break;
+ if( !self->private->dispose_has_run ){
- case BASE_APPLICATION_PROP_ARGV_ID:
- g_value_set_pointer( value, self->private->argv );
- break;
+ switch( property_id ){
+ case BASE_APPLICATION_PROP_ARGC_ID:
+ g_value_set_int( value, self->private->argc );
+ break;
- case BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID:
- g_value_set_boolean( value, self->private->is_gtk_initialized );
- break;
+ case BASE_APPLICATION_PROP_ARGV_ID:
+ g_value_set_pointer( value, self->private->argv );
+ break;
- case BASE_APPLICATION_PROP_UNIQUE_APP_HANDLE_ID:
- g_value_set_pointer( value, self->private->unique_app_handle );
- break;
+ case BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID:
+ g_value_set_boolean( value, self->private->is_gtk_initialized );
+ break;
- case BASE_APPLICATION_PROP_EXIT_CODE_ID:
- g_value_set_int( value, self->private->exit_code );
- break;
+ case BASE_APPLICATION_PROP_UNIQUE_APP_HANDLE_ID:
+ g_value_set_pointer( value, self->private->unique_app_handle );
+ break;
- case BASE_APPLICATION_PROP_EXIT_MESSAGE1_ID:
- g_value_set_string( value, self->private->exit_message1 );
- break;
+ case BASE_APPLICATION_PROP_EXIT_CODE_ID:
+ g_value_set_int( value, self->private->exit_code );
+ break;
- case BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID:
- g_value_set_string( value, self->private->exit_message2 );
- break;
+ case BASE_APPLICATION_PROP_EXIT_MESSAGE1_ID:
+ g_value_set_string( value, self->private->exit_message1 );
+ break;
- case BASE_APPLICATION_PROP_UI_XML_ID:
- g_value_set_pointer( value, self->private->ui_xml );
- break;
+ case BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID:
+ g_value_set_string( value, self->private->exit_message2 );
+ break;
- case BASE_APPLICATION_PROP_MAIN_WINDOW_ID:
- g_value_set_pointer( value, self->private->main_window );
- break;
+ case BASE_APPLICATION_PROP_UI_XML_ID:
+ g_value_set_pointer( value, self->private->ui_xml );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ case BASE_APPLICATION_PROP_MAIN_WINDOW_ID:
+ g_value_set_pointer( value, self->private->main_window );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -333,48 +336,51 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
g_return_if_fail( BASE_IS_APPLICATION( object ));
self = BASE_APPLICATION( object );
- switch( property_id ){
- case BASE_APPLICATION_PROP_ARGC_ID:
- self->private->argc = g_value_get_int( value );
- break;
+ if( !self->private->dispose_has_run ){
- case BASE_APPLICATION_PROP_ARGV_ID:
- self->private->argv = g_value_get_pointer( value );
- break;
+ switch( property_id ){
+ case BASE_APPLICATION_PROP_ARGC_ID:
+ self->private->argc = g_value_get_int( value );
+ break;
- case BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID:
- self->private->is_gtk_initialized = g_value_get_boolean( value );
- break;
+ case BASE_APPLICATION_PROP_ARGV_ID:
+ self->private->argv = g_value_get_pointer( value );
+ break;
- case BASE_APPLICATION_PROP_UNIQUE_APP_HANDLE_ID:
- self->private->unique_app_handle = g_value_get_pointer( value );
- break;
+ case BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID:
+ self->private->is_gtk_initialized = g_value_get_boolean( value );
+ break;
- case BASE_APPLICATION_PROP_EXIT_CODE_ID:
- self->private->exit_code = g_value_get_int( value );
- break;
+ case BASE_APPLICATION_PROP_UNIQUE_APP_HANDLE_ID:
+ self->private->unique_app_handle = g_value_get_pointer( value );
+ break;
- case BASE_APPLICATION_PROP_EXIT_MESSAGE1_ID:
- g_free( self->private->exit_message1 );
- self->private->exit_message1 = g_value_dup_string( value );
- break;
+ case BASE_APPLICATION_PROP_EXIT_CODE_ID:
+ self->private->exit_code = g_value_get_int( value );
+ break;
- case BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID:
- g_free( self->private->exit_message2 );
- self->private->exit_message2 = g_value_dup_string( value );
- break;
+ case BASE_APPLICATION_PROP_EXIT_MESSAGE1_ID:
+ g_free( self->private->exit_message1 );
+ self->private->exit_message1 = g_value_dup_string( value );
+ break;
- case BASE_APPLICATION_PROP_UI_XML_ID:
- self->private->ui_xml = g_value_get_pointer( value );
- break;
+ case BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID:
+ g_free( self->private->exit_message2 );
+ self->private->exit_message2 = g_value_dup_string( value );
+ break;
- case BASE_APPLICATION_PROP_MAIN_WINDOW_ID:
- self->private->main_window = g_value_get_pointer( value );
- break;
+ case BASE_APPLICATION_PROP_UI_XML_ID:
+ self->private->ui_xml = g_value_get_pointer( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ case BASE_APPLICATION_PROP_MAIN_WINDOW_ID:
+ self->private->main_window = g_value_get_pointer( value );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -415,7 +421,7 @@ instance_finalize( GObject *application )
g_debug( "%s: application=%p", thisfn, ( void * ) application );
g_return_if_fail( BASE_IS_APPLICATION( application ));
- self = ( BaseApplication * ) application;
+ self = BASE_APPLICATION( application );
g_free( self->private->exit_message1 );
g_free( self->private->exit_message2 );
@@ -447,12 +453,17 @@ int
base_application_run( BaseApplication *application )
{
static const gchar *thisfn = "base_application_run";
+ int code = -1;
g_debug( "%s: application=%p", thisfn, ( void * ) application );
g_return_val_if_fail( BASE_IS_APPLICATION( application ), -1 );
- return( BASE_APPLICATION_GET_CLASS( application )->run( application ));
+ if( !application->private->dispose_has_run ){
+ code = BASE_APPLICATION_GET_CLASS( application )->run( application );
+ }
+
+ return( code );
}
/**
@@ -471,16 +482,17 @@ base_application_get_application_name( BaseApplication *application )
{
/*static const gchar *thisfn = "base_application_get_application_name";
g_debug( "%s: application=%p", thisfn, application );*/
-
gchar *name = NULL;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- if( BASE_APPLICATION_GET_CLASS( application )->get_application_name ){
- name = BASE_APPLICATION_GET_CLASS( application )->get_application_name( application );
+ if( !application->private->dispose_has_run ){
+ if( BASE_APPLICATION_GET_CLASS( application )->get_application_name ){
+ name = BASE_APPLICATION_GET_CLASS( application )->get_application_name( application );
- } else {
- name = g_strdup( "" );
+ } else {
+ name = g_strdup( "" );
+ }
}
return( name );
@@ -501,16 +513,17 @@ base_application_get_icon_name( BaseApplication *application )
{
/*static const gchar *thisfn = "base_application_get_icon_name";
g_debug( "%s: icon=%p", thisfn, application );*/
-
gchar *name = NULL;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- if( BASE_APPLICATION_GET_CLASS( application )->get_icon_name ){
- name = BASE_APPLICATION_GET_CLASS( application )->get_icon_name( application );
+ if( !application->private->dispose_has_run ){
+ if( BASE_APPLICATION_GET_CLASS( application )->get_icon_name ){
+ name = BASE_APPLICATION_GET_CLASS( application )->get_icon_name( application );
- } else {
- name = g_strdup( "" );
+ } else {
+ name = g_strdup( "" );
+ }
}
return( name );
@@ -531,16 +544,17 @@ base_application_get_unique_app_name( BaseApplication *application )
{
/*static const gchar *thisfn = "base_application_get_unique_app_name";
g_debug( "%s: icon=%p", thisfn, application );*/
-
gchar *name = NULL;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- if( BASE_APPLICATION_GET_CLASS( application )->get_unique_app_name ){
- name = BASE_APPLICATION_GET_CLASS( application )->get_unique_app_name( application );
+ if( !application->private->dispose_has_run ){
+ if( BASE_APPLICATION_GET_CLASS( application )->get_unique_app_name ){
+ name = BASE_APPLICATION_GET_CLASS( application )->get_unique_app_name( application );
- } else {
- name = g_strdup( "" );
+ } else {
+ name = g_strdup( "" );
+ }
}
return( name );
@@ -562,16 +576,17 @@ base_application_get_ui_filename( BaseApplication *application )
{
/*static const gchar *thisfn = "base_application_get_ui_filename";
g_debug( "%s: icon=%p", thisfn, application );*/
-
gchar *name = NULL;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- if( BASE_APPLICATION_GET_CLASS( application )->get_ui_filename ){
- name = BASE_APPLICATION_GET_CLASS( application )->get_ui_filename( application );
+ if( !application->private->dispose_has_run ){
+ if( BASE_APPLICATION_GET_CLASS( application )->get_ui_filename ){
+ name = BASE_APPLICATION_GET_CLASS( application )->get_ui_filename( application );
- } else {
- name = g_strdup( "" );
+ } else {
+ name = g_strdup( "" );
+ }
}
return( name );
@@ -599,9 +614,11 @@ base_application_get_main_window( BaseApplication *application )
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
- if( !application->private->main_window &&
- BASE_APPLICATION_GET_CLASS( application )->get_main_window ){
- application->private->main_window = BASE_WINDOW( BASE_APPLICATION_GET_CLASS( application )->get_main_window( application ));
+ if( !application->private->dispose_has_run ){
+ if( !application->private->main_window &&
+ BASE_APPLICATION_GET_CLASS( application )->get_main_window ){
+ application->private->main_window = BASE_WINDOW( BASE_APPLICATION_GET_CLASS( application )->get_main_window( application ));
+ }
}
return( application->private->main_window );
@@ -624,19 +641,22 @@ base_application_get_toplevel( BaseApplication *application, const gchar *name )
{
/*static const gchar *thisfn = "base_application_get_dialog";
g_debug( "%s: application=%p, name=%s", thisfn, application, name );*/
- GtkWindow *toplevel;
+ GtkWindow *toplevel = NULL;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
g_return_val_if_fail( name, NULL );
g_return_val_if_fail( strlen( name ), NULL );
- toplevel = GTK_WINDOW( gtk_builder_get_object( application->private->ui_xml, name ));
+ if( !application->private->dispose_has_run ){
- if( !toplevel ){
- set_get_toplevel_error( application, name );
+ toplevel = GTK_WINDOW( gtk_builder_get_object( application->private->ui_xml, name ));
- } else {
- g_assert( GTK_IS_WINDOW( toplevel ));
+ if( !toplevel ){
+ set_get_toplevel_error( application, name );
+
+ } else {
+ g_assert( GTK_IS_WINDOW( toplevel ));
+ }
}
return( toplevel );
@@ -661,15 +681,20 @@ base_application_get_widget( BaseApplication *application, BaseWindow *window, c
/*static const gchar *thisfn = "base_application_get_widget";
g_debug( "%s: application=%p, name=%s", thisfn, application, name );*/
GtkWindow *toplevel;
+ GtkWidget *widget = NULL;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
g_return_val_if_fail( name, NULL );
g_return_val_if_fail( strlen( name ), NULL );
- toplevel = base_window_get_toplevel_window( window );
+ if( !application->private->dispose_has_run ){
+
+ toplevel = base_window_get_toplevel_window( window );
+ widget = base_application_search_for_widget( application, toplevel, name );
+ }
- return( base_application_search_for_widget( application, toplevel, name ));
+ return( widget );
}
/**
@@ -689,11 +714,15 @@ base_application_search_for_widget( BaseApplication *application, GtkWindow *win
{
/*static const gchar *thisfn = "base_application_get_widget";
g_debug( "%s: application=%p, name=%s", thisfn, application, name );*/
+ GtkWidget *widget = NULL;
- GtkWidget *widget = recursive_search_for_child( application, window, name );
+ if( !application->private->dispose_has_run ){
- if( widget ){
- g_assert( GTK_IS_WIDGET( widget ));
+ widget = recursive_search_for_child( application, window, name );
+
+ if( widget ){
+ g_assert( GTK_IS_WIDGET( widget ));
+ }
}
return( widget );
@@ -709,10 +738,14 @@ base_application_search_for_widget( BaseApplication *application, GtkWindow *win
* Displays an error dialog with only an OK button.
*/
void
-base_application_error_dlg(
- BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second )
+base_application_error_dlg( BaseApplication *application,
+ GtkMessageType type,
+ const gchar *first,
+ const gchar *second )
{
- display_dlg( application, type, GTK_BUTTONS_OK, first, second );
+ if( !application->private->dispose_has_run ){
+ display_dlg( application, type, GTK_BUTTONS_OK, first, second );
+ }
}
/**
@@ -730,9 +763,16 @@ base_application_error_dlg(
gboolean
base_application_yesno_dlg( BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second )
{
- gint result = display_dlg( application, type, GTK_BUTTONS_YES_NO, first, second );
+ gboolean ret = FALSE;
+ gint result;
- return( result == GTK_RESPONSE_YES );
+ if( !application->private->dispose_has_run ){
+
+ result = display_dlg( application, type, GTK_BUTTONS_YES_NO, first, second );
+ ret = ( result == GTK_RESPONSE_YES );
+ }
+
+ return( ret );
}
static gboolean
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index dafcdba..dae5b1e 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -31,10 +31,10 @@
#ifndef __BASE_APPLICATION_H__
#define __BASE_APPLICATION_H__
-/*
- * BaseApplication class definition.
- *
- * This is a base class for Gtk+ programs.
+/**
+ * SECTION: base_application
+ * @short_description: #BaseApplication public function declarations.
+ * @include: nact/base-application.h
*/
#include <gtk/gtk.h>
diff --git a/src/nact/base-assistant.c b/src/nact/base-assistant.c
index 4417226..a5ded4d 100644
--- a/src/nact/base-assistant.c
+++ b/src/nact/base-assistant.c
@@ -190,7 +190,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
- g_assert( BASE_IS_ASSISTANT( instance ));
+ g_return_if_fail( BASE_IS_ASSISTANT( instance ));
self = BASE_ASSISTANT( instance );
self->private = g_new0( BaseAssistantPrivate, 1 );
@@ -220,25 +220,28 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
{
BaseAssistant *self;
- g_assert( BASE_IS_ASSISTANT( object ));
+ g_return_if_fail( BASE_IS_ASSISTANT( object ));
self = BASE_ASSISTANT( object );
- switch( property_id ){
- case BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID:
- g_value_set_boolean( value, self->private->cancel_on_escape );
- break;
+ if( !self->private->dispose_has_run ){
- case BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID:
- g_value_set_boolean( value, self->private->warn_on_escape );
- break;
+ switch( property_id ){
+ case BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID:
+ g_value_set_boolean( value, self->private->cancel_on_escape );
+ break;
- case BASE_ASSISTANT_PROP_WARN_ON_CANCEL_ID:
- g_value_set_boolean( value, self->private->warn_on_cancel );
- break;
+ case BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID:
+ g_value_set_boolean( value, self->private->warn_on_escape );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- 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;
+ }
}
}
@@ -250,22 +253,25 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
g_assert( BASE_IS_ASSISTANT( object ));
self = BASE_ASSISTANT( object );
- switch( property_id ){
- case BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID:
- self->private->cancel_on_escape = g_value_get_boolean( value );
- break;
+ if( !self->private->dispose_has_run ){
- case BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID:
- self->private->warn_on_escape = g_value_get_boolean( value );
- break;
+ switch( property_id ){
+ case BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE_ID:
+ self->private->cancel_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;
+ case BASE_ASSISTANT_PROP_WARN_ON_ESCAPE_ID:
+ self->private->warn_on_escape = g_value_get_boolean( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- 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;
+ }
}
}
@@ -276,7 +282,7 @@ instance_dispose( GObject *window )
BaseAssistant *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
self = BASE_ASSISTANT( window );
if( !self->private->dispose_has_run ){
@@ -299,7 +305,7 @@ instance_finalize( GObject *window )
BaseAssistant *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
self = BASE_ASSISTANT( window );
g_free( self->private );
@@ -324,14 +330,13 @@ base_get_window( BaseWindow *window, const gchar *name )
gchar *fname;
GtkWindow *dialog;
+ g_return_val_if_fail( BASE_IS_ASSISTANT( window ), NULL );
+
BASE_ASSISTANT( window )->private->builder = gtk_builder_new();
appli = base_window_get_application( window );
-
fname = base_application_get_ui_filename( appli );
-
gtk_builder_add_from_file( BASE_ASSISTANT( window )->private->builder, fname, NULL );
-
g_free( fname );
dialog = GTK_WINDOW( gtk_builder_get_object( BASE_ASSISTANT( window )->private->builder, name ));
@@ -349,7 +354,7 @@ base_get_window( BaseWindow *window, const gchar *name )
void
base_assistant_set_cancel_on_esc( BaseAssistant *window, gboolean cancel )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
g_object_set( G_OBJECT( window ), BASE_ASSISTANT_PROP_CANCEL_ON_ESCAPE, cancel, NULL );
}
@@ -365,7 +370,7 @@ base_assistant_set_cancel_on_esc( BaseAssistant *window, gboolean cancel )
void
base_assistant_set_warn_on_esc( BaseAssistant *window, gboolean warn )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
g_object_set( G_OBJECT( window ), BASE_ASSISTANT_PROP_WARN_ON_ESCAPE, warn, NULL );
}
@@ -380,7 +385,7 @@ base_assistant_set_warn_on_esc( BaseAssistant *window, gboolean warn )
void
base_assistant_set_warn_on_cancel( BaseAssistant *window, gboolean warn )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
g_object_set( G_OBJECT( window ), BASE_ASSISTANT_PROP_WARN_ON_CANCEL, warn, NULL );
}
@@ -388,7 +393,7 @@ base_assistant_set_warn_on_cancel( BaseAssistant *window, gboolean warn )
static void
v_assistant_apply( GtkAssistant *assistant, BaseAssistant *window )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
if( BASE_ASSISTANT_GET_CLASS( window )->apply ){
BASE_ASSISTANT_GET_CLASS( window )->apply( window, assistant );
@@ -403,7 +408,7 @@ v_assistant_apply( GtkAssistant *assistant, BaseAssistant *window )
static void
v_assistant_cancel( GtkAssistant *assistant, BaseAssistant *window )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
if( BASE_ASSISTANT_GET_CLASS( window )->cancel ){
BASE_ASSISTANT_GET_CLASS( window )->cancel( window, assistant );
@@ -416,7 +421,7 @@ v_assistant_cancel( GtkAssistant *assistant, BaseAssistant *window )
static void
v_assistant_close( GtkAssistant *assistant, BaseAssistant *window )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
if( BASE_ASSISTANT_GET_CLASS( window )->close ){
BASE_ASSISTANT_GET_CLASS( window )->close( window, assistant );
@@ -429,7 +434,7 @@ v_assistant_close( GtkAssistant *assistant, BaseAssistant *window )
static void
v_assistant_prepare( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *window )
{
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
if( BASE_ASSISTANT_GET_CLASS( window )->prepare ){
BASE_ASSISTANT_GET_CLASS( window )->prepare( window, assistant, page );
@@ -446,6 +451,8 @@ v_assistant_prepare( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *wi
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 );
}
@@ -454,12 +461,16 @@ on_apply_message( GtkAssistant *assistant, BaseAssistant *window )
static void
on_cancel_message( GtkAssistant *assistant, BaseAssistant *window )
{
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
+
v_assistant_cancel( assistant, window );
}
static void
on_close_message( GtkAssistant *assistant, BaseAssistant *window )
{
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
+
v_assistant_close( assistant, window );
}
@@ -471,6 +482,7 @@ on_prepare_message( GtkAssistant *assistant, GtkWidget *page, BaseAssistant *win
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 );
@@ -494,11 +506,14 @@ on_initial_load( BaseAssistant *window, gpointer user_data )
static const gchar *thisfn = "base_assistant_on_initial_load";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( BASE_IS_ASSISTANT( window ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
- 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( !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 );
+ }
}
static void
@@ -508,40 +523,43 @@ on_runtime_init( BaseAssistant *window, gpointer user_data )
GtkWindow *toplevel;
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( BASE_IS_ASSISTANT( window ));
-
- toplevel = base_window_get_toplevel_window( 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 ));
+ g_return_if_fail( BASE_IS_ASSISTANT( window ));
+
+ if( !window->private->dispose_has_run ){
+
+ toplevel = base_window_get_toplevel_window( 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 ));
+ }
}
static gboolean
@@ -552,13 +570,18 @@ on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseAssistant *assi
gboolean stop = FALSE;
GtkWindow *toplevel;
- if( event->keyval == GDK_Escape &&
- assistant->private->cancel_on_escape ){
+ g_return_val_if_fail( BASE_IS_ASSISTANT( assistant ), FALSE );
+
+ if( !assistant->private->dispose_has_run ){
- assistant->private->escape_key_pressed = TRUE;
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( assistant ));
- g_signal_emit_by_name( toplevel, "cancel", toplevel );
- stop = TRUE;
+ if( event->keyval == GDK_Escape &&
+ assistant->private->cancel_on_escape ){
+
+ assistant->private->escape_key_pressed = TRUE;
+ toplevel = base_window_get_toplevel_window( BASE_WINDOW( assistant ));
+ g_signal_emit_by_name( toplevel, "cancel", toplevel );
+ stop = TRUE;
+ }
}
return( stop );
diff --git a/src/nact/base-dialog.c b/src/nact/base-dialog.c
index 66c6e31..f8fc60e 100644
--- a/src/nact/base-dialog.c
+++ b/src/nact/base-dialog.c
@@ -115,8 +115,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
BaseDialog *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
- g_assert( BASE_IS_DIALOG( instance ));
+ g_return_if_fail( BASE_IS_DIALOG( instance ));
self = BASE_DIALOG( instance );
self->private = g_new0( BaseDialogPrivate, 1 );
@@ -131,7 +130,7 @@ instance_dispose( GObject *window )
BaseDialog *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( BASE_IS_DIALOG( window ));
+ g_return_if_fail( BASE_IS_DIALOG( instance ));
self = BASE_DIALOG( window );
if( !self->private->dispose_has_run ){
@@ -152,8 +151,8 @@ instance_finalize( GObject *window )
BaseDialog *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( BASE_IS_DIALOG( window ));
- self = ( BaseDialog * ) window;
+ g_return_if_fail( BASE_IS_DIALOG( instance ));
+ self = BASE_DIALOG( window );
g_free( self->private );
diff --git a/src/nact/base-iprefs.c b/src/nact/base-iprefs.c
index b49b144..cfeeb72 100644
--- a/src/nact/base-iprefs.c
+++ b/src/nact/base-iprefs.c
@@ -47,6 +47,9 @@ struct BaseIPrefsInterfacePrivate {
#define BASE_IPREFS_SCHEMAS_PATH NAUTILUS_ACTIONS_GCONF_SCHEMASDIR NA_GCONF_PREFS_PATH
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
static GType register_type( void );
static void interface_base_init( BaseIPrefsInterface *klass );
static void interface_base_finalize( BaseIPrefsInterface *klass );
@@ -114,18 +117,17 @@ static void
interface_base_init( BaseIPrefsInterface *klass )
{
static const gchar *thisfn = "base_iprefs_interface_base_init";
- static gboolean initialized = FALSE;
- if( !initialized ){
+ if( !st_initialized ){
+
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
klass->private = g_new0( BaseIPrefsInterfacePrivate, 1 );
-
klass->private->client = gconf_client_get_default();
klass->iprefs_get_window_id = NULL;
- initialized = TRUE;
+ st_initialized = TRUE;
}
}
@@ -133,14 +135,14 @@ static void
interface_base_finalize( BaseIPrefsInterface *klass )
{
static const gchar *thisfn = "base_iprefs_interface_base_finalize";
- static gboolean finalized = FALSE ;
- if( !finalized ){
+ if( !st_finalized ){
+
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
- finalized = TRUE;
+ st_finalized = TRUE;
}
}
@@ -162,16 +164,21 @@ base_iprefs_migrate_key( BaseWindow *window, const gchar *old_key, const gchar *
GConfValue *value;
g_debug( "%s: window=%p, old_key=%s, new_key=%s", thisfn, ( void * ) window, old_key, new_key );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
- value = get_value( BASE_IPREFS_GET_INTERFACE( window )->private->client, NA_GCONF_PREFS_PATH, old_key );
+ if( st_initialized && !st_finalized ){
- if( value ){
- set_value( BASE_IPREFS_GET_INTERFACE( window )->private->client, NA_GCONF_PREFS_PATH, new_key, value );
- gconf_value_free( value );
- }
+ value = get_value( BASE_IPREFS_GET_INTERFACE( window )->private->client, NA_GCONF_PREFS_PATH, old_key );
+
+ if( value ){
+ set_value( BASE_IPREFS_GET_INTERFACE( window )->private->client, NA_GCONF_PREFS_PATH, new_key, value );
+ gconf_value_free( value );
+ }
- remove_entry( BASE_IPREFS_GET_INTERFACE( window )->private->client, NA_GCONF_PREFS_PATH, old_key );
- remove_entry( BASE_IPREFS_GET_INTERFACE( window )->private->client, BASE_IPREFS_SCHEMAS_PATH, old_key );
+ remove_entry( BASE_IPREFS_GET_INTERFACE( window )->private->client, NA_GCONF_PREFS_PATH, old_key );
+ remove_entry( BASE_IPREFS_GET_INTERFACE( window )->private->client, BASE_IPREFS_SCHEMAS_PATH, old_key );
+ }
}
/**
@@ -188,19 +195,26 @@ base_iprefs_position_window( BaseWindow *window )
GtkWindow *toplevel;
gchar *key = v_iprefs_get_window_id( window );
- if( key ){
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
- base_iprefs_position_named_window( window, toplevel, key );
- g_free( key );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ if( key ){
+ toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ base_iprefs_position_named_window( window, toplevel, key );
+ g_free( key );
+ }
}
}
/**
* base_iprefs_position_named_window:
* @window: this #BaseWindow-derived window.
- * @name: the name of the window
+ * @toplevel: the toplevel #GtkWindow whose size and position are to be
+ * set.
+ * @key: the string id of this toplevel.
*
- * Position the specified window on the screen.
+ * Positions the specified window on the screen.
*/
void
base_iprefs_position_named_window( BaseWindow *window, GtkWindow *toplevel, const gchar *key )
@@ -209,44 +223,57 @@ base_iprefs_position_named_window( BaseWindow *window, GtkWindow *toplevel, cons
GSList *list;
gint x=0, y=0, width=0, height=0;
- list = read_int_list( window, key );
- if( list ){
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+
+ list = read_int_list( window, key );
+ if( list ){
- int_list_to_position( window, list, &x, &y, &width, &height );
- g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
- free_int_list( list );
+ int_list_to_position( window, list, &x, &y, &width, &height );
+ g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
+ free_int_list( list );
- gtk_window_move( toplevel, x, y );
- gtk_window_resize( toplevel, width, height );
+ gtk_window_move( toplevel, x, y );
+ gtk_window_resize( toplevel, width, height );
+ }
}
}
/**
- * Save the position of the specified window.
- *
- * @window: this BaseWindow-derived window.
+ * base_iprefs_save_window_position:
+ * @window: this #BaseWindow-derived window.
*
- * @code: the IPrefs identifiant of the window
+ * Save the size and position of the specified window.
*/
void
base_iprefs_save_window_position( BaseWindow *window )
{
GtkWindow *toplevel;
- gchar *key = v_iprefs_get_window_id( window );
+ gchar *key;
+
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
- if( key ){
- toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
- base_iprefs_save_named_window_position( window, toplevel, key );
- g_free( key );
+ if( st_initialized && !st_finalized ){
+
+ key = v_iprefs_get_window_id( window );
+ if( key ){
+ toplevel = base_window_get_toplevel_window( BASE_WINDOW( window ));
+ base_iprefs_save_named_window_position( window, toplevel, key );
+ g_free( key );
+ }
}
}
/**
- * Save the position of the specified window.
- *
- * @window: this BaseWindow-derived window.
+ * base_iprefs_save_named_window_position:
+ * @window: this #BaseWindow-derived window.
+ * @toplevel: the #GtkWindow whose size and position are to be saved.
+ * @key: the name of the window.
*
- * @key: the name of the window
+ * Save size and position of the specified window.
*/
void
base_iprefs_save_named_window_position( BaseWindow *window, GtkWindow *toplevel, const gchar *key )
@@ -255,49 +282,103 @@ base_iprefs_save_named_window_position( BaseWindow *window, GtkWindow *toplevel,
gint x, y, width, height;
GSList *list;
- if( GTK_IS_WINDOW( toplevel )){
- gtk_window_get_position( toplevel, &x, &y );
- gtk_window_get_size( toplevel, &width, &height );
- g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
- list = position_to_int_list( window, x, y, width, height );
- write_int_list( window, key, list );
- free_int_list( list );
+ if( GTK_IS_WINDOW( toplevel )){
+ gtk_window_get_position( toplevel, &x, &y );
+ gtk_window_get_size( toplevel, &width, &height );
+ g_debug( "%s: key=%s, x=%d, y=%d, width=%d, height=%d", thisfn, key, x, y, width, height );
+
+ list = position_to_int_list( window, x, y, width, height );
+ write_int_list( window, key, list );
+ free_int_list( list );
+ }
}
}
/**
- * Get/set a named boolean.
+ * base_iprefs_get_bool:
+ * @window: this #BaseWindow-derived window.
+ * @name: the entry to be readen.
*
- * @window: this BaseWindow-derived window.
+ * Returns: the named boolean.
*/
gboolean
base_iprefs_get_bool( BaseWindow *window, const gchar *name )
{
- return( read_bool( window, name ));
+ gboolean ret = FALSE;
+
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ ret = read_bool( window, name );
+ }
+
+ return( ret );
}
+/**
+ * base_iprefs_set_bool:
+ * @window: this #BaseWindow-derived window.
+ * @name: the entry to be readen.
+ * @value: the value to be set.
+ *
+ * Writes the named boolean in GConf.
+ */
void
base_iprefs_set_bool( BaseWindow *window, const gchar *name, gboolean value )
{
- write_bool( window, name, value );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ write_bool( window, name, value );
+ }
}
/**
- * Get/set a named integer.
- *
+ * base_iprefs_get_int:
* @window: this BaseWindow-derived window.
+ * @name: the entry to be readen.
+ *
+ * Returns: the named integer.
*/
gint
base_iprefs_get_int( BaseWindow *window, const gchar *name )
{
- return( read_int( window, name ));
+ gint ret = 0;
+
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ ret = read_int( window, name );
+ }
+
+ return( ret );
}
+/**
+ * base_iprefs_set_int:
+ * @window: this BaseWindow-derived window.
+ * @name: the entry to be written.
+ * @value: the integer to be set.
+ *
+ * Writes an integer in the GConf system.
+ */
void
base_iprefs_set_int( BaseWindow *window, const gchar *name, gint value )
{
- write_int( window, name, value );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ write_int( window, name, value );
+ }
}
/**
@@ -311,7 +392,16 @@ base_iprefs_set_int( BaseWindow *window, const gchar *name, gint value )
gchar *
base_iprefs_get_string( BaseWindow *window, const gchar *name )
{
- return( read_str( window, name ));
+ gchar *string = NULL;
+
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ string = read_str( window, name );
+ }
+
+ return( string );
}
/**
@@ -320,12 +410,17 @@ base_iprefs_get_string( BaseWindow *window, const gchar *name )
* @name: entry of the string value.
* @string: value to save.
*
- * Save the required string.
+ * Saves the required string.
*/
void
base_iprefs_set_string( BaseWindow *window, const gchar *name, const gchar *string )
{
- write_str( window, name, string );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_IPREFS( window ));
+
+ if( st_initialized && !st_finalized ){
+ write_str( window, name, string );
+ }
}
static gchar *
diff --git a/src/nact/base-window-class.h b/src/nact/base-window-class.h
index f9d56a4..f71faed 100644
--- a/src/nact/base-window-class.h
+++ b/src/nact/base-window-class.h
@@ -31,8 +31,10 @@
#ifndef __BASE_WINDOW_CLASS_H__
#define __BASE_WINDOW_CLASS_H__
-/*
- * BaseWindow class definition.
+/**
+ * SECTION: base_window
+ * @short_description: #BaseWindow class definition.
+ * @include: nact/base-window-class.h
*
* This is a base class which encapsulates a Gtk+ windows.
* It works together with the BaseApplication class to run a Gtk+
diff --git a/src/nact/base-window.c b/src/nact/base-window.c
index 508022c..b917dd1 100644
--- a/src/nact/base-window.c
+++ b/src/nact/base-window.c
@@ -328,7 +328,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
BaseWindow *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
g_return_if_fail( BASE_IS_WINDOW( instance ));
self = BASE_WINDOW( instance );
@@ -353,34 +352,37 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_return_if_fail( BASE_IS_WINDOW( object ));
self = BASE_WINDOW( object );
- switch( property_id ){
- case BASE_WINDOW_PROP_PARENT_ID:
- g_value_set_pointer( value, self->private->parent );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case BASE_WINDOW_PROP_PARENT_ID:
+ g_value_set_pointer( value, self->private->parent );
+ break;
- case BASE_WINDOW_PROP_APPLICATION_ID:
- g_value_set_pointer( value, self->private->application );
- break;
+ case BASE_WINDOW_PROP_APPLICATION_ID:
+ g_value_set_pointer( value, self->private->application );
+ break;
- case BASE_WINDOW_PROP_TOPLEVEL_NAME_ID:
- g_value_set_string( value, self->private->toplevel_name );
- break;
+ case BASE_WINDOW_PROP_TOPLEVEL_NAME_ID:
+ g_value_set_string( value, self->private->toplevel_name );
+ break;
- case BASE_WINDOW_PROP_TOPLEVEL_WIDGET_ID:
- g_value_set_pointer( value, self->private->toplevel_window );
- break;
+ case BASE_WINDOW_PROP_TOPLEVEL_WIDGET_ID:
+ g_value_set_pointer( value, self->private->toplevel_window );
+ break;
- case BASE_WINDOW_PROP_INITIALIZED_ID:
- g_value_set_boolean( value, self->private->initialized );
- break;
+ case BASE_WINDOW_PROP_INITIALIZED_ID:
+ g_value_set_boolean( value, self->private->initialized );
+ break;
- case BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID:
- g_value_set_boolean( value, self->private->save_window_position );
- break;
+ case BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID:
+ g_value_set_boolean( value, self->private->save_window_position );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -392,35 +394,38 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
g_return_if_fail( BASE_IS_WINDOW( object ));
self = BASE_WINDOW( object );
- switch( property_id ){
- case BASE_WINDOW_PROP_PARENT_ID:
- self->private->parent = g_value_get_pointer( value );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case BASE_WINDOW_PROP_PARENT_ID:
+ self->private->parent = g_value_get_pointer( value );
+ break;
- case BASE_WINDOW_PROP_APPLICATION_ID:
- self->private->application = g_value_get_pointer( value );
- break;
+ case BASE_WINDOW_PROP_APPLICATION_ID:
+ self->private->application = g_value_get_pointer( value );
+ break;
- case BASE_WINDOW_PROP_TOPLEVEL_NAME_ID:
- g_free( self->private->toplevel_name );
- self->private->toplevel_name = g_value_dup_string( value );
- break;
+ case BASE_WINDOW_PROP_TOPLEVEL_NAME_ID:
+ g_free( self->private->toplevel_name );
+ self->private->toplevel_name = g_value_dup_string( value );
+ break;
- case BASE_WINDOW_PROP_TOPLEVEL_WIDGET_ID:
- self->private->toplevel_window = g_value_get_pointer( value );
- break;
+ case BASE_WINDOW_PROP_TOPLEVEL_WIDGET_ID:
+ self->private->toplevel_window = g_value_get_pointer( value );
+ break;
- case BASE_WINDOW_PROP_INITIALIZED_ID:
- self->private->initialized = g_value_get_boolean( value );
- break;
+ case BASE_WINDOW_PROP_INITIALIZED_ID:
+ self->private->initialized = g_value_get_boolean( value );
+ break;
- case BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID:
- self->private->save_window_position = g_value_get_boolean( value );
- break;
+ case BASE_WINDOW_PROP_SAVE_WINDOW_POSITION_ID:
+ self->private->save_window_position = g_value_get_boolean( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -487,7 +492,7 @@ instance_finalize( GObject *window )
g_debug( "%s: window=%p", thisfn, ( void * ) window );
g_return_if_fail( BASE_IS_WINDOW( window ));
- self = ( BaseWindow * ) window;
+ self = BASE_WINDOW( window );
g_free( self->private->toplevel_name );
@@ -500,30 +505,38 @@ instance_finalize( GObject *window )
}
/**
- * Initializes the window.
+ * base_window_init:
* @window: this #BaseWindow object.
*
+ * Initializes the window.
+ *
* This is a one-time initialization just after the BaseWindow has been
* allocated. This should leave the BaseWindow object with a valid
* toplevel GtkWindow dialog. This is also time to make one-time
* initialization on this toplevel dialog.
*
- * For an every-time initialization, see base_window_run.
+ * For an every-time initialization, see base_window_run().
*
* Note that the BaseWindow itself should be initialized each time
* the user opens the dialog, though the GtkWindow itself needs only
* be initialized the first time it is loaded.
+ *
+ * Returns: %TRUE if the window has been successfully initialized,
+ * %FALSE else.
*/
gboolean
base_window_init( BaseWindow *window )
{
static const gchar *thisfn = "base_window_init";
+ gboolean initialized = FALSE;
gchar *dialog_name;
GtkWindow *toplevel;
g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
- if( !window->private->initialized ){
+ if( !window->private->dispose_has_run &&
+ !window->private->initialized ){
+
g_debug( "%s: window=%p", thisfn, ( void * ) window );
if( !window->private->application ){
@@ -552,18 +565,20 @@ base_window_init( BaseWindow *window )
set_toplevel_initialized( window, toplevel, TRUE );
}
window->private->initialized = TRUE;
+ initialized = TRUE;
}
g_free( dialog_name );
}
- return( window->private->initialized );
+ return( initialized );
}
/**
- * Run the window.
+ * base_window_run:
+ * @window: this #BaseWindow object.
*
- * @window: this BaseWindow object.
+ * Runs the window.
*/
void
base_window_run( BaseWindow *window )
@@ -574,56 +589,70 @@ base_window_run( BaseWindow *window )
g_return_if_fail( BASE_IS_WINDOW( window ));
- if( !window->private->initialized ){
- base_window_init( window );
- }
+ if( !window->private->dispose_has_run ){
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
+ if( !window->private->initialized ){
+ base_window_init( window );
+ }
- g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_RUNTIME_INIT, NULL );
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
- this_dialog = GTK_WIDGET( window->private->toplevel_window );
+ g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_RUNTIME_INIT, NULL );
- gtk_widget_show_all( this_dialog );
+ this_dialog = GTK_WIDGET( window->private->toplevel_window );
- g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED, NULL );
+ gtk_widget_show_all( this_dialog );
- if( is_main_window( window )){
+ g_signal_emit_by_name( window, BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED, NULL );
- if( GTK_IS_DIALOG( this_dialog )){
- g_signal_connect( G_OBJECT( this_dialog ), "response", G_CALLBACK( v_dialog_response ), window );
- } else {
- g_signal_connect( G_OBJECT( this_dialog ), "delete-event", G_CALLBACK( on_delete_event ), window );
- }
+ if( is_main_window( window )){
+
+ if( GTK_IS_DIALOG( this_dialog )){
+ g_signal_connect( G_OBJECT( this_dialog ), "response", G_CALLBACK( v_dialog_response ), window );
+ } else {
+ g_signal_connect( G_OBJECT( this_dialog ), "delete-event", G_CALLBACK( on_delete_event ), window );
+ }
- g_debug( "%s: application=%p, starting gtk_main", thisfn, ( void * ) window->private->application );
- gtk_main();
+ g_debug( "%s: application=%p, starting gtk_main", thisfn, ( void * ) window->private->application );
+ gtk_main();
- } else if( GTK_IS_ASSISTANT( this_dialog )){
- g_debug( "%s: starting gtk_main", thisfn );
- gtk_main();
+ } else if( GTK_IS_ASSISTANT( this_dialog )){
+ g_debug( "%s: starting gtk_main", thisfn );
+ gtk_main();
- } else {
- g_assert( GTK_IS_DIALOG( this_dialog ));
- g_debug( "%s: starting gtk_dialog_run", thisfn );
- do {
- code = gtk_dialog_run( GTK_DIALOG( this_dialog ));
+ } else {
+ g_assert( GTK_IS_DIALOG( this_dialog ));
+ g_debug( "%s: starting gtk_dialog_run", thisfn );
+ do {
+ code = gtk_dialog_run( GTK_DIALOG( this_dialog ));
+ }
+ while( !v_dialog_response( GTK_DIALOG( this_dialog ), code, window ));
}
- while( !v_dialog_response( GTK_DIALOG( this_dialog ), code, window ));
}
}
/**
- * Returns a pointer on the BaseApplication object.
+ * base_window_get_application:
+ * @window: this #BaseWindow object.
*
- * @window: this BaseWindow object.
+ * Returns: a pointer on the #BaseApplication object.
+ *
+ * The returned pointer is owned by the primary allocator of the
+ * application ; it should not be g_free() nor g_object_unref() by the
+ * caller.
*/
BaseApplication *
base_window_get_application( BaseWindow *window )
{
+ BaseApplication *application = NULL;
+
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
- return( v_get_application( window ));
+ if( !window->private->dispose_has_run ){
+ application = v_get_application( window );
+ }
+
+ return( application );
}
/**
@@ -631,13 +660,22 @@ base_window_get_application( BaseWindow *window )
* @window: this #BaseWindow instance..
*
* Returns the top-level GtkWindow attached to this BaseWindow object.
+ *
+ * The caller may close the window by g_object_unref()-ing the returned
+ * #GtkWindow.
*/
GtkWindow *
base_window_get_toplevel_window( BaseWindow *window )
{
+ GtkWindow *toplevel = NULL;
+
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
- return( v_get_toplevel_window( window ));
+ if( !window->private->dispose_has_run ){
+ toplevel = v_get_toplevel_window( window );
+ }
+
+ return( toplevel );
}
/**
@@ -645,29 +683,47 @@ base_window_get_toplevel_window( BaseWindow *window )
* @window: this #BaseWindow instance.
* @name: the name of the searched GtkWindow.
*
- * Returns a top-level GtkWindow.
+ * Returns: the named top-level GtkWindow.
+ *
+ * The caller may close the window by g_object_unref()-ing the returned
+ * #GtkWindow.
*/
GtkWindow *
base_window_get_toplevel( BaseWindow *window, const gchar *name )
{
- g_assert( BASE_IS_WINDOW( window ));
+ GtkWindow *toplevel = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+ toplevel = v_get_window( window, name );
+ }
- return( v_get_window( window, name ));
+ return( toplevel );
}
/**
- * Returns the GtkWidget which is a child of this parent.
- *
+ * base_window_get_widget:
* @window: this BaseWindow object.
- *
* @name: the name of the searched child.
+ *
+ * Returns: the GtkWidget which is a child of this parent.
+ *
+ * The returned #GtkWidget is owned by the #GtkBuilder UI. It should
+ * not be g_free nor g_object_unref() by the caller.
*/
GtkWidget *
base_window_get_widget( BaseWindow *window, const gchar *name )
{
- g_assert( BASE_IS_WINDOW( window ));
+ GtkWidget *widget = NULL;
- return( v_get_widget( window, name ));
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+ widget = v_get_widget( window, name );
+ }
+
+ return( widget );
}
/*
@@ -679,16 +735,23 @@ 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_debug( "%s: toplevel=%p, event=%p, window=%p",
thisfn, ( void * ) toplevel, ( void * ) event, ( void * ) window );
- g_assert( BASE_IS_WINDOW( window ));
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
- if( BASE_WINDOW_GET_CLASS( window )->delete_event ){
- return( BASE_WINDOW_GET_CLASS( window )->delete_event( window, GTK_WINDOW( toplevel ), event ));
+ 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( window_do_delete_event( window, GTK_WINDOW( toplevel ), event ));
+ return( stop );
}
/*
@@ -701,13 +764,16 @@ v_initial_load_toplevel( BaseWindow *window, gpointer user_data )
static const gchar *thisfn = "base_window_v_initial_load_toplevel";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( BASE_IS_WINDOW( window ));
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
- if( BASE_WINDOW_GET_CLASS( window )->initial_load_toplevel ){
- BASE_WINDOW_GET_CLASS( window )->initial_load_toplevel( window, user_data );
+ if( BASE_WINDOW_GET_CLASS( window )->initial_load_toplevel ){
+ BASE_WINDOW_GET_CLASS( window )->initial_load_toplevel( window, user_data );
- } else {
- window_do_initial_load_toplevel( window, user_data );
+ } else {
+ window_do_initial_load_toplevel( window, user_data );
+ }
}
}
@@ -721,13 +787,16 @@ v_runtime_init_toplevel( BaseWindow *window, gpointer user_data )
static const gchar *thisfn = "base_window_v_runtime_init_toplevel";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( BASE_IS_WINDOW( window ));
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
- if( BASE_WINDOW_GET_CLASS( window )->runtime_init_toplevel ){
- BASE_WINDOW_GET_CLASS( window )->runtime_init_toplevel( window, user_data );
+ if( BASE_WINDOW_GET_CLASS( window )->runtime_init_toplevel ){
+ BASE_WINDOW_GET_CLASS( window )->runtime_init_toplevel( window, user_data );
- } else {
- window_do_runtime_init_toplevel( window, user_data );
+ } else {
+ window_do_runtime_init_toplevel( window, user_data );
+ }
}
}
@@ -737,13 +806,16 @@ v_all_widgets_showed( BaseWindow *window, gpointer user_data )
static const gchar *thisfn = "base_window_v_all_widgets_showed";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( BASE_IS_WINDOW( window ));
+ g_return_if_fail( BASE_IS_WINDOW( window ));
- if( BASE_WINDOW_GET_CLASS( window )->all_widgets_showed ){
- BASE_WINDOW_GET_CLASS( window )->all_widgets_showed( window, user_data );
+ if( !window->private->dispose_has_run ){
- } else {
- window_do_all_widgets_showed( window, user_data );
+ if( BASE_WINDOW_GET_CLASS( window )->all_widgets_showed ){
+ BASE_WINDOW_GET_CLASS( window )->all_widgets_showed( window, user_data );
+
+ } else {
+ window_do_all_widgets_showed( window, user_data );
+ }
}
}
@@ -751,27 +823,40 @@ static gboolean
v_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
{
static const gchar *thisfn = "base_window_v_dialog_response";
+ gboolean stop = FALSE;
g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
- g_assert( BASE_IS_WINDOW( window ));
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
- if( BASE_WINDOW_GET_CLASS( window )->dialog_response ){
- return( BASE_WINDOW_GET_CLASS( window )->dialog_response( dialog, code, 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 );
- return( window_do_dialog_response( dialog, code, window ));
+ } else {
+ stop = window_do_dialog_response( dialog, code, window );
+ }
+ }
}
static BaseApplication *
v_get_application( BaseWindow *window )
{
- g_assert( BASE_IS_WINDOW( window ));
+ BaseApplication *application = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+
+ if( BASE_WINDOW_GET_CLASS( window )->get_application ){
+ application = BASE_WINDOW_GET_CLASS( window )->get_application( window );
- if( BASE_WINDOW_GET_CLASS( window )->get_application ){
- return( BASE_WINDOW_GET_CLASS( window )->get_application( window ));
+ } else {
+ application = window_do_get_application( window );
+ }
}
- return( window_do_get_application( window ));
+ return( application );
}
static GtkWindow *
@@ -789,37 +874,58 @@ v_get_toplevel_window( BaseWindow *window )
static GtkWindow *
v_get_window( BaseWindow *window, const gchar *name )
{
- g_assert( BASE_IS_WINDOW( window ));
+ GtkWindow *toplevel = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
- if( BASE_WINDOW_GET_CLASS( window )->get_window ){
- return( BASE_WINDOW_GET_CLASS( window )->get_window( window, name ));
+ if( BASE_WINDOW_GET_CLASS( window )->get_window ){
+ toplevel = BASE_WINDOW_GET_CLASS( window )->get_window( window, name );
+
+ } else {
+ toplevel = window_do_get_window( window, name );
+ }
}
- return( window_do_get_window( window, name ));
+ return( toplevel );
}
static GtkWidget *
v_get_widget( BaseWindow *window, const gchar *name )
{
- g_assert( BASE_IS_WINDOW( window ));
+ GtkWidget *widget = NULL;
- if( BASE_WINDOW_GET_CLASS( window )->get_widget ){
- return( BASE_WINDOW_GET_CLASS( window )->get_widget( window, name ));
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+
+ if( BASE_WINDOW_GET_CLASS( window )->get_widget ){
+ widget = BASE_WINDOW_GET_CLASS( window )->get_widget( window, name );
+
+ } else {
+ widget = window_do_get_widget( window, name );
+ }
}
- return( window_do_get_widget( window, name ));
+ return( widget );
}
static gchar *
v_get_iprefs_window_id( BaseWindow *window )
{
- g_assert( BASE_IS_IPREFS( window ));
+ gchar *id = NULL;
- if( BASE_WINDOW_GET_CLASS( window )->get_iprefs_window_id ){
- return( BASE_WINDOW_GET_CLASS( window )->get_iprefs_window_id( window ));
+ 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( NULL );
+ return( id );
}
static void
@@ -830,14 +936,18 @@ on_runtime_init_toplevel( BaseWindow *window, gpointer user_data )
g_debug( "%s: window=%p, user_data=%p, parent_window=%p",
thisfn, ( void * ) window, ( void * ) user_data, ( void * ) window->private->parent );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
- if( window->private->parent ){
- g_assert( BASE_IS_WINDOW( window->private->parent ));
- parent_toplevel = base_window_get_toplevel_window( BASE_WINDOW( window->private->parent ));
- gtk_window_set_transient_for( window->private->toplevel_window, parent_toplevel );
- }
+ if( !window->private->dispose_has_run ){
+
+ if( window->private->parent ){
+ g_assert( BASE_IS_WINDOW( window->private->parent ));
+ parent_toplevel = base_window_get_toplevel_window( BASE_WINDOW( window->private->parent ));
+ gtk_window_set_transient_for( window->private->toplevel_window, parent_toplevel );
+ }
- base_iprefs_position_window( window );
+ base_iprefs_position_window( window );
+ }
}
static void
@@ -846,6 +956,11 @@ window_do_initial_load_toplevel( BaseWindow *window, gpointer user_data )
static const gchar *thisfn = "base_window_do_initial_load_toplevel";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
+ /* nothing to do here */
+ }
}
static void
@@ -854,6 +969,11 @@ window_do_runtime_init_toplevel( BaseWindow *window, gpointer user_data )
static const gchar *thisfn = "base_window_do_runtime_init_toplevel";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
+ /* nothing to do here */
+ }
}
static void
@@ -862,6 +982,11 @@ window_do_all_widgets_showed( BaseWindow *window, gpointer user_data )
static const gchar *thisfn = "base_window_do_all_widgets_showed";
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
+ /* nothing to do here */
+ }
}
/*
@@ -899,22 +1024,33 @@ window_do_delete_event( BaseWindow *window, GtkWindow *toplevel, GdkEvent *event
static BaseApplication *
window_do_get_application( BaseWindow *window )
{
- return( window->private->application );
+ BaseApplication *application = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+ application = window->private->application;
+ }
+
+ return( application );
}
static gchar *
window_do_get_toplevel_name( BaseWindow *window )
{
- gchar *name;
+ gchar *name = NULL;
- g_assert( BASE_IS_WINDOW( window ));
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
- g_object_get( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, &name, NULL );
+ g_object_get( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, &name, NULL );
- if( !name || !strlen( name )){
- name = BASE_WINDOW_GET_CLASS( window )->get_toplevel_name( window );
- if( name && strlen( name )){
- g_object_set( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, name, NULL );
+ if( !name || !strlen( name )){
+ name = BASE_WINDOW_GET_CLASS( window )->get_toplevel_name( window );
+ if( name && strlen( name )){
+ g_object_set( G_OBJECT( window ), BASE_WINDOW_PROP_TOPLEVEL_NAME, name, NULL );
+ }
}
}
@@ -924,37 +1060,66 @@ window_do_get_toplevel_name( BaseWindow *window )
static GtkWindow *
window_do_get_toplevel_window( BaseWindow *window )
{
- return( window->private->toplevel_window );
+ GtkWindow *toplevel = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+ toplevel = window->private->toplevel_window;
+ }
+
+ return( toplevel );
}
static GtkWindow *
window_do_get_window( BaseWindow *window, const gchar *name )
{
- g_assert( BASE_IS_WINDOW( window ));
+ GtkWindow *toplevel = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+ toplevel = base_application_get_toplevel( window->private->application, name );
+ }
- return( base_application_get_toplevel( window->private->application, name ));
+ return( toplevel );
}
static GtkWidget *
window_do_get_widget( BaseWindow *window, const gchar *name )
{
- g_assert( BASE_IS_WINDOW( window ));
+ GtkWidget *widget = NULL;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+ widget = base_application_get_widget( window->private->application, window, name );
+ }
- return( base_application_get_widget( window->private->application, window, name ));
+ return( widget );
}
static gboolean
is_main_window( BaseWindow *window )
{
- BaseApplication *appli = window->private->application;
+ gboolean is_main = FALSE;
- BaseWindow *main_window = BASE_WINDOW( base_application_get_main_window( appli ));
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
+
+ if( !window->private->dispose_has_run ){
+
+ BaseApplication *appli = window->private->application;
- GtkWidget *main_dialog = GTK_WIDGET( base_window_get_toplevel_window( main_window ));
+ BaseWindow *main_window = BASE_WINDOW( base_application_get_main_window( appli ));
- GtkWidget *this_dialog = GTK_WIDGET( window->private->toplevel_window );
+ GtkWidget *main_dialog = GTK_WIDGET( base_window_get_toplevel_window( main_window ));
- return( main_dialog == this_dialog );
+ GtkWidget *this_dialog = GTK_WIDGET( window->private->toplevel_window );
+
+ is_main = ( main_dialog == this_dialog );
+ }
+
+ return( is_main );
}
static gboolean
@@ -976,15 +1141,25 @@ set_toplevel_initialized( BaseWindow *window, GtkWindow *toplevel, gboolean init
void
base_window_error_dlg( BaseWindow *window, GtkMessageType type, const gchar *primary, const gchar *secondary )
{
- g_assert( BASE_IS_WINDOW( window ));
- base_application_error_dlg( window->private->application, type, primary, secondary );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
+ base_application_error_dlg( window->private->application, type, primary, secondary );
+ }
}
gboolean
base_window_yesno_dlg( BaseWindow *window, GtkMessageType type, const gchar *first, const gchar *second )
{
- g_assert( BASE_IS_WINDOW( window ));
- return( base_application_yesno_dlg( window->private->application, type, first, second ));
+ gboolean yesno = FALSE;
+
+ g_return_val_if_fail( BASE_IS_WINDOW( window ), FALSE );
+
+ if( !window->private->dispose_has_run ){
+ yesno = base_application_yesno_dlg( window->private->application, type, first, second );
+ }
+
+ return( yesno );
}
/**
@@ -995,23 +1170,34 @@ base_window_signal_connect( BaseWindow *window, GObject *instance, const gchar *
{
static const gchar *thisfn = "base_window_signal_connect";
- gulong handler_id = g_signal_connect( instance, signal, fn, window );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
- BaseWindowRecordedSignal *str = g_new0( BaseWindowRecordedSignal, 1 );
- str->instance = instance;
- str->handler_id = handler_id;
- window->private->signals = g_slist_prepend( window->private->signals, str );
+ gulong handler_id = g_signal_connect( instance, signal, fn, window );
- if( st_debug_signal_connect ){
- g_debug( "%s: connecting signal handler %p:%lu", thisfn, ( void * ) instance, handler_id );
+ BaseWindowRecordedSignal *str = g_new0( BaseWindowRecordedSignal, 1 );
+ str->instance = instance;
+ str->handler_id = handler_id;
+ window->private->signals = g_slist_prepend( window->private->signals, str );
+
+ if( st_debug_signal_connect ){
+ g_debug( "%s: connecting signal handler %p:%lu", thisfn, ( void * ) instance, handler_id );
+ }
}
}
void
base_window_signal_connect_by_name( BaseWindow *window, const gchar *name, const gchar *signal, GCallback fn )
{
- GtkWidget *widget = base_window_get_widget( window, name );
- if( GTK_IS_WIDGET( widget )){
- base_window_signal_connect( window, G_OBJECT( widget ), signal, fn );
+ g_return_if_fail( BASE_IS_WINDOW( window ));
+
+ if( !window->private->dispose_has_run ){
+
+ GtkWidget *widget = base_window_get_widget( window, name );
+ if( GTK_IS_WIDGET( widget )){
+
+ base_window_signal_connect( window, G_OBJECT( widget ), signal, fn );
+ }
}
}
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index c55a817..6c5734d 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -31,8 +31,10 @@
#ifndef __BASE_WINDOW_H__
#define __BASE_WINDOW_H__
-/*
- * BaseWindow class definition.
+/**
+ * SECTION: base_window
+ * @short_description: #BaseWindow public function declaration.
+ * @include: nact/base-window.h
*
* This is a base class which encapsulates a Gtk+ windows.
* It works together with the BaseApplication class to run a Gtk+
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index 593d9e1..ee36a5e 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -162,7 +162,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactApplication *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
g_assert( NACT_IS_APPLICATION( instance ));
self = NACT_APPLICATION( instance );
@@ -179,14 +178,17 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_assert( NACT_IS_APPLICATION( object ));
self = NACT_APPLICATION( object );
- switch( property_id ){
- case NACT_APPLICATION_PROP_PIVOT_ID:
- g_value_set_pointer( value, self->private->pivot );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NACT_APPLICATION_PROP_PIVOT_ID:
+ g_value_set_pointer( value, self->private->pivot );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -198,14 +200,17 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
g_assert( NACT_IS_APPLICATION( object ));
self = NACT_APPLICATION( object );
- switch( property_id ){
- case NACT_APPLICATION_PROP_PIVOT_ID:
- self->private->pivot = g_value_get_pointer( value );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NACT_APPLICATION_PROP_PIVOT_ID:
+ self->private->pivot = g_value_get_pointer( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -216,7 +221,7 @@ instance_dispose( GObject *application )
NactApplication *self;
g_debug( "%s: application=%p", thisfn, ( void * ) application );
- g_assert( NACT_IS_APPLICATION( application ));
+ g_return_if_fail( NACT_IS_APPLICATION( application ));
self = NACT_APPLICATION( application );
if( !self->private->dispose_has_run ){
@@ -241,8 +246,8 @@ instance_finalize( GObject *application )
NactApplication *self;
g_debug( "%s: application=%p", thisfn, ( void * ) application );
- g_assert( NACT_IS_APPLICATION( application ));
- self = ( NactApplication * ) application;
+ g_return_if_fail( NACT_IS_APPLICATION( application ));
+ self = NACT_APPLICATION( application );
g_free( self->private );
@@ -282,8 +287,15 @@ nact_application_new_with_args( int argc, char **argv )
NAPivot *
nact_application_get_pivot( NactApplication *application )
{
- g_assert( NACT_IS_APPLICATION( application ));
- return( NA_PIVOT( application->private->pivot ));
+ NAPivot *pivot = NULL;
+
+ g_return_val_if_fail( NACT_IS_APPLICATION( application ), NULL );
+
+ if( !application->private->dispose_has_run ){
+ pivot = application->private->pivot;
+ }
+
+ return( pivot );
}
/*
diff --git a/src/nact/nact-application.h b/src/nact/nact-application.h
index 3232965..ef2c7d9 100644
--- a/src/nact/nact-application.h
+++ b/src/nact/nact-application.h
@@ -31,10 +31,12 @@
#ifndef __NACT_APPLICATION_H__
#define __NACT_APPLICATION_H__
-/*
- * NactApplication class definition.
+/**
+ * SECTION: nact_application
+ * @short_description: #NactApplication class definition.
+ * @include: nact/nact-application.h
*
- * This is the main class for UI programs.
+ * This is the main class for nautilus-actions-config-tool program.
*/
#include <common/na-pivot.h>
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index b17e18e..759b793 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -275,7 +275,7 @@ instance_dispose( GObject *window )
NactAssistantExport *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( NACT_IS_ASSISTANT_EXPORT( window ));
+ g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( window ));
self = NACT_ASSISTANT_EXPORT( window );
if( !self->private->dispose_has_run ){
@@ -296,8 +296,8 @@ instance_finalize( GObject *window )
NactAssistantExport *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( NACT_IS_ASSISTANT_EXPORT( window ));
- self = ( NactAssistantExport * ) window;
+ g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( window ));
+ self = NACT_ASSISTANT_EXPORT( window );
g_free( self->private->uri );
na_utils_free_string_list( self->private->fnames );
diff --git a/src/nact/nact-assistant-export.h b/src/nact/nact-assistant-export.h
index d52c357..3ae539d 100644
--- a/src/nact/nact-assistant-export.h
+++ b/src/nact/nact-assistant-export.h
@@ -31,8 +31,10 @@
#ifndef __NACT_ASSISTANT_EXPORT_H__
#define __NACT_ASSISTANT_EXPORT_H__
-/*
- * NactAssistantExport class definition.
+/**
+ * SECTION: nact_assistant_export
+ * @short_description: #NactAssistantExport class definition.
+ * @include: nact/nact-assistant-export.h
*
* Rationale:
*
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index e120263..b2efe75 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -184,8 +184,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactAssistantImport *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
- g_assert( NACT_IS_ASSISTANT_IMPORT( instance ));
+ g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( instance ));
self = NACT_ASSISTANT_IMPORT( instance );
self->private = g_new0( NactAssistantImportPrivate, 1 );
@@ -207,7 +206,7 @@ instance_dispose( GObject *window )
NactAssistantImport *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( NACT_IS_ASSISTANT_IMPORT( window ));
+ g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( window ));
self = NACT_ASSISTANT_IMPORT( window );
if( !self->private->dispose_has_run ){
@@ -228,8 +227,8 @@ instance_finalize( GObject *window )
NactAssistantImport *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( NACT_IS_ASSISTANT_IMPORT( window ));
- self = ( NactAssistantImport * ) window;
+ g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( window ));
+ self = NACT_ASSISTANT_IMPORT( window );
free_results( self->private->results );
diff --git a/src/nact/nact-assistant-import.h b/src/nact/nact-assistant-import.h
index 2e679cb..3eb921c 100644
--- a/src/nact/nact-assistant-import.h
+++ b/src/nact/nact-assistant-import.h
@@ -31,8 +31,10 @@
#ifndef __NACT_ASSISTANT_IMPORT_H__
#define __NACT_ASSISTANT_IMPORT_H__
-/*
- * NactAssistantImport class definition.
+/**
+ * SECTION: nact_assistant_import
+ * @short_description: #NactAssistantImport class definition.
+ * @include: nact/nact-assistant-import.h
*/
#include "base-assistant.h"
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index d685526..621d078 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -62,6 +62,9 @@ enum {
*/
#define IACTION_TAB_PROP_STATUS_CONTEXT "nact-iaction-tab-status-context"
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
static GType register_type( void );
static void interface_base_init( NactIActionTabInterface *klass );
static void interface_base_finalize( NactIActionTabInterface *klass );
@@ -124,14 +127,13 @@ static void
interface_base_init( NactIActionTabInterface *klass )
{
static const gchar *thisfn = "nact_iaction_tab_interface_base_init";
- static gboolean initialized = FALSE;
- if( !initialized ){
+ if( !st_initialized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
klass->private = g_new0( NactIActionTabInterfacePrivate, 1 );
- initialized = TRUE;
+ st_initialized = TRUE;
}
}
@@ -139,14 +141,13 @@ static void
interface_base_finalize( NactIActionTabInterface *klass )
{
static const gchar *thisfn = "nact_iaction_tab_interface_base_finalize";
- static gboolean finalized = FALSE ;
- if( !finalized ){
+ if( !st_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
- finalized = TRUE;
+ st_finalized = TRUE;
}
}
@@ -157,10 +158,14 @@ nact_iaction_tab_initial_load_toplevel( NactIActionTab *instance )
GtkWidget *icon_widget;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
- icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
- gtk_combo_box_set_model( GTK_COMBO_BOX( icon_widget ), create_stock_icon_model());
- icon_combo_list_fill( GTK_COMBO_BOX_ENTRY( icon_widget ));
+ icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
+ gtk_combo_box_set_model( GTK_COMBO_BOX( icon_widget ), create_stock_icon_model());
+ icon_combo_list_fill( GTK_COMBO_BOX_ENTRY( icon_widget ));
+ }
}
void
@@ -172,47 +177,51 @@ nact_iaction_tab_runtime_init_toplevel( NactIActionTab *instance )
GtkButton *enabled_button;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
- label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionLabelEntry" );
- g_signal_connect(
- G_OBJECT( label_widget ),
- "changed",
- G_CALLBACK( on_label_changed ),
- instance );
-
- tooltip_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionTooltipEntry" );
- g_signal_connect(
- G_OBJECT( tooltip_widget ),
- "changed",
- G_CALLBACK( on_tooltip_changed ),
- instance );
-
- icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
- g_signal_connect(
- G_OBJECT( GTK_BIN( icon_widget )->child ),
- "changed",
- G_CALLBACK( on_icon_changed ),
- instance );
-
- button = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconBrowseButton" );
- g_signal_connect(
- G_OBJECT( button ),
- "clicked",
- G_CALLBACK( on_icon_browse ),
- instance );
-
- enabled_button = get_enabled_button( instance );
- g_signal_connect(
- G_OBJECT( enabled_button ),
- "toggled",
- G_CALLBACK( on_enabled_toggled ),
- instance );
-
- g_signal_connect(
- G_OBJECT( instance ),
- TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_tab_updatable_selection_changed ),
- instance );
+ if( st_initialized && !st_finalized ){
+
+ label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionLabelEntry" );
+ g_signal_connect(
+ G_OBJECT( label_widget ),
+ "changed",
+ G_CALLBACK( on_label_changed ),
+ instance );
+
+ tooltip_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionTooltipEntry" );
+ g_signal_connect(
+ G_OBJECT( tooltip_widget ),
+ "changed",
+ G_CALLBACK( on_tooltip_changed ),
+ instance );
+
+ icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
+ g_signal_connect(
+ G_OBJECT( GTK_BIN( icon_widget )->child ),
+ "changed",
+ G_CALLBACK( on_icon_changed ),
+ instance );
+
+ button = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconBrowseButton" );
+ g_signal_connect(
+ G_OBJECT( button ),
+ "clicked",
+ G_CALLBACK( on_icon_browse ),
+ instance );
+
+ enabled_button = get_enabled_button( instance );
+ g_signal_connect(
+ G_OBJECT( enabled_button ),
+ "toggled",
+ G_CALLBACK( on_enabled_toggled ),
+ instance );
+
+ g_signal_connect(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+ G_CALLBACK( on_tab_updatable_selection_changed ),
+ instance );
+ }
}
void
@@ -221,6 +230,10 @@ nact_iaction_tab_all_widgets_showed( NactIActionTab *instance )
static const gchar *thisfn = "nact_iaction_tab_all_widgets_showed";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
void
@@ -229,6 +242,10 @@ nact_iaction_tab_dispose( NactIActionTab *instance )
static const gchar *thisfn = "nact_iaction_tab_dispose";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
/**
@@ -244,10 +261,18 @@ nact_iaction_tab_has_label( NactIActionTab *instance )
{
GtkWidget *label_widget;
const gchar *label;
+ gboolean has_label = FALSE;
+
+ g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
- label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionLabelEntry" );
- label = gtk_entry_get_text( GTK_ENTRY( label_widget ));
- return( g_utf8_strlen( label, -1 ) > 0 );
+ if( st_initialized && !st_finalized ){
+
+ label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionLabelEntry" );
+ label = gtk_entry_get_text( GTK_ENTRY( label_widget ));
+ has_label = ( g_utf8_strlen( label, -1 ) > 0 );
+ }
+
+ return( has_label );
}
static void
@@ -263,53 +288,57 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
g_return_if_fail( BASE_IS_WINDOW( instance ));
+ g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
- g_object_get(
- G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
- NULL );
+ if( st_initialized && !st_finalized ){
- g_return_if_fail( !item || NA_IS_OBJECT_ITEM( item ));
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+ NULL );
- enabled_tab = ( count_selected == 1 );
+ g_return_if_fail( !item || NA_IS_OBJECT_ITEM( item ));
- label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionLabelEntry" );
- label = item ? na_object_get_label( item ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
- gtk_widget_set_sensitive( label_widget, enabled_tab );
- if( item ){
- check_for_label( instance, GTK_ENTRY( label_widget ), label );
- }
- g_free( label );
-
- tooltip_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionTooltipEntry" );
- tooltip = item ? na_object_get_tooltip( item ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( tooltip_widget ), tooltip );
- gtk_widget_set_sensitive( tooltip_widget, enabled_tab );
- g_free( tooltip );
-
- icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
- icon = item ? na_object_get_icon( item ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( GTK_BIN( icon_widget )->child ), icon );
- gtk_widget_set_sensitive( icon_widget, enabled_tab );
- g_free( icon );
-
- button = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconBrowseButton" );
- gtk_widget_set_sensitive( button, enabled_tab );
-
- group_title = base_window_get_widget( BASE_WINDOW( instance ), "ActionPropertiesGroupTitle" );
- if( NA_IS_OBJECT_MENU( item )){
- gtk_label_set_markup( GTK_LABEL( group_title ), _( "<b>Menu properties</b>" ));
- } else {
- gtk_label_set_markup( GTK_LABEL( group_title ), _( "<b>Action properties</b>" ));
- }
+ enabled_tab = ( count_selected == 1 );
+
+ label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionLabelEntry" );
+ label = item ? na_object_get_label( item ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+ gtk_widget_set_sensitive( label_widget, enabled_tab );
+ if( item ){
+ check_for_label( instance, GTK_ENTRY( label_widget ), label );
+ }
+ g_free( label );
+
+ tooltip_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionTooltipEntry" );
+ tooltip = item ? na_object_get_tooltip( item ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( tooltip_widget ), tooltip );
+ gtk_widget_set_sensitive( tooltip_widget, enabled_tab );
+ g_free( tooltip );
+
+ icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
+ icon = item ? na_object_get_icon( item ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( GTK_BIN( icon_widget )->child ), icon );
+ gtk_widget_set_sensitive( icon_widget, enabled_tab );
+ g_free( icon );
+
+ button = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconBrowseButton" );
+ gtk_widget_set_sensitive( button, enabled_tab );
+
+ group_title = base_window_get_widget( BASE_WINDOW( instance ), "ActionPropertiesGroupTitle" );
+ if( NA_IS_OBJECT_MENU( item )){
+ gtk_label_set_markup( GTK_LABEL( group_title ), _( "<b>Menu properties</b>" ));
+ } else {
+ gtk_label_set_markup( GTK_LABEL( group_title ), _( "<b>Action properties</b>" ));
+ }
- enabled_button = get_enabled_button( instance );
- enabled_item = item ? na_object_is_enabled( NA_OBJECT_ITEM( item )) : FALSE;
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( enabled_button ), enabled_item );
- gtk_widget_set_sensitive( GTK_WIDGET( enabled_button ), enabled_tab );
+ enabled_button = get_enabled_button( instance );
+ enabled_item = item ? na_object_is_enabled( NA_OBJECT_ITEM( item )) : FALSE;
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( enabled_button ), enabled_item );
+ gtk_widget_set_sensitive( GTK_WIDGET( enabled_button ), enabled_tab );
- /* TODO: manage read-only flag */
+ /* TODO: manage read-only flag */
+ }
}
static void
@@ -320,26 +349,29 @@ check_for_label( NactIActionTab *instance, GtkEntry *entry, const gchar *label )
g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
g_return_if_fail( GTK_IS_ENTRY( entry ));
- nact_main_statusbar_hide_status(
- NACT_MAIN_WINDOW( instance ),
- IACTION_TAB_PROP_STATUS_CONTEXT );
+ if( st_initialized && !st_finalized ){
- set_label_label( instance, "black" );
+ nact_main_statusbar_hide_status(
+ NACT_MAIN_WINDOW( instance ),
+ IACTION_TAB_PROP_STATUS_CONTEXT );
- g_object_get(
- G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_ACTION, &edited,
- NULL );
+ set_label_label( instance, "black" );
- if( edited && g_utf8_strlen( label, -1 ) == 0 ){
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &edited,
+ NULL );
- /* i18n: status bar message when the action label is empty */
- nact_main_statusbar_display_status(
- NACT_MAIN_WINDOW( instance ),
- IACTION_TAB_PROP_STATUS_CONTEXT,
- _( "Caution: a label is mandatory for the action or the menu." ));
+ if( edited && g_utf8_strlen( label, -1 ) == 0 ){
- set_label_label( instance, "red" );
+ /* i18n: status bar message when the action label is empty */
+ nact_main_statusbar_display_status(
+ NACT_MAIN_WINDOW( instance ),
+ IACTION_TAB_PROP_STATUS_CONTEXT,
+ _( "Caution: a label is mandatory for the action or the menu." ));
+
+ set_label_label( instance, "red" );
+ }
}
}
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index fd95d2e..97102f6 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -111,6 +111,8 @@ typedef struct {
#define FILTER_SELECTION_MODE "nact-iactions-list-filter-selection-mode"
static gint st_signals[ LAST_SIGNAL ] = { 0 };
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
static GType register_type( void );
static void interface_base_init( NactIActionsListInterface *klass );
@@ -192,9 +194,8 @@ static void
interface_base_init( NactIActionsListInterface *klass )
{
static const gchar *thisfn = "nact_iactions_list_interface_base_init";
- static gboolean initialized = FALSE;
- if( !initialized ){
+ if( !st_initialized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
klass->private = g_new0( NactIActionsListInterfacePrivate, 1 );
@@ -255,7 +256,7 @@ interface_base_init( NactIActionsListInterface *klass )
1,
G_TYPE_POINTER );
- initialized = TRUE;
+ st_initialized = TRUE;
}
}
@@ -269,14 +270,13 @@ static void
interface_base_finalize( NactIActionsListInterface *klass )
{
static const gchar *thisfn = "nact_iactions_list_interface_base_finalize";
- static gboolean finalized = FALSE ;
- if( !finalized ){
+ if( !st_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
- finalized = TRUE;
+ st_finalized = TRUE;
}
}
@@ -304,35 +304,38 @@ nact_iactions_list_initial_load_toplevel( NactIActionsList *instance )
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
- treeview = get_actions_list_treeview( instance );
+ if( st_initialized && !st_finalized ){
- /* associates the ActionsList to the label */
- label = base_window_get_widget( BASE_WINDOW( instance ), "ActionsListLabel" );
- gtk_label_set_mnemonic_widget( GTK_LABEL( label ), GTK_WIDGET( treeview ));
+ treeview = get_actions_list_treeview( instance );
- nact_iactions_list_set_dnd_mode( instance, FALSE );
- nact_iactions_list_set_multiple_selection_mode( instance, FALSE );
- nact_iactions_list_set_only_actions_mode( instance, FALSE );
- set_selection_changed_mode( instance, FALSE );
+ /* associates the ActionsList to the label */
+ label = base_window_get_widget( BASE_WINDOW( instance ), "ActionsListLabel" );
+ gtk_label_set_mnemonic_widget( GTK_LABEL( label ), GTK_WIDGET( treeview ));
- nact_tree_model_initial_load( BASE_WINDOW( instance ), treeview );
+ nact_iactions_list_set_dnd_mode( instance, FALSE );
+ nact_iactions_list_set_multiple_selection_mode( instance, FALSE );
+ nact_iactions_list_set_only_actions_mode( instance, FALSE );
+ set_selection_changed_mode( instance, FALSE );
- gtk_tree_view_set_enable_tree_lines( treeview, TRUE );
+ nact_tree_model_initial_load( BASE_WINDOW( instance ), treeview );
- /* create visible columns on the tree view
- */
- column = gtk_tree_view_column_new_with_attributes(
- "icon", gtk_cell_renderer_pixbuf_new(), "pixbuf", IACTIONS_LIST_ICON_COLUMN, NULL );
- gtk_tree_view_append_column( treeview, column );
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title( column, "label" );
- gtk_tree_view_column_set_sort_column_id( column, IACTIONS_LIST_LABEL_COLUMN );
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start( column, renderer, TRUE );
- gtk_tree_view_column_set_cell_data_func(
- column, renderer, ( GtkTreeCellDataFunc ) display_label, instance, NULL );
- gtk_tree_view_append_column( treeview, column );
+ gtk_tree_view_set_enable_tree_lines( treeview, TRUE );
+
+ /* create visible columns on the tree view
+ */
+ column = gtk_tree_view_column_new_with_attributes(
+ "icon", gtk_cell_renderer_pixbuf_new(), "pixbuf", IACTIONS_LIST_ICON_COLUMN, NULL );
+ gtk_tree_view_append_column( treeview, column );
+
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title( column, "label" );
+ gtk_tree_view_column_set_sort_column_id( column, IACTIONS_LIST_LABEL_COLUMN );
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start( column, renderer, TRUE );
+ gtk_tree_view_column_set_cell_data_func(
+ column, renderer, ( GtkTreeCellDataFunc ) display_label, instance, NULL );
+ gtk_tree_view_append_column( treeview, column );
+ }
}
/**
@@ -356,70 +359,73 @@ nact_iactions_list_runtime_init_toplevel( NactIActionsList *instance, GList *ite
thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- have_dnd = have_dnd_mode( instance );
+ if( st_initialized && !st_finalized ){
- have_filter_selection = have_filter_selection_mode( instance );
- if( have_filter_selection ){
- selection = gtk_tree_view_get_selection( treeview );
- gtk_tree_selection_set_select_function( selection, ( GtkTreeSelectionFunc ) filter_selection, instance, NULL );
- }
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ have_dnd = have_dnd_mode( instance );
- nact_tree_model_runtime_init( model, have_dnd );
-
- /* set up selection control */
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( gtk_tree_view_get_selection( treeview )),
- "changed",
- G_CALLBACK( on_treeview_selection_changed ));
-
- /* catch press 'Enter' */
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( treeview ),
- "key-press-event",
- G_CALLBACK( on_key_pressed_event ));
-
- /* catch double-click */
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( treeview ),
- "button-press-event",
- G_CALLBACK( on_button_press_event ));
-
- /* install a virtual function as 'selection-changed' handler */
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- IACTIONS_LIST_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_iactions_list_selection_changed ));
-
- /* updates the treeview display when an item is modified */
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- IACTIONS_LIST_SIGNAL_ITEM_UPDATED,
- G_CALLBACK( on_iactions_list_item_updated_treeview ));
-
- /* install a virtual function as 'item-updated' handler */
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- IACTIONS_LIST_SIGNAL_ITEM_UPDATED,
- G_CALLBACK( on_iactions_list_item_updated ));
-
- /* records NactIActionsList as a proxy for edition status modification
- */
- na_iduplicable_register_consumer( G_OBJECT( instance ));
- g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_MODIFIED_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
- g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_VALID_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
+ have_filter_selection = have_filter_selection_mode( instance );
+ if( have_filter_selection ){
+ selection = gtk_tree_view_get_selection( treeview );
+ gtk_tree_selection_set_select_function( selection, ( GtkTreeSelectionFunc ) filter_selection, instance, NULL );
+ }
- /* fill the model after having connected the signals
- * so that callbacks are triggered at last
- */
- nact_iactions_list_fill( instance, items );
+ nact_tree_model_runtime_init( model, have_dnd );
+
+ /* set up selection control */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( gtk_tree_view_get_selection( treeview )),
+ "changed",
+ G_CALLBACK( on_treeview_selection_changed ));
+
+ /* catch press 'Enter' */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( treeview ),
+ "key-press-event",
+ G_CALLBACK( on_key_pressed_event ));
+
+ /* catch double-click */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( treeview ),
+ "button-press-event",
+ G_CALLBACK( on_button_press_event ));
+
+ /* install a virtual function as 'selection-changed' handler */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( instance ),
+ IACTIONS_LIST_SIGNAL_SELECTION_CHANGED,
+ G_CALLBACK( on_iactions_list_selection_changed ));
+
+ /* updates the treeview display when an item is modified */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( instance ),
+ IACTIONS_LIST_SIGNAL_ITEM_UPDATED,
+ G_CALLBACK( on_iactions_list_item_updated_treeview ));
+
+ /* install a virtual function as 'item-updated' handler */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( instance ),
+ IACTIONS_LIST_SIGNAL_ITEM_UPDATED,
+ G_CALLBACK( on_iactions_list_item_updated ));
+
+ /* records NactIActionsList as a proxy for edition status modification
+ */
+ na_iduplicable_register_consumer( G_OBJECT( instance ));
+ g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_MODIFIED_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
+ g_signal_override_class_handler( NA_IDUPLICABLE_SIGNAL_VALID_CHANGED, BASE_WINDOW_TYPE, G_CALLBACK( on_edition_status_changed ));
+
+ /* fill the model after having connected the signals
+ * so that callbacks are triggered at last
+ */
+ nact_iactions_list_fill( instance, items );
+ }
}
/**
@@ -432,6 +438,10 @@ nact_iactions_list_all_widgets_showed( NactIActionsList *instance )
static const gchar *thisfn = "nact_iactions_list_all_widgets_showed";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
/**
@@ -446,11 +456,15 @@ nact_iactions_list_dispose( NactIActionsList *instance )
NactTreeModel *model;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ if( st_initialized && !st_finalized ){
- nact_tree_model_dispose( model );
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+
+ nact_tree_model_dispose( model );
+ }
}
/**
@@ -473,26 +487,29 @@ nact_iactions_list_delete_selection( NactIActionsList *instance )
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
- treeview = get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- selected = gtk_tree_selection_get_selected_rows( selection, &model );
+ if( st_initialized && !st_finalized ){
- set_selection_changed_mode( instance, FALSE );
+ treeview = get_actions_list_treeview( instance );
+ selection = gtk_tree_view_get_selection( treeview );
+ selected = gtk_tree_selection_get_selected_rows( selection, &model );
- if( g_list_length( selected )){
- path = gtk_tree_path_copy(( GtkTreePath * ) selected->data );
- nact_tree_model_remove( NACT_TREE_MODEL( model ), selected );
- }
+ set_selection_changed_mode( instance, FALSE );
- set_selection_changed_mode( instance, TRUE );
+ if( g_list_length( selected )){
+ path = gtk_tree_path_copy(( GtkTreePath * ) selected->data );
+ nact_tree_model_remove( NACT_TREE_MODEL( model ), selected );
+ }
- g_list_foreach( selected, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( selected );
+ set_selection_changed_mode( instance, TRUE );
- if( path ){
- gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
- select_row_at_path( instance, treeview, model, path );
- gtk_tree_path_free( path );
+ g_list_foreach( selected, ( GFunc ) gtk_tree_path_free, NULL );
+ g_list_free( selected );
+
+ if( path ){
+ gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
+ select_row_at_path( instance, treeview, model, path );
+ gtk_tree_path_free( path );
+ }
}
}
@@ -514,16 +531,20 @@ nact_iactions_list_fill( NactIActionsList *instance, GList *items )
gboolean only_actions;
g_debug( "%s: instance=%p, items=%p", thisfn, ( void * ) instance, ( void * ) items );
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- only_actions = nact_iactions_list_is_only_actions_mode( instance );
+ if( st_initialized && !st_finalized ){
- set_selection_changed_mode( instance, FALSE );
- nact_tree_model_fill( model, items, only_actions );
- set_selection_changed_mode( instance, TRUE );
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ only_actions = nact_iactions_list_is_only_actions_mode( instance );
+
+ set_selection_changed_mode( instance, FALSE );
+ nact_tree_model_fill( model, items, only_actions );
+ set_selection_changed_mode( instance, TRUE );
- select_first_row( instance );
+ select_first_row( instance );
+ }
}
/**
@@ -546,17 +567,20 @@ nact_iactions_list_get_item( NactIActionsList *instance, const gchar *uuid )
g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), NULL );
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ if( st_initialized && !st_finalized ){
- ito = g_new0( IdToObjectIter, 1 );
- ito->uuid = ( gchar * ) uuid;
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- nact_tree_model_iter( model, ( FnIterOnStore ) get_item_iter, ito );
+ ito = g_new0( IdToObjectIter, 1 );
+ ito->uuid = ( gchar * ) uuid;
- item = ito->object;
+ nact_tree_model_iter( model, ( FnIterOnStore ) get_item_iter, ito );
- g_free( ito );
+ item = ito->object;
+
+ g_free( ito );
+ }
return( item );
}
@@ -579,12 +603,17 @@ nact_iactions_list_get_items( NactIActionsList *instance )
g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), NULL );
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ if( st_initialized && !st_finalized ){
- nact_tree_model_iter( model, ( FnIterOnStore ) get_items_iter, &items );
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- return( g_list_reverse( items ));
+ nact_tree_model_iter( model, ( FnIterOnStore ) get_items_iter, &items );
+
+ items = g_list_reverse( items );
+ }
+
+ return( items );
}
/**
@@ -612,21 +641,28 @@ nact_iactions_list_get_selected_items( NactIActionsList *instance )
NAObject *object;
GtkTreePath *path;
- treeview = get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- listrows = gtk_tree_selection_get_selected_rows( selection, &model );
+ g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), NULL );
- for( it = listrows ; it ; it = it->next ){
- path = ( GtkTreePath * ) it->data;
- gtk_tree_model_get_iter( model, &iter, path );
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
- items = g_list_prepend( items, object );
- }
+ if( st_initialized && !st_finalized ){
- g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( listrows );
+ treeview = get_actions_list_treeview( instance );
+ selection = gtk_tree_view_get_selection( treeview );
+ listrows = gtk_tree_selection_get_selected_rows( selection, &model );
- return( g_list_reverse( items ));
+ for( it = listrows ; it ; it = it->next ){
+ path = ( GtkTreePath * ) it->data;
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ items = g_list_prepend( items, object );
+ }
+
+ g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
+ g_list_free( listrows );
+
+ items = g_list_reverse( items );
+ }
+
+ return( items );
}
/**
@@ -647,9 +683,12 @@ nact_iactions_list_has_exportable( NactIActionsList *instance )
g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), FALSE );
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- nact_tree_model_iter( model, ( FnIterOnStore ) has_exportable_iter, &has_exportable );
+ if( st_initialized && !st_finalized ){
+
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ nact_tree_model_iter( model, ( FnIterOnStore ) has_exportable_iter, &has_exportable );
+ }
return( has_exportable );
}
@@ -669,10 +708,13 @@ nact_iactions_list_has_modified_items( NactIActionsList *instance )
g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), FALSE );
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ if( st_initialized && !st_finalized ){
- nact_tree_model_iter( model, ( FnIterOnStore ) has_modified_iter, &has_modified );
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+
+ nact_tree_model_iter( model, ( FnIterOnStore ) has_modified_iter, &has_modified );
+ }
return( has_modified );
}
@@ -716,34 +758,37 @@ nact_iactions_list_insert_items( NactIActionsList *instance, GList *items, NAObj
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
g_return_if_fail( NACT_IS_WINDOW( instance ));
- treeview = get_actions_list_treeview( instance );
- model = gtk_tree_view_get_model( treeview );
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
+ if( st_initialized && !st_finalized ){
+
+ treeview = get_actions_list_treeview( instance );
+ model = gtk_tree_view_get_model( treeview );
+ g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- if( sibling ){
- insert_path = object_to_path( instance, NACT_TREE_MODEL( model ), sibling );
+ if( sibling ){
+ insert_path = object_to_path( instance, NACT_TREE_MODEL( model ), sibling );
- } else {
- selection = gtk_tree_view_get_selection( treeview );
- list_selected = gtk_tree_selection_get_selected_rows( selection, NULL );
- if( g_list_length( list_selected )){
- insert_path = gtk_tree_path_copy(( GtkTreePath * ) list_selected->data );
+ } else {
+ selection = gtk_tree_view_get_selection( treeview );
+ list_selected = gtk_tree_selection_get_selected_rows( selection, NULL );
+ if( g_list_length( list_selected )){
+ insert_path = gtk_tree_path_copy(( GtkTreePath * ) list_selected->data );
+ }
+ g_list_foreach( list_selected, ( GFunc ) gtk_tree_path_free, NULL );
+ g_list_free( list_selected );
}
- g_list_foreach( list_selected, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( list_selected );
- }
- last_path = do_insert_items( treeview, model, items, insert_path, 0, &parents );
+ last_path = do_insert_items( treeview, model, items, insert_path, 0, &parents );
- for( it = parents ; it ; it = it->next ){
- na_object_check_edition_status( it->data );
- }
+ for( it = parents ; it ; it = it->next ){
+ na_object_check_edition_status( it->data );
+ }
- gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
- select_row_at_path( instance, treeview, model, last_path );
+ gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
+ select_row_at_path( instance, treeview, model, last_path );
- gtk_tree_path_free( last_path );
- gtk_tree_path_free( insert_path );
+ gtk_tree_path_free( last_path );
+ gtk_tree_path_free( insert_path );
+ }
}
static GtkTreePath *
@@ -828,7 +873,7 @@ nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item
{
GtkTreeView *treeview;
GtkTreeModel *model;
- gboolean is_expanded;
+ gboolean is_expanded = FALSE;
GtkTreeIter iter;
gboolean iterok, stop;
NAObject *iter_object;
@@ -836,24 +881,27 @@ nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item
g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), FALSE );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), FALSE );
- treeview = get_actions_list_treeview( instance );
- model = gtk_tree_view_get_model( treeview );
- iterok = gtk_tree_model_get_iter_first( model, &iter );
- stop = FALSE;
- is_expanded = FALSE;
+ if( st_initialized && !st_finalized ){
- while( iterok && !stop ){
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, -1 );
+ treeview = get_actions_list_treeview( instance );
+ model = gtk_tree_view_get_model( treeview );
+ iterok = gtk_tree_model_get_iter_first( model, &iter );
+ stop = FALSE;
+ is_expanded = FALSE;
- if( iter_object == item ){
- GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
- is_expanded = gtk_tree_view_row_expanded( treeview, path );
- gtk_tree_path_free( path );
- stop = TRUE;
- }
+ while( iterok && !stop ){
+ gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, -1 );
+
+ if( iter_object == item ){
+ GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
+ is_expanded = gtk_tree_view_row_expanded( treeview, path );
+ gtk_tree_path_free( path );
+ stop = TRUE;
+ }
- g_object_unref( iter_object );
- iterok = gtk_tree_model_iter_next( model, &iter );
+ g_object_unref( iter_object );
+ iterok = gtk_tree_model_iter_next( model, &iter );
+ }
}
return( is_expanded );
@@ -868,7 +916,15 @@ nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item
gboolean
nact_iactions_list_is_only_actions_mode( NactIActionsList *instance )
{
- return(( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), SHOW_ONLY_ACTIONS_MODE )));
+ gboolean mode = FALSE;
+
+ g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), FALSE );
+
+ if( st_initialized && !st_finalized ){
+ mode = ( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), SHOW_ONLY_ACTIONS_MODE ));
+ }
+
+ return( mode );
}
/**
@@ -884,7 +940,11 @@ nact_iactions_list_is_only_actions_mode( NactIActionsList *instance )
void
nact_iactions_list_set_dnd_mode( NactIActionsList *instance, gboolean have_dnd )
{
- g_object_set_data( G_OBJECT( instance ), HAVE_DND_MODE, GINT_TO_POINTER( have_dnd ));
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
+
+ if( st_initialized && !st_finalized ){
+ g_object_set_data( G_OBJECT( instance ), HAVE_DND_MODE, GINT_TO_POINTER( have_dnd ));
+ }
}
/**
@@ -903,7 +963,11 @@ nact_iactions_list_set_dnd_mode( NactIActionsList *instance, gboolean have_dnd )
void
nact_iactions_list_set_filter_selection_mode( NactIActionsList *instance, gboolean filter )
{
- g_object_set_data( G_OBJECT( instance ), FILTER_SELECTION_MODE, GINT_TO_POINTER( filter ));
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
+
+ if( st_initialized && !st_finalized ){
+ g_object_set_data( G_OBJECT( instance ), FILTER_SELECTION_MODE, GINT_TO_POINTER( filter ));
+ }
}
/**
@@ -922,9 +986,14 @@ nact_iactions_list_set_multiple_selection_mode( NactIActionsList *instance, gboo
GtkTreeView *treeview;
GtkTreeSelection *selection;
- treeview = get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- gtk_tree_selection_set_mode( selection, multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE );
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ treeview = get_actions_list_treeview( instance );
+ selection = gtk_tree_view_get_selection( treeview );
+ gtk_tree_selection_set_mode( selection, multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE );
+ }
}
/**
@@ -945,7 +1014,11 @@ nact_iactions_list_set_multiple_selection_mode( NactIActionsList *instance, gboo
void
nact_iactions_list_set_only_actions_mode( NactIActionsList *instance, gboolean only_actions )
{
- g_object_set_data( G_OBJECT( instance ), SHOW_ONLY_ACTIONS_MODE, GINT_TO_POINTER( only_actions ));
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
+
+ if( st_initialized && !st_finalized ){
+ g_object_set_data( G_OBJECT( instance ), SHOW_ONLY_ACTIONS_MODE, GINT_TO_POINTER( only_actions ));
+ }
}
/*
@@ -964,36 +1037,39 @@ nact_iactions_list_toggle_collapse( NactIActionsList *instance, const NAObject *
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- treeview = get_actions_list_treeview( instance );
- model = gtk_tree_view_get_model( treeview );
- iterok = gtk_tree_model_get_iter_first( model, &iter );
- stop = FALSE;
+ if( st_initialized && !st_finalized ){
- while( iterok && !stop ){
+ treeview = get_actions_list_treeview( instance );
+ model = gtk_tree_view_get_model( treeview );
+ iterok = gtk_tree_model_get_iter_first( model, &iter );
+ stop = FALSE;
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, -1 );
- if( iter_object == item ){
+ while( iterok && !stop ){
- if( na_object_get_items_count( item ) > 1 ){
+ gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, -1 );
+ if( iter_object == item ){
- GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
+ if( na_object_get_items_count( item ) > 1 ){
- if( gtk_tree_view_row_expanded( GTK_TREE_VIEW( treeview ), path )){
- gtk_tree_view_collapse_row( GTK_TREE_VIEW( treeview ), path );
- g_debug( "%s: action=%p collapsed", thisfn, ( void * ) item );
+ GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
- } else {
- gtk_tree_view_expand_row( GTK_TREE_VIEW( treeview ), path, TRUE );
- g_debug( "%s: action=%p expanded", thisfn, ( void * ) item );
- }
+ if( gtk_tree_view_row_expanded( GTK_TREE_VIEW( treeview ), path )){
+ gtk_tree_view_collapse_row( GTK_TREE_VIEW( treeview ), path );
+ g_debug( "%s: action=%p collapsed", thisfn, ( void * ) item );
- gtk_tree_path_free( path );
+ } else {
+ gtk_tree_view_expand_row( GTK_TREE_VIEW( treeview ), path, TRUE );
+ g_debug( "%s: action=%p expanded", thisfn, ( void * ) item );
+ }
+
+ gtk_tree_path_free( path );
+ }
+ stop = TRUE;
}
- stop = TRUE;
- }
- g_object_unref( iter_object );
- iterok = gtk_tree_model_iter_next( model, &iter );
+ g_object_unref( iter_object );
+ iterok = gtk_tree_model_iter_next( model, &iter );
+ }
}
}
diff --git a/src/nact/nact-iactions-list.h b/src/nact/nact-iactions-list.h
index 3522f60..d534c5d 100644
--- a/src/nact/nact-iactions-list.h
+++ b/src/nact/nact-iactions-list.h
@@ -31,6 +31,12 @@
#ifndef __NACT_IACTIONS_LIST_H__
#define __NACT_IACTIONS_LIST_H__
+/**
+ * SECTION: nact_iactions_list
+ * @short_description: #NactIActionsList interface definition.
+ * @include: nact/nact-iactions-list.h
+ */
+
#include <common/na-object-class.h>
G_BEGIN_DECLS
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
index f60dcc9..1d92aa1 100644
--- a/src/nact/nact-iadvanced-tab.c
+++ b/src/nact/nact-iadvanced-tab.c
@@ -60,6 +60,9 @@ enum {
SCHEMES_N_COLUMN
};
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
static GType register_type( void );
static void interface_base_init( NactIAdvancedTabInterface *klass );
static void interface_base_finalize( NactIAdvancedTabInterface *klass );
@@ -128,14 +131,13 @@ static void
interface_base_init( NactIAdvancedTabInterface *klass )
{
static const gchar *thisfn = "nact_iadvanced_tab_interface_base_init";
- static gboolean initialized = FALSE;
- if( !initialized ){
+ if( !st_initialized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
klass->private = g_new0( NactIAdvancedTabInterfacePrivate, 1 );
- initialized = TRUE;
+ st_initialized = TRUE;
}
}
@@ -143,14 +145,13 @@ static void
interface_base_finalize( NactIAdvancedTabInterface *klass )
{
static const gchar *thisfn = "nact_iadvanced_tab_interface_base_finalize";
- static gboolean finalized = FALSE ;
- if( !finalized ){
+ if( !st_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
- finalized = TRUE;
+ st_finalized = TRUE;
}
}
@@ -160,8 +161,11 @@ nact_iadvanced_tab_initial_load_toplevel( NactIAdvancedTab *instance )
static const gchar *thisfn = "nact_iadvanced_tab_initial_load_toplevel";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
- initial_load_create_schemes_selection_list( instance );
+ if( st_initialized && !st_finalized ){
+ initial_load_create_schemes_selection_list( instance );
+ }
}
/*
@@ -179,37 +183,41 @@ initial_load_create_schemes_selection_list( NactIAdvancedTab *instance )
GtkCellRenderer *text_cell;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
- model = gtk_list_store_new( SCHEMES_N_COLUMN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING );
- listview = get_schemes_tree_view( instance );
- gtk_tree_view_set_model( listview, GTK_TREE_MODEL( model ));
- g_object_unref( model );
-
- toggled_cell = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes(
- "scheme-selected",
- toggled_cell,
- "active", SCHEMES_CHECKBOX_COLUMN,
- NULL );
- gtk_tree_view_append_column( listview, column );
-
- text_cell = gtk_cell_renderer_text_new();
- g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
- column = gtk_tree_view_column_new_with_attributes(
- "scheme-code",
- text_cell,
- "text", SCHEMES_KEYWORD_COLUMN,
- NULL );
- gtk_tree_view_append_column( listview, column );
-
- text_cell = gtk_cell_renderer_text_new();
- g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
- column = gtk_tree_view_column_new_with_attributes(
- "scheme-description",
- text_cell,
- "text", SCHEMES_DESC_COLUMN,
- NULL );
- gtk_tree_view_append_column( listview, column );
+ if( st_initialized && !st_finalized ){
+
+ model = gtk_list_store_new( SCHEMES_N_COLUMN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING );
+ listview = get_schemes_tree_view( instance );
+ gtk_tree_view_set_model( listview, GTK_TREE_MODEL( model ));
+ g_object_unref( model );
+
+ toggled_cell = gtk_cell_renderer_toggle_new();
+ column = gtk_tree_view_column_new_with_attributes(
+ "scheme-selected",
+ toggled_cell,
+ "active", SCHEMES_CHECKBOX_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( listview, column );
+
+ text_cell = gtk_cell_renderer_text_new();
+ g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
+ column = gtk_tree_view_column_new_with_attributes(
+ "scheme-code",
+ text_cell,
+ "text", SCHEMES_KEYWORD_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( listview, column );
+
+ text_cell = gtk_cell_renderer_text_new();
+ g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
+ column = gtk_tree_view_column_new_with_attributes(
+ "scheme-description",
+ text_cell,
+ "text", SCHEMES_DESC_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( listview, column );
+ }
}
void
@@ -219,12 +227,16 @@ nact_iadvanced_tab_runtime_init_toplevel( NactIAdvancedTab *instance )
GtkTreeView *listview;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
- listview = get_schemes_tree_view( instance );
+ if( st_initialized && !st_finalized ){
+
+ listview = get_schemes_tree_view( instance );
- runtime_init_connect_signals( instance, listview );
+ runtime_init_connect_signals( instance, listview );
- runtime_init_setup_values( instance, listview );
+ runtime_init_setup_values( instance, listview );
+ }
}
static void
@@ -236,56 +248,60 @@ runtime_init_connect_signals( NactIAdvancedTab *instance, GtkTreeView *listview
GtkButton *add_button, *remove_button;
g_debug( "%s: instance=%p, listview=%p", thisfn, ( void * ) instance, ( void * ) listview );
-
- column = gtk_tree_view_get_column( listview, SCHEMES_CHECKBOX_COLUMN );
- renderers = gtk_tree_view_column_get_cell_renderers( column );
- g_signal_connect(
- G_OBJECT( renderers->data ),
- "toggled",
- G_CALLBACK( on_scheme_selection_toggled ),
- instance );
-
- column = gtk_tree_view_get_column( listview, SCHEMES_KEYWORD_COLUMN );
- renderers = gtk_tree_view_column_get_cell_renderers( column );
- g_signal_connect(
- G_OBJECT( renderers->data ),
- "edited",
- G_CALLBACK( on_scheme_keyword_edited ),
- instance );
-
- column = gtk_tree_view_get_column( listview, SCHEMES_DESC_COLUMN );
- renderers = gtk_tree_view_column_get_cell_renderers( column );
- g_signal_connect(
- G_OBJECT( renderers->data ),
- "edited",
- G_CALLBACK( on_scheme_desc_edited ),
- instance );
-
- add_button = get_add_button( instance );
- g_signal_connect(
- G_OBJECT( add_button ),
- "clicked",
- G_CALLBACK( on_add_scheme_clicked ),
- instance );
-
- remove_button = get_remove_button( instance );
- g_signal_connect(
- G_OBJECT( remove_button ),
- "clicked",
- G_CALLBACK( on_remove_scheme_clicked ),
- instance );
-
- g_signal_connect(
- G_OBJECT( gtk_tree_view_get_selection( listview )),
- "changed",
- G_CALLBACK( on_scheme_list_selection_changed ),
- instance );
-
- g_signal_connect(
- G_OBJECT( instance ),
- TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_tab_updatable_selection_changed ),
- instance );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ column = gtk_tree_view_get_column( listview, SCHEMES_CHECKBOX_COLUMN );
+ renderers = gtk_tree_view_column_get_cell_renderers( column );
+ g_signal_connect(
+ G_OBJECT( renderers->data ),
+ "toggled",
+ G_CALLBACK( on_scheme_selection_toggled ),
+ instance );
+
+ column = gtk_tree_view_get_column( listview, SCHEMES_KEYWORD_COLUMN );
+ renderers = gtk_tree_view_column_get_cell_renderers( column );
+ g_signal_connect(
+ G_OBJECT( renderers->data ),
+ "edited",
+ G_CALLBACK( on_scheme_keyword_edited ),
+ instance );
+
+ column = gtk_tree_view_get_column( listview, SCHEMES_DESC_COLUMN );
+ renderers = gtk_tree_view_column_get_cell_renderers( column );
+ g_signal_connect(
+ G_OBJECT( renderers->data ),
+ "edited",
+ G_CALLBACK( on_scheme_desc_edited ),
+ instance );
+
+ add_button = get_add_button( instance );
+ g_signal_connect(
+ G_OBJECT( add_button ),
+ "clicked",
+ G_CALLBACK( on_add_scheme_clicked ),
+ instance );
+
+ remove_button = get_remove_button( instance );
+ g_signal_connect(
+ G_OBJECT( remove_button ),
+ "clicked",
+ G_CALLBACK( on_remove_scheme_clicked ),
+ instance );
+
+ g_signal_connect(
+ G_OBJECT( gtk_tree_view_get_selection( listview )),
+ "changed",
+ G_CALLBACK( on_scheme_list_selection_changed ),
+ instance );
+
+ g_signal_connect(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+ G_CALLBACK( on_tab_updatable_selection_changed ),
+ instance );
+ }
}
static void
@@ -299,24 +315,28 @@ runtime_init_setup_values( NactIAdvancedTab *instance, GtkTreeView *listview )
gchar **tokens;
g_debug( "%s: instance=%p, listview=%p", thisfn, ( void * ) instance, ( void * ) listview );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
- model = GTK_LIST_STORE( gtk_tree_view_get_model( listview ));
+ if( st_initialized && !st_finalized ){
- schemes_list = get_schemes_default_list( instance );
+ model = GTK_LIST_STORE( gtk_tree_view_get_model( listview ));
- for( iter = schemes_list ; iter ; iter = iter->next ){
+ schemes_list = get_schemes_default_list( instance );
- tokens = g_strsplit(( gchar * ) iter->data, "|", 2 );
- gtk_list_store_append( model, &row );
- gtk_list_store_set( model, &row,
- SCHEMES_CHECKBOX_COLUMN, FALSE,
- SCHEMES_KEYWORD_COLUMN, tokens[0],
- SCHEMES_DESC_COLUMN, tokens[1],
- -1 );
- g_strfreev( tokens );
- }
+ for( iter = schemes_list ; iter ; iter = iter->next ){
- na_utils_free_string_list( schemes_list );
+ tokens = g_strsplit(( gchar * ) iter->data, "|", 2 );
+ gtk_list_store_append( model, &row );
+ gtk_list_store_set( model, &row,
+ SCHEMES_CHECKBOX_COLUMN, FALSE,
+ SCHEMES_KEYWORD_COLUMN, tokens[0],
+ SCHEMES_DESC_COLUMN, tokens[1],
+ -1 );
+ g_strfreev( tokens );
+ }
+
+ na_utils_free_string_list( schemes_list );
+ }
}
void
@@ -325,6 +345,10 @@ nact_iadvanced_tab_all_widgets_showed( NactIAdvancedTab *instance )
static const gchar *thisfn = "nact_iadvanced_tab_all_widgets_showed";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
void
@@ -333,7 +357,10 @@ nact_iadvanced_tab_dispose( NactIAdvancedTab *instance )
static const gchar *thisfn = "nact_iadvanced_tab_dispose";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
-}
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
/**
* Returns selected schemes as a list of strings.
@@ -345,8 +372,12 @@ nact_iadvanced_tab_get_schemes( NactIAdvancedTab *instance )
GSList *list = NULL;
GtkTreeModel* scheme_model;
- scheme_model = get_schemes_tree_model( instance );
- gtk_tree_model_foreach( scheme_model, ( GtkTreeModelForeachFunc ) get_action_schemes_list, &list );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ scheme_model = get_schemes_tree_model( instance );
+ gtk_tree_model_foreach( scheme_model, ( GtkTreeModelForeachFunc ) get_action_schemes_list, &list );
+ }
return( list );
}
@@ -362,28 +393,32 @@ on_tab_updatable_selection_changed( NactIAdvancedTab *instance, gint count_selec
GtkButton *add, *remove;
g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
+ g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
- scheme_model = get_schemes_tree_model( instance );
- gtk_tree_model_foreach( scheme_model, ( GtkTreeModelForeachFunc ) reset_schemes_list, NULL );
+ if( st_initialized && !st_finalized ){
- g_object_get(
- G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
- NULL );
+ scheme_model = get_schemes_tree_model( instance );
+ gtk_tree_model_foreach( scheme_model, ( GtkTreeModelForeachFunc ) reset_schemes_list, NULL );
- if( profile ){
- schemes = na_object_profile_get_schemes( profile );
- g_slist_foreach( schemes, ( GFunc ) set_action_schemes, scheme_model );
- }
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
+ NULL );
- listview = get_schemes_tree_view( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( listview ), profile != NULL );
+ if( profile ){
+ schemes = na_object_profile_get_schemes( profile );
+ g_slist_foreach( schemes, ( GFunc ) set_action_schemes, scheme_model );
+ }
- add = get_add_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( add ), profile != NULL );
+ listview = get_schemes_tree_view( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( listview ), profile != NULL );
- remove = get_remove_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( remove ), profile != NULL );
+ add = get_add_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( add ), profile != NULL );
+
+ remove = get_remove_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( remove ), profile != NULL );
+ }
}
/*
diff --git a/src/nact/nact-iadvanced-tab.h b/src/nact/nact-iadvanced-tab.h
index 5a5bb4d..a0ba8cf 100644
--- a/src/nact/nact-iadvanced-tab.h
+++ b/src/nact/nact-iadvanced-tab.h
@@ -31,8 +31,10 @@
#ifndef __NACT_IADVANCED_TAB_H__
#define __NACT_IADVANCED_TAB_H__
-/*
- * NactIAdvancedTab interface definition.
+/**
+ * SECTION: nact_iadvanced_tab
+ * @short_description: #NactIAdvancedTab interface declaration.
+ * @include: nact/nact-iadvanced-tab.h
*
* This interface implements all the widgets which define the
* conditions for the action.
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index e74106e..a8f487e 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -65,6 +65,9 @@ struct NactICommandTabInterfacePrivate {
#define ICOMMAND_TAB_LEGEND_VISIBLE "nact-icommand-tab-legend-dialog-visible"
#define ICOMMAND_TAB_STATUSBAR_CONTEXT "nact-icommand-tab-statusbar-context"
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
static GType register_type( void );
static void interface_base_init( NactICommandTabInterface *klass );
static void interface_base_finalize( NactICommandTabInterface *klass );
@@ -131,14 +134,13 @@ static void
interface_base_init( NactICommandTabInterface *klass )
{
static const gchar *thisfn = "nact_icommand_tab_interface_base_init";
- static gboolean initialized = FALSE;
- if( !initialized ){
+ if( !st_initialized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
klass->private = g_new0( NactICommandTabInterfacePrivate, 1 );
- initialized = TRUE;
+ st_initialized = TRUE;
}
}
@@ -146,14 +148,13 @@ static void
interface_base_finalize( NactICommandTabInterface *klass )
{
static const gchar *thisfn = "nact_icommand_tab_interface_base_finalize";
- static gboolean finalized = FALSE ;
- if( !finalized ){
+ if( !st_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
- finalized = TRUE;
+ st_finalized = TRUE;
}
}
@@ -173,10 +174,14 @@ nact_icommand_tab_initial_load_toplevel( NactICommandTab *instance )
static const gchar *thisfn = "nact_icommand_tab_initial_load_toplevel";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
- base_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-legend-dialog", IPREFS_LEGEND_DIALOG );
- base_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-command-chooser", IPREFS_COMMAND_CHOOSER );
- base_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-folder-uri", IPREFS_FOLDER_URI );
+ base_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-legend-dialog", IPREFS_LEGEND_DIALOG );
+ base_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-command-chooser", IPREFS_COMMAND_CHOOSER );
+ base_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-folder-uri", IPREFS_FOLDER_URI );
+ }
}
/**
@@ -194,47 +199,51 @@ nact_icommand_tab_runtime_init_toplevel( NactICommandTab *instance )
GtkButton *path_button, *legend_button;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ label_entry = get_label_entry( instance );
+ g_signal_connect(
+ G_OBJECT( label_entry ),
+ "changed",
+ G_CALLBACK( on_label_changed ),
+ instance );
+
+ path_entry = get_path_entry( instance );
+ g_signal_connect(
+ G_OBJECT( path_entry ),
+ "changed",
+ G_CALLBACK( on_path_changed ),
+ instance );
+
+ path_button = get_path_button( instance );
+ g_signal_connect(
+ G_OBJECT( path_button ),
+ "clicked",
+ G_CALLBACK( on_path_browse ),
+ instance );
+
+ parameters_entry = get_parameters_entry( instance );
+ g_signal_connect(
+ G_OBJECT( parameters_entry ),
+ "changed",
+ G_CALLBACK( on_parameters_changed ),
+ instance );
- label_entry = get_label_entry( instance );
- g_signal_connect(
- G_OBJECT( label_entry ),
- "changed",
- G_CALLBACK( on_label_changed ),
- instance );
-
- path_entry = get_path_entry( instance );
- g_signal_connect(
- G_OBJECT( path_entry ),
- "changed",
- G_CALLBACK( on_path_changed ),
- instance );
-
- path_button = get_path_button( instance );
- g_signal_connect(
- G_OBJECT( path_button ),
- "clicked",
- G_CALLBACK( on_path_browse ),
- instance );
-
- parameters_entry = get_parameters_entry( instance );
- g_signal_connect(
- G_OBJECT( parameters_entry ),
- "changed",
- G_CALLBACK( on_parameters_changed ),
- instance );
-
- legend_button = get_legend_button( instance );
- g_signal_connect(
- G_OBJECT( legend_button ),
- "clicked",
- G_CALLBACK( on_legend_clicked ),
- instance );
-
- g_signal_connect(
- G_OBJECT( instance ),
- TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_tab_updatable_selection_changed ),
- instance );
+ legend_button = get_legend_button( instance );
+ g_signal_connect(
+ G_OBJECT( legend_button ),
+ "clicked",
+ G_CALLBACK( on_legend_clicked ),
+ instance );
+
+ g_signal_connect(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+ G_CALLBACK( on_tab_updatable_selection_changed ),
+ instance );
+ }
}
void
@@ -243,6 +252,10 @@ nact_icommand_tab_all_widgets_showed( NactICommandTab *instance )
static const gchar *thisfn = "nact_icommand_tab_all_widgets_showed";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
/**
@@ -257,8 +270,11 @@ nact_icommand_tab_dispose( NactICommandTab *instance )
static const gchar *thisfn = "nact_icommand_tab_dispose";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
- legend_dialog_hide( instance );
+ if( st_initialized && !st_finalized ){
+ legend_dialog_hide( instance );
+ }
}
/**
@@ -268,9 +284,20 @@ nact_icommand_tab_dispose( NactICommandTab *instance )
gboolean
nact_icommand_tab_has_label( NactICommandTab *instance )
{
- GtkWidget *label_entry = get_label_entry( instance );
- const gchar *label = gtk_entry_get_text( GTK_ENTRY( label_entry ));
- return( g_utf8_strlen( label, -1 ) > 0 );
+ gboolean has_label = FALSE;
+ GtkWidget *label_entry;
+ const gchar *label;
+
+ g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ label_entry = get_label_entry( instance );
+ label = gtk_entry_get_text( GTK_ENTRY( label_entry ));
+ has_label = ( g_utf8_strlen( label, -1 ) > 0 );
+ }
+
+ return( has_label );
}
static void
@@ -283,36 +310,40 @@ on_tab_updatable_selection_changed( NactICommandTab *instance, gint count_select
GtkButton *path_button, *legend_button;
g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
+ g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
+ NULL );
+
+ label_entry = get_label_entry( instance );
+ label = profile ? na_object_get_label( profile ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( label_entry ), label );
+ gtk_widget_set_sensitive( label_entry, profile != NULL );
+ check_for_label( instance, GTK_ENTRY( label_entry ), label );
+ g_free( label );
+
+ path_entry = get_path_entry( instance );
+ path = profile ? na_object_profile_get_path( profile ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( path_entry ), path );
+ gtk_widget_set_sensitive( path_entry, profile != NULL );
+ g_free( path );
+
+ parameters_entry = get_parameters_entry( instance );
+ parameters = profile ? na_object_profile_get_parameters( profile ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( parameters_entry ), parameters );
+ gtk_widget_set_sensitive( parameters_entry, profile != NULL );
+ g_free( parameters );
- g_object_get(
- G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
- NULL );
-
- label_entry = get_label_entry( instance );
- label = profile ? na_object_get_label( profile ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( label_entry ), label );
- gtk_widget_set_sensitive( label_entry, profile != NULL );
- check_for_label( instance, GTK_ENTRY( label_entry ), label );
- g_free( label );
+ path_button = get_path_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( path_button ), profile != NULL );
- path_entry = get_path_entry( instance );
- path = profile ? na_object_profile_get_path( profile ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( path_entry ), path );
- gtk_widget_set_sensitive( path_entry, profile != NULL );
- g_free( path );
-
- parameters_entry = get_parameters_entry( instance );
- parameters = profile ? na_object_profile_get_parameters( profile ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( parameters_entry ), parameters );
- gtk_widget_set_sensitive( parameters_entry, profile != NULL );
- g_free( parameters );
-
- path_button = get_path_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( path_button ), profile != NULL );
-
- legend_button = get_legend_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile != NULL );
+ legend_button = get_legend_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile != NULL );
+ }
}
static void
diff --git a/src/nact/nact-icommand-tab.h b/src/nact/nact-icommand-tab.h
index 98e7203..0cbc9cf 100644
--- a/src/nact/nact-icommand-tab.h
+++ b/src/nact/nact-icommand-tab.h
@@ -31,10 +31,13 @@
#ifndef __NACT_ICOMMAND_TAB_H__
#define __NACT_ICOMMAND_TAB_H__
-/*
- * NactICommandTab interface definition.
+/**
+ * SECTION: nact_icommand_tab
+ * @short_description: #NactICommandTab interface declaration.
+ * @include: nact/nact-icommand-tab.h
*
- * This interface implements the "Nautilus Menu Item" box.
+ * This interface implements all the widgets which define the
+ * actual action to be executed.
*/
#include <glib-object.h>
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
index 8642064..b0d23c3 100644
--- a/src/nact/nact-iconditions-tab.c
+++ b/src/nact/nact-iconditions-tab.c
@@ -51,6 +51,9 @@ struct NactIConditionsTabInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
static GType register_type( void );
static void interface_base_init( NactIConditionsTabInterface *klass );
static void interface_base_finalize( NactIConditionsTabInterface *klass );
@@ -113,14 +116,13 @@ static void
interface_base_init( NactIConditionsTabInterface *klass )
{
static const gchar *thisfn = "nact_iconditions_tab_interface_base_init";
- static gboolean initialized = FALSE;
- if( !initialized ){
+ if( !st_initialized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
klass->private = g_new0( NactIConditionsTabInterfacePrivate, 1 );
- initialized = TRUE;
+ st_initialized = TRUE;
}
}
@@ -128,14 +130,13 @@ static void
interface_base_finalize( NactIConditionsTabInterface *klass )
{
static const gchar *thisfn = "nact_iconditions_tab_interface_base_finalize";
- static gboolean finalized = FALSE ;
- if( !finalized ){
+ if( !st_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
g_free( klass->private );
- finalized = TRUE;
+ st_finalized = TRUE;
}
}
@@ -145,6 +146,10 @@ nact_iconditions_tab_initial_load_toplevel( NactIConditionsTab *instance )
static const gchar *thisfn = "nact_iconditions_tab_initial_load_toplevel";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
void
@@ -158,61 +163,65 @@ nact_iconditions_tab_runtime_init_toplevel( NactIConditionsTab *instance )
GtkButton *multiple_button;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
-
- basenames_widget = get_basenames_entry( instance );
- g_signal_connect(
- G_OBJECT( basenames_widget ),
- "changed",
- G_CALLBACK( on_basenames_changed ),
- instance );
-
- matchcase_button = get_matchcase_button( instance );
- g_signal_connect(
- G_OBJECT( matchcase_button ),
- "toggled",
- G_CALLBACK( on_matchcase_toggled ),
- instance );
-
- mimetypes_widget = get_mimetypes_entry( instance );
- g_signal_connect(
- G_OBJECT( mimetypes_widget ),
- "changed",
- G_CALLBACK( on_mimetypes_changed ),
- instance );
-
- isfile_button = get_isfile_button( instance );
- g_signal_connect(
- G_OBJECT( isfile_button ),
- "toggled",
- G_CALLBACK( on_isfiledir_toggled ),
- instance );
-
- isdir_button = get_isdir_button( instance );
- g_signal_connect(
- G_OBJECT( isdir_button ),
- "toggled",
- G_CALLBACK( on_isfiledir_toggled ),
- instance );
-
- both_button = get_both_button( instance );
- g_signal_connect(
- G_OBJECT( both_button ),
- "toggled",
- G_CALLBACK( on_isfiledir_toggled ),
- instance );
-
- multiple_button = get_multiple_button( instance );
- g_signal_connect(
- G_OBJECT( multiple_button ),
- "toggled",
- G_CALLBACK( on_multiple_toggled ),
- instance );
-
- g_signal_connect(
- G_OBJECT( instance ),
- TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
- G_CALLBACK( on_tab_updatable_selection_changed ),
- instance );
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ basenames_widget = get_basenames_entry( instance );
+ g_signal_connect(
+ G_OBJECT( basenames_widget ),
+ "changed",
+ G_CALLBACK( on_basenames_changed ),
+ instance );
+
+ matchcase_button = get_matchcase_button( instance );
+ g_signal_connect(
+ G_OBJECT( matchcase_button ),
+ "toggled",
+ G_CALLBACK( on_matchcase_toggled ),
+ instance );
+
+ mimetypes_widget = get_mimetypes_entry( instance );
+ g_signal_connect(
+ G_OBJECT( mimetypes_widget ),
+ "changed",
+ G_CALLBACK( on_mimetypes_changed ),
+ instance );
+
+ isfile_button = get_isfile_button( instance );
+ g_signal_connect(
+ G_OBJECT( isfile_button ),
+ "toggled",
+ G_CALLBACK( on_isfiledir_toggled ),
+ instance );
+
+ isdir_button = get_isdir_button( instance );
+ g_signal_connect(
+ G_OBJECT( isdir_button ),
+ "toggled",
+ G_CALLBACK( on_isfiledir_toggled ),
+ instance );
+
+ both_button = get_both_button( instance );
+ g_signal_connect(
+ G_OBJECT( both_button ),
+ "toggled",
+ G_CALLBACK( on_isfiledir_toggled ),
+ instance );
+
+ multiple_button = get_multiple_button( instance );
+ g_signal_connect(
+ G_OBJECT( multiple_button ),
+ "toggled",
+ G_CALLBACK( on_multiple_toggled ),
+ instance );
+
+ g_signal_connect(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+ G_CALLBACK( on_tab_updatable_selection_changed ),
+ instance );
+ }
}
void
@@ -221,6 +230,10 @@ nact_iconditions_tab_all_widgets_showed( NactIConditionsTab *instance )
static const gchar *thisfn = "nact_iconditions_tab_all_widgets_showed";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
void
@@ -229,6 +242,10 @@ nact_iconditions_tab_dispose( NactIConditionsTab *instance )
static const gchar *thisfn = "nact_iconditions_tab_dispose";
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ }
}
void
@@ -236,24 +253,37 @@ nact_iconditions_tab_get_isfiledir( NactIConditionsTab *instance, gboolean *isfi
{
gboolean both;
- g_assert( isfile );
- g_assert( isdir );
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
+ g_return_if_fail( isfile );
+ g_return_if_fail( isdir );
+
+ if( st_initialized && !st_finalized ){
- both = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_both_button( instance )));
- if( both ){
- *isfile = TRUE;
- *isdir = TRUE;
- } else {
- *isfile = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isfile_button( instance )));
- *isdir = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isdir_button( instance )));
+ both = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_both_button( instance )));
+ if( both ){
+ *isfile = TRUE;
+ *isdir = TRUE;
+ } else {
+ *isfile = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isfile_button( instance )));
+ *isdir = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isdir_button( instance )));
+ }
}
}
gboolean
nact_iconditions_tab_get_multiple( NactIConditionsTab *instance )
{
- GtkButton *button = get_multiple_button( instance );
- return( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button )));
+ gboolean multiple = FALSE;
+ GtkButton *button;
+
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
+
+ if( st_initialized && !st_finalized ){
+ button = get_multiple_button( instance );
+ multiple = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
+ }
+
+ return( multiple );
}
static void
@@ -272,47 +302,50 @@ on_tab_updatable_selection_changed( NactIConditionsTab *instance, gint count_sel
gboolean multiple;
g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
+ g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
- g_object_get(
- G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
- NULL );
+ if( st_initialized && !st_finalized ){
+
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
+ NULL );
- basenames_widget = get_basenames_entry( instance );
- basenames = profile ? na_object_profile_get_basenames( profile ) : NULL;
- basenames_text = profile ? na_utils_string_list_to_text( basenames ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( basenames_widget ), basenames_text );
- g_free( basenames_text );
- na_utils_free_string_list( basenames );
- gtk_widget_set_sensitive( basenames_widget, profile != NULL );
-
- matchcase_button = get_matchcase_button( instance );
- matchcase = profile ? na_object_profile_get_matchcase( profile ) : FALSE;
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( matchcase_button ), matchcase );
- gtk_widget_set_sensitive( GTK_WIDGET( matchcase_button ), profile != NULL );
-
- mimetypes_widget = get_mimetypes_entry( instance );
- mimetypes = profile ? na_object_profile_get_mimetypes( profile ) : NULL;
- mimetypes_text = profile ? na_utils_string_list_to_text( mimetypes ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( mimetypes_widget ), mimetypes_text );
- g_free( mimetypes_text );
- na_utils_free_string_list( mimetypes );
- gtk_widget_set_sensitive( mimetypes_widget, profile != NULL );
-
- isfile = profile ? na_object_profile_get_is_file( profile ) : FALSE;
- isdir = profile ? na_object_profile_get_is_dir( profile ) : FALSE;
- set_isfiledir( instance, isfile, isdir );
- files_button = get_isfile_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( files_button ), profile != NULL );
- dir_button = get_isdir_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( dir_button ), profile != NULL );
- both_button = get_both_button( instance );
- gtk_widget_set_sensitive( GTK_WIDGET( both_button ), profile != NULL );
-
- multiple_button = get_multiple_button( instance );
- multiple = profile ? na_object_profile_get_multiple( profile ) : FALSE;
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( multiple_button ), multiple );
- gtk_widget_set_sensitive( GTK_WIDGET( multiple_button ), profile != NULL );
+ basenames_widget = get_basenames_entry( instance );
+ basenames = profile ? na_object_profile_get_basenames( profile ) : NULL;
+ basenames_text = profile ? na_utils_string_list_to_text( basenames ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( basenames_widget ), basenames_text );
+ g_free( basenames_text );
+ na_utils_free_string_list( basenames );
+ gtk_widget_set_sensitive( basenames_widget, profile != NULL );
+
+ matchcase_button = get_matchcase_button( instance );
+ matchcase = profile ? na_object_profile_get_matchcase( profile ) : FALSE;
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( matchcase_button ), matchcase );
+ gtk_widget_set_sensitive( GTK_WIDGET( matchcase_button ), profile != NULL );
+
+ mimetypes_widget = get_mimetypes_entry( instance );
+ mimetypes = profile ? na_object_profile_get_mimetypes( profile ) : NULL;
+ mimetypes_text = profile ? na_utils_string_list_to_text( mimetypes ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( mimetypes_widget ), mimetypes_text );
+ g_free( mimetypes_text );
+ na_utils_free_string_list( mimetypes );
+ gtk_widget_set_sensitive( mimetypes_widget, profile != NULL );
+
+ isfile = profile ? na_object_profile_get_is_file( profile ) : FALSE;
+ isdir = profile ? na_object_profile_get_is_dir( profile ) : FALSE;
+ set_isfiledir( instance, isfile, isdir );
+ files_button = get_isfile_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( files_button ), profile != NULL );
+ dir_button = get_isdir_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( dir_button ), profile != NULL );
+ both_button = get_both_button( instance );
+ gtk_widget_set_sensitive( GTK_WIDGET( both_button ), profile != NULL );
+
+ multiple_button = get_multiple_button( instance );
+ multiple = profile ? na_object_profile_get_multiple( profile ) : FALSE;
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( multiple_button ), multiple );
+ gtk_widget_set_sensitive( GTK_WIDGET( multiple_button ), profile != NULL );
}
static GtkWidget *
diff --git a/src/nact/nact-iconditions-tab.h b/src/nact/nact-iconditions-tab.h
index e060bab..89a6555 100644
--- a/src/nact/nact-iconditions-tab.h
+++ b/src/nact/nact-iconditions-tab.h
@@ -31,8 +31,10 @@
#ifndef __NACT_ICONDITIONS_TAB_H__
#define __NACT_ICONDITIONS_TAB_H__
-/*
- * NactIConditions_Tab interface definition.
+/**
+ * SECTION: nact_iconditionstab
+ * @short_description: #NactIConditionsTab interface declaration.
+ * @include: nact/nact-iconditions-tab.h
*
* This interface implements all the widgets which define the
* conditions for the action.
@@ -52,7 +54,7 @@ typedef struct NactIConditionsTab NactIConditionsTab;
typedef struct NactIConditionsTabInterfacePrivate NactIConditionsTabInterfacePrivate;
typedef struct {
- GTypeInterface parent;
+ GTypeInterface parent;
NactIConditionsTabInterfacePrivate *private;
}
NactIConditionsTabInterface;
diff --git a/src/nact/nact-main-menubar.h b/src/nact/nact-main-menubar.h
index 8559bbb..7916a74 100644
--- a/src/nact/nact-main-menubar.h
+++ b/src/nact/nact-main-menubar.h
@@ -31,8 +31,10 @@
#ifndef __NACT_MAIN_MENUBAR_H__
#define __NACT_MAIN_MENUBAR_H__
-/*
- * Menu bar management.
+/**
+ * SECTION: nact_main_menubar
+ * @short_description: Main menubar management.
+ * @include: nact/nact-main-menubar.h
*/
#include <gtk/gtk.h>
diff --git a/src/nact/nact-main-statusbar.c b/src/nact/nact-main-statusbar.c
index 51e7895..2ae4346 100644
--- a/src/nact/nact-main-statusbar.c
+++ b/src/nact/nact-main-statusbar.c
@@ -66,7 +66,7 @@ nact_main_statusbar_hide_status( NactMainWindow *window, const gchar *context )
}
}
-/**
+/*
* Returns the status bar widget
*/
static GtkStatusbar *
diff --git a/src/nact/nact-main-statusbar.h b/src/nact/nact-main-statusbar.h
index 0433636..35f8cb1 100644
--- a/src/nact/nact-main-statusbar.h
+++ b/src/nact/nact-main-statusbar.h
@@ -31,8 +31,10 @@
#ifndef __NACT_MAIN_STATUSBAR_H__
#define __NACT_MAIN_STATUSBAR_H__
-/*
- * Status bar management.
+/**
+ * SECTION: nact_main_statusbar
+ * @short_description: Main statusbar functions.
+ * @include: nact/nact-main-statusbar.h
*/
#include "nact-main-window.h"
diff --git a/src/nact/nact-main-tab.h b/src/nact/nact-main-tab.h
index 7936964..713e752 100644
--- a/src/nact/nact-main-tab.h
+++ b/src/nact/nact-main-tab.h
@@ -31,6 +31,14 @@
#ifndef __NACT_MAIN_TAB_H__
#define __NACT_MAIN_TAB_H__
+/**
+ * SECTION: nact_main_tab
+ * @short_description: Signals and properties.
+ * @include: nact/nact-main-tab.h
+ *
+ * Here as defined signals and properties common to all tabs.
+ */
+
/* properties set against the GObject instance
*/
#define TAB_UPDATABLE_PROP_EDITED_ACTION "nact-tab-updatable-edited-action"
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 8374cc4..1e8c658 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -396,8 +396,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactMainWindow *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
- g_assert( NACT_IS_MAIN_WINDOW( instance ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( instance ));
self = NACT_MAIN_WINDOW( instance );
self->private = g_new0( NactMainWindowPrivate, 1 );
@@ -434,21 +433,24 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
{
NactMainWindow *self;
- g_assert( NACT_IS_MAIN_WINDOW( object ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( object ));
self = NACT_MAIN_WINDOW( object );
- switch( property_id ){
- case PROP_EDITED_ITEM:
- g_value_set_pointer( value, self->private->edited_item );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case PROP_EDITED_ITEM:
+ g_value_set_pointer( value, self->private->edited_item );
+ break;
- case PROP_EDITED_PROFILE:
- g_value_set_pointer( value, self->private->edited_profile );
- break;
+ case PROP_EDITED_PROFILE:
+ g_value_set_pointer( value, self->private->edited_profile );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -457,21 +459,24 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
{
NactMainWindow *self;
- g_assert( NACT_IS_MAIN_WINDOW( object ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( object ));
self = NACT_MAIN_WINDOW( object );
- switch( property_id ){
- case PROP_EDITED_ITEM:
- self->private->edited_item = g_value_get_pointer( value );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case PROP_EDITED_ITEM:
+ self->private->edited_item = g_value_get_pointer( value );
+ break;
- case PROP_EDITED_PROFILE:
- self->private->edited_profile = g_value_get_pointer( value );
- break;
+ case PROP_EDITED_PROFILE:
+ self->private->edited_profile = g_value_get_pointer( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -484,7 +489,7 @@ instance_dispose( GObject *window )
gint pos;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- g_assert( NACT_IS_MAIN_WINDOW( window ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
self = NACT_MAIN_WINDOW( window );
if( !self->private->dispose_has_run ){
@@ -519,8 +524,7 @@ instance_finalize( GObject *window )
NactMainWindow *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
-
- g_assert( NACT_IS_MAIN_WINDOW( window ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
self = NACT_MAIN_WINDOW( window );
g_free( self->private );
@@ -537,7 +541,7 @@ instance_finalize( GObject *window )
NactMainWindow *
nact_main_window_new( BaseApplication *application )
{
- g_assert( NACT_IS_APPLICATION( application ));
+ g_return_val_if_fail( NACT_IS_APPLICATION( application ), NULL );
return( g_object_new( NACT_MAIN_WINDOW_TYPE, BASE_WINDOW_PROP_APPLICATION, application, NULL ));
}
@@ -556,23 +560,31 @@ nact_main_window_new( BaseApplication *application )
gboolean
nact_main_window_action_exists( const NactMainWindow *window, const gchar *uuid )
{
+ gboolean exists = FALSE;
NactApplication *application;
NAPivot *pivot;
NAObject *action;
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- pivot = nact_application_get_pivot( application );
- action = na_pivot_get_item( pivot, uuid );
- if( action ){
- return( TRUE );
- }
+ g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), FALSE );
+
+ if( !window->private->dispose_has_run ){
- action = nact_iactions_list_get_item( NACT_IACTIONS_LIST( window ), uuid );
- if( action ){
- return( TRUE );
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ pivot = nact_application_get_pivot( application );
+ action = na_pivot_get_item( pivot, uuid );
+ if( action ){
+ exists = TRUE;
+ }
+
+ if( !exists ){
+ action = nact_iactions_list_get_item( NACT_IACTIONS_LIST( window ), uuid );
+ if( action ){
+ exists = TRUE;
+ }
+ }
}
- return( FALSE );
+ return( exists );
}
/**
@@ -632,7 +644,9 @@ nact_main_window_move_to_deleted( NactMainWindow *window, GList *items )
{
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- window->private->deleted = g_list_concat( window->private->deleted, items );
+ if( !window->private->dispose_has_run ){
+ window->private->deleted = g_list_concat( window->private->deleted, items );
+ }
}
/**
@@ -649,22 +663,24 @@ nact_main_window_remove_deleted( NactMainWindow *window )
GList *it;
NAObject *item;
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- pivot = nact_application_get_pivot( application );
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- for( it = window->private->deleted ; it ; it = it->next ){
- item = NA_OBJECT( it->data );
- actually_delete_item( window, item, pivot );
- }
+ if( !window->private->dispose_has_run ){
- na_object_free_items( window->private->deleted );
- window->private->deleted = NULL;
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ pivot = nact_application_get_pivot( application );
+
+ for( it = window->private->deleted ; it ; it = it->next ){
+ item = NA_OBJECT( it->data );
+ actually_delete_item( window, item, pivot );
+ }
+
+ na_object_free_items( window->private->deleted );
+ window->private->deleted = NULL;
+ }
}
/*
- * from nact_main_window_remove_deleted:
- * Removes the deleted items from the underlying I/O storage subsystem.
- *
* If the deleted item is a profile, then do nothing because the parent
* action has been marked as modified when the profile has been deleted,
* and thus updated in the storage subsystem as well as in the pivot
@@ -722,25 +738,28 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
GtkWidget *pane;
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( NACT_IS_MAIN_WINDOW( window ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- window->private->clipboard = nact_clipboard_new();
+ if( !window->private->dispose_has_run ){
- pos = base_iprefs_get_int( BASE_WINDOW( window ), "main-paned" );
- if( pos ){
- pane = base_window_get_widget( BASE_WINDOW( window ), "MainPaned" );
- gtk_paned_set_position( GTK_PANED( pane ), pos );
- }
+ window->private->clipboard = nact_clipboard_new();
- nact_iactions_list_initial_load_toplevel( NACT_IACTIONS_LIST( window ));
- nact_iactions_list_set_filter_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
- nact_iactions_list_set_multiple_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
- nact_iactions_list_set_dnd_mode( NACT_IACTIONS_LIST( window ), TRUE );
+ pos = base_iprefs_get_int( BASE_WINDOW( window ), "main-paned" );
+ if( pos ){
+ pane = base_window_get_widget( BASE_WINDOW( window ), "MainPaned" );
+ gtk_paned_set_position( GTK_PANED( pane ), pos );
+ }
+
+ nact_iactions_list_initial_load_toplevel( NACT_IACTIONS_LIST( window ));
+ nact_iactions_list_set_filter_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
+ nact_iactions_list_set_multiple_selection_mode( NACT_IACTIONS_LIST( window ), TRUE );
+ nact_iactions_list_set_dnd_mode( NACT_IACTIONS_LIST( window ), TRUE );
- nact_iaction_tab_initial_load_toplevel( NACT_IACTION_TAB( window ));
- nact_icommand_tab_initial_load_toplevel( NACT_ICOMMAND_TAB( window ));
- nact_iconditions_tab_initial_load_toplevel( NACT_ICONDITIONS_TAB( window ));
- nact_iadvanced_tab_initial_load_toplevel( NACT_IADVANCED_TAB( window ));
+ nact_iaction_tab_initial_load_toplevel( NACT_IACTION_TAB( window ));
+ nact_icommand_tab_initial_load_toplevel( NACT_ICOMMAND_TAB( window ));
+ nact_iconditions_tab_initial_load_toplevel( NACT_ICONDITIONS_TAB( window ));
+ nact_iadvanced_tab_initial_load_toplevel( NACT_IADVANCED_TAB( window ));
+ }
}
static void
@@ -752,28 +771,31 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
GList *tree;
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- g_assert( NACT_IS_MAIN_WINDOW( window ));
-
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- pivot = nact_application_get_pivot( application );
- tree = na_pivot_get_items( pivot );
- g_debug( "%s: pivot_tree=%p", thisfn, ( void * ) tree );
-
- nact_iaction_tab_runtime_init_toplevel( NACT_IACTION_TAB( window ));
- nact_icommand_tab_runtime_init_toplevel( NACT_ICOMMAND_TAB( window ));
- nact_iconditions_tab_runtime_init_toplevel( NACT_ICONDITIONS_TAB( window ));
- nact_iadvanced_tab_runtime_init_toplevel( NACT_IADVANCED_TAB( window ));
+ g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- /* fill the IActionsList at last so that all signals are connected
- */
- nact_iactions_list_runtime_init_toplevel( NACT_IACTIONS_LIST( window ), tree );
- nact_main_menubar_runtime_init( window );
+ if( !window->private->dispose_has_run ){
- /* forces a no-selection when the list is initially empty
- */
- /*if( !g_slist_length( wnd->private->actions )){
- set_current_action( NACT_MAIN_WINDOW( window ), NULL );
- }*/
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ pivot = nact_application_get_pivot( application );
+ tree = na_pivot_get_items( pivot );
+ g_debug( "%s: pivot_tree=%p", thisfn, ( void * ) tree );
+
+ nact_iaction_tab_runtime_init_toplevel( NACT_IACTION_TAB( window ));
+ nact_icommand_tab_runtime_init_toplevel( NACT_ICOMMAND_TAB( window ));
+ nact_iconditions_tab_runtime_init_toplevel( NACT_ICONDITIONS_TAB( window ));
+ nact_iadvanced_tab_runtime_init_toplevel( NACT_IADVANCED_TAB( window ));
+
+ /* fill the IActionsList at last so that all signals are connected
+ */
+ nact_iactions_list_runtime_init_toplevel( NACT_IACTIONS_LIST( window ), tree );
+ nact_main_menubar_runtime_init( window );
+
+ /* forces a no-selection when the list is initially empty
+ */
+ /*if( !g_slist_length( wnd->private->actions )){
+ set_current_action( NACT_MAIN_WINDOW( window ), NULL );
+ }*/
+ }
}
static void
@@ -789,13 +811,16 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
g_return_if_fail( NACT_IS_ICONDITIONS_TAB( window ));
g_return_if_fail( NACT_IS_IADVANCED_TAB( window ));
- nact_iactions_list_all_widgets_showed( NACT_IACTIONS_LIST( window ));
- nact_iaction_tab_all_widgets_showed( NACT_IACTION_TAB( window ));
- nact_icommand_tab_all_widgets_showed( NACT_ICOMMAND_TAB( window ));
- nact_iconditions_tab_all_widgets_showed( NACT_ICONDITIONS_TAB( window ));
- nact_iadvanced_tab_all_widgets_showed( NACT_IADVANCED_TAB( window ));
+ if( !window->private->dispose_has_run ){
+
+ nact_iactions_list_all_widgets_showed( NACT_IACTIONS_LIST( window ));
+ nact_iaction_tab_all_widgets_showed( NACT_IACTION_TAB( window ));
+ nact_icommand_tab_all_widgets_showed( NACT_ICOMMAND_TAB( window ));
+ nact_iconditions_tab_all_widgets_showed( NACT_ICONDITIONS_TAB( window ));
+ nact_iadvanced_tab_all_widgets_showed( NACT_IADVANCED_TAB( window ));
- nact_main_menubar_refresh_actions_sensitivity( window );
+ nact_main_menubar_refresh_actions_sensitivity( window );
+ }
}
/*
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index 9ca948d..5ada6fb 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -31,8 +31,10 @@
#ifndef __NACT_MAIN_WINDOW_H__
#define __NACT_MAIN_WINDOW_H__
-/*
- * NactMainWindow class definition.
+/**
+ * SECTION: nact_main_window
+ * @short_description: #NactMainWindow class definition.
+ * @include: nact/nact-main-window.h
*
* This class is derived from BaseWindow and manages the main window.
*/
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index f7b9803..828017e 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -161,8 +161,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactPreferencesEditor *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
- g_assert( NACT_IS_PREFERENCES_EDITOR( instance ));
+ g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( instance ));
self = NACT_PREFERENCES_EDITOR( instance );
self->private = g_new0( NactPreferencesEditorPrivate, 1 );
@@ -189,8 +188,7 @@ instance_dispose( GObject *dialog )
NactPreferencesEditor *self;
g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
-
- g_assert( NACT_IS_PREFERENCES_EDITOR( dialog ));
+ g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( dialog ));
self = NACT_PREFERENCES_EDITOR( dialog );
if( !self->private->dispose_has_run ){
@@ -198,7 +196,9 @@ instance_dispose( GObject *dialog )
self->private->dispose_has_run = TRUE;
/* chain up to the parent class */
- G_OBJECT_CLASS( st_parent_class )->dispose( dialog );
+ if( G_OBJECT_CLASS( st_parent_class )->dispose ){
+ G_OBJECT_CLASS( st_parent_class )->dispose( dialog );
+ }
}
}
@@ -209,14 +209,13 @@ instance_finalize( GObject *dialog )
NactPreferencesEditor *self;
g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
-
- g_assert( NACT_IS_PREFERENCES_EDITOR( dialog ));
- self = ( NactPreferencesEditor * ) dialog;
+ g_return_if_fail( NACT_IS_PREFERENCES_EDITOR( dialog ));
+ self = NACT_PREFERENCES_EDITOR( dialog );
g_free( self->private );
/* chain call to parent class */
- if( st_parent_class->finalize ){
+ if( G_OBJECT_CLASS( st_parent_class )->finalize ){
G_OBJECT_CLASS( st_parent_class )->finalize( dialog );
}
}
@@ -248,7 +247,7 @@ nact_preferences_editor_run( BaseWindow *parent )
NactPreferencesEditor *editor;
g_debug( "%s: parent=%p", thisfn, ( void * ) parent );
- g_assert( BASE_IS_WINDOW( parent ));
+ g_return_if_fail( BASE_IS_WINDOW( parent ));
application = NACT_APPLICATION( base_window_get_application( parent ));
g_assert( NACT_IS_APPLICATION( application ));
diff --git a/src/nact/nact-preferences-editor.h b/src/nact/nact-preferences-editor.h
index 1024651..9af3b43 100644
--- a/src/nact/nact-preferences-editor.h
+++ b/src/nact/nact-preferences-editor.h
@@ -31,8 +31,10 @@
#ifndef __NACT_PREFERENCES_EDITOR_H__
#define __NACT_PREFERENCES_EDITOR_H__
-/*
- * NactPreferencesEditor class definition.
+/**
+ * SECTION: nact_preferences_editor
+ * @short_description: #NactPreferencesEditor class definition.
+ * @include: nact/nact-preferences-editor.h
*
* This class is derived from NactWindow.
* It encapsulates the "PreferencesDialog" widget dialog.
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 3ab8e5a..33cd5cd 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -285,7 +285,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactTreeModel *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
- g_assert( NACT_IS_TREE_MODEL( instance ));
+ g_return_if_fail( NACT_IS_TREE_MODEL( instance ));
self = NACT_TREE_MODEL( instance );
self->private = g_new0( NactTreeModelPrivate, 1 );
@@ -300,7 +300,7 @@ instance_dispose( GObject *object )
NactTreeModel *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
- g_assert( NACT_IS_TREE_MODEL( object ));
+ g_return_if_fail( NACT_IS_TREE_MODEL( object ));
self = NACT_TREE_MODEL( object );
if( !self->private->dispose_has_run ){
@@ -321,7 +321,7 @@ instance_finalize( GObject *object )
NactTreeModel *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
- g_assert( NACT_IS_TREE_MODEL( object ));
+ g_return_if_fail( NACT_IS_TREE_MODEL( object ));
self = NACT_TREE_MODEL( object );
g_free( self->private->drag_dest_uri );
@@ -442,36 +442,39 @@ nact_tree_model_runtime_init( NactTreeModel *model, gboolean have_dnd )
g_debug( "%s: model=%p, have_dnd=%s", thisfn, ( void * ) model, have_dnd ? "True":"False" );
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- if( have_dnd ){
- egg_tree_multi_drag_add_drag_support( EGG_TREE_MULTI_DRAG_SOURCE( model ), model->private->treeview );
-
- gtk_tree_view_enable_model_drag_dest(
- model->private->treeview,
- dnd_dest_targets, G_N_ELEMENTS( dnd_dest_targets ), GDK_ACTION_COPY | GDK_ACTION_MOVE );
-
- base_window_signal_connect(
- BASE_WINDOW( model->private->window ),
- G_OBJECT( model->private->treeview ),
- "drag-begin",
- G_CALLBACK( on_drag_begin ));
-
- base_window_signal_connect(
- BASE_WINDOW( model->private->window ),
- G_OBJECT( model->private->treeview ),
- "drag-end",
- G_CALLBACK( on_drag_end ));
-
- /*nact_window_signal_connect(
- NACT_WINDOW( window ),
- G_OBJECT( treeview ),
- "drag_drop",
- G_CALLBACK( on_drag_drop ));
-
- nact_window_signal_connect(
- NACT_WINDOW( window ),
- G_OBJECT( treeview ),
- "drag_data-received",
- G_CALLBACK( on_drag_data_received ));*/
+ if( !model->private->dispose_has_run ){
+
+ if( have_dnd ){
+ egg_tree_multi_drag_add_drag_support( EGG_TREE_MULTI_DRAG_SOURCE( model ), model->private->treeview );
+
+ gtk_tree_view_enable_model_drag_dest(
+ model->private->treeview,
+ dnd_dest_targets, G_N_ELEMENTS( dnd_dest_targets ), GDK_ACTION_COPY | GDK_ACTION_MOVE );
+
+ base_window_signal_connect(
+ BASE_WINDOW( model->private->window ),
+ G_OBJECT( model->private->treeview ),
+ "drag-begin",
+ G_CALLBACK( on_drag_begin ));
+
+ base_window_signal_connect(
+ BASE_WINDOW( model->private->window ),
+ G_OBJECT( model->private->treeview ),
+ "drag-end",
+ G_CALLBACK( on_drag_end ));
+
+ /*nact_window_signal_connect(
+ NACT_WINDOW( window ),
+ G_OBJECT( treeview ),
+ "drag_drop",
+ G_CALLBACK( on_drag_drop ));
+
+ nact_window_signal_connect(
+ NACT_WINDOW( window ),
+ G_OBJECT( treeview ),
+ "drag_data-received",
+ G_CALLBACK( on_drag_data_received ));*/
+ }
}
}
@@ -484,13 +487,14 @@ nact_tree_model_dispose( NactTreeModel *model )
g_debug( "%s: model=%p", thisfn, ( void * ) model );
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
-#ifdef NA_MAINTAINER_MODE
- nact_tree_model_dump( model );
-#endif
+ if( !model->private->dispose_has_run ){
+
+ nact_tree_model_dump( model );
- ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- gtk_tree_store_clear( ts_model );
+ gtk_tree_store_clear( ts_model );
+ }
}
/**
@@ -507,17 +511,21 @@ nact_tree_model_display( NactTreeModel *model, NAObject *object )
/*g_debug( "%s: model=%p (%s), object=%p (%s)", thisfn,
( void * ) model, G_OBJECT_TYPE_NAME( model ),
( void * ) object, G_OBJECT_TYPE_NAME( object ));*/
+ g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ if( !model->private->dispose_has_run ){
- if( search_for_object( model, GTK_TREE_MODEL( store ), object, &iter )){
- display_item( store, model->private->treeview, &iter, object );
- path = gtk_tree_model_get_path( GTK_TREE_MODEL( store ), &iter );
- gtk_tree_model_row_changed( GTK_TREE_MODEL( store ), path, &iter );
- gtk_tree_path_free( path );
- }
+ store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- /*gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));*/
+ if( search_for_object( model, GTK_TREE_MODEL( store ), object, &iter )){
+ display_item( store, model->private->treeview, &iter, object );
+ path = gtk_tree_model_get_path( GTK_TREE_MODEL( store ), &iter );
+ gtk_tree_model_row_changed( GTK_TREE_MODEL( store ), path, &iter );
+ gtk_tree_path_free( path );
+ }
+
+ /*gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));*/
+ }
}
void
@@ -529,20 +537,23 @@ nact_tree_model_dump( NactTreeModel *model )
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ if( !model->private->dispose_has_run ){
- g_debug( "%s: %s at %p, %s at %p", thisfn,
- G_OBJECT_TYPE_NAME( model ), ( void * ) model, G_OBJECT_TYPE_NAME( store ), ( void * ) store );
+ store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- ntm = g_new0( ntmDumpStruct, 1 );
- ntm->fname = g_strdup( thisfn );
- ntm->prefix = g_strdup( "" );
+ g_debug( "%s: %s at %p, %s at %p", thisfn,
+ G_OBJECT_TYPE_NAME( model ), ( void * ) model, G_OBJECT_TYPE_NAME( store ), ( void * ) store );
- nact_tree_model_iter( model, ( FnIterOnStore ) dump_store, ntm );
+ ntm = g_new0( ntmDumpStruct, 1 );
+ ntm->fname = g_strdup( thisfn );
+ ntm->prefix = g_strdup( "" );
- g_free( ntm->prefix );
- g_free( ntm->fname );
- g_free( ntm );
+ nact_tree_model_iter( model, ( FnIterOnStore ) dump_store, ntm );
+
+ g_free( ntm->prefix );
+ g_free( ntm->fname );
+ g_free( ntm );
+ }
}
/**
@@ -569,11 +580,14 @@ nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean only_actions)
thisfn, ( void * ) model, ( void * ) items, g_list_length( items ), only_actions ? "True":"False" );
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ if( !model->private->dispose_has_run ){
- gtk_tree_store_clear( ts_model );
+ ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- fill_tree_store( ts_model, model->private->treeview, items, only_actions, NULL );
+ gtk_tree_store_clear( ts_model );
+
+ fill_tree_store( ts_model, model->private->treeview, items, only_actions, NULL );
+ }
}
static void
@@ -666,7 +680,7 @@ gchar *
nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **obj_parent )
{
static const gchar *thisfn = "nact_tree_model_insert";
- gchar *path_str;
+ gchar *path_str = NULL;
GtkTreeModel *store;
GtkTreeIter select_iter;
NAObject *select_object;
@@ -686,41 +700,46 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
- store = gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model ));
- has_parent_iter = FALSE;
- has_sibling_iter = FALSE;
- *obj_parent = NA_OBJECT( object );
+ if( !model->private->dispose_has_run ){
- if( path ){
- gtk_tree_model_get_iter( GTK_TREE_MODEL( model ), &select_iter, path );
- gtk_tree_model_get( GTK_TREE_MODEL( model ), &select_iter, IACTIONS_LIST_NAOBJECT_COLUMN, &select_object, -1 );
+ store = gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model ));
+ has_parent_iter = FALSE;
+ has_sibling_iter = FALSE;
+ *obj_parent = NA_OBJECT( object );
- g_return_val_if_fail( select_object, NULL );
- g_return_val_if_fail( NA_IS_OBJECT( select_object ), NULL );
+ if( path ){
+ gtk_tree_model_get_iter( GTK_TREE_MODEL( model ), &select_iter, path );
+ gtk_tree_model_get( GTK_TREE_MODEL( model ), &select_iter, IACTIONS_LIST_NAOBJECT_COLUMN, &select_object, -1 );
- if( NA_IS_OBJECT_ACTION( object )){
- insert_get_iters_action( GTK_TREE_MODEL( store ), select_object, path, object, &parent_iter, &has_parent_iter, &sibling_iter, &has_sibling_iter, obj_parent );
- }
+ g_return_val_if_fail( select_object, NULL );
+ g_return_val_if_fail( NA_IS_OBJECT( select_object ), NULL );
- if( NA_IS_OBJECT_PROFILE( object )){
- insert_get_iters_profile( GTK_TREE_MODEL( store ), select_object, path, object, &parent_iter, &has_parent_iter, &sibling_iter, &has_sibling_iter, obj_parent );
- }
+ if( NA_IS_OBJECT_ACTION( object )){
+ insert_get_iters_action( GTK_TREE_MODEL( store ), select_object, path, object, &parent_iter, &has_parent_iter, &sibling_iter, &has_sibling_iter, obj_parent );
+ }
- if( NA_IS_OBJECT_MENU( object )){
- insert_get_iters_menu( GTK_TREE_MODEL( store ), select_object, path, object, &parent_iter, &has_parent_iter, &sibling_iter, &has_sibling_iter, obj_parent );
+ if( NA_IS_OBJECT_PROFILE( object )){
+ insert_get_iters_profile( GTK_TREE_MODEL( store ), select_object, path, object, &parent_iter, &has_parent_iter, &sibling_iter, &has_sibling_iter, obj_parent );
+ }
+
+ if( NA_IS_OBJECT_MENU( object )){
+ insert_get_iters_menu( GTK_TREE_MODEL( store ), select_object, path, object, &parent_iter, &has_parent_iter, &sibling_iter, &has_sibling_iter, obj_parent );
+ }
+
+ g_object_unref( select_object );
+
+ } else {
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( object ), NULL );
}
- g_object_unref( select_object );
+ gtk_tree_store_insert_before( GTK_TREE_STORE( store ), &store_iter, has_parent_iter ? &parent_iter : NULL, has_sibling_iter ? &sibling_iter : NULL );
+ gtk_tree_store_set( GTK_TREE_STORE( store ), &store_iter, IACTIONS_LIST_NAOBJECT_COLUMN, object, -1 );
+ display_item( GTK_TREE_STORE( store ), model->private->treeview, &store_iter, object );
- } else {
- g_return_val_if_fail( NA_IS_OBJECT_ITEM( object ), NULL );
+ path_str = gtk_tree_model_get_string_from_iter( store, &store_iter );
}
- gtk_tree_store_insert_before( GTK_TREE_STORE( store ), &store_iter, has_parent_iter ? &parent_iter : NULL, has_sibling_iter ? &sibling_iter : NULL );
- gtk_tree_store_set( GTK_TREE_STORE( store ), &store_iter, IACTIONS_LIST_NAOBJECT_COLUMN, object, -1 );
- display_item( GTK_TREE_STORE( store ), model->private->treeview, &store_iter, object );
-
- return( gtk_tree_model_get_string_from_iter( store, &store_iter ));
+ return( path_str );
}
static void
@@ -879,9 +898,11 @@ nact_tree_model_iter( NactTreeModel *model, FnIterOnStore fn, gpointer user_data
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ if( !model->private->dispose_has_run ){
- iter_on_store( model, GTK_TREE_MODEL( store ), NULL, fn, user_data );
+ store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ iter_on_store( model, GTK_TREE_MODEL( store ), NULL, fn, user_data );
+ }
}
/**
@@ -904,22 +925,27 @@ nact_tree_model_remove( NactTreeModel *model, GList *selected )
gchar *path_str;
GList *parents = NULL;
- reversed = g_list_reverse( selected );
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- for( it = reversed ; it ; it = it->next ){
+ if( !model->private->dispose_has_run ){
- path_str = gtk_tree_path_to_string(( GtkTreePath * ) it->data );
- g_debug( "nact_tree_model_remove: path=%s", path_str );
- g_free( path_str );
+ reversed = g_list_reverse( selected );
+ store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, ( GtkTreePath * ) it->data );
- parents = add_parent( parents, GTK_TREE_MODEL( store ), &iter, ( GtkTreePath * ) it->data );
- gtk_tree_store_remove( store, &iter );
- }
+ for( it = reversed ; it ; it = it->next ){
- for( it = parents ; it ; it = it->next ){
- na_object_check_edition_status( it->data );
+ path_str = gtk_tree_path_to_string(( GtkTreePath * ) it->data );
+ g_debug( "nact_tree_model_remove: path=%s", path_str );
+ g_free( path_str );
+
+ gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, ( GtkTreePath * ) it->data );
+ parents = add_parent( parents, GTK_TREE_MODEL( store ), &iter, ( GtkTreePath * ) it->data );
+ gtk_tree_store_remove( store, &iter );
+ }
+
+ for( it = parents ; it ; it = it->next ){
+ na_object_check_edition_status( it->data );
+ }
}
}
diff --git a/src/nact/nact-tree-model.h b/src/nact/nact-tree-model.h
index 5cf9522..1ac9009 100644
--- a/src/nact/nact-tree-model.h
+++ b/src/nact/nact-tree-model.h
@@ -30,6 +30,8 @@
/**
* SECTION: nact_tree_model
+ * @short_description: #NactTreeModel class definition.
+ * @include: nact/nact-tree-model.h
*
* NactTreeModel is derived from GtkTreeModelFilter in order to be able
* to selectively display profiles, whether an action has one or more
diff --git a/src/nact/nact-window.c b/src/nact/nact-window.c
index 393416c..9aead0d 100644
--- a/src/nact/nact-window.c
+++ b/src/nact/nact-window.c
@@ -124,8 +124,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
NactWindow *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
- g_assert( NACT_IS_WINDOW( instance ));
+ g_return_if_fail( NACT_IS_WINDOW( instance ));
self = NACT_WINDOW( instance );
self->private = g_new0( NactWindowPrivate, 1 );
@@ -140,8 +139,7 @@ instance_dispose( GObject *window )
NactWindow *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
-
- g_assert( NACT_IS_WINDOW( window ));
+ g_return_if_fail( NACT_IS_WINDOW( window ));
self = NACT_WINDOW( window );
if( !self->private->dispose_has_run ){
@@ -162,9 +160,8 @@ instance_finalize( GObject *window )
NactWindow *self;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
-
- g_assert( NACT_IS_WINDOW( window ));
- self = ( NactWindow * ) window;
+ g_return_if_fail( NACT_IS_WINDOW( window ));
+ self = NACT_WINDOW( window );
g_free( self->private );
@@ -180,14 +177,19 @@ instance_finalize( GObject *window )
NAPivot *
nact_window_get_pivot( NactWindow *window )
{
+ NAPivot *pivot = NULL;
NactApplication *application;
- NAPivot *pivot;
- g_object_get( G_OBJECT( window ), BASE_WINDOW_PROP_APPLICATION, &application, NULL );
- g_return_val_if_fail( NACT_IS_APPLICATION( application ), NULL );
+ g_return_val_if_fail( NACT_IS_WINDOW( window ), NULL );
+
+ if( !window->private->dispose_has_run ){
+
+ g_object_get( G_OBJECT( window ), BASE_WINDOW_PROP_APPLICATION, &application, NULL );
+ g_return_val_if_fail( NACT_IS_APPLICATION( application ), NULL );
- pivot = nact_application_get_pivot( application );
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
+ pivot = nact_application_get_pivot( application );
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
+ }
return( pivot );
}
@@ -209,29 +211,36 @@ gboolean
nact_window_save_item( NactWindow *window, NAObjectItem *item )
{
static const gchar *thisfn = "nact_window_save_item";
+ gboolean save_ok = FALSE;
NAPivot *pivot;
gchar *msg = NULL;
guint ret;
- g_debug( "%s: window=%p (%s), item=%p (%s)", thisfn,
- ( void * ) window, G_OBJECT_TYPE_NAME( window ),
- ( void * ) item, G_OBJECT_TYPE_NAME( item ));
+ g_debug( "%s: window=%p, item=%p (%s)", thisfn,
+ ( void * ) window, ( void * ) item, G_OBJECT_TYPE_NAME( item ));
+ g_return_val_if_fail( NACT_IS_WINDOW( window ), FALSE );
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), FALSE );
+
+ if( !window->private->dispose_has_run ){
+
+ pivot = nact_window_get_pivot( window );
+ g_assert( NA_IS_PIVOT( pivot ));
- pivot = nact_window_get_pivot( window );
- g_assert( NA_IS_PIVOT( pivot ));
+ na_object_dump_norec( item );
- na_object_dump_norec( item );
+ ret = na_pivot_write_item( pivot, NA_OBJECT( item ), &msg );
- ret = na_pivot_write_item( pivot, NA_OBJECT( item ), &msg );
+ if( msg ){
+ base_window_error_dlg(
+ BASE_WINDOW( window ),
+ GTK_MESSAGE_WARNING, _( "An error has occured when trying to save the item" ), msg );
+ g_free( msg );
+ }
- if( msg ){
- base_window_error_dlg(
- BASE_WINDOW( window ),
- GTK_MESSAGE_WARNING, _( "An error has occured when trying to save the item" ), msg );
- g_free( msg );
+ save_ok = ( ret == NA_IIO_PROVIDER_WRITE_OK );
}
- return( ret == NA_IIO_PROVIDER_WRITE_OK );
+ return( save_ok );
}
/**
@@ -245,27 +254,36 @@ gboolean
nact_window_delete_item( NactWindow *window, NAObjectItem *item )
{
static const gchar *thisfn = "nact_window_delete_item";
+ gboolean delete_ok = FALSE;
NAPivot *pivot;
gchar *msg = NULL;
guint ret;
- g_debug( "%s: window=%p, item=%p", thisfn, ( void * ) window, ( void * ) item );
+ g_debug( "%s: window=%p, item=%p (%s)", thisfn,
+ ( void * ) window, ( void * ) item, G_OBJECT_TYPE_NAME( item ));
+ g_return_val_if_fail( NACT_IS_WINDOW( window ), FALSE );
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), FALSE );
+
+ if( !window->private->dispose_has_run ){
+
+ pivot = nact_window_get_pivot( window );
+ g_assert( NA_IS_PIVOT( pivot ));
- pivot = nact_window_get_pivot( window );
- g_assert( NA_IS_PIVOT( pivot ));
+ na_object_dump_norec( item );
- na_object_dump_norec( item );
+ ret = na_pivot_delete_item( pivot, NA_OBJECT( item ), &msg );
- ret = na_pivot_delete_item( pivot, NA_OBJECT( item ), &msg );
+ if( msg ){
+ base_window_error_dlg(
+ BASE_WINDOW( window ),
+ GTK_MESSAGE_WARNING, _( "An error has occured when trying to delete the item" ), msg );
+ g_free( msg );
+ }
- if( msg ){
- base_window_error_dlg(
- BASE_WINDOW( window ),
- GTK_MESSAGE_WARNING, _( "An error has occured when trying to delete the item" ), msg );
- g_free( msg );
+ delete_ok = ( ret == NA_IIO_PROVIDER_WRITE_OK );
}
- return( ret == NA_IIO_PROVIDER_WRITE_OK );
+ return( delete_ok );
}
/**
@@ -288,18 +306,21 @@ nact_window_write_level_zero( NactWindow *window, GList *items )
g_debug( "%s: window=%p, items=%p (%d items)", thisfn, ( void * ) window, ( void * ) items, g_list_length( items ));
g_return_if_fail( NACT_IS_WINDOW( window ));
- content = NULL;
- for( it = items ; it ; it = it->next ){
- id = na_object_get_id( it->data );
- content = g_slist_prepend( content, id );
- }
- content = g_slist_reverse( content );
+ if( !window->private->dispose_has_run ){
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- pivot = nact_application_get_pivot( application );
- na_iprefs_set_level_zero_items( NA_IPREFS( pivot ), content );
+ content = NULL;
+ for( it = items ; it ; it = it->next ){
+ id = na_object_get_id( it->data );
+ content = g_slist_prepend( content, id );
+ }
+ content = g_slist_reverse( content );
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ pivot = nact_application_get_pivot( application );
+ na_iprefs_set_level_zero_items( NA_IPREFS( pivot ), content );
- na_utils_free_string_list( content );
+ na_utils_free_string_list( content );
+ }
}
/**
@@ -340,17 +361,22 @@ nact_window_count_level_zero_items( GList *items, guint *actions, guint *profile
gboolean
nact_window_warn_modified( NactWindow *window )
{
+ gboolean confirm = FALSE;
gchar *first;
gchar *second;
- gboolean ok;
- first = g_strdup_printf( _( "Some items have been modified." ));
- second = g_strdup( _( "Are you sure you want to quit without saving them ?" ));
+ g_return_val_if_fail( NACT_IS_WINDOW( window ), FALSE );
- ok = base_window_yesno_dlg( BASE_WINDOW( window ), GTK_MESSAGE_QUESTION, first, second );
+ if( !window->private->dispose_has_run ){
- g_free( second );
- g_free( first );
+ first = g_strdup_printf( _( "Some items have been modified." ));
+ second = g_strdup( _( "Are you sure you want to quit without saving them ?" ));
+
+ confirm = base_window_yesno_dlg( BASE_WINDOW( window ), GTK_MESSAGE_QUESTION, first, second );
+
+ g_free( second );
+ g_free( first );
+ }
return( ok );
}
diff --git a/src/nact/nact-window.h b/src/nact/nact-window.h
index a70c8b0..3b686d7 100644
--- a/src/nact/nact-window.h
+++ b/src/nact/nact-window.h
@@ -31,8 +31,10 @@
#ifndef __NACT_WINDOW_H__
#define __NACT_WINDOW_H__
-/*
- * NactWindow class definition.
+/**
+ * SECTION: nact_window
+ * @short_description: #NactWindow class definition.
+ * @include: nact/nact-window.h
*
* This class is derived from BaseWindow class.
* It is a common base class for all Nautilus Actions window documents.
diff --git a/src/nact/nact-xml-reader.h b/src/nact/nact-xml-reader.h
index dce0258..a6926cc 100644
--- a/src/nact/nact-xml-reader.h
+++ b/src/nact/nact-xml-reader.h
@@ -31,8 +31,10 @@
#ifndef __NACT_XML_READER_H__
#define __NACT_XML_READER_H__
-/*
- * NactXMLReader class definition.
+/**
+ * SECTION: nact_xml_reader
+ * @short_description: #NactXMLReader class definition.
+ * @include: nact/nact-xml-reader.h
*
* This is the base class for importing actions from XML files.
*/
diff --git a/src/plugin/nautilus-actions.c b/src/plugin/nautilus-actions.c
index b31528e..fb945de 100644
--- a/src/plugin/nautilus-actions.c
+++ b/src/plugin/nautilus-actions.c
@@ -187,7 +187,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
NautilusActions *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
-
g_return_if_fail( NAUTILUS_IS_ACTIONS( instance ));
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
@@ -208,7 +207,7 @@ instance_dispose( GObject *object )
NautilusActions *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
- g_assert( NAUTILUS_IS_ACTIONS( object ));
+ g_return_if_fail( NAUTILUS_IS_ACTIONS( instance ));
self = NAUTILUS_ACTIONS( object );
if( !self->private->dispose_has_run ){
@@ -231,7 +230,7 @@ instance_finalize( GObject *object )
NautilusActions *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
- g_assert( NAUTILUS_IS_ACTIONS( object ));
+ g_return_if_fail( NAUTILUS_IS_ACTIONS( instance ));
self = NAUTILUS_ACTIONS( object );
g_free( self->private );
@@ -264,6 +263,8 @@ static void nautilus_menu_provider_emit_items_updated_signal (NautilusMenuProvid
* one of the first calls is with current_folder = 'x-nautilus-desktop:///'
* we have nothing to do here ; the function is left as a placeholder
* (and as an historic remainder)
+ * .../...
+ * until we have some actions defined as specific to backgrounds !
*/
static GList *
get_background_items( NautilusMenuProvider *provider, GtkWidget *window, NautilusFileInfo *current_folder )
@@ -298,68 +299,71 @@ get_file_items( NautilusMenuProvider *provider, GtkWidget *window, GList *files
g_return_val_if_fail( NAUTILUS_IS_ACTIONS( provider ), NULL );
self = NAUTILUS_ACTIONS( provider );
- /* no need to go further if there is no files in the list */
- if( !g_list_length( files )){
- return(( GList * ) NULL );
- }
-
if( !self->private->dispose_has_run ){
- tree = na_pivot_get_items( self->private->pivot );
- for( ia = tree ; ia ; ia = ia->next ){
+ /* no need to go further if there is no files in the list */
+ if( !g_list_length( files )){
+ return(( GList * ) NULL );
+ }
- NAObjectAction *action = NA_OBJECT_ACTION( ia->data );
+ if( !self->private->dispose_has_run ){
+ tree = na_pivot_get_items( self->private->pivot );
- if( !na_object_is_enabled( action )){
- continue;
- }
+ for( ia = tree ; ia ; ia = ia->next ){
- label = na_object_get_label( action );
+ NAObjectAction *action = NA_OBJECT_ACTION( ia->data );
- if( !label || !g_utf8_strlen( label, -1 )){
- uuid = na_object_get_id( action );
- g_warning( "%s: label null or empty for uuid=%s", thisfn, uuid );
- g_free( uuid );
- continue;
- }
+ if( !na_object_is_enabled( action )){
+ continue;
+ }
- g_debug( "%s: examining '%s' action", thisfn, label );
- g_free( label );
+ label = na_object_get_label( action );
- profiles = na_object_get_items( action );
+ if( !label || !g_utf8_strlen( label, -1 )){
+ uuid = na_object_get_id( action );
+ g_warning( "%s: label null or empty for uuid=%s", thisfn, uuid );
+ g_free( uuid );
+ continue;
+ }
+
+ g_debug( "%s: examining '%s' action", thisfn, label );
+ g_free( label );
- for( ip = profiles ; ip ; ip = ip->next ){
+ profiles = na_object_get_items( action );
- NAObjectProfile *profile = NA_OBJECT_PROFILE( ip->data );
+ for( ip = profiles ; ip ; ip = ip->next ){
+
+ NAObjectProfile *profile = NA_OBJECT_PROFILE( ip->data );
#ifdef NA_MAINTAINER_MODE
- label = na_object_get_label( profile );
- g_debug( "%s: examining '%s' profile", thisfn, label );
- g_free( label );
+ label = na_object_get_label( profile );
+ g_debug( "%s: examining '%s' profile", thisfn, label );
+ g_free( label );
#endif
- if( na_object_profile_is_candidate( profile, files )){
- item = create_menu_item( action, profile, files );
- items = g_list_append( items, item );
+ if( na_object_profile_is_candidate( profile, files )){
+ item = create_menu_item( action, profile, files );
+ items = g_list_append( items, item );
- /*if( have_submenu ){
- if( !menu ){
- items = g_list_append( items, create_sub_menu( &menu ));
- }
- nautilus_menu_append_item( menu, item );
+ /*if( have_submenu ){
+ if( !menu ){
+ items = g_list_append( items, create_sub_menu( &menu ));
+ }
+ nautilus_menu_append_item( menu, item );
- } else {
- }*/
- break;
+ } else {
+ }*/
+ break;
+ }
}
- }
- na_object_free_items( profiles );
- }
+ na_object_free_items( profiles );
+ }
- add_about = FALSE; /*na_iprefs_get_add_about_item( NA_IPREFS( self ));*/
- if( submenus == 1 && add_about ){
- add_about_item( menu );
+ add_about = FALSE; /*na_iprefs_get_add_about_item( NA_IPREFS( self ));*/
+ if( submenus == 1 && add_about ){
+ add_about_item( menu );
+ }
}
}
diff --git a/src/plugin/nautilus-actions.h b/src/plugin/nautilus-actions.h
index ce43d05..8a4490c 100644
--- a/src/plugin/nautilus-actions.h
+++ b/src/plugin/nautilus-actions.h
@@ -31,8 +31,10 @@
#ifndef __NAUTILUS_ACTIONS_H__
#define __NAUTILUS_ACTIONS_H__
-/*
- * NautilusActions class definition.
+/**
+ * SECTION: nautilus_actions
+ * @short_description: #NautilusActions class definition.
+ * @include: plugin/nautilus-actions.h
*
* There is only one NautilusActions object in the process.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]