diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-08-14 08:49:46 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-08-14 08:56:33 +0800 |
commit | 6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f (patch) | |
tree | 8ac6832a905017845b3095112b83bb14da112617 /composer | |
parent | caed9460b2d518005abe34035d5b414ff07c0212 (diff) | |
download | gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.tar gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.tar.gz gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.tar.bz2 gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.tar.lz gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.tar.xz gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.tar.zst gsoc2013-evolution-6cb0cbd0be5791aa0af1f78ce44c7a6563611d8f.zip |
Pass an EShell to EMsgComposer instances.
Reduce the composer's dependency on e_shell_get_default().
Diffstat (limited to 'composer')
-rw-r--r-- | composer/e-composer-actions.c | 5 | ||||
-rw-r--r-- | composer/e-composer-header-table.c | 27 | ||||
-rw-r--r-- | composer/e-composer-private.c | 31 | ||||
-rw-r--r-- | composer/e-composer-private.h | 2 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 281 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 19 |
6 files changed, 224 insertions, 141 deletions
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c index d028beb56f..a49567cea2 100644 --- a/composer/e-composer-actions.c +++ b/composer/e-composer-actions.c @@ -208,8 +208,11 @@ action_new_message_cb (GtkAction *action, EMsgComposer *composer) { EMsgComposer *new_composer; + EShell *shell; - new_composer = e_msg_composer_new (); + shell = e_msg_composer_get_shell (composer); + + new_composer = e_msg_composer_new (shell); gtk_widget_show (GTK_WIDGET (new_composer)); } diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c index b83bcd96db..927408222b 100644 --- a/composer/e-composer-header-table.c +++ b/composer/e-composer-header-table.c @@ -168,9 +168,13 @@ static void composer_header_table_notify_widget (GtkWidget *widget, const gchar *property_name) { + EShell *shell; GtkWidget *parent; - if (e_msg_composer_get_lite ()) { + /* FIXME Pass this in somehow. */ + shell = e_shell_get_default (); + + if (e_shell_get_small_screen_mode (shell)) { parent = gtk_widget_get_parent (widget); parent = g_object_get_data (G_OBJECT (parent), "pdata"); } else @@ -516,17 +520,6 @@ composer_header_table_set_shell (EComposerHeaderTable *table, table->priv->shell = g_object_ref (shell); } -static gint -get_row_padding (void) -{ - /* For small screens, make the header-table's rows be packed closely together */ - - if (e_msg_composer_get_lite ()) - return 0; - else - return 3; -} - static GObject * composer_header_table_constructor (GType type, guint n_construct_properties, @@ -536,6 +529,7 @@ composer_header_table_constructor (GType type, EComposerHeaderTablePrivate *priv; guint rows, ii; gint row_padding; + gboolean small_screen_mode; /* Chain up to parent's constructor() method. */ object = G_OBJECT_CLASS (parent_class)->constructor ( @@ -543,6 +537,8 @@ composer_header_table_constructor (GType type, priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (object); + small_screen_mode = e_shell_get_small_screen_mode (priv->shell); + rows = G_N_ELEMENTS (priv->headers); gtk_table_resize (GTK_TABLE (object), rows, 4); gtk_table_set_row_spacings (GTK_TABLE (object), 0); @@ -551,7 +547,8 @@ composer_header_table_constructor (GType type, /* Use "ypadding" instead of "row-spacing" because some rows may * be invisible and we don't want spacing around them. */ - row_padding = get_row_padding (); + /* For small screens, pack the table's rows closely together. */ + row_padding = small_screen_mode ? 0 : 3; for (ii = 0; ii < rows; ii++) { gtk_table_attach ( @@ -580,13 +577,13 @@ composer_header_table_constructor (GType type, priv->signature_combo_box, "visible"); /* Now add the signature stuff. */ - if (!e_msg_composer_get_lite ()) { + if (!small_screen_mode) { gtk_table_attach ( GTK_TABLE (object), priv->signature_label, 2, 3, ii, ii + 1, 0, 0, 0, row_padding); gtk_table_attach ( GTK_TABLE (object), priv->signature_combo_box, - 3, 4, ii, ii + 1, e_msg_composer_get_lite () ? GTK_FILL: 0, 0, 0, row_padding); + 3, 4, ii, ii + 1, 0, 0, 0, row_padding); } else { GtkWidget *box = gtk_hbox_new (FALSE, 0); diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index 2e6dad64ac..ed9e19096f 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -138,6 +138,7 @@ e_composer_private_constructed (EMsgComposer *composer) GtkWindow *window; GtkHTML *html; const gchar *path; + gboolean small_screen_mode; gchar *filename; gint ii; GError *error = NULL; @@ -146,16 +147,19 @@ e_composer_private_constructed (EMsgComposer *composer) html = gtkhtml_editor_get_html (editor); ui_manager = gtkhtml_editor_get_ui_manager (editor); - shell = e_shell_get_default (); + shell = e_msg_composer_get_shell (composer); + small_screen_mode = e_shell_get_small_screen_mode (shell); - if (e_msg_composer_get_lite ()) { + if (small_screen_mode) { #if 0 - /* In the lite composer, for small screens, we are not ready yet - * to hide the menubar. It still has useful items like the ones - * to show/hide the various header fields, plus the security options. + /* In the lite composer, for small screens, we are not + * ready yet to hide the menubar. It still has useful + * items like the ones to show/hide the various header + * fields, plus the security options. * - * When we move those options out of the menu and into the composer's - * toplevel, we can probably get rid of the menu. + * When we move those options out of the menu and into + * the composer's toplevel, we can probably get rid of + * the menu. */ widget = gtkhtml_editor_get_managed_widget (editor, "/main-menu"); gtk_widget_hide (widget); @@ -255,7 +259,7 @@ e_composer_private_constructed (EMsgComposer *composer) widget = e_composer_header_table_new (shell); gtk_container_set_border_width (GTK_CONTAINER (widget), 6); gtk_box_pack_start (GTK_BOX (editor->vbox), widget, FALSE, FALSE, 0); - if (e_msg_composer_get_lite ()) + if (small_screen_mode) gtk_box_reorder_child (GTK_BOX (editor->vbox), widget, 1); else gtk_box_reorder_child (GTK_BOX (editor->vbox), widget, 2); @@ -265,7 +269,7 @@ e_composer_private_constructed (EMsgComposer *composer) /* Construct the attachment paned. */ - if (e_msg_composer_get_lite ()) { + if (small_screen_mode) { e_attachment_paned_set_default_height (75); /* short attachment bar for Anjal */ e_attachment_icon_view_set_default_icon_size (GTK_ICON_SIZE_BUTTON); } @@ -274,7 +278,7 @@ e_composer_private_constructed (EMsgComposer *composer) priv->attachment_paned = g_object_ref (widget); gtk_widget_show (widget); - if (e_msg_composer_get_lite ()) { + if (small_screen_mode) { GtkWidget *tmp, *tmp1, *tmp_box, *container; GtkWidget *combo; @@ -414,6 +418,13 @@ e_composer_private_dispose (EMsgComposer *composer) g_array_remove_index_fast (array, 0); } + if (composer->priv->shell != NULL) { + g_object_remove_weak_pointer ( + G_OBJECT (composer->priv->shell), + &composer->priv->shell); + composer->priv->shell = NULL; + } + if (composer->priv->header_table != NULL) { g_object_unref (composer->priv->header_table); composer->priv->header_table = NULL; diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h index 570439530a..85b51c0356 100644 --- a/composer/e-composer-private.h +++ b/composer/e-composer-private.h @@ -87,6 +87,8 @@ G_BEGIN_DECLS struct _EMsgComposerPrivate { + gpointer shell; /* weak pointer */ + /*** UI Management ***/ GtkWidget *html_editor; diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index e56bab9362..4a6c6b267f 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -75,7 +75,8 @@ enum { PROP_0, - PROP_FOCUS_TRACKER + PROP_FOCUS_TRACKER, + PROP_SHELL }; enum { @@ -1272,19 +1273,19 @@ is_top_signature (EMsgComposer *composer) if (priv->is_from_message) return FALSE; - shell = e_shell_get_default (); + shell = e_msg_composer_get_shell (composer); shell_settings = e_shell_get_shell_settings (shell); return e_shell_settings_get_boolean (shell_settings, "composer-top-signature"); } static gboolean -add_signature_delim (void) +add_signature_delim (EMsgComposer *composer) { EShell *shell; EShellSettings *shell_settings; - shell = e_shell_get_default (); + shell = e_msg_composer_get_shell (composer); shell_settings = e_shell_get_shell_settings (shell); return !e_shell_settings_get_boolean (shell_settings, "composer-no-signature-delim"); @@ -1313,7 +1314,7 @@ get_signature_html (EMsgComposer *composer) if (!signature) return NULL; - add_delim = add_signature_delim (); + add_delim = add_signature_delim (composer); if (!e_signature_get_autogenerated (signature)) { const gchar *filename; @@ -1468,12 +1469,14 @@ autosave_load_draft_cb (EMsgComposer *composer, } static EMsgComposer * -autosave_load_draft (const gchar *filename) +autosave_load_draft (EShell *shell, + const gchar *filename) { CamelStream *stream; - CamelMimeMessage *msg; + CamelMimeMessage *message; EMsgComposer *composer; + g_return_val_if_fail (E_IS_SHELL (shell), NULL); g_return_val_if_fail (filename != NULL, NULL); stream = camel_stream_fs_new_with_name ( @@ -1481,12 +1484,12 @@ autosave_load_draft (const gchar *filename) if (stream == NULL) return NULL; - msg = camel_mime_message_new (); + message = camel_mime_message_new (); camel_data_wrapper_construct_from_stream ( - CAMEL_DATA_WRAPPER (msg), stream, NULL); + CAMEL_DATA_WRAPPER (message), stream, NULL); g_object_unref (stream); - composer = e_msg_composer_new_with_message (msg); + composer = e_msg_composer_new_with_message (shell, message); if (composer) { /* Mark the message as changed so it gets autosaved again, * then we can safely remove the old autosave file in the @@ -1708,61 +1711,18 @@ msg_composer_notify_header_cb (EMsgComposer *composer) gtkhtml_editor_set_changed (editor, TRUE); } -static void -msg_composer_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_FOCUS_TRACKER: - g_value_set_object ( - value, e_msg_composer_get_focus_tracker ( - E_MSG_COMPOSER (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -msg_composer_dispose (GObject *object) -{ - EMsgComposer *composer = E_MSG_COMPOSER (object); - - e_composer_private_dispose (composer); - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -msg_composer_finalize (GObject *object) -{ - EMsgComposer *composer = E_MSG_COMPOSER (object); - - e_composer_autosave_unregister (composer); - e_composer_private_finalize (composer); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static gboolean -msg_composer_delete_event_cb (GtkWidget *widget, gpointer user_data) +msg_composer_delete_event_cb (EMsgComposer *composer) { EShell *shell; - shell = e_shell_get_default (); + shell = e_msg_composer_get_shell (composer); if (g_list_length (e_shell_get_watched_windows (shell)) == 1) { /* This is the last watched window, use the quit * mechanism to have a draft saved properly */ e_shell_quit (shell, E_SHELL_QUIT_ACTION); } else { - /* This is needed for the ACTION macro. */ - EMsgComposer *composer = E_MSG_COMPOSER (widget); - /* There are more watched windows opened, * invoke only a close action */ gtk_action_activate (ACTION (CLOSE)); @@ -1792,10 +1752,6 @@ msg_composer_quit_requested_cb (EShell *shell, EMsgComposer *composer) { if (e_msg_composer_is_exiting (composer)) { - EShell *shell; - - shell = e_shell_get_default (); - g_signal_handlers_disconnect_by_func ( shell, msg_composer_quit_requested_cb, composer); g_signal_handlers_disconnect_by_func ( @@ -1807,6 +1763,82 @@ msg_composer_quit_requested_cb (EShell *shell, } static void +msg_composer_set_shell (EMsgComposer *composer, + EShell *shell) +{ + g_return_if_fail (E_IS_SHELL (shell)); + g_return_if_fail (composer->priv->shell == NULL); + + composer->priv->shell = shell; + + g_object_add_weak_pointer ( + G_OBJECT (shell), &composer->priv->shell); +} + +static void +msg_composer_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_SHELL: + msg_composer_set_shell ( + E_MSG_COMPOSER (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +msg_composer_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_FOCUS_TRACKER: + g_value_set_object ( + value, e_msg_composer_get_focus_tracker ( + E_MSG_COMPOSER (object))); + return; + + case PROP_SHELL: + g_value_set_object ( + value, e_msg_composer_get_shell ( + E_MSG_COMPOSER (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +msg_composer_dispose (GObject *object) +{ + EMsgComposer *composer = E_MSG_COMPOSER (object); + + e_composer_private_dispose (composer); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +msg_composer_finalize (GObject *object) +{ + EMsgComposer *composer = E_MSG_COMPOSER (object); + + e_composer_autosave_unregister (composer); + e_composer_private_finalize (composer); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void msg_composer_constructed (GObject *object) { EShell *shell; @@ -1827,9 +1859,14 @@ msg_composer_constructed (GObject *object) editor = GTKHTML_EDITOR (object); composer = E_MSG_COMPOSER (object); - shell = e_shell_get_default (); + shell = e_msg_composer_get_shell (composer); shell_settings = e_shell_get_shell_settings (shell); + if (e_shell_get_express_mode (shell)) { + GtkWindow *parent = e_shell_get_active_window (shell); + gtk_window_set_transient_for (GTK_WINDOW (composer), parent); + } + e_composer_private_constructed (composer); html = gtkhtml_editor_get_html (editor); @@ -1840,16 +1877,19 @@ msg_composer_constructed (GObject *object) gtk_window_set_title (GTK_WINDOW (composer), _("Compose Message")); gtk_window_set_icon_name (GTK_WINDOW (composer), "mail-message-new"); - g_signal_connect (object, "delete-event", + g_signal_connect ( + object, "delete-event", G_CALLBACK (msg_composer_delete_event_cb), NULL); e_shell_adapt_window_size (shell, GTK_WINDOW (composer)); e_shell_watch_window (shell, GTK_WINDOW (object)); - g_signal_connect (shell, "quit-requested", + g_signal_connect ( + shell, "quit-requested", G_CALLBACK (msg_composer_quit_requested_cb), composer); - g_signal_connect (shell, "prepare-for-quit", + g_signal_connect ( + shell, "prepare-for-quit", G_CALLBACK (msg_composer_prepare_for_quit_cb), composer); /* Restore Persistent State */ @@ -1962,6 +2002,7 @@ msg_composer_destroy (GtkObject *object) composer->priv->address_dialog = NULL; } + /* FIXME Our EShell is already unreferenced. */ shell = e_shell_get_default (); g_signal_handlers_disconnect_by_func ( @@ -2238,6 +2279,7 @@ msg_composer_class_init (EMsgComposerClass *class) g_type_class_add_private (class, sizeof (EMsgComposerPrivate)); object_class = G_OBJECT_CLASS (class); + object_class->set_property = msg_composer_set_property; object_class->get_property = msg_composer_get_property; object_class->dispose = msg_composer_dispose; object_class->finalize = msg_composer_finalize; @@ -2271,6 +2313,17 @@ msg_composer_class_init (EMsgComposerClass *class) E_TYPE_FOCUS_TRACKER, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_SHELL, + g_param_spec_object ( + "shell", + "Shell", + "The EShell singleton", + E_TYPE_SHELL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + signals[SEND] = g_signal_new ( "send", G_OBJECT_CLASS_TYPE (class), @@ -2300,14 +2353,7 @@ msg_composer_class_init (EMsgComposerClass *class) static void msg_composer_init (EMsgComposer *composer) { - EShell *shell = e_shell_get_default (); - composer->priv = E_MSG_COMPOSER_GET_PRIVATE (composer); - - if (e_shell_get_express_mode (shell)) { - GtkWindow *window = e_shell_get_active_window(shell); - gtk_window_set_transient_for (GTK_WINDOW(composer), window); - } } GType @@ -2340,34 +2386,20 @@ e_msg_composer_get_type (void) /** * e_msg_composer_new: + * @shell: an #EShell * * Create a new message composer widget. * * Returns: A pointer to the newly created widget **/ EMsgComposer * -e_msg_composer_new (void) +e_msg_composer_new (EShell *shell) { + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + return g_object_new ( E_TYPE_MSG_COMPOSER, - "html", e_web_view_new (), NULL); -} - -/** - * e_msg_composer_get_lite: - * - * Used within the composer to see if it should be made suitable for small - * screens. - * - * Return value: whether the surrounding #EShell is in small screen mode. - */ -gboolean -e_msg_composer_get_lite (void) -{ - EShell *shell; - - shell = e_shell_get_default (); - return e_shell_get_small_screen_mode (shell); + "html", e_web_view_new (), "shell", shell, NULL); } EFocusTracker * @@ -2823,6 +2855,7 @@ set_signature_gui (EMsgComposer *composer) /** * e_msg_composer_new_with_message: + * @shell: an #EShell * @message: The message to use as the source * * Create a new message composer widget. @@ -2832,7 +2865,8 @@ set_signature_gui (EMsgComposer *composer) * Returns: A pointer to the newly created widget **/ EMsgComposer * -e_msg_composer_new_with_message (CamelMimeMessage *message) +e_msg_composer_new_with_message (EShell *shell, + CamelMimeMessage *message) { CamelInternetAddress *to, *cc, *bcc; GList *To = NULL, *Cc = NULL, *Bcc = NULL, *postto = NULL; @@ -2851,12 +2885,14 @@ e_msg_composer_new_with_message (CamelMimeMessage *message) struct _camel_header_raw *xev; gint len, i; + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + for (headers = CAMEL_MIME_PART (message)->headers;headers;headers = headers->next) { if (!strcmp (headers->name, "X-Evolution-PostTo")) postto = g_list_append (postto, g_strstrip (g_strdup (headers->value))); } - composer = e_msg_composer_new (); + composer = e_msg_composer_new (shell); priv = E_MSG_COMPOSER_GET_PRIVATE (composer); table = e_msg_composer_get_header_table (composer); @@ -3154,6 +3190,7 @@ disable_editor (EMsgComposer *composer) /** * e_msg_composer_new_redirect: + * @shell: an #EShell * @message: The message to use as the source * * Create a new message composer widget. @@ -3161,16 +3198,18 @@ disable_editor (EMsgComposer *composer) * Returns: A pointer to the newly created widget **/ EMsgComposer * -e_msg_composer_new_redirect (CamelMimeMessage *message, +e_msg_composer_new_redirect (EShell *shell, + CamelMimeMessage *message, const gchar *resent_from) { EMsgComposer *composer; EComposerHeaderTable *table; const gchar *subject; + g_return_val_if_fail (E_IS_SHELL (shell), NULL); g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); - composer = e_msg_composer_new_with_message (message); + composer = e_msg_composer_new_with_message (shell, message); table = e_msg_composer_get_header_table (composer); subject = camel_mime_message_get_subject (message); @@ -3202,11 +3241,9 @@ e_msg_composer_get_session (EMsgComposer *composer) EShellSettings *shell_settings; CamelSession *session; - /* FIXME EMsgComposer should own a reference to EShell. */ - g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); - shell = e_shell_get_default (); + shell = e_msg_composer_get_shell (composer); shell_settings = e_shell_get_shell_settings (shell); session = e_shell_settings_get_pointer (shell_settings, "mail-session"); @@ -3216,6 +3253,22 @@ e_msg_composer_get_session (EMsgComposer *composer) } /** + * e_msg_composer_get_shell: + * @composer: an #EMsgComposer + * + * Returns the #EShell that was passed to e_msg_composer_new(). + * + * Returns: the #EShell + **/ +EShell * +e_msg_composer_get_shell (EMsgComposer *composer) +{ + g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); + + return E_SHELL (composer->priv->shell); +} + +/** * e_msg_composer_send: * @composer: an #EMsgComposer * @@ -3443,21 +3496,22 @@ handle_mailto (EMsgComposer *composer, const gchar *mailto) /** * e_msg_composer_new_from_url: + * @shell: an #EShell * @url: a mailto URL * * Create a new message composer widget, and fill in fields as * defined by the provided URL. **/ EMsgComposer * -e_msg_composer_new_from_url (const gchar *url) +e_msg_composer_new_from_url (EShell *shell, + const gchar *url) { EMsgComposer *composer; + g_return_val_if_fail (E_IS_SHELL (shell), NULL); g_return_val_if_fail (g_ascii_strncasecmp (url, "mailto:", 7) == 0, NULL); - composer = e_msg_composer_new (); - if (!composer) - return NULL; + composer = e_msg_composer_new (shell); handle_mailto (composer, url); @@ -3815,12 +3869,15 @@ CamelMimeMessage * e_msg_composer_get_message_print (EMsgComposer *composer, gboolean save_html_object_data) { + EShell *shell; GtkhtmlEditor *editor; EMsgComposer *temp_composer; CamelMimeMessage *msg; gboolean html_content; gchar *flags; + g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); + editor = GTKHTML_EDITOR (composer); html_content = gtkhtml_editor_get_html_mode (editor); @@ -3828,7 +3885,8 @@ e_msg_composer_get_message_print (EMsgComposer *composer, if (msg == NULL) return NULL; - temp_composer = e_msg_composer_new_with_message (msg); + shell = e_msg_composer_get_shell (composer); + temp_composer = e_msg_composer_new_with_message (shell, msg); g_object_unref (msg); /* Override composer flags. */ @@ -4140,12 +4198,14 @@ e_msg_composer_can_close (EMsgComposer *composer, } EMsgComposer * -e_msg_composer_load_from_file (const gchar *filename) +e_msg_composer_load_from_file (EShell *shell, + const gchar *filename) { CamelStream *stream; - CamelMimeMessage *msg; + CamelMimeMessage *message; EMsgComposer *composer; + g_return_val_if_fail (E_IS_SHELL (shell), NULL); g_return_val_if_fail (filename != NULL, NULL); stream = camel_stream_fs_new_with_name ( @@ -4153,12 +4213,12 @@ e_msg_composer_load_from_file (const gchar *filename) if (stream == NULL) return NULL; - msg = camel_mime_message_new (); + message = camel_mime_message_new (); camel_data_wrapper_construct_from_stream ( - CAMEL_DATA_WRAPPER (msg), stream, NULL); + CAMEL_DATA_WRAPPER (message), stream, NULL); g_object_unref (stream); - composer = e_msg_composer_new_with_message (msg); + composer = e_msg_composer_new_with_message (shell, message); if (composer != NULL) gtk_widget_show (GTK_WIDGET (composer)); @@ -4166,12 +4226,17 @@ e_msg_composer_load_from_file (const gchar *filename) } void -e_msg_composer_check_autosave (GtkWindow *parent) +e_msg_composer_check_autosave (EShell *shell) { + GtkWindow *parent; GList *orphans = NULL; gint response; GError *error = NULL; + g_return_if_fail (E_IS_SHELL (shell)); + + parent = e_shell_get_active_window (shell); + /* Look for orphaned autosave files. */ orphans = e_composer_autosave_find_orphans (&error); if (orphans == NULL) { @@ -4193,7 +4258,7 @@ e_msg_composer_check_autosave (GtkWindow *parent) if (response == GTK_RESPONSE_YES) { /* FIXME: composer is never used */ - composer = autosave_load_draft (filename); + composer = autosave_load_draft (shell, filename); } else { g_unlink (filename); } diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index b10253d6eb..92368a4384 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -30,6 +30,7 @@ #include <gtkhtml-editor.h> #include <misc/e-attachment-view.h> #include <misc/e-focus-tracker.h> +#include <shell/e-shell.h> #include "e-composer-header-table.h" @@ -68,14 +69,17 @@ struct _EMsgComposerClass { }; GType e_msg_composer_get_type (void); -EMsgComposer * e_msg_composer_new (void); -gboolean e_msg_composer_get_lite (void); -EMsgComposer * e_msg_composer_new_with_message (CamelMimeMessage *msg); -EMsgComposer * e_msg_composer_new_from_url (const gchar *url); -EMsgComposer * e_msg_composer_new_redirect (CamelMimeMessage *message, +EMsgComposer * e_msg_composer_new (EShell *shell); +EMsgComposer * e_msg_composer_new_with_message (EShell *shell, + CamelMimeMessage *msg); +EMsgComposer * e_msg_composer_new_from_url (EShell *shell, + const gchar *url); +EMsgComposer * e_msg_composer_new_redirect (EShell *shell, + CamelMimeMessage *message, const gchar *resent_from); EFocusTracker * e_msg_composer_get_focus_tracker(EMsgComposer *composer); CamelSession * e_msg_composer_get_session (EMsgComposer *composer); +EShell * e_msg_composer_get_shell (EMsgComposer *composer); void e_msg_composer_send (EMsgComposer *composer); void e_msg_composer_save_draft (EMsgComposer *composer); @@ -137,8 +141,9 @@ void e_msg_composer_request_close (EMsgComposer *composer); gboolean e_msg_composer_can_close (EMsgComposer *composer, gboolean can_save_draft); -EMsgComposer * e_msg_composer_load_from_file (const gchar *filename); -void e_msg_composer_check_autosave (GtkWindow *parent); +EMsgComposer * e_msg_composer_load_from_file (EShell *shell, + const gchar *filename); +void e_msg_composer_check_autosave (EShell *shell); void e_msg_composer_reply_indent (EMsgComposer *composer); |