From 62a8388327ec6f86086aabff784d30c52609cab5 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Tue, 21 Feb 2006 14:34:38 +0000 Subject: [PATCH] r1302@mlap: muntyan | 2006-02-21 02:30:32 -0600 Removed MooAppWindowPolicy; removed all terminal stuff from MooApp --- moo/mooapp/mooapp.c | 147 +------------------------- moo/mooapp/mooapp.h | 13 --- moo/moopython/pygtk/mooapp-pygtk.defs | 15 --- tests/medit-app.c | 3 + tests/medit-app.opag | 3 + 5 files changed, 8 insertions(+), 173 deletions(-) diff --git a/moo/mooapp/mooapp.c b/moo/mooapp/mooapp.c index 402efd9d..282bd837 100644 --- a/moo/mooapp/mooapp.c +++ b/moo/mooapp/mooapp.c @@ -52,7 +52,6 @@ struct _MooAppPrivate { gboolean run_python; gboolean run_input; gboolean run_output; - MooAppWindowPolicy window_policy; gboolean running; gboolean in_try_quit; @@ -116,8 +115,6 @@ static void moo_app_set_name (MooApp *app, static void moo_app_set_description (MooApp *app, const char *description); -static void all_editors_closed (MooApp *app); - static void start_io (MooApp *app); static void execute_selection (MooEditWindow *window); @@ -158,7 +155,6 @@ enum { PROP_SHORT_NAME, PROP_FULL_NAME, PROP_DESCRIPTION, - PROP_WINDOW_POLICY, PROP_RUN_PYTHON, PROP_RUN_INPUT, PROP_RUN_OUTPUT, @@ -234,15 +230,6 @@ moo_app_class_init (MooAppClass *klass) NULL, G_PARAM_READWRITE)); - g_object_class_install_property (gobject_class, - PROP_WINDOW_POLICY, - g_param_spec_flags ("window-policy", - "window-policy", - "window-policy", - MOO_TYPE_APP_WINDOW_POLICY, - MOO_APP_QUIT_ON_CLOSE_ALL_WINDOWS, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (gobject_class, PROP_RUN_PYTHON, g_param_spec_boolean ("run-python", @@ -368,12 +355,8 @@ moo_app_instance_init (MooApp *app) app->priv->info = moo_app_info_new (); app->priv->info->version = g_strdup (APP_VERSION); - app->priv->info->website = g_strdup ("http://ggap.sourceforge.net/"); - app->priv->info->website_label = g_strdup ("ggap.sourceforge.net"); - -#ifdef MOO_BUILD_TERM - moo_app_set_terminal_type (app, MOO_TYPE_TERM_WINDOW); -#endif + app->priv->info->website = g_strdup ("http://ggap.berlios.de/"); + app->priv->info->website_label = g_strdup ("http://ggap.berlios.de"); } @@ -459,11 +442,6 @@ moo_app_set_property (GObject *object, moo_app_set_description (app, g_value_get_string (value)); break; - case PROP_WINDOW_POLICY: - app->priv->window_policy = g_value_get_flags (value); - g_object_notify (object, "window-policy"); - break; - case PROP_RUN_PYTHON: app->priv->run_python = g_value_get_boolean (value); break; @@ -525,10 +503,6 @@ moo_app_get_property (GObject *object, g_value_set_string (value, app->priv->info->description); break; - case PROP_WINDOW_POLICY: - g_value_set_flags (value, app->priv->window_policy); - break; - case PROP_RUN_PYTHON: g_value_set_boolean (value, app->priv->run_python); break; @@ -920,11 +894,6 @@ moo_app_init_real (MooApp *app) moo_lang_mgr_read_dirs (lang_mgr); - g_signal_connect_swapped (app->priv->editor, - "all-windows-closed", - G_CALLBACK (all_editors_closed), - app); - plugin_dirs = moo_app_get_plugin_dirs (app); moo_set_plugin_dirs (plugin_dirs); moo_plugin_init_builtin (); @@ -1256,86 +1225,6 @@ static void install_actions (MooApp *app, GType type) } -#ifdef MOO_BUILD_TERM -static void terminal_destroyed (MooTermWindow *term, - MooApp *app) -{ - MooAppWindowPolicy policy; - gboolean quit; - - app->priv->terminals = g_slist_remove (app->priv->terminals, - term); - - if (app->priv->term_window == term) - app->priv->term_window = app->priv->terminals ? - app->priv->terminals->data : NULL; - - policy = app->priv->window_policy; - quit = (policy & MOO_APP_QUIT_ON_CLOSE_ALL_TERMINALS) || - ((policy & MOO_APP_QUIT_ON_CLOSE_ALL_WINDOWS) && - !moo_editor_get_active_window (app->priv->editor)); - - if (quit) - moo_app_quit (app); -} - - -static MooTermWindow *new_terminal (MooApp *app) -{ - MooTermWindow *term; - - term = g_object_new (app->priv->term_window_type, - "ui-xml", app->priv->ui_xml, - NULL); - app->priv->terminals = g_slist_append (app->priv->terminals, term); - - if (!app->priv->term_window) - app->priv->term_window = term; - - g_signal_connect (term, "destroy", - G_CALLBACK (terminal_destroyed), app); - - return term; -} - - -void -moo_app_set_terminal_type (MooApp *app, - GType type) -{ - g_return_if_fail (MOO_IS_APP (app)); - g_return_if_fail (g_type_is_a (type, MOO_TYPE_TERM_WINDOW)); - app->priv->term_window_type = type; -} - - -MooTermWindow* -moo_app_get_terminal (MooApp *app) -{ - MooTermWindow *term; - - g_return_val_if_fail (MOO_IS_APP (app), NULL); - - if (app->priv->terminals) - { - return app->priv->terminals->data; - } - else - { - term = new_terminal (app); - gtk_window_present (GTK_WINDOW (term)); - return term; - } -} -#else /* !MOO_BUILD_TERM */ -MooTermWindow *moo_app_get_terminal (MooApp *app) -{ - g_return_val_if_fail (MOO_IS_APP (app), NULL); - g_return_val_if_reached (NULL); -} -#endif /* !MOO_BUILD_TERM */ - - static void install_editor_actions (MooApp *app) { MooWindowClass *klass = g_type_class_ref (MOO_TYPE_EDIT_WINDOW); @@ -1408,17 +1297,6 @@ static void install_terminal_actions (G_GNUC_UNUSED MooApp *app) #endif /* !MOO_BUILD_TERM */ -static void all_editors_closed (MooApp *app) -{ - MooAppWindowPolicy policy = app->priv->window_policy; - gboolean quit = (policy & MOO_APP_QUIT_ON_CLOSE_ALL_EDITORS) || - ((policy & MOO_APP_QUIT_ON_CLOSE_ALL_WINDOWS) && !app->priv->terminals); - - if (quit) - moo_app_quit (app); -} - - MooUIXML *moo_app_get_ui_xml (MooApp *app) { g_return_val_if_fail (MOO_IS_APP (app), NULL); @@ -1456,27 +1334,6 @@ void moo_app_set_ui_xml (MooApp *app, } -GType -moo_app_window_policy_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GFlagsValue values[] = { - { MOO_APP_QUIT_ON_CLOSE_ALL_EDITORS, (char*)"MOO_APP_QUIT_ON_CLOSE_ALL_EDITORS", (char*)"quit-on-close-all-editors" }, - { MOO_APP_QUIT_ON_CLOSE_ALL_TERMINALS, (char*)"MOO_APP_QUIT_ON_CLOSE_ALL_TERMINALS", (char*)"quit-on-close-all-terminals" }, - { MOO_APP_QUIT_ON_CLOSE_ALL_WINDOWS, (char*)"MOO_APP_QUIT_ON_CLOSE_ALL_WINDOWS", (char*)"quit-on-close-all-windows" }, - { 0, NULL, NULL } - }; - - type = g_flags_register_static ("MooAppWindowPolicy", values); - } - - return type; -} - - static MooAppInfo* moo_app_info_new (void) { diff --git a/moo/mooapp/mooapp.h b/moo/mooapp/mooapp.h index 55420b12..82275028 100644 --- a/moo/mooapp/mooapp.h +++ b/moo/mooapp/mooapp.h @@ -21,7 +21,6 @@ G_BEGIN_DECLS #define MOO_TYPE_APP_INFO (moo_app_info_get_type ()) -#define MOO_TYPE_APP_WINDOW_POLICY (moo_app_window_policy_get_type ()) #define MOO_TYPE_APP (moo_app_get_type ()) #define MOO_APP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_APP, MooApp)) @@ -36,13 +35,6 @@ typedef struct _MooAppInfo MooAppInfo; typedef struct _MooAppPrivate MooAppPrivate; typedef struct _MooAppClass MooAppClass; -typedef enum _MooAppWindowPolicy -{ - MOO_APP_QUIT_ON_CLOSE_ALL_EDITORS = 1 << 0, - MOO_APP_QUIT_ON_CLOSE_ALL_TERMINALS = 1 << 1, - MOO_APP_QUIT_ON_CLOSE_ALL_WINDOWS = 1 << 2 -} MooAppWindowPolicy; - struct _MooAppInfo { char *short_name; @@ -83,7 +75,6 @@ struct _MooAppClass GType moo_app_get_type (void) G_GNUC_CONST; GType moo_app_info_get_type (void) G_GNUC_CONST; -GType moo_app_window_policy_get_type (void) G_GNUC_CONST; MooApp *moo_app_get_instance (void); @@ -104,10 +95,6 @@ const char *moo_app_get_application_dir (MooApp *app); MooEditor *moo_app_get_editor (MooApp *app); -MooTermWindow *moo_app_get_terminal (MooApp *app); -void moo_app_set_terminal_type (MooApp *app, - GType type); - void moo_app_prefs_dialog (GtkWidget *parent); void moo_app_about_dialog (GtkWidget *parent); diff --git a/moo/moopython/pygtk/mooapp-pygtk.defs b/moo/moopython/pygtk/mooapp-pygtk.defs index ca48b531..20b66071 100644 --- a/moo/moopython/pygtk/mooapp-pygtk.defs +++ b/moo/moopython/pygtk/mooapp-pygtk.defs @@ -102,21 +102,6 @@ (return-type "MooEditor*") ) -(define-method get_terminal - (of-object "MooApp") - (c-name "moo_app_get_terminal") - (return-type "MooTermWindow*") -) - -(define-method set_terminal_type - (of-object "MooApp") - (c-name "moo_app_set_terminal_type") - (return-type "none") - (parameters - '("GType" "type") - ) -) - (define-function prefs_dialog (c-name "moo_app_prefs_dialog") (return-type "none") diff --git a/tests/medit-app.c b/tests/medit-app.c index 7aaaccd3..c3d22c5a 100644 --- a/tests/medit-app.c +++ b/tests/medit-app.c @@ -295,5 +295,8 @@ int main (int argc, char *argv[]) editor = moo_app_get_editor (app); moo_editor_new_window (editor); + g_signal_connect_swapped (editor, "all-windows-closed", + G_CALLBACK (moo_app_quit), app); + return moo_app_run (app); } diff --git a/tests/medit-app.opag b/tests/medit-app.opag index 34ce7e7a..3feba66f 100644 --- a/tests/medit-app.opag +++ b/tests/medit-app.opag @@ -117,5 +117,8 @@ int main (int argc, char *argv[]) editor = moo_app_get_editor (app); moo_editor_new_window (editor); + g_signal_connect_swapped (editor, "all-windows-closed", + G_CALLBACK (moo_app_quit), app); + return moo_app_run (app); }