[geary] Use click-to-focus prop on toolbar buttons rather than other workarounds.



commit 478ab2d7008574e742b0ecc38bffcf27ffe74bf3
Author: Michael James Gratton <mike vee net>
Date:   Thu Oct 20 16:58:48 2016 +1100

    Use click-to-focus prop on toolbar buttons rather than other workarounds.
    
    * src/client/application/geary-controller.vala
      (GearyController::archive_or_delete_selection_async): Don't modify the
      focus after archiving/trashing/deleting.
    
    * src/client/components/pill-toolbar.vala, ui/composer-headerbar.ui,
      ui/composer-widget.ui: Ensure all toolbar buttons are focusable but
      have focus-on-click disabled.

 src/client/application/geary-controller.vala |   14 ++++--------
 src/client/components/pill-toolbar.vala      |    1 +
 ui/composer-headerbar.ui                     |    9 ++++++++
 ui/composer-widget.ui                        |   29 +++++++++++++++++--------
 4 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index a7a6468..a4c3a1a 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -248,9 +248,9 @@ public class GearyController : Geary.BaseObject {
         
         // This is fired after the accounts are ready.
         Geary.Engine.instance.opened.connect(on_engine_opened);
-        
-        main_window.conversation_list_view.grab_focus();
-        
+
+        this.main_window.conversation_list_view.grab_focus();
+
         // instantiate here to ensure that Config is initialized and ready
         autostart_manager = new AutostartManager();
         
@@ -2578,10 +2578,6 @@ public class GearyController : Geary.BaseObject {
 
         last_deleted_conversation = selected_conversations.size > 0
             ? Geary.traverse<Geary.App.Conversation>(selected_conversations).first() : null;
-        
-        // Return focus to the conversation list from the clicked
-        // toolbar button.
-        this.main_window.conversation_list_view.grab_focus();
 
         this.main_window.conversation_list_view.set_changing_selection(true);
 
@@ -2732,9 +2728,9 @@ public class GearyController : Geary.BaseObject {
     }
 
     private void on_conversation_list() {
-        main_window.conversation_list_view.grab_focus();
+        this.main_window.conversation_list_view.grab_focus();
     }
-    
+
     private void on_sent(Geary.RFC822.Message rfc822) {
         Libnotify.play_sound("message-sent-email");
     }
diff --git a/src/client/components/pill-toolbar.vala b/src/client/components/pill-toolbar.vala
index 849a94f..98c9adb 100644
--- a/src/client/components/pill-toolbar.vala
+++ b/src/client/components/pill-toolbar.vala
@@ -36,6 +36,7 @@ public interface PillBar : Gtk.Container {
     public virtual void setup_button(Gtk.Button b, string? icon_name, string action_name,
         bool show_label = false) {
         Gtk.Action related_action = action_group.get_action(action_name);
+        b.focus_on_click = false;
         b.tooltip_text = related_action.tooltip;
         related_action.notify["tooltip"].connect(() => { b.tooltip_text = related_action.tooltip; });
         b.related_action = related_action;
diff --git a/ui/composer-headerbar.ui b/ui/composer-headerbar.ui
index cbbdf07..888f294 100644
--- a/ui/composer-headerbar.ui
+++ b/ui/composer-headerbar.ui
@@ -13,6 +13,7 @@
           <object class="GtkButton" id="detach_start_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
             <property name="margin_end">6</property>
             <property name="relief">GTK_RELIEF_NONE</property>
             <property name="action_name">cmh.detach</property>
@@ -39,6 +40,7 @@
       <object class="GtkButton" id="new_message_attach_button">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
+        <property name="focus_on_click">False</property>
         <property name="action_name">cmh.add-attachment</property>
         <property name="always_show_image">True</property>
         <property name="tooltip_text" translatable="yes">Attach File (Ctrl+T)</property>
@@ -61,6 +63,7 @@
           <object class="GtkButton" id="conversation_attach_new_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
             <property name="action_name">cmh.add-attachment</property>
             <property name="always_show_image">True</property>
             <property name="tooltip_text" translatable="yes">Attach File (Ctrl+T)</property>
@@ -76,6 +79,7 @@
           <object class="GtkButton" id="conversation_attach_original_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
             <property name="action_name">cmh.add-original-attachments</property>
             <property name="always_show_image">True</property>
             <property name="tooltip_text" translatable="yes">Include Original Attachments</property>
@@ -94,6 +98,7 @@
         <property name="visible">True</property>
         <property name="can_focus">True</property>
         <property name="relief">GTK_RELIEF_NONE</property>
+        <property name="focus_on_click">False</property>
         <child>
           <object class="GtkLabel" id="recipients_label">
             <property name="visible">True</property>
@@ -117,6 +122,7 @@
           <object class="GtkButton" id="detach_end_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
             <property name="margin_start">6</property>
             <property name="relief">GTK_RELIEF_NONE</property>
             <property name="action_name">cmh.detach</property>
@@ -139,6 +145,7 @@
       <object class="GtkButton" id="send_button">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
+        <property name="focus_on_click">False</property>
         <property name="action_name">cmh.send</property>
         <property name="always_show_image">True</property>
         <property name="use_underline">True</property>
@@ -163,6 +170,7 @@
           <object class="GtkButton" id="discard_and_close_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
             <property name="action_name">cmh.close-and-discard</property>
             <property name="always_show_image">True</property>
             <property name="tooltip_text" translatable="yes">Discard and Close</property>
@@ -178,6 +186,7 @@
           <object class="GtkButton" id="save_and_close_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="focus_on_click">False</property>
             <property name="action_name">cmh.close-and-save</property>
             <property name="always_show_image">True</property>
             <property name="tooltip_text" translatable="yes">Save and Close</property>
diff --git a/ui/composer-widget.ui b/ui/composer-widget.ui
index d20c392..9461bea 100644
--- a/ui/composer-widget.ui
+++ b/ui/composer-widget.ui
@@ -369,9 +369,10 @@
                 <child>
                   <object class="GtkToggleButton" id="bold_button">
                     <property name="visible" bind-source="bold_button" bind-property="sensitive" />
-                    <property name="can_focus">False</property>
                     <property name="always_show_image">True</property>
                     <property name="action_name">cmp.bold</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="tooltip_text" translatable="yes">Bold (Ctrl+B)</property>
                     <child>
                       <object class="GtkImage" id="bold_image">
@@ -384,7 +385,8 @@
                 <child>
                   <object class="GtkToggleButton" id="italics_button">
                     <property name="visible" bind-source="italics_button" bind-property="sensitive" />
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="action_name">cmp.italic</property>
                     <property name="always_show_image">True</property>
                     <property name="tooltip_text" translatable="yes">Italic (Ctrl+I)</property>
@@ -399,7 +401,8 @@
                 <child>
                   <object class="GtkToggleButton" id="underline_button">
                     <property name="visible" bind-source="underline_button" bind-property="sensitive" />
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="action_name">cmp.underline</property>
                     <property name="always_show_image">True</property>
                     <property name="tooltip_text" translatable="yes">Underline (Ctrl+U)</property>
@@ -414,7 +417,8 @@
                 <child>
                   <object class="GtkToggleButton" id="strikethrough_button">
                     <property name="visible" bind-source="strikethrough_button" bind-property="sensitive" />
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="action_name">cmp.strikethrough</property>
                     <property name="always_show_image">True</property>
                     <property name="tooltip_text" translatable="yes">Strikethrough (Ctrl+K)</property>
@@ -438,7 +442,8 @@
                 <child>
                   <object class="GtkButton" id="indent_button">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="action_name">cmp.indent</property>
                     <property name="always_show_image">True</property>
                     <property name="tooltip_text" translatable="yes">Quote text  (Ctrl+])</property>
@@ -453,7 +458,8 @@
                 <child>
                   <object class="GtkButton" id="outdent_button">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="action_name">cmp.outdent</property>
                     <property name="always_show_image">True</property>
                     <property name="tooltip_text" translatable="yes">Unquote text  (Ctrl+[)</property>
@@ -477,7 +483,8 @@
                 <child>
                   <object class="GtkButton" id="insert_link_button">
                     <property name="visible" bind-source="insert_link_button" bind-property="sensitive" />
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="focus_on_click">False</property>
                     <property name="action_name">cmp.insert-link</property>
                     <property name="always_show_image">True</property>
                     <property name="tooltip_text" translatable="yes">Link (Ctrl+L)</property>
@@ -498,6 +505,7 @@
                   <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="focus_on_click">False</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>
@@ -521,9 +529,10 @@
             <child>
               <object class="GtkButton" id="remove_format_button">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="always_show_image">True</property>
                 <property name="action_name">cmp.remove-format</property>
+                <property name="can_focus">True</property>
+                <property name="focus_on_click">False</property>
                 <property name="tooltip_text" translatable="yes">Remove formatting (Ctrl+Space)</property>
                 <child>
                   <object class="GtkImage" id="remove_format_image">
@@ -536,7 +545,8 @@
             <child>
               <object class="GtkButton" id="select_dictionary_button">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can_focus">True</property>
+                <property name="focus_on_click">False</property>
                 <property name="action_name">cmp.select-dictionary</property>
                 <property name="always_show_image">True</property>
                 <property name="tooltip_text" translatable="yes">Select spell checking language</property>
@@ -552,6 +562,7 @@
               <object class="GtkMenuButton" id="menu_button">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="focus_on_click">False</property>
               </object>
               <packing>
                 <property name="pack_type">end</property>


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