[nautilus-actions] src/nact/base-application-class.h: removed file
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] src/nact/base-application-class.h: removed file
- Date: Fri, 21 Jan 2011 18:47:53 +0000 (UTC)
commit 197326b9b75dd9c7a575081727b459139b07990b
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 21 00:57:51 2011 +0100
src/nact/base-application-class.h: removed file
+ src/nact/Makefile.am:
+ src/nact/base-application.h:
+ src/nact/base-window-class.h:
+ src/nact/base-window.h: Updated accordingly.
ChangeLog | 7 +
src/nact/Makefile.am | 1 -
src/nact/base-application-class.h | 410 -------------------------------------
src/nact/base-application.c | 1 +
src/nact/base-application.h | 377 +++++++++++++++++++++++++++++++++-
src/nact/base-window-class.h | 2 +-
src/nact/base-window.h | 3 -
7 files changed, 379 insertions(+), 422 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a17e043..0796ff4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-01-20 Pierre Wieser <pwieser trychlos org>
+ * src/nact/base-application-class.h: Removed file.
+
+ * src/nact/Makefile.am:
+ * src/nact/base-application.h:
+ * src/nact/base-window-class.h:
+ * src/nact/base-window.h: Updated accordingly.
+
* src/nact/base-application-class.h (main_window_new):
* src/nact/base-application.c (application_do_run):
* src/nact/nact-application.c
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 29d2789..775de0c 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -50,7 +50,6 @@ BUILT_SOURCES = \
nautilus_actions_config_tool_SOURCES = \
base-application.c \
base-application.h \
- base-application-class.h \
base-assistant.c \
base-assistant.h \
base-builder.c \
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index 5861231..a77eb9a 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -54,6 +54,7 @@ struct _BaseApplicationPrivate {
int argc;
gpointer argv;
GOptionEntry *options;
+
gboolean is_gtk_initialized;
UniqueApp *unique_app_handle;
int exit_code;
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index a76b6d7..14a004a 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -32,19 +32,379 @@
#define __BASE_APPLICATION_H__
/**
- * SECTION: base_application
- * @short_description: #BaseApplication public function declarations.
- * @include: nact/base-application.h
+ * SECTION: base-application
+ * @title: BaseApplication
+ * @short_description: The Base Application application base class definition
+ * @include: base-application.h
+ *
+ * #BaseApplication is the base class for the application part of Gtk programs.
+ * It aims at providing all common services. It interacts with #BaseBuilder
+ * and #BaseWindow classes.
+ *
+ * #BaseApplication is a pure virtual class. A Gtk program should derive
+ * its own class from #BaseApplication, and instantiate it in its main()
+ * program entry point.
+ *
+ * <example>
+ * <programlisting>
+ * #include "my-application.h"
+ *
+ * int
+ * main( int argc, char **argv )
+ * {
+ * MyApplication *appli;
+ * int code;
+ *
+ * appli = my_application_new_with_args( argc, argv );
+ * code = base_appliction_run( BASE_APPLICATION( appli ));
+ * g_object_unref( appli );
+ *
+ * return( code );
+ * }
+ * </programlisting>
+ * </example>
*/
-#include <gtk/gtk.h>
-
-#include "base-application-class.h"
#include "base-builder.h"
-#include "base-window-class.h"
G_BEGIN_DECLS
+#define BASE_APPLICATION_TYPE ( base_application_get_type())
+#define BASE_APPLICATION( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, BASE_APPLICATION_TYPE, BaseApplication ))
+#define BASE_APPLICATION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, BASE_APPLICATION_TYPE, BaseApplicationClass ))
+#define BASE_IS_APPLICATION( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, BASE_APPLICATION_TYPE ))
+#define BASE_IS_APPLICATION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), BASE_APPLICATION_TYPE ))
+#define BASE_APPLICATION_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), BASE_APPLICATION_TYPE, BaseApplicationClass ))
+
+typedef struct _BaseApplicationPrivate BaseApplicationPrivate;
+
+typedef struct {
+ /*< private >*/
+ GObject parent;
+ BaseApplicationPrivate *private;
+}
+ BaseApplication;
+
+typedef struct _BaseApplicationClassPrivate BaseApplicationClassPrivate;
+
+/**
+ * BaseApplicationClass:
+ * @manage_options: manage the command-line arguments.
+ * @main_window_new: open and run the first (main) window of the application.
+ *
+ * This defines the virtual method a derived class may, should or must implement.
+ */
+typedef struct {
+ /*< private >*/
+ GObjectClass parent;
+ BaseApplicationClassPrivate *private;
+
+ /*< public >*/
+ /**
+ * manage_options:
+ * @appli: this #BaseApplication -derived instance.
+ * @code: a pointer to an integer that the derived application may
+ * set as the exit code of the program if it chooses to stop
+ * the execution; the code set here will be ignored if execution
+ * is allowed to continue.
+ *
+ * This is invoked by the BaseApplication base class, after arguments
+ * in the command-line have been processed by gtk_init_with_args()
+ * function.
+ *
+ * This let the derived class an opportunity to manage command-line
+ * arguments.
+ *
+ * If it does not dected an error, the derived class should call the
+ * parent method, to give it a chance to manage its own options.
+ *
+ * Returns: %TRUE to continue execution, %FALSE to stop it.
+ * In this later case only, the exit code set in @code will be considered.
+ */
+ gboolean ( *manage_options ) ( const BaseApplication *appli, int *code );
+
+ /**
+ * main_window_new:
+ * @appli: this #BaseApplication -derived instance.
+ *
+ * This is invoked by the BaseApplication base class to let the derived
+ * class do its own initializations and create its main window.
+ *
+ * This is a pure virtual method.
+ *
+ * Returns: the main window of the application, as a #BaseWindow
+ * -derived object. It may or may not having already been initialized.
+ */
+ 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_i18n:
+ * @appli: this #BaseApplication instance.
+ *
+ * Initializes the i18n context.
+ *
+ * Returns: %TRUE if OK, %FALSE else.
+ *
+ * The base class implementation always returns %TRUE.
+ */
+ gboolean ( *initialize_i18n ) ( BaseApplication *appli );
+
+ /**
+ * initialize_gtk:
+ * @appli: this #BaseApplication instance.
+ *
+ * Initializes the Gtk+ GUI interface.
+ *
+ * This function must have been successfully called to be able to
+ * display error message in a graphical dialog box rather than as
+ * a character-style stdout message.
+ *
+ * Returns: %TRUE if OK, %FALSE if Gtk+ has been unable to
+ * initialize the GUI interface.
+ *
+ * The base class implementation defaults to gtk_init_check(). The
+ * derived class may want override it, for example if it wants
+ * parse some command-line parameters.
+ *
+ * If failed, the base class implementation sets #exit_code to
+ * %APPLICATION_ERROR_GTK, and prepares a short #exit_message to be
+ * written to stdout.
+ */
+ gboolean ( *initialize_gtk ) ( BaseApplication *appli );
+
+ /**
+ * initialize_application_name:
+ * @appli: this #BaseApplication instance.
+ *
+ * Initializes the name of the application.
+ */
+ gboolean ( *initialize_application_name )( 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_session_manager:
+ * @appli: this #BaseApplication instance.
+ *
+ * Initializes the Egg session manager.
+ *
+ * Returns: %TRUE.
+ */
+ gboolean ( *initialize_session_manager ) ( 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_default_icon:
+ * @appli: this #BaseApplication instance.
+ *
+ * Initializes the default icon for the application.
+ *
+ * Returns: %TRUE if the default icon has been successfully set for
+ * the application, %FALSE else.
+ *
+ * The base class implementation always returns %TRUE.
+ */
+ gboolean ( *initialize_default_icon ) ( BaseApplication *appli );
+
+ /**
+ * initialize_application:
+ * @appli: this #BaseApplication instance.
+ *
+ * Initializes the derived-class application.
+ *
+ * When this function successfully returns, the #BaseApplication
+ * instance must have a valid pointer to the #BaseWindow-derived
+ * object which will be used as a main window for the application.
+ *
+ * Returns: %TRUE if at least all mandatory informations have been
+ * collected, %FALSE else.
+ *
+ * The base class implementation asks the derived class to
+ * allocates and provides the BaseWindow-derived object which will
+ * be the main window of the application
+ * (cf. get_main_window()). This step is mandatory.
+ *
+ * If failed, this function sets #exit_code to the value which is
+ * pertinent depending of the missing information, and prepares a
+ * short #exit_message to be displayed in a dialog box.
+ */
+ gboolean ( *initialize_application ) ( BaseApplication *appli );
+
+ /**
+ * get_application_name:
+ * @appli: this #BaseApplication instance.
+ *
+ * Asks the derived class for the application name.
+ *
+ * It is typically used as the primary title of the main window.
+ *
+ * If not provided by the derived class, application name defaults
+ * to empty.
+ *
+ * Returns: the application name, to be g_free() by the caller.
+ */
+ gchar * ( *get_application_name ) ( BaseApplication *appli );
+
+ /**
+ * get_icon_name:
+ * @appli: this #BaseApplication instance.
+ *
+ * Asks the derived class for the name of the default icon.
+ *
+ * It is typically used as the icon of the main window.
+ *
+ * No default is provided by the base class.
+ *
+ * Returns: the default icon name for the application, to be
+ * g_free() by the caller.
+ */
+ gchar * ( *get_icon_name ) ( 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.
+ *
+ * Asks the derived class for the filename of the XML definition of
+ * the user interface. This XML definition must be suitable in order
+ * to be loaded via GtkBuilder.
+ *
+ * No default is provided by the base class. If the base class does
+ * not provide one, then the program stops and exits with the code
+ * %APPLICATION_ERROR_UI_FNAME.
+ *
+ * Returns: the filename of the XML definition, to be g_free() by
+ * the caller.
+ */
+ gchar * ( *get_ui_filename ) ( BaseApplication *appli );
+
+ /**
+ * get_main_window:
+ * @appli: this #BaseApplication instance.
+ *
+ * Returns: a pointer to the #BaseWindow-derived main window of the
+ * application. This pointer is owned by the @appli, and should not
+ * be g_free() not g_object_unref() by the caller.
+ */
+ GObject * ( *get_main_window ) ( BaseApplication *appli );
+}
+ BaseApplicationClass;
+
enum {
BASE_APPLICATION_ERROR_I18N = 1, /* i18n initialization error */
BASE_APPLICATION_ERROR_GTK, /* gtk+ initialization error */
@@ -118,7 +478,10 @@ enum {
*/
#define BASE_APPLICATION_PROP_MAIN_WINDOW "base-application-main-window"
+GType base_application_get_type( void );
+
int base_application_run( BaseApplication *application );
+
gchar *base_application_get_application_name( BaseApplication *application );
gchar *base_application_get_icon_name( BaseApplication *application );
gchar *base_application_get_unique_app_name( BaseApplication *application );
diff --git a/src/nact/base-window-class.h b/src/nact/base-window-class.h
index c5e8fa7..cf66ce6 100644
--- a/src/nact/base-window-class.h
+++ b/src/nact/base-window-class.h
@@ -71,7 +71,7 @@
#include <gtk/gtk.h>
-#include "base-application-class.h"
+#include "base-application.h"
G_BEGIN_DECLS
diff --git a/src/nact/base-window.h b/src/nact/base-window.h
index 33c0c4b..4f2a174 100644
--- a/src/nact/base-window.h
+++ b/src/nact/base-window.h
@@ -41,9 +41,6 @@
* application.
*/
-#include <gtk/gtk.h>
-
-#include "base-application-class.h"
#include "base-window-class.h"
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]