[geary] Add Insert Image button, action and hander to composer. Bug 712995.



commit 8191ed429803a952fac8b571ede94fe3a66e5b69
Author: Michael James Gratton <mike vee net>
Date:   Wed Sep 28 22:47:40 2016 +1000

    Add Insert Image button, action and hander to composer. Bug 712995.
    
    * src/client/composer/composer-widget.vala (ComposerWidget): Add action
      and callback that simply does a normal attachment for now.
    
    * ui/composer-widget.ui: Add insert image button to the composer toobar.

 src/client/composer/composer-widget.vala |   12 ++++++++++--
 ui/composer-widget.ui                    |   29 ++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 3eaf9b2..31e69da 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -58,6 +58,7 @@ public class ComposerWidget : Gtk.EventBox {
     private const string ACTION_OUTDENT = "outdent";
     private const string ACTION_JUSTIFY = "justify";
     private const string ACTION_COLOR = "color";
+    private const string ACTION_INSERT_IMAGE = "insert-image";
     private const string ACTION_INSERT_LINK = "insert-link";
     private const string ACTION_COMPOSE_AS_HTML = "compose-as-html";
     private const string ACTION_SHOW_EXTENDED = "show-extended";
@@ -72,8 +73,8 @@ public class ComposerWidget : Gtk.EventBox {
 
     private const string[] html_actions = {
         ACTION_BOLD, ACTION_ITALIC, ACTION_UNDERLINE, ACTION_STRIKETHROUGH, ACTION_FONT_SIZE,
-        ACTION_FONT_FAMILY, ACTION_REMOVE_FORMAT, ACTION_COLOR, ACTION_JUSTIFY, ACTION_INSERT_LINK,
-        ACTION_COPY_LINK, ACTION_PASTE_WITH_FORMATTING
+        ACTION_FONT_FAMILY, ACTION_REMOVE_FORMAT, ACTION_COLOR, ACTION_JUSTIFY,
+        ACTION_INSERT_IMAGE, ACTION_INSERT_LINK, ACTION_COPY_LINK, ACTION_PASTE_WITH_FORMATTING
     };
 
     private const ActionEntry[] action_entries = {
@@ -97,6 +98,7 @@ public class ComposerWidget : Gtk.EventBox {
         {ACTION_OUTDENT,                  on_action                                     },
         {ACTION_JUSTIFY,                  on_justify,                "s",     "'left'"  },
         {ACTION_COLOR,                    on_select_color                               },
+        {ACTION_INSERT_IMAGE,             on_insert_image                               },
         {ACTION_INSERT_LINK,              on_insert_link                                },
         // Composer commands
         {ACTION_COMPOSE_AS_HTML,          on_toggle_action,        null,   "true",  
on_compose_as_html_toggled },
@@ -119,6 +121,7 @@ public class ComposerWidget : Gtk.EventBox {
         action_accelerators.set(ACTION_COPY, "<Ctrl>x");
         action_accelerators.set(ACTION_PASTE, "<Ctrl>v");
         action_accelerators.set(ACTION_PASTE_WITH_FORMATTING, "<Ctrl><Shift>v");
+        action_accelerators.set(ACTION_INSERT_IMAGE, "<Ctrl>g");
         action_accelerators.set(ACTION_INSERT_LINK, "<Ctrl>l");
         action_accelerators.set(ACTION_INDENT, "<Ctrl>bracketright");
         action_accelerators.set(ACTION_OUTDENT, "<Ctrl>bracketleft");
@@ -1884,6 +1887,11 @@ public class ComposerWidget : Gtk.EventBox {
         }
     }
 
+    private void on_insert_image(SimpleAction action, Variant? param) {
+        AttachmentDialog dialog = new AttachmentDialog(this.container.top_window);
+        dialog.is_finished(add_attachment);
+    }
+
     private void on_insert_link(SimpleAction action, Variant? param) {
         link_dialog("http://";);
     }
diff --git a/ui/composer-widget.ui b/ui/composer-widget.ui
index 98c17b5..0260a35 100644
--- a/ui/composer-widget.ui
+++ b/ui/composer-widget.ui
@@ -468,7 +468,7 @@
               </object>
             </child>
             <child>
-              <object class="GtkBox" id="link_buttons">
+              <object class="GtkBox" id="insert_buttons">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <style>
@@ -488,6 +488,33 @@
                       </object>
                     </child>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="insert_image_button">
+                    <property name="visible" bind-source="insert_image_button" bind-property="sensitive" />
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">Image (Ctrl+G)</property>
+                    <property name="action_name">cmp.insert-image</property>
+                    <property name="always_show_image">True</property>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="can_focus">False</property>
+                        <property name="pixel_size">16</property>
+                        <property name="icon_name">insert-image-symbolic</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
             </child>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]