[nautilus-actions] Remove base_application_get_main_window() function
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Remove base_application_get_main_window() function
- Date: Fri, 21 Jan 2011 18:47:48 +0000 (UTC)
commit 30adb07864fb80a588925110d38e61542719e136
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 21 00:41:42 2011 +0100
Remove base_application_get_main_window() function
The creation of the main window is moved to new main_window_new() virtual method.
ChangeLog | 7 ++
src/nact/base-application-class.h | 14 ++---
src/nact/base-application.c | 111 +++++++++++++------------------------
src/nact/base-application.h | 1 -
src/nact/nact-application.c | 36 ++++++++++++
src/nact/nact-main-window.c | 6 +-
src/nact/nact-main-window.h | 3 +-
7 files changed, 93 insertions(+), 85 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e73b505..a17e043 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-01-20 Pierre Wieser <pwieser trychlos org>
+ * src/nact/base-application-class.h (main_window_new):
+ * src/nact/base-application.c (application_do_run):
+ * src/nact/nact-application.c
+ * src/nact/nact-main-window.h (appli_main_window_new):
+ Move the creation of the main window to the main_window_new() method.
+ Remove base_application_get_main_window() function.
+
* src/nact/base-application-class.h (manage_options):
* src/nact/base-application.c:
* src/nact/nact-application.c: Return exit code of the program.
diff --git a/src/nact/base-application-class.h b/src/nact/base-application-class.h
index e51775f..0a38d3d 100644
--- a/src/nact/base-application-class.h
+++ b/src/nact/base-application-class.h
@@ -119,23 +119,21 @@ typedef struct {
*
* This is a pure virtual method.
*/
- gboolean ( *manage_options )( const BaseApplication *appli, int *code );
+ gboolean ( *manage_options ) ( const BaseApplication *appli, int *code );
/**
- * run_window:
+ * main_window_new:
* @appli: this #BaseApplication -derived instance.
*
* This is invoked by the BaseApplication base class to let the derived
- * class create, run and then release its first (maybe main) window.
- *
- * When the derived class returns, then the application is supposed
- * willing to terminate.
+ * class create its main window.
*
* This is a pure virtual method.
*
- * Returns: the exit code of the program.
+ * Returns: the main window of the application, as a #BaseWindow
+ * -derived object. It may or may not having already been initialized.
*/
- int ( *run_window ) ( const BaseApplication *appli );
+ GObject * ( *main_window_new )( const BaseApplication *appli, int *code );
/**
* run:
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index 2804919..5861231 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -98,8 +98,11 @@ static gboolean v_initialize_session_manager( BaseApplication *application
static gboolean v_initialize_unique_app( BaseApplication *application );
static gboolean v_initialize_ui( BaseApplication *application );
static gboolean v_initialize_default_icon( BaseApplication *application );
+#if 0
static gboolean v_initialize_application( BaseApplication *application );
-
+static void set_initialize_application_error( BaseApplication *application );
+static gboolean application_do_initialize_application( BaseApplication *application );
+#endif
static int application_do_run( BaseApplication *application );
static gboolean application_do_initialize( BaseApplication *application );
static gboolean application_do_initialize_i18n( BaseApplication *application );
@@ -110,7 +113,6 @@ static gboolean application_do_initialize_session_manager( BaseApplication
static gboolean application_do_initialize_unique_app( BaseApplication *application );
static gboolean application_do_initialize_ui( BaseApplication *application );
static gboolean application_do_initialize_default_icon( BaseApplication *application );
-static gboolean application_do_initialize_application( BaseApplication *application );
static gboolean check_for_unique_app( BaseApplication *application );
/*static UniqueResponse on_unique_message_received( UniqueApp *app, UniqueCommand command, UniqueMessageData *message, guint time, gpointer user_data );*/
@@ -126,7 +128,6 @@ static void set_initialize_unique_app_error( BaseApplication *applicat
static void set_initialize_ui_get_fname_error( BaseApplication *application );
static void set_initialize_ui_add_xml_error( BaseApplication *application, const gchar *filename, GError *error );
static void set_initialize_default_icon_error( BaseApplication *application );
-static void set_initialize_application_error( BaseApplication *application );
GType
base_application_get_type( void )
@@ -256,17 +257,19 @@ class_init( BaseApplicationClass *klass )
klass->private = g_new0( BaseApplicationClassPrivate, 1 );
+ klass->manage_options = application_do_manage_options;
+ klass->main_window_new = NULL;
+
klass->run = application_do_run;
klass->initialize = application_do_initialize;
klass->initialize_i18n = application_do_initialize_i18n;
klass->initialize_gtk = application_do_initialize_gtk;
- klass->manage_options = application_do_manage_options;
klass->initialize_application_name = application_do_initialize_application_name;
klass->initialize_session_manager = application_do_initialize_session_manager;
klass->initialize_unique_app = application_do_initialize_unique_app;
klass->initialize_ui = application_do_initialize_ui;
klass->initialize_default_icon = application_do_initialize_default_icon;
- klass->initialize_application = application_do_initialize_application;
+ klass->initialize_application = NULL;
klass->get_application_name = NULL;
klass->get_icon_name = NULL;
klass->get_unique_app_name = NULL;
@@ -650,38 +653,6 @@ base_application_get_ui_filename( BaseApplication *application )
}
/**
- * base_application_get_main_window:
- * @application: this #BaseApplication instance.
- *
- * Returns: a pointer to the #BaseWindow-derived object which serves as
- * the main window of the application.
- *
- * The returned pointer is owned by @application, and thus should not be
- * g_free() nor g_object_unref() by the caller.
- *
- * When first called, #BaseApplication asks for its derived class to
- * allocate a new object. This same object is then returned on
- * subsequent calls.
- */
-BaseWindow *
-base_application_get_main_window( BaseApplication *application )
-{
- /*static const gchar *thisfn = "base_application_get_main_window";
- g_debug( "%s: application=%p", thisfn, application );*/
-
- g_return_val_if_fail( BASE_IS_APPLICATION( application ), NULL );
-
- 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 );
-}
-
-/**
* base_application_message_dlg:
* @application: this #BaseApplication instance.
* @message: the message to be displayed.
@@ -886,6 +857,7 @@ v_initialize_default_icon( BaseApplication *application )
return( ok );
}
+#if 0
static gboolean
v_initialize_application( BaseApplication *application )
{
@@ -903,30 +875,48 @@ v_initialize_application( BaseApplication *application )
return( ok );
}
+static void
+set_initialize_application_error( BaseApplication *application )
+{
+ application->private->exit_code = BASE_APPLICATION_ERROR_MAIN_WINDOW;
+
+ application->private->exit_message1 =
+ g_strdup( _( "Unable to get the main window of the application." ));
+}
+#endif
+
static int
application_do_run( BaseApplication *application )
{
static const gchar *thisfn = "base_application_do_run";
- GtkWindow *wnd;
+ BaseWindow *main_window;
+ GtkWindow *gtk_toplevel;
g_debug( "%s: application=%p", thisfn, ( void * ) application );
if( v_initialize( application )){
- g_return_val_if_fail( application->private->main_window, -1 );
- g_return_val_if_fail( BASE_IS_WINDOW( application->private->main_window ), -1 );
+ main_window = NULL;
- if( base_window_init( application->private->main_window )){
+ if( BASE_APPLICATION_GET_CLASS( application )->main_window_new ){
+ main_window = ( BaseWindow * ) BASE_APPLICATION_GET_CLASS( application )->main_window_new( application, &application->private->exit_code );
+ }
- wnd = base_window_get_toplevel( application->private->main_window );
- g_assert( wnd );
- g_assert( GTK_IS_WINDOW( wnd ));
+ if( main_window ){
+ g_return_val_if_fail( BASE_IS_WINDOW( main_window ), -1 );
- if( application->private->unique_app_handle ){
- unique_app_watch_window( application->private->unique_app_handle, wnd );
- }
+ if( base_window_init( main_window )){
+
+ gtk_toplevel = base_window_get_toplevel( main_window );
+ g_assert( gtk_toplevel );
+ g_assert( GTK_IS_WINDOW( gtk_toplevel ));
- base_window_run( application->private->main_window );
+ if( application->private->unique_app_handle ){
+ unique_app_watch_window( application->private->unique_app_handle, gtk_toplevel );
+ }
+
+ base_window_run( main_window );
+ }
}
}
@@ -951,8 +941,7 @@ application_do_initialize( BaseApplication *application )
v_initialize_session_manager( application ) &&
v_initialize_unique_app( application ) &&
v_initialize_ui( application ) &&
- v_initialize_default_icon( application ) &&
- v_initialize_application( application )
+ v_initialize_default_icon( application )
);
}
@@ -1130,19 +1119,6 @@ application_do_initialize_default_icon( BaseApplication *application )
}
static gboolean
-application_do_initialize_application( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_do_initialize_application";
- BaseWindow *window;
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- window = base_application_get_main_window( application );
-
- return( window != NULL );
-}
-
-static gboolean
check_for_unique_app( BaseApplication *application )
{
static const gchar *thisfn = "base_application_check_for_unique_app";
@@ -1353,12 +1329,3 @@ set_initialize_default_icon_error( BaseApplication *application )
application->private->exit_message1 =
g_strdup( _( "Unable to set the default icon for the application." ));
}
-
-static void
-set_initialize_application_error( BaseApplication *application )
-{
- application->private->exit_code = BASE_APPLICATION_ERROR_MAIN_WINDOW;
-
- application->private->exit_message1 =
- g_strdup( _( "Unable to get the main window of the application." ));
-}
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index 554a839..a76b6d7 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -124,7 +124,6 @@ gchar *base_application_get_icon_name( BaseApplication *application );
gchar *base_application_get_unique_app_name( BaseApplication *application );
gchar *base_application_get_ui_filename( BaseApplication *application );
BaseBuilder *base_application_get_builder( BaseApplication *application );
-BaseWindow *base_application_get_main_window( BaseApplication *application );
void base_application_message_dlg( BaseApplication *application, GSList *message );
void base_application_error_dlg( BaseApplication *application, GtkMessageType type, const gchar *first, const gchar *second );
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index 3fc67b1..027151e 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -86,6 +86,8 @@ static void instance_dispose( GObject *application );
static void instance_finalize( GObject *application );
static gboolean appli_manage_options( const BaseApplication *application, int *code );
+static GObject *appli_main_window_new( const BaseApplication *application, int *code );
+
static gboolean appli_initialize_unique_app( BaseApplication *application );
static gboolean appli_initialize_application( BaseApplication *application );
static gchar *appli_get_application_name( BaseApplication *application );
@@ -160,6 +162,8 @@ class_init( NactApplicationClass *klass )
appli_class = BASE_APPLICATION_CLASS( klass );
appli_class->manage_options = appli_manage_options;
+ appli_class->main_window_new = appli_main_window_new;
+
appli_class->initialize_unique_app = appli_initialize_unique_app;
appli_class->initialize_application = appli_initialize_application;
appli_class->get_application_name = appli_get_application_name;
@@ -344,6 +348,35 @@ appli_manage_options( const BaseApplication *application, int *code )
}
/*
+ * create the main window
+ */
+static GObject *
+appli_main_window_new( const BaseApplication *application, int *code )
+{
+ static const gchar *thisfn = "nact_application_appli_main_window_new";
+ NactApplication *appli;
+ NactMainWindow *main_window;
+
+ g_return_val_if_fail( NACT_IS_APPLICATION( application ), NULL );
+
+ g_debug( "%s: application=%p, code=%p", thisfn, ( void * ) application, ( void * ) code );
+
+ appli = NACT_APPLICATION( application );
+
+ appli->private->updater = na_updater_new();
+ na_pivot_set_loadable( NA_PIVOT( appli->private->updater ), PIVOT_LOAD_ALL );
+ na_pivot_load_items( NA_PIVOT( appli->private->updater ));
+
+ main_window = nact_main_window_new( appli );
+
+ na_pivot_register_consumer(
+ NA_PIVOT( appli->private->updater ),
+ NA_IPIVOT_CONSUMER( main_window ));
+
+ return( G_OBJECT( main_window ));
+}
+
+/*
* overrided to provide a personalized error message
*/
static gboolean
@@ -456,6 +489,7 @@ appli_get_gtkbuilder_filename( BaseApplication *application )
static GObject *
appli_get_main_window( BaseApplication *application )
{
+#if 0
static const gchar *thisfn = "nact_application_appli_get_main_window";
BaseWindow *window;
@@ -468,4 +502,6 @@ appli_get_main_window( BaseApplication *application )
NA_IPIVOT_CONSUMER( window ));
return( G_OBJECT( window ));
+#endif
+ return( NULL );
}
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 99b30e7..9eb5fc8 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -45,7 +45,6 @@
#include <core/na-pivot.h>
#include "base-iprefs.h"
-#include "nact-application.h"
#include "nact-iactions-list.h"
#include "nact-iaction-tab.h"
#include "nact-icommand-tab.h"
@@ -823,11 +822,12 @@ instance_finalize( GObject *window )
* Returns a newly allocated NactMainWindow object.
*/
NactMainWindow *
-nact_main_window_new( BaseApplication *application )
+nact_main_window_new( const NactApplication *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 ));
+ return( g_object_new( NACT_MAIN_WINDOW_TYPE,
+ BASE_WINDOW_PROP_APPLICATION, application, NULL ));
}
/**
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index 09f212b..815f925 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -41,6 +41,7 @@
#include <api/na-object-item.h>
+#include "nact-application.h"
#include "nact-clipboard.h"
#include "nact-window.h"
@@ -77,7 +78,7 @@ typedef struct {
GType nact_main_window_get_type( void );
-NactMainWindow *nact_main_window_new( BaseApplication *application );
+NactMainWindow *nact_main_window_new( const NactApplication *application );
NactClipboard *nact_main_window_get_clipboard ( const NactMainWindow *window );
NAObjectItem *nact_main_window_get_item ( const NactMainWindow *window, const gchar *id );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]