From a7abe3ac594dd3324f473b8200641e03cf64f774 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 31 Dec 2011 14:38:29 -0500 Subject: Composer cleanups. --- composer/e-composer-activity.c | 7 +++-- composer/e-composer-header-table.c | 55 +++++++++++++++++++++++++------------- composer/e-composer-header.c | 7 +++-- composer/e-composer-name-header.c | 19 +++++++------ composer/e-composer-post-header.c | 16 ++++++----- composer/e-composer-private.c | 1 - composer/e-composer-private.h | 4 +++ composer/e-msg-composer.c | 2 +- 8 files changed, 70 insertions(+), 41 deletions(-) diff --git a/composer/e-composer-activity.c b/composer/e-composer-activity.c index ee46d9b6b0..603a271580 100644 --- a/composer/e-composer-activity.c +++ b/composer/e-composer-activity.c @@ -22,6 +22,10 @@ #include "e-composer-private.h" +#define E_COMPOSER_ACTIVITY_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_COMPOSER_ACTIVITY, EComposerActivityPrivate)) + struct _EComposerActivityPrivate { EMsgComposer *composer; gboolean saved_editable; @@ -164,8 +168,7 @@ e_composer_activity_class_init (EComposerActivityClass *class) static void e_composer_activity_init (EComposerActivity *activity) { - activity->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - activity, E_TYPE_COMPOSER_ACTIVITY, EComposerActivityPrivate); + activity->priv = E_COMPOSER_ACTIVITY_GET_PRIVATE (activity); } EActivity * diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c index d0955c4afe..5966791ba0 100644 --- a/composer/e-composer-header-table.c +++ b/composer/e-composer-header-table.c @@ -44,6 +44,10 @@ "carbon copy of the message without appearing " \ "in the recipient list of the message") +#define E_COMPOSER_HEADER_TABLE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_COMPOSER_HEADER_TABLE, EComposerHeaderTablePrivate)) + enum { PROP_0, PROP_ACCOUNT, @@ -362,7 +366,10 @@ composer_header_table_setup_mail_headers (EComposerHeaderTable *table) e_composer_header_set_visible (header, visible); if (key != NULL) - g_settings_bind (settings, key, G_OBJECT (header), "visible", G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, key, + header, "visible", + G_SETTINGS_BIND_DEFAULT); } g_object_unref (settings); @@ -415,7 +422,10 @@ composer_header_table_setup_post_headers (EComposerHeaderTable *table) } if (key != NULL) - g_settings_bind (settings, key, G_OBJECT (header), "visible", G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, key, + header, "visible", + G_SETTINGS_BIND_DEFAULT); } g_object_unref (settings); @@ -523,7 +533,7 @@ composer_header_table_constructor (GType type, e_composer_header_table_parent_class)->constructor ( type, n_construct_properties, construct_properties); - priv = E_COMPOSER_HEADER_TABLE (object)->priv; + priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (object); small_screen_mode = e_shell_get_small_screen_mode (priv->shell); @@ -795,7 +805,7 @@ composer_header_table_dispose (GObject *object) EComposerHeaderTablePrivate *priv; gint ii; - priv = E_COMPOSER_HEADER_TABLE (object)->priv; + priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (object); for (ii = 0; ii < G_N_ELEMENTS (priv->headers); ii++) { if (priv->headers[ii] != NULL) { @@ -874,7 +884,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, E_TYPE_DESTINATION, - G_PARAM_READWRITE); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); g_object_class_install_property ( object_class, @@ -884,7 +895,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, element_spec, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -894,7 +906,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, element_spec, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -904,7 +917,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, element_spec, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); /* floating reference */ element_spec = g_param_spec_string ( @@ -912,7 +926,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, NULL, - G_PARAM_READWRITE); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); g_object_class_install_property ( object_class, @@ -922,7 +937,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, element_spec, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -932,7 +948,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, NULL, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -943,7 +960,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, E_TYPE_SHELL, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -953,7 +971,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, E_TYPE_SIGNATURE, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -963,7 +982,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, E_TYPE_SIGNATURE_LIST, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -973,7 +993,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) NULL, NULL, NULL, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } static void @@ -996,9 +1017,7 @@ e_composer_header_table_init (EComposerHeaderTable *table) GtkWidget *widget; gint ii; - table->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - table, E_TYPE_COMPOSER_HEADER_TABLE, - EComposerHeaderTablePrivate); + table->priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (table); name_selector = e_name_selector_new (); table->priv->name_selector = name_selector; diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c index 29a9a5c790..ebfe564dcb 100644 --- a/composer/e-composer-header.c +++ b/composer/e-composer-header.c @@ -128,7 +128,7 @@ composer_header_set_property (GObject *object, { EComposerHeaderPrivate *priv; - priv = E_COMPOSER_HEADER (object)->priv; + priv = E_COMPOSER_HEADER_GET_PRIVATE (object); switch (property_id) { case PROP_BUTTON: /* construct only */ @@ -163,7 +163,7 @@ composer_header_get_property (GObject *object, { EComposerHeaderPrivate *priv; - priv = E_COMPOSER_HEADER (object)->priv; + priv = E_COMPOSER_HEADER_GET_PRIVATE (object); switch (property_id) { case PROP_BUTTON: /* construct only */ @@ -292,8 +292,7 @@ e_composer_header_class_init (EComposerHeaderClass *class) static void e_composer_header_init (EComposerHeader *header) { - header->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - header, E_TYPE_COMPOSER_HEADER, EComposerHeaderPrivate); + header->priv = E_COMPOSER_HEADER_GET_PRIVATE (header); } gchar * diff --git a/composer/e-composer-name-header.c b/composer/e-composer-name-header.c index b17cb4a75a..740eceef27 100644 --- a/composer/e-composer-name-header.c +++ b/composer/e-composer-name-header.c @@ -31,6 +31,10 @@ #include "addressbook/gui/contact-editor/e-contact-editor.h" #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" +#define E_COMPOSER_NAME_HEADER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_COMPOSER_NAME_HEADER, EComposerNameHeaderPrivate)) + /* Convenience macro */ #define E_COMPOSER_NAME_HEADER_GET_ENTRY(header) \ (E_NAME_SELECTOR_ENTRY (E_COMPOSER_HEADER (header)->input_widget)) @@ -123,7 +127,7 @@ composer_name_header_constructor (GType type, e_composer_name_header_parent_class)->constructor ( type, n_construct_properties, construct_properties); - priv = E_COMPOSER_NAME_HEADER (object)->priv; + priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object); g_assert (E_IS_NAME_SELECTOR (priv->name_selector)); model = e_name_selector_peek_model (priv->name_selector); @@ -171,7 +175,7 @@ composer_name_header_set_property (GObject *object, { EComposerNameHeaderPrivate *priv; - priv = E_COMPOSER_NAME_HEADER (object)->priv; + priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object); switch (property_id) { case PROP_NAME_SELECTOR: /* construct only */ @@ -206,7 +210,7 @@ composer_name_header_dispose (GObject *object) { EComposerNameHeaderPrivate *priv; - priv = E_COMPOSER_NAME_HEADER (object)->priv; + priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (object); if (priv->name_selector != NULL) { g_object_unref (priv->name_selector); @@ -223,12 +227,13 @@ composer_name_header_clicked (EComposerHeader *header) EComposerNameHeaderPrivate *priv; ENameSelectorDialog *dialog; - priv = E_COMPOSER_NAME_HEADER (header)->priv; + priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header); dialog = e_name_selector_peek_dialog (priv->name_selector); e_name_selector_dialog_set_destination_index ( dialog, priv->destination_index); - e_name_selector_show_dialog (priv->name_selector, header->title_widget); + e_name_selector_show_dialog ( + priv->name_selector, header->title_widget); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_hide (GTK_WIDGET (dialog)); } @@ -265,9 +270,7 @@ e_composer_name_header_class_init (EComposerNameHeaderClass *class) static void e_composer_name_header_init (EComposerNameHeader *header) { - header->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - header, E_TYPE_COMPOSER_NAME_HEADER, - EComposerNameHeaderPrivate); + header->priv = E_COMPOSER_NAME_HEADER_GET_PRIVATE (header); } EComposerHeader * diff --git a/composer/e-composer-post-header.c b/composer/e-composer-post-header.c index fd08c67d64..a2a4f4893f 100644 --- a/composer/e-composer-post-header.c +++ b/composer/e-composer-post-header.c @@ -28,6 +28,10 @@ #include #include +#define E_COMPOSER_POST_HEADER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_COMPOSER_POST_HEADER, EComposerPostHeaderPrivate)) + enum { PROP_0, PROP_ACCOUNT @@ -172,7 +176,7 @@ composer_post_header_dispose (GObject *object) { EComposerPostHeaderPrivate *priv; - priv = E_COMPOSER_POST_HEADER (object)->priv; + priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (object); if (priv->account != NULL) { g_object_unref (priv->account); @@ -188,7 +192,7 @@ composer_post_header_finalize (GObject *object) { EComposerPostHeaderPrivate *priv; - priv = E_COMPOSER_POST_HEADER (object)->priv; + priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (object); g_free (priv->base_url); @@ -201,7 +205,7 @@ composer_post_header_changed (EComposerHeader *header) { EComposerPostHeaderPrivate *priv; - priv = E_COMPOSER_POST_HEADER (header)->priv; + priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header); priv->custom = TRUE; } @@ -211,7 +215,7 @@ composer_post_header_clicked (EComposerHeader *header) { EComposerPostHeaderPrivate *priv; - priv = E_COMPOSER_POST_HEADER (header)->priv; + priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header); priv->custom = FALSE; } @@ -249,9 +253,7 @@ e_composer_post_header_class_init (EComposerPostHeaderClass *class) static void e_composer_post_header_init (EComposerPostHeader *header) { - header->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - header, E_TYPE_COMPOSER_POST_HEADER, - EComposerPostHeaderPrivate); + header->priv = E_COMPOSER_POST_HEADER_GET_PRIVATE (header); } EComposerHeader * diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index 467d5c6731..a5282afe2b 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -309,7 +309,6 @@ e_composer_private_constructed (EMsgComposer *composer) gtk_box_reorder_child (GTK_BOX (container), widget, 1); else gtk_box_reorder_child (GTK_BOX (container), widget, 2); - priv->header_table = g_object_ref (widget); gtk_widget_show (widget); diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h index 695510949a..3a3bf62128 100644 --- a/composer/e-composer-private.h +++ b/composer/e-composer-private.h @@ -58,6 +58,10 @@ #include #endif +#define E_MSG_COMPOSER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MSG_COMPOSER, EMsgComposerPrivate)) + /* Shorthand, requires a variable named "composer". */ #define ACTION(name) (E_COMPOSER_ACTION_##name (composer)) diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index daca277e33..7ff8b487ef 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -2479,7 +2479,7 @@ msg_composer_submit_alert (EAlertSink *alert_sink, GtkWidget *dialog; GtkWindow *parent; - priv = E_MSG_COMPOSER (alert_sink)->priv; + priv = E_MSG_COMPOSER_GET_PRIVATE (alert_sink); switch (e_alert_get_message_type (alert)) { case GTK_MESSAGE_INFO: -- cgit