[nautilus-actions] Remove BaseApplication::initialize_ui() virtual method
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Remove BaseApplication::initialize_ui() virtual method
- Date: Fri, 21 Jan 2011 18:48:34 +0000 (UTC)
commit f1c04e240faccc896fe0a5aff35dff9299c2d978
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 21 03:28:05 2011 +0100
Remove BaseApplication::initialize_ui() virtual method
ChangeLog | 11 +-
src/nact/base-application.c | 338 ++++++++++++++-----------------------------
src/nact/base-application.h | 126 +----------------
src/nact/base-window.c | 48 ++++++-
src/nact/base-window.h | 3 +-
src/nact/nact-application.c | 22 +---
6 files changed, 172 insertions(+), 376 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7c3001e..5633f3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-01-20 Pierre Wieser <pwieser trychlos org>
+ * src/nact/base-window.c:
+ * src/nact/base-window.h (base_window_display_error_dlg): New function.
+
* src/nact/base-application.c:
* src/nact/base-application.h (base_application_get_icon_name):
Removed function.
@@ -8,11 +11,11 @@
* src/nact/base-application.h
(initialize_i18n, initialize_application_name, get_application_name,
initialize_default_icon, get_icon_name, initialize_gtk,
- initialize_session_manager:):
- Remove virtual methods.
+ initialize_session_manager, get_unique_app_name, initialize_ui,
+ initialize_unique_app, initialize, run): Remove virtual methods.
- * src/nact/nact-application.c
- (appli_get_application_name, appli_get_icon_name): Removed functions.
+ * src/nact/nact-application.c (appli_get_application_name,
+ appli_get_icon_name, appli_get_unique_app_name): Removed functions.
* src/nact/nact-application.c (nact_application_new_with_args):
Make NactApplication initializes with these new properties.
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index a991303..67df737 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -110,28 +110,22 @@ static gboolean appli_initialize_i18n( BaseApplication *application, int *
static gboolean appli_initialize_application_name( BaseApplication *application, int *code );
static gboolean appli_initialize_gtk( BaseApplication *application, int *code );
static gboolean appli_initialize_manage_options( const BaseApplication *application, int *code );
+static gboolean appli_initialize_unique_app( BaseApplication *application, int *code );
+#if 0
+static UniqueResponse on_unique_message_received( UniqueApp *app, UniqueCommand command, UniqueMessageData *message, guint time, gpointer user_data );
+#endif
static gboolean appli_initialize_session_manager( BaseApplication *application, int *code );
static void session_manager_client_quit_cb( EggSMClient *client, BaseApplication *application );
static void session_manager_client_quit_requested_cb( EggSMClient *client, BaseApplication *application );
static gboolean appli_initialize_application_icon( BaseApplication *application, int *code );
-
-static gboolean v_initialize( BaseApplication *application );
-static gboolean v_initialize_unique_app( BaseApplication *application );
-static gboolean v_initialize_ui( BaseApplication *application );
-
-static int application_do_run( BaseApplication *application );
-static gboolean application_do_initialize( BaseApplication *application );
-static gboolean application_do_initialize_unique_app( BaseApplication *application );
-static gboolean application_do_initialize_ui( 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 );*/
+static gboolean appli_initialize_builder( BaseApplication *application, int *code );
static gint display_dlg( BaseApplication *application, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *first, const gchar *second );
+#if 0
static void display_error_message( BaseApplication *application );
-static void set_initialize_unique_app_error( BaseApplication *application );
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 );
+#endif
GType
base_application_get_type( void )
@@ -289,15 +283,6 @@ class_init( BaseApplicationClass *klass )
klass->manage_options = NULL;
klass->main_window_new = NULL;
-
- klass->run = application_do_run;
- klass->initialize = application_do_initialize;
- klass->initialize_unique_app = application_do_initialize_unique_app;
- klass->initialize_ui = application_do_initialize_ui;
- klass->initialize_application = NULL;
- klass->get_unique_app_name = NULL;
- klass->get_ui_filename = NULL;
- klass->get_main_window = NULL;
}
static void
@@ -316,7 +301,6 @@ instance_init( GTypeInstance *application, gpointer klass )
self->private = g_new0( BaseApplicationPrivate, 1 );
self->private->dispose_has_run = FALSE;
- self->private->exit_code = 0;
}
static void
@@ -549,6 +533,7 @@ base_application_run( BaseApplication *application )
{
static const gchar *thisfn = "base_application_run";
int code;
+ GtkWindow *gtk_toplevel;
g_return_val_if_fail( BASE_IS_APPLICATION( application ), BASE_EXIT_CODE_START_FAIL );
@@ -558,19 +543,39 @@ base_application_run( BaseApplication *application )
g_debug( "%s: application=%p", thisfn, ( void * ) application );
code = BASE_EXIT_CODE_OK;
+ application->private->main_window = NULL;
if( appli_initialize_i18n( application, &code ) &&
appli_initialize_application_name( application, &code ) &&
appli_initialize_gtk( application, &code ) &&
appli_initialize_manage_options( application, &code ) &&
+ appli_initialize_unique_app( application, &code ) &&
appli_initialize_session_manager( application, &code ) &&
appli_initialize_application_icon( application, &code ) &&
- v_initialize( application ) /*
- appli_initialize_unique_app( application, &code ) &&
- appli_initialize_builder( application, &code ) &&
- appli_initialize_first_window( application, &code )*/){
+ appli_initialize_builder( application, &code )){
+
+
+ if( BASE_APPLICATION_GET_CLASS( application )->main_window_new ){
+ application->private->main_window = ( BaseWindow * ) BASE_APPLICATION_GET_CLASS( application )->main_window_new( application, &application->private->exit_code );
+ } else {
+ code = BASE_EXIT_CODE_MAIN_WINDOW;
+ }
- code = application_do_run( application );
+ if( application->private->main_window ){
+ g_return_val_if_fail( BASE_IS_WINDOW( application->private->main_window ), BASE_EXIT_CODE_START_FAIL );
+
+ if( base_window_init( application->private->main_window )){
+ gtk_toplevel = base_window_get_toplevel( application->private->main_window );
+ g_return_val_if_fail( gtk_toplevel, BASE_EXIT_CODE_START_FAIL );
+ g_return_val_if_fail( GTK_IS_WINDOW( gtk_toplevel ), BASE_EXIT_CODE_START_FAIL );
+
+ if( application->private->unique_app_handle ){
+ unique_app_watch_window( application->private->unique_app_handle, gtk_toplevel );
+ }
+
+ code = base_window_run( application->private->main_window );
+ }
+ }
}
}
@@ -664,6 +669,69 @@ appli_initialize_manage_options( const BaseApplication *application, int *code )
}
static gboolean
+appli_initialize_unique_app( BaseApplication *application, int *code )
+{
+ static const gchar *thisfn = "base_application_appli_initialize_unique_app";
+ gboolean ret;
+ gboolean is_first;
+ gchar *msg;
+
+ g_debug( "%s: application=%p, code=%p (%d)", thisfn, ( void * ) application, ( void * ) code, *code );
+
+ ret = TRUE;
+
+ if( application->private->unique_app_name &&
+ strlen( application->private->unique_app_name )){
+
+ application->private->unique_app_handle = unique_app_new( application->private->unique_app_name, NULL );
+ is_first = unique_app_is_running( application->private->unique_app_handle );
+
+ if( !is_first ){
+ unique_app_send_message( application->private->unique_app_handle, UNIQUE_ACTIVATE, NULL );
+ /* i18n: application name */
+ msg = g_strdup_printf(
+ _( "Another instance of %s is already running.\n"
+ "Please switch back to it." ), application->private->application_name );
+ base_window_display_error_dlg( NULL, _( "The application is not unique" ), msg );
+ g_free( msg );
+ ret = FALSE;
+ *code = BASE_EXIT_CODE_UNIQUE_APP;
+#if 0
+ /* default from libunique is actually to activate the first window
+ * so we rely on the default..
+ */
+ } else {
+ g_signal_connect( application->private->unique_app_handle,
+ "message-received", G_CALLBACK( on_unique_message_received ), application );
+#endif
+ }
+ }
+
+ return( ret );
+}
+
+#if 0
+static UniqueResponse
+on_unique_message_received(
+ UniqueApp *app, UniqueCommand command, UniqueMessageData *message, guint time, gpointer user_data )
+{
+ static const gchar *thisfn = "base_application_check_for_unique_app";
+ UniqueResponse resp = UNIQUE_RESPONSE_OK;
+
+ switch( command ){
+ case UNIQUE_ACTIVATE:
+ g_debug( "%s: received message UNIQUE_ACTIVATE", thisfn );
+ break;
+ default:
+ resp = UNIQUE_RESPONSE_PASSTHROUGH;
+ break;
+ }
+
+ return( resp );
+}
+#endif
+
+static gboolean
appli_initialize_session_manager( BaseApplication *application, int *code )
{
static const gchar *thisfn = "base_application_do_initialize_session_manager";
@@ -736,6 +804,18 @@ appli_initialize_application_icon( BaseApplication *application, int *code )
return( TRUE );
}
+static gboolean
+appli_initialize_builder( BaseApplication *application, int *code )
+{
+ static const gchar *thisfn = "base_application_appli_initialize_builder";
+
+ g_debug( "%s: application=%p, code=%p (%d)", thisfn, ( void * ) application, ( void * ) code, *code );
+
+ application->private->builder = base_builder_new();
+
+ return( TRUE );
+}
+
/**
* base_application_get_application_name:
* @application: this #BaseApplication instance.
@@ -781,37 +861,6 @@ base_application_get_builder( BaseApplication *application )
}
/**
- * base_application_get_unique_app_name:
- * @application: this #BaseApplication instance.
- *
- * Asks the #BaseApplication-derived class for its UniqueApp name if any.
- *
- * Defaults to empty.
- *
- * Returns: a newly allocated string to be g_free() by the caller.
- */
-gchar *
-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( !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( "" );
- }
- }
-
- return( name );
-}
-
-/**
* base_application_get_ui_filename:
* @application: this #BaseApplication instance.
*
@@ -918,115 +967,7 @@ base_application_yesno_dlg( BaseApplication *application, GtkMessageType type, c
return( ret );
}
-static gboolean
-v_initialize( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_v_initialize";
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- return( BASE_APPLICATION_GET_CLASS( application )->initialize( application ));
-}
-
-static gboolean
-v_initialize_unique_app( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_v_initialize_unique_app";
- gboolean ok;
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- ok = BASE_APPLICATION_GET_CLASS( application )->initialize_unique_app( application );
-
- if( !ok ){
- set_initialize_unique_app_error( application );
- }
-
- return( ok );
-}
-
-static gboolean
-v_initialize_ui( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_v_initialize_ui";
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- return( BASE_APPLICATION_GET_CLASS( application )->initialize_ui( application ));
-}
-
-static int
-application_do_run( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_do_run";
- GtkWindow *gtk_toplevel;
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- if( v_initialize( application )){
-
- application->private->main_window = NULL;
-
- if( BASE_APPLICATION_GET_CLASS( application )->main_window_new ){
- application->private->main_window = ( BaseWindow * ) BASE_APPLICATION_GET_CLASS( application )->main_window_new( application, &application->private->exit_code );
- }
-
- if( application->private->main_window ){
- g_return_val_if_fail( BASE_IS_WINDOW( application->private->main_window ), -1 );
-
- if( base_window_init( application->private->main_window )){
-
- gtk_toplevel = base_window_get_toplevel( application->private->main_window );
- g_assert( gtk_toplevel );
- g_assert( GTK_IS_WINDOW( gtk_toplevel ));
-
- if( application->private->unique_app_handle ){
- unique_app_watch_window( application->private->unique_app_handle, gtk_toplevel );
- }
-
- base_window_run( application->private->main_window );
- }
- }
- }
-
- display_error_message( application );
-
- return( application->private->exit_code );
-}
-
-static gboolean
-application_do_initialize( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_do_initialize";
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- return(
- v_initialize_unique_app( application ) &&
- v_initialize_ui( application )
- );
-}
-
-static gboolean
-application_do_initialize_unique_app( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_do_initialize_unique_app";
- gboolean ret = TRUE;
- gchar *name;
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- name = base_application_get_unique_app_name( application );
-
- if( name && strlen( name )){
- application->private->unique_app_handle = unique_app_new( name, NULL );
- ret = check_for_unique_app( application );
- }
-
- g_free( name );
- return( ret );
-}
-
+#if 0
static gboolean
application_do_initialize_ui( BaseApplication *application )
{
@@ -1057,55 +998,7 @@ application_do_initialize_ui( BaseApplication *application )
g_free( name );
return( ret );
}
-
-static gboolean
-check_for_unique_app( BaseApplication *application )
-{
- static const gchar *thisfn = "base_application_check_for_unique_app";
- gboolean is_first = TRUE;
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
- g_assert( BASE_IS_APPLICATION( application ));
-
- if( unique_app_is_running( application->private->unique_app_handle )){
-
- is_first = FALSE;
-
- unique_app_send_message( application->private->unique_app_handle, UNIQUE_ACTIVATE, NULL );
-
- /* default from libunique is actually to activate the first window
- * so we rely on the default..
- */
- /*} else {
- g_signal_connect(
- application->private->unique,
- "message-received",
- G_CALLBACK( on_unique_message_received ),
- application
- );*/
- }
-
- return( is_first );
-}
-
-/*static UniqueResponse
-on_unique_message_received(
- UniqueApp *app, UniqueCommand command, UniqueMessageData *message, guint time, gpointer user_data )
-{
- static const gchar *thisfn = "base_application_check_for_unique_app";
- UniqueResponse resp = UNIQUE_RESPONSE_OK;
-
- switch( command ){
- case UNIQUE_ACTIVATE:
- g_debug( "%s: received message UNIQUE_ACTIVATE", thisfn );
- break;
- default:
- resp = UNIQUE_RESPONSE_PASSTHROUGH;
- break;
- }
-
- return( resp );
-}*/
+#endif
static gint
display_dlg( BaseApplication *application, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *first, const gchar *second )
@@ -1139,6 +1032,7 @@ display_dlg( BaseApplication *application, GtkMessageType type_message, GtkButto
return( result );
}
+#if 0
static void
display_error_message( BaseApplication *application )
{
@@ -1161,15 +1055,6 @@ display_error_message( BaseApplication *application )
}
static void
-set_initialize_unique_app_error( BaseApplication *application )
-{
- application->private->exit_code = BASE_APPLICATION_ERROR_UNIQUE_APP;
-
- application->private->exit_message1 =
- g_strdup( _( "Another instance of the application is already running." ));
-}
-
-static void
set_initialize_ui_get_fname_error( BaseApplication *application )
{
application->private->exit_code = BASE_APPLICATION_ERROR_UI_FNAME;
@@ -1191,3 +1076,4 @@ set_initialize_ui_add_xml_error( BaseApplication *application, const gchar *file
application->private->exit_message2 = g_strdup( error->message );
}
}
+#endif
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index 3aafd7d..3522de7 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -138,105 +138,6 @@ typedef struct {
GObject * ( *main_window_new )( const BaseApplication *appli, int *code );
/**
- * run:
- * @appli: this #BaseApplication instance.
- *
- * Starts and runs the application.
- *
- * Returns: an %int code suitable as an exit code for the program.
- *
- * Overriding this function should be very seldomly needed.
- *
- * Base class implementation takes care of creating, initializing,
- * and running the main window. It blocks until the end of the
- * program.
- */
- int ( *run ) ( BaseApplication *appli );
-
- /**
- * initialize:
- * @appli: this #BaseApplication instance.
- *
- * Initializes the program.
- *
- * If this function successfully returns, the program is supposed
- * to be able to successfully run the main window.
- *
- * Returns: %TRUE if all initialization is complete and the program
- * can be ran.
- *
- * Returning %FALSE means that something has gone wrong in the
- * initialization process, thus preventing the application to
- * actually be ran. Aside of returning %FALSE, the responsible
- * code may also have setup #exit_code and #exit_message.
- *
- * When overriding this function, and unless you want have a whole
- * new initialization process, you should call the base class
- * implementation.
- *
- * From the base class implementation point of view, this function
- * leads the global initialization process of the program. It
- * actually calls a suite of elementary initialization virtual
- * functions which may themselves be individually overriden by the
- * derived class.
- *
- * Each individual function should return %TRUE in order to
- * continue with the initialization process, or %FALSE to stop it.
- *
- * In other words, the base class implementation considers that the
- * application is correctly initialized if and only if all
- * individual initialization virtual functions have returned %TRUE.
- */
- gboolean ( *initialize ) ( BaseApplication *appli );
-
- /**
- * initialize_unique_app:
- * @appli: this #BaseApplication instance.
- *
- * If relevant, checks if an instance of the application is already
- * running.
- *
- * Returns: %TRUE if the initialization process can continue,
- * %FALSE if the application asked for to be unique and another
- * instance is already running.
- *
- * If failed, this function sets #exit_code to
- * %APPLICATION_ERROR_UNIQUE_APP, and prepares a short #exit_message
- * to be displayed in a dialog box.
- *
- * The base class implementation asks the #BaseApplication-derived
- * class for a DBus unique name. If not empty, it then allocates a
- * UniqueApp object, delegating it the actual check for the unicity
- * of the application instance.
- *
- * If another instance is already running, the base class
- * implementation sets #exit_code to APPLICATION_ERROR_UNIQUE_APP,
- * and prepares a short #exit_message to be displayed in a dialog
- * box.
- */
- gboolean ( *initialize_unique_app ) ( BaseApplication *appli );
-
- /**
- * initialize_ui:
- * @appli: this #BaseApplication instance.
- *
- * Loads and initializes the XML file which contains the description
- * of the user interface of the application.
- *
- * Returns: %TRUE if the UI description has been successfully
- * loaded, %FALSE else.
- *
- * If failed, this function sets #exit_code to %APPLICATION_ERROR_UI,
- * and prepares a short #exit_message to be displayed in a dialog
- * box.
- *
- * The base class implementation asks the #BaseApplication-derived
- * class for the XML filename. If not empty, it then loads it, and
- * initializes a corresponding GtkBuilder object.
- */
- gboolean ( *initialize_ui ) ( BaseApplication *appli );
-
- /**
* initialize_application:
* @appli: this #BaseApplication instance.
*
@@ -261,26 +162,6 @@ typedef struct {
gboolean ( *initialize_application ) ( BaseApplication *appli );
/**
- * get_unique_app_name:
- * @appli: this #BaseApplication instance.
- *
- * Asks the derived class for the UniqueApp name of this application.
- *
- * A UniqueApp name is typically of the form
- * "com.mydomain.MyApplication.MyName". It is registered in DBus
- * system by each running instance of the application, and is then
- * used to check if another instance of the application is already
- * running.
- *
- * No default is provided by the base class, which means that the
- * base class defaults to not check for another instance.
- *
- * Returns: the UniqueApp name of the application, to be g_free()
- * by the caller.
- */
- gchar * ( *get_unique_app_name ) ( BaseApplication *appli );
-
- /**
* get_ui_filename:
* @appli: this #BaseApplication instance.
*
@@ -330,11 +211,9 @@ typedef struct {
typedef enum {
BASE_EXIT_CODE_START_FAIL = -1,
BASE_EXIT_CODE_OK = 0,
+ BASE_EXIT_CODE_UNIQUE_APP,
+ BASE_EXIT_CODE_MAIN_WINDOW,
- BASE_APPLICATION_ERROR_I18N = 1, /* i18n initialization error */
- BASE_APPLICATION_ERROR_GTK, /* gtk+ initialization error */
- BASE_APPLICATION_ERROR_MAIN_WINDOW, /* unable to obtain the main window */
- BASE_APPLICATION_ERROR_UNIQUE_APP, /* another instance is running */
BASE_APPLICATION_ERROR_UI_FNAME, /* empty XML filename */
BASE_APPLICATION_ERROR_UI_LOAD, /* unable to load the XML definition of the UI */
BASE_APPLICATION_ERROR_DEFAULT_ICON /* unable to set default icon */
@@ -392,7 +271,6 @@ gchar *base_application_get_application_name( const BaseApplication *appli
*/
#define BASE_APPLICATION_PROP_MAIN_WINDOW "base-application-main-window"
-gchar *base_application_get_unique_app_name( BaseApplication *application );
gchar *base_application_get_ui_filename( BaseApplication *application );
BaseBuilder *base_application_get_builder( BaseApplication *application );
diff --git a/src/nact/base-window.c b/src/nact/base-window.c
index 7e5a5d0..7191e44 100644
--- a/src/nact/base-window.c
+++ b/src/nact/base-window.c
@@ -135,6 +135,7 @@ static void set_toplevel_initialized( BaseWindow *window, GtkWindow
static void setup_builder( BaseWindow *window );
static void record_connected_signal( BaseWindow *window, GObject *instance, gulong handler_id );
+static gint display_dlg( const BaseWindow *parent, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *primary, const gchar *secondary );
GType
base_window_get_type( void )
@@ -645,7 +646,7 @@ base_window_init( BaseWindow *window )
*
* Runs the window.
*/
-gboolean
+int
base_window_run( BaseWindow *window )
{
static const gchar *thisfn = "base_window_run";
@@ -704,7 +705,7 @@ base_window_run( BaseWindow *window )
}
}
- return( run_ok );
+ return( run_ok ? BASE_EXIT_CODE_OK : BASE_EXIT_CODE_MAIN_WINDOW );
}
/**
@@ -1312,6 +1313,49 @@ setup_builder( BaseWindow *window )
}
}
+/**
+ * base_window_display_error_dlg:
+ * @parent: the #BaseWindow parent, may be %NULL.
+ * @primary: the primary message.
+ * @secondary: the secondary message.
+ *
+ * Display an error dialog box, with a 'OK' button only.
+ *
+ * if @secondary is not null, then @primary is displayed as a bold title.
+ */
+void
+base_window_display_error_dlg( const BaseWindow *parent, const gchar *primary, const gchar *secondary )
+{
+ display_dlg( parent, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, primary, secondary );
+}
+
+static gint
+display_dlg( const BaseWindow *parent, GtkMessageType type_message, GtkButtonsType type_buttons, const gchar *primary, const gchar *secondary )
+{
+ GtkWindow *gtk_parent;
+ GtkWidget *dialog;
+ gint result;
+
+ gtk_parent = NULL;
+ if( parent ){
+ gtk_parent = base_window_get_toplevel( parent );
+ }
+
+ dialog = gtk_message_dialog_new( gtk_parent, GTK_DIALOG_MODAL, type_message, type_buttons, "%s", primary );
+
+ if( secondary && g_utf8_strlen( secondary, -1 )){
+ gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( dialog ), "%s", secondary );
+ }
+
+ g_object_set( G_OBJECT( dialog ) , "title", g_get_application_name(), NULL );
+
+ result = gtk_dialog_run( GTK_DIALOG( dialog ));
+
+ gtk_widget_destroy( dialog );
+
+ return( result );
+}
+
void
base_window_error_dlg( const BaseWindow *window, GtkMessageType type, const gchar *primary, const gchar *secondary )
{
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index 4f2a174..f78b0a8 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -72,7 +72,7 @@ G_BEGIN_DECLS
#define BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED "nact-base-window-all-widgets-showed"
gboolean base_window_init( BaseWindow *window );
-gboolean base_window_run( BaseWindow *window );
+int base_window_run( BaseWindow *window );
BaseApplication *base_window_get_application( const BaseWindow *window );
GtkWindow *base_window_get_named_toplevel( const BaseWindow *window, const gchar *name );
@@ -82,6 +82,7 @@ GtkWidget *base_window_get_widget( const BaseWindow *window, const gchar *
GtkWidget *base_window_peek_widget( GtkWindow *window, const gchar *name );
gboolean base_window_is_willing_to_quit( const BaseWindow *window );
+void base_window_display_error_dlg( const BaseWindow *parent, const gchar *primary, const gchar *secondary );
void base_window_error_dlg( const BaseWindow *window, GtkMessageType type, const gchar *primary, const gchar *secondary );
gboolean base_window_yesno_dlg( const BaseWindow *window, GtkMessageType type, const gchar *first, const gchar *second );
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index 0f339b1..b1fd437 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -91,9 +91,7 @@ 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_unique_app_name( BaseApplication *application );
static gchar *appli_get_gtkbuilder_filename( BaseApplication *application );
static GObject *appli_get_main_window( BaseApplication *application );
@@ -165,9 +163,7 @@ class_init( NactApplicationClass *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_unique_app_name = appli_get_unique_app_name;
appli_class->get_ui_filename = appli_get_gtkbuilder_filename;
appli_class->get_main_window = appli_get_main_window;
}
@@ -300,7 +296,7 @@ nact_application_new_with_args( int argc, char **argv )
BASE_PROP_ARGC, argc,
BASE_PROP_ARGV, argv,
BASE_PROP_OPTIONS, st_option_entries,
- BASE_PROP_APPLICATION_NAME, st_application_name,
+ BASE_PROP_APPLICATION_NAME, gettext( st_application_name ),
BASE_PROP_ICON_NAME, icon_name,
BASE_PROP_UNIQUE_APP_NAME, st_unique_app_name,
NULL );
@@ -394,6 +390,7 @@ appli_main_window_new( const BaseApplication *application, int *code )
return( G_OBJECT( main_window ));
}
+# if 0
/*
* overrided to provide a personalized error message
*/
@@ -422,6 +419,7 @@ appli_initialize_unique_app( BaseApplication *application )
return( ok );
}
+#endif
/*
* Overrided to complete the initialization of the application:
@@ -460,20 +458,6 @@ appli_initialize_application( BaseApplication *application )
}
static gchar *
-appli_get_unique_app_name( BaseApplication *application )
-{
- static const gchar *thisfn = "nact_application_appli_get_unique_app_name";
-
- g_debug( "%s: application=%p", thisfn, ( void * ) application );
-
- if( st_non_unique_opt ){
- return( g_strdup( "" ));
- }
-
- return( g_strdup( "org.nautilus-actions.ConfigurationTool" ));
-}
-
-static gchar *
appli_get_gtkbuilder_filename( BaseApplication *application )
{
return( g_strdup( PKGDATADIR "/nautilus-actions-config-tool.ui" ));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]