diff options
author | Milan Crha <mcrha@redhat.com> | 2010-12-22 04:11:10 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-12-22 04:11:10 +0800 |
commit | e861630f113e4dcff45bbc2684310c793838f384 (patch) | |
tree | 034e0f4ce0883ab2c7caca63835c595599ce1d8f /composer | |
parent | 74098399cc5fe7e07b32439952272101f86b8502 (diff) | |
download | gsoc2013-evolution-e861630f113e4dcff45bbc2684310c793838f384.tar.gz gsoc2013-evolution-e861630f113e4dcff45bbc2684310c793838f384.tar.zst gsoc2013-evolution-e861630f113e4dcff45bbc2684310c793838f384.zip |
Bug #567879 - Add View >> Gallery Option In Email Composer
Diffstat (limited to 'composer')
-rw-r--r-- | composer/e-composer-actions.c | 16 | ||||
-rw-r--r-- | composer/e-composer-actions.h | 2 | ||||
-rw-r--r-- | composer/e-composer-private.c | 81 | ||||
-rw-r--r-- | composer/e-composer-private.h | 5 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 32 | ||||
-rw-r--r-- | composer/evolution-composer.ui | 6 |
6 files changed, 135 insertions, 7 deletions
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c index 3b2aabfefc..1f1cb44a7c 100644 --- a/composer/e-composer-actions.c +++ b/composer/e-composer-actions.c @@ -353,6 +353,14 @@ static GtkToggleActionEntry toggle_entries[] = { G_CALLBACK (action_pgp_sign_cb), FALSE }, + { "picture-gallery", + "emblem-photos", + N_("_Picture Gallery"), + NULL, + N_("Show a collection of pictures that you can drag to your message"), + NULL, /* no callback */ + FALSE }, + { "prioritize-message", NULL, N_("_Prioritize Message"), @@ -461,9 +469,17 @@ e_composer_actions_init (EMsgComposer *composer) ACTION (ATTACH), "short-label", _("Attach"), NULL); g_object_set ( + ACTION (PICTURE_GALLERY), "is-important", TRUE, NULL); + + g_object_set ( ACTION (SAVE_DRAFT), "short-label", _("Save Draft"), NULL); g_object_bind_property ( + composer, "html-mode", + ACTION (PICTURE_GALLERY), "sensitive", + G_BINDING_SYNC_CREATE); + + g_object_bind_property ( web_view, "editable", GTKHTML_EDITOR_ACTION_EDIT_MENU (editor), "sensitive", G_BINDING_SYNC_CREATE); diff --git a/composer/e-composer-actions.h b/composer/e-composer-actions.h index 80147a8f24..4aed102a64 100644 --- a/composer/e-composer-actions.h +++ b/composer/e-composer-actions.h @@ -29,6 +29,8 @@ E_COMPOSER_ACTION ((composer), "pgp-encrypt") #define E_COMPOSER_ACTION_PGP_SIGN(composer) \ E_COMPOSER_ACTION ((composer), "pgp-sign") +#define E_COMPOSER_ACTION_PICTURE_GALLERY(composer) \ + E_COMPOSER_ACTION ((composer), "picture-gallery") #define E_COMPOSER_ACTION_PRINT(composer) \ E_COMPOSER_ACTION ((composer), "print") #define E_COMPOSER_ACTION_PRINT_PREVIEW(composer) \ diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index f9840bd929..816ea10b16 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -20,6 +20,9 @@ #include "e-composer-private.h" #include "e-util/e-util-private.h" +/* Initial height of the picture gallery. */ +#define GALLERY_INITIAL_HEIGHT 150 + static void composer_setup_charset_menu (EMsgComposer *composer) { @@ -124,12 +127,36 @@ msg_composer_url_requested_cb (GtkHTML *html, g_signal_stop_emission_by_name (html, "url-requested"); } +static void +composer_update_gallery_visibility (EMsgComposer *composer) +{ + GtkhtmlEditor *editor; + GtkToggleAction *toggle_action; + gboolean gallery_active; + gboolean html_mode; + + editor = GTKHTML_EDITOR (composer); + html_mode = gtkhtml_editor_get_html_mode (editor); + + toggle_action = GTK_TOGGLE_ACTION (ACTION (PICTURE_GALLERY)); + gallery_active = gtk_toggle_action_get_active (toggle_action); + + if (html_mode && gallery_active) { + gtk_widget_show (composer->priv->gallery_scrolled_window); + gtk_widget_show (composer->priv->gallery_icon_view); + } else { + gtk_widget_hide (composer->priv->gallery_scrolled_window); + gtk_widget_hide (composer->priv->gallery_icon_view); + } +} + void e_composer_private_constructed (EMsgComposer *composer) { EMsgComposerPrivate *priv = composer->priv; EFocusTracker *focus_tracker; EShell *shell; + EShellSettings *shell_settings; EWebView *web_view; GtkhtmlEditor *editor; GtkUIManager *ui_manager; @@ -140,7 +167,7 @@ e_composer_private_constructed (EMsgComposer *composer) GtkWindow *window; const gchar *path; gboolean small_screen_mode; - gchar *filename; + gchar *filename, *gallery_path; gint ii; GError *error = NULL; @@ -148,6 +175,7 @@ e_composer_private_constructed (EMsgComposer *composer) ui_manager = gtkhtml_editor_get_ui_manager (editor); shell = e_msg_composer_get_shell (composer); + shell_settings = e_shell_get_shell_settings (shell); web_view = e_msg_composer_get_web_view (composer); small_screen_mode = e_shell_get_small_screen_mode (shell); @@ -289,6 +317,7 @@ e_composer_private_constructed (EMsgComposer *composer) e_attachment_paned_set_default_height (75); /* short attachment bar for Anjal */ e_attachment_icon_view_set_default_icon_size (GTK_ICON_SIZE_BUTTON); } + widget = e_attachment_paned_new (); gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); priv->attachment_paned = g_object_ref (widget); @@ -354,18 +383,53 @@ e_composer_private_constructed (EMsgComposer *composer) gtk_box_pack_end (GTK_BOX (container), tmp_box, FALSE, FALSE, 3); } - g_object_set_data ((GObject *)composer, "vbox", editor->vbox); + container = e_attachment_paned_get_content_area ( + E_ATTACHMENT_PANED (priv->attachment_paned)); + + widget = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (container), widget); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type ( + GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); + gtk_widget_set_size_request (widget, -1, GALLERY_INITIAL_HEIGHT); + gtk_paned_pack1 (GTK_PANED (container), widget, FALSE, FALSE); + priv->gallery_scrolled_window = g_object_ref (widget); + gtk_widget_show (widget); /* Reparent the scrolled window containing the GtkHTML widget * into the content area of the top attachment pane. */ widget = GTK_WIDGET (web_view); widget = gtk_widget_get_parent (widget); - container = e_attachment_paned_get_content_area ( - E_ATTACHMENT_PANED (priv->attachment_paned)); gtk_widget_reparent (widget, container); - gtk_box_set_child_packing ( - GTK_BOX (container), widget, TRUE, TRUE, 0, GTK_PACK_START); + + /* Construct the picture gallery. */ + + container = priv->gallery_scrolled_window; + + gallery_path = e_shell_settings_get_string (shell_settings, "composer-gallery-path"); + widget = e_picture_gallery_new (gallery_path); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->gallery_icon_view = g_object_ref (widget); + g_free (gallery_path); + + g_signal_connect ( + composer, "notify::html-mode", + G_CALLBACK (composer_update_gallery_visibility), NULL); + + g_signal_connect_swapped ( + ACTION (PICTURE_GALLERY), "toggled", + G_CALLBACK (composer_update_gallery_visibility), composer); + + /* XXX What is this for? */ + g_object_set_data (G_OBJECT (composer), "vbox", editor->vbox); composer_setup_recent_menu (composer); @@ -498,6 +562,11 @@ e_composer_private_dispose (EMsgComposer *composer) composer->priv->composer_actions = NULL; } + if (composer->priv->gallery_scrolled_window != NULL) { + g_object_unref (composer->priv->gallery_scrolled_window); + composer->priv->gallery_scrolled_window = NULL; + } + g_hash_table_remove_all (composer->priv->inline_images); g_hash_table_remove_all (composer->priv->inline_images_by_url); diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h index b4818d4c57..230d2f4fec 100644 --- a/composer/e-composer-private.h +++ b/composer/e-composer-private.h @@ -51,6 +51,7 @@ #include "widgets/misc/e-attachment-icon-view.h" #include "widgets/misc/e-attachment-paned.h" #include "widgets/misc/e-attachment-store.h" +#include "widgets/misc/e-picture-gallery.h" #include "widgets/misc/e-signature-combo-box.h" #include "widgets/misc/e-web-view.h" #include "shell/e-shell.h" @@ -113,7 +114,6 @@ struct _EMsgComposerPrivate { /*** UI Management ***/ - GtkWidget *html_editor; GtkWidget *header_table; GtkWidget *activity_bar; GtkWidget *alert_bar; @@ -132,6 +132,9 @@ struct _EMsgComposerPrivate { GtkWidget *focused_entry; + GtkWidget *gallery_icon_view; + GtkWidget *gallery_scrolled_window; + GtkWidget *address_dialog; GHashTable *inline_images; diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 227df24277..b79eaa3a71 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1976,6 +1976,34 @@ msg_composer_finalize (GObject *object) } static void +msg_composer_gallery_drag_data_get (GtkIconView *icon_view, + GdkDragContext *context, + GtkSelectionData *selection_data, + guint target_type, + guint time) +{ + GtkTreePath *path; + GtkCellRenderer *cell; + GtkTreeModel *model; + GtkTreeIter iter; + gchar *str_data; + + if (!gtk_icon_view_get_cursor (icon_view, &path, &cell)) + return; + + model = gtk_icon_view_get_model (icon_view); + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, 1, &str_data, -1); + gtk_tree_path_free (path); + + /* only supports "text/uri-list" */ + gtk_selection_data_set ( + selection_data, selection_data->target, 8, + (guchar *) str_data, strlen (str_data)); + g_free (str_data); +} + +static void msg_composer_constructed (GObject *object) { EShell *shell; @@ -2072,6 +2100,10 @@ msg_composer_constructed (GObject *object) web_view, "drag-data-received", G_CALLBACK (msg_composer_drag_data_received_cb), composer); + g_signal_connect ( + composer->priv->gallery_icon_view, "drag-data-get", + G_CALLBACK (msg_composer_gallery_drag_data_get), NULL); + /* Configure Headers */ e_composer_header_table_set_account_list ( diff --git a/composer/evolution-composer.ui b/composer/evolution-composer.ui index f283d35dcb..d1eb10c76c 100644 --- a/composer/evolution-composer.ui +++ b/composer/evolution-composer.ui @@ -25,6 +25,8 @@ <menuitem action='view-reply-to'/> <menuitem action='view-cc'/> <menuitem action='view-bcc'/> + <separator/> + <menuitem action='picture-gallery'/> </menu> </placeholder> <menu action='insert-menu'> @@ -56,4 +58,8 @@ <separator/> </placeholder> </toolbar> + <toolbar name='html-toolbar'> + <separator/> + <toolitem action='picture-gallery'/> + </toolbar> </ui> |