diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-11 03:58:39 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-09-14 20:08:48 +0800 |
commit | 911d9f8c6b947d8ac922489fc03b1d063b377973 (patch) | |
tree | 9d5a080bed88e0601e2eec57f9e2073a6f231c26 | |
parent | bae19960b300c3f39ca093f51576621aacbbc84f (diff) | |
download | gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.tar gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.tar.gz gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.tar.bz2 gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.tar.lz gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.tar.xz gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.tar.zst gsoc2013-evolution-911d9f8c6b947d8ac922489fc03b1d063b377973.zip |
EConfig: Broadcast abort/commit events by way of signals.
Remove the clumsy abortfunc and commitfunc callback arguments from
e_config_add_items().
-rw-r--r-- | calendar/gui/dialogs/calendar-setup.c | 19 | ||||
-rw-r--r-- | e-util/e-config.c | 106 | ||||
-rw-r--r-- | e-util/e-config.h | 6 | ||||
-rw-r--r-- | mail/em-account-editor.c | 15 | ||||
-rw-r--r-- | mail/em-folder-properties.c | 2 | ||||
-rw-r--r-- | modules/addressbook/addressbook-config.c | 9 | ||||
-rw-r--r-- | modules/addressbook/autocompletion-config.c | 2 | ||||
-rw-r--r-- | modules/calendar/e-calendar-preferences.c | 2 | ||||
-rw-r--r-- | modules/mail/em-composer-prefs.c | 2 | ||||
-rw-r--r-- | modules/mail/em-mailer-prefs.c | 2 | ||||
-rw-r--r-- | modules/mail/em-network-prefs.c | 2 | ||||
-rw-r--r-- | modules/startup-wizard/evolution-startup-wizard.c | 12 |
12 files changed, 102 insertions, 77 deletions
diff --git a/calendar/gui/dialogs/calendar-setup.c b/calendar/gui/dialogs/calendar-setup.c index 7dfbfdb4f2..8cb3f50d04 100644 --- a/calendar/gui/dialogs/calendar-setup.c +++ b/calendar/gui/dialogs/calendar-setup.c @@ -73,9 +73,9 @@ eccp_check_complete (EConfig *ec, const gchar *pageid, gpointer data) } static void -eccp_commit (EConfig *ec, GSList *items, gpointer data) +eccp_commit (EConfig *ec, + CalendarSourceDialog *sdialog) { - CalendarSourceDialog *sdialog = data; xmlNodePtr xml; GtkWindow *window; @@ -493,8 +493,11 @@ calendar_setup_edit_calendar (GtkWindow *parent, ESource *source, ESourceGroup * sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties"); for (i = 0; eccp_items[i].path; i++) items = g_slist_prepend (items, &eccp_items[i]); - e_config_add_items ((EConfig *) ec, items, eccp_commit, NULL, eccp_free, sdialog); + e_config_add_items ((EConfig *) ec, items, eccp_free, sdialog); e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog); + g_signal_connect ( + ec, "commit", + G_CALLBACK (eccp_commit), sdialog); target = e_cal_config_target_new_source (ec, sdialog->source); target->source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; @@ -549,8 +552,11 @@ calendar_setup_edit_task_list (GtkWindow *parent, ESource *source) sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties"); for (i = 0; ectp_items[i].path; i++) items = g_slist_prepend (items, &ectp_items[i]); - e_config_add_items ((EConfig *) ec, items, eccp_commit, NULL, eccp_free, sdialog); + e_config_add_items ((EConfig *) ec, items, eccp_free, sdialog); e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog); + g_signal_connect ( + ec, "commit", + G_CALLBACK (eccp_commit), sdialog); target = e_cal_config_target_new_source (ec, sdialog->source); target->source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS; @@ -605,8 +611,11 @@ calendar_setup_edit_memo_list (GtkWindow *parent, ESource *source) sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties"); for (i = 0; ecmp_items[i].path; i++) items = g_slist_prepend (items, &ecmp_items[i]); - e_config_add_items ((EConfig *) ec, items, eccp_commit, NULL, eccp_free, sdialog); + e_config_add_items ((EConfig *) ec, items, eccp_free, sdialog); e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog); + g_signal_connect ( + ec, "commit", + G_CALLBACK (eccp_commit), sdialog); target = e_cal_config_target_new_source (ec, sdialog->source); target->source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS; diff --git a/e-util/e-config.c b/e-util/e-config.c index 9242c73fcc..18b707092d 100644 --- a/e-util/e-config.c +++ b/e-util/e-config.c @@ -55,8 +55,6 @@ struct _EConfigFactory { struct _menu_node { GSList *menu; EConfigItemsFunc free; - EConfigItemsFunc abort; - EConfigItemsFunc commit; gpointer data; }; @@ -100,6 +98,14 @@ static GtkWidget * gpointer data, GtkWidget **real_frame); +enum { + ABORT, + COMMIT, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + G_DEFINE_TYPE ( EConfig, e_config, @@ -197,6 +203,24 @@ e_config_class_init (EConfigClass *class) class->set_target = config_set_target; class->target_free = config_target_free; + + signals[ABORT] = g_signal_new ( + "abort", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EConfigClass, abort), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[COMMIT] = g_signal_new ( + "commit", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EConfigClass, commit), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -233,10 +257,6 @@ e_config_construct (EConfig *ep, gint type, const gchar *id) * @ec: An initialised implementing instance of EConfig. * @items: A list of EConfigItem's to add to the configuration manager * @ec. - * @commitfunc: If supplied, called to commit the configuration items - * to persistent storage. - * @abortfunc: If supplied, called to abort/undo the storage of these - * items permanently. * @freefunc: If supplied, called to free the item list (and/or items) * once they are no longer needed. * @data: Data for the callback methods. @@ -247,14 +267,15 @@ e_config_construct (EConfig *ep, gint type, const gchar *id) * TODO: perhaps commit and abort should just be signals. **/ void -e_config_add_items (EConfig *ec, GSList *items, EConfigItemsFunc commitfunc, EConfigItemsFunc abortfunc, EConfigItemsFunc freefunc, gpointer data) +e_config_add_items (EConfig *ec, + GSList *items, + EConfigItemsFunc freefunc, + gpointer data) { struct _menu_node *node; node = g_malloc (sizeof (*node)); node->menu = items; - node->commit = commitfunc; - node->abort = abortfunc; node->free = freefunc; node->data = data; @@ -1259,22 +1280,9 @@ e_config_target_changed (EConfig *emp, e_config_target_change_t how) void e_config_abort (EConfig *config) { - GList *link; - g_return_if_fail (E_IS_CONFIG (config)); - /* TODO: should these just be signals? */ - - link = config->priv->menus; - - while (link != NULL) { - struct _menu_node *node = link->data; - - if (node->abort != NULL) - node->abort (config, node->menu, node->data); - - link = g_list_next (link); - } + g_signal_emit (config, signals[ABORT], 0); } /** @@ -1288,22 +1296,9 @@ e_config_abort (EConfig *config) void e_config_commit (EConfig *config) { - GList *link; - g_return_if_fail (E_IS_CONFIG (config)); - /* TODO: should these just be signals? */ - - link = config->priv->menus; - - while (link != NULL) { - struct _menu_node *node = link->data; - - if (node->commit != NULL) - node->commit (config, node->menu, node->data); - - link = g_list_next (link); - } + g_signal_emit (config, signals[COMMIT], 0); } /** @@ -1603,19 +1598,17 @@ G_DEFINE_TYPE ( E_TYPE_PLUGIN_HOOK) static void -ech_commit (EConfig *ec, GSList *items, gpointer data) +ech_commit (EConfig *ec, + EConfigHookGroup *group) { - struct _EConfigHookGroup *group = data; - if (group->commit && group->hook->hook.plugin->enabled) e_plugin_invoke (group->hook->hook.plugin, group->commit, ec->target); } static void -ech_abort (EConfig *ec, GSList *items, gpointer data) +ech_abort (EConfig *ec, + EConfigHookGroup *group) { - struct _EConfigHookGroup *group = data; - if (group->abort && group->hook->hook.plugin->enabled) e_plugin_invoke (group->hook->hook.plugin, group->abort, ec->target); } @@ -1623,7 +1616,7 @@ ech_abort (EConfig *ec, GSList *items, gpointer data) static gboolean ech_check (EConfig *ec, const gchar *pageid, gpointer data) { - struct _EConfigHookGroup *group = data; + EConfigHookGroup *group = data; EConfigHookPageCheckData hdata; if (!group->hook->hook.plugin->enabled) @@ -1639,7 +1632,7 @@ ech_check (EConfig *ec, const gchar *pageid, gpointer data) static void ech_config_factory (EConfig *emp, gpointer data) { - struct _EConfigHookGroup *group = data; + EConfigHookGroup *group = data; d(printf("config factory called %s\n", group->id?group->id:"all menus")); @@ -1647,8 +1640,15 @@ ech_config_factory (EConfig *emp, gpointer data) || !group->hook->hook.plugin->enabled) return; - if (group->items) - e_config_add_items (emp, group->items, ech_commit, ech_abort, NULL, group); + if (group->items) { + e_config_add_items (emp, group->items, NULL, group); + g_signal_connect ( + emp, "abort", + G_CALLBACK (ech_abort), group); + g_signal_connect ( + emp, "commit", + G_CALLBACK (ech_commit), group); + } if (group->check) e_config_add_page_check (emp, NULL, ech_check, group); @@ -1664,7 +1664,7 @@ emph_free_item (struct _EConfigItem *item) } static void -emph_free_group (struct _EConfigHookGroup *group) +emph_free_group (EConfigHookGroup *group) { g_slist_foreach (group->items, (GFunc) emph_free_item, NULL); g_slist_free (group->items); @@ -1681,7 +1681,7 @@ ech_config_widget_factory (EConfig *config, gint position, gpointer data) { - struct _EConfigHookGroup *group = data; + EConfigHookGroup *group = data; EConfigHookItemFactoryData factory_data; EPlugin *plugin; @@ -1705,7 +1705,7 @@ ech_config_section_factory (EConfig *config, gpointer data, GtkWidget **real_frame) { - struct _EConfigHookGroup *group = data; + EConfigHookGroup *group = data; GtkWidget *label = NULL; GtkWidget *widget; EPlugin *plugin; @@ -1803,10 +1803,10 @@ error: return NULL; } -static struct _EConfigHookGroup * +static EConfigHookGroup * emph_construct_menu (EPluginHook *eph, xmlNodePtr root) { - struct _EConfigHookGroup *menu; + EConfigHookGroup *menu; xmlNodePtr node; EConfigHookTargetMap *map; EConfigHookClass *class = (EConfigHookClass *) G_OBJECT_GET_CLASS (eph); @@ -1868,7 +1868,7 @@ emph_construct (EPluginHook *eph, EPlugin *ep, xmlNodePtr root) node = root->children; while (node) { if (strcmp((gchar *)node->name, "group") == 0) { - struct _EConfigHookGroup *group; + EConfigHookGroup *group; group = emph_construct_menu (eph, node); if (group) { diff --git a/e-util/e-config.h b/e-util/e-config.h index 338824ec95..f7484e7947 100644 --- a/e-util/e-config.h +++ b/e-util/e-config.h @@ -251,6 +251,10 @@ struct _EConfigClass { EConfigTarget *target); void (*target_free) (EConfig *config, EConfigTarget *target); + + /* Signals */ + void (*abort) (EConfig *config); + void (*commit) (EConfig *config); }; GType e_config_get_type (void); @@ -261,7 +265,7 @@ void e_config_class_remove_factory (EConfigClass *klass, EConfigFactory *f); EConfig *e_config_construct (EConfig *, gint type, const gchar *id); -void e_config_add_items (EConfig *, GSList *items, EConfigItemsFunc commitfunc, EConfigItemsFunc abortfunc, EConfigItemsFunc freefunc, gpointer data); +void e_config_add_items (EConfig *, GSList *items, EConfigItemsFunc freefunc, gpointer data); void e_config_add_page_check (EConfig *, const gchar *pageid, EConfigCheckFunc, gpointer data); void e_config_set_page_is_finish (EConfig *ec, const gchar *pageid, gboolean is_finish); diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index f852441450..5ae0b9ea1f 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -3945,9 +3945,9 @@ forget_password_if_needed (EAccount *original_account, EAccount *modified_accoun } static void -emae_commit (EConfig *ec, GSList *items, gpointer data) +emae_commit (EConfig *ec, + EMAccountEditor *emae) { - EMAccountEditor *emae = data; EAccountList *accounts = e_get_account_list (); EAccount *account; EAccount *modified_account; @@ -3994,7 +3994,7 @@ emae_commit (EConfig *ec, GSList *items, gpointer data) void em_account_editor_commit (EMAccountEditor *emae) { - emae_commit ((EConfig *) emae->config, NULL, emae); + emae_commit (E_CONFIG (emae->config), emae); } static void @@ -4127,11 +4127,16 @@ em_account_editor_construct (EMAccountEditor *emae, } } + /* Connect "after" to let plugins go first. */ + g_signal_connect_after ( + ec, "commit", + G_CALLBACK (emae_commit), emae); + emae->config = priv->config = ec; l = NULL; for (i=0;items[i].path;i++) l = g_slist_prepend (l, &items[i]); - e_config_add_items ((EConfig *) ec, l, emae_commit, NULL, emae_free, emae); + e_config_add_items ((EConfig *) ec, l, emae_free, emae); /* This is kinda yuck, we're dynamically mapping from the 'old style' extensibility api to the new one */ l = NULL; @@ -4174,7 +4179,7 @@ em_account_editor_construct (EMAccountEditor *emae, } } g_hash_table_destroy (have); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, emae_free_auto, emae); + e_config_add_items ((EConfig *) ec, l, emae_free_auto, emae); priv->extra_items = l; e_config_add_page_check ((EConfig *) ec, NULL, emae_check_complete, emae); diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c index ff9d0d991d..059ce867d7 100644 --- a/mail/em-folder-properties.c +++ b/mail/em-folder-properties.c @@ -335,7 +335,7 @@ emfp_dialog_run (AsyncContext *context) l = NULL; for (i = 0; i < G_N_ELEMENTS (emfp_items); i++) l = g_slist_prepend (l, &emfp_items[i]); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, emfp_free, context); + e_config_add_items ((EConfig *) ec, l, emfp_free, context); target = em_config_target_new_folder (ec, context->folder); diff --git a/modules/addressbook/addressbook-config.c b/modules/addressbook/addressbook-config.c index 3686fa60bd..a41651459a 100644 --- a/modules/addressbook/addressbook-config.c +++ b/modules/addressbook/addressbook-config.c @@ -1076,9 +1076,9 @@ static EConfigItem eabc_new_items[] = { }; static void -eabc_commit (EConfig *ec, GSList *items, gpointer data) +eabc_commit (EConfig *ec, + AddressbookSourceDialog *sdialog) { - AddressbookSourceDialog *sdialog = data; xmlNodePtr xml; #if d(!)0 gchar *txt; @@ -1262,8 +1262,11 @@ addressbook_config_edit_source (GtkWidget *parent, ESource *source) items = g_slist_prepend (items, &eabc_items[i]); } - e_config_add_items ((EConfig *) ec, items, eabc_commit, NULL, eabc_free, sdialog); + e_config_add_items ((EConfig *) ec, items, eabc_free, sdialog); e_config_add_page_check ((EConfig *) ec, NULL, eabc_check_complete, sdialog); + g_signal_connect ( + ec, "commit", + G_CALLBACK (eabc_commit), sdialog); target = eab_config_target_new_source (ec, sdialog->source); e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); diff --git a/modules/addressbook/autocompletion-config.c b/modules/addressbook/autocompletion-config.c index c78b958022..d4124193a6 100644 --- a/modules/addressbook/autocompletion-config.c +++ b/modules/addressbook/autocompletion-config.c @@ -265,7 +265,7 @@ autocompletion_config_new (EPreferencesWindow *window) l = NULL; for (ii = 0; ii < G_N_ELEMENTS (acc_items); ii++) l = g_slist_prepend (l, &acc_items[ii]); - e_config_add_items ((EConfig *) eab, l, NULL, NULL, acc_free, shell); + e_config_add_items ((EConfig *) eab, l, acc_free, shell); gconf = gconf_client_get_default (); diff --git a/modules/calendar/e-calendar-preferences.c b/modules/calendar/e-calendar-preferences.c index ad04d307cf..a3dd435910 100644 --- a/modules/calendar/e-calendar-preferences.c +++ b/modules/calendar/e-calendar-preferences.c @@ -545,7 +545,7 @@ calendar_preferences_construct (ECalendarPreferences *prefs, l = NULL; for (i = 0; i < G_N_ELEMENTS (eccp_items); i++) l = g_slist_prepend (l, &eccp_items[i]); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, eccp_free, prefs); + e_config_add_items ((EConfig *) ec, l, eccp_free, prefs); widget = e_builder_get_widget (prefs->builder, "use-system-tz-check"); g_object_bind_property ( diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index 2703a8d9e4..f8825f701c 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -350,7 +350,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, l = NULL; for (i = 0; i < G_N_ELEMENTS (emcp_items); i++) l = g_slist_prepend (l, &emcp_items[i]); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, emcp_free, prefs); + e_config_add_items ((EConfig *) ec, l, emcp_free, prefs); /* General tab */ diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c index bbf65e36b5..62d9377bc1 100644 --- a/modules/mail/em-mailer-prefs.c +++ b/modules/mail/em-mailer-prefs.c @@ -719,7 +719,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, l = NULL; for (i = 0; i < G_N_ELEMENTS (emmp_items); i++) l = g_slist_prepend (l, &emmp_items[i]); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, emmp_free, prefs); + e_config_add_items ((EConfig *) ec, l, emmp_free, prefs); /* General tab */ diff --git a/modules/mail/em-network-prefs.c b/modules/mail/em-network-prefs.c index d33f71ec6c..e12bb3c9c2 100644 --- a/modules/mail/em-network-prefs.c +++ b/modules/mail/em-network-prefs.c @@ -335,7 +335,7 @@ em_network_prefs_construct (EMNetworkPrefs *prefs) l = NULL; for (i = 0; i < G_N_ELEMENTS (emnp_items); i++) l = g_slist_prepend (l, &emnp_items[i]); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, emnp_free, prefs); + e_config_add_items ((EConfig *) ec, l, emnp_free, prefs); /* Proxy tab */ diff --git a/modules/startup-wizard/evolution-startup-wizard.c b/modules/startup-wizard/evolution-startup-wizard.c index 5e3b028cdf..3cfca9318a 100644 --- a/modules/startup-wizard/evolution-startup-wizard.c +++ b/modules/startup-wizard/evolution-startup-wizard.c @@ -167,7 +167,6 @@ completed: static void startup_wizard_config_abort (EConfig *config, - GSList *items, EStartupWizard *extension) { GtkAssistant *assistant; @@ -209,7 +208,6 @@ startup_wizard_config_abort (EConfig *config, static void startup_wizard_config_commit (EConfig *config, - GSList *items, EStartupWizard *extension) { EShell *shell; @@ -480,8 +478,6 @@ startup_wizard_new_assistant (EStartupWizard *extension) e_config_add_items ( config, items, - (EConfigItemsFunc) startup_wizard_config_commit, - (EConfigItemsFunc) startup_wizard_config_abort, (EConfigItemsFunc) startup_wizard_config_free, g_object_ref (extension)); @@ -489,6 +485,14 @@ startup_wizard_new_assistant (EStartupWizard *extension) config, "70.progress", (EConfigCheckFunc) startup_wizard_check_progress, extension); + g_signal_connect ( + config, "abort", + G_CALLBACK (startup_wizard_config_abort), extension); + + g_signal_connect ( + config, "commit", + G_CALLBACK (startup_wizard_config_commit), extension); + e_config_create_window (config, NULL, _("Evolution Setup Assistant")); /* Additional tweaks. The window must be created at this point. */ |