[gnome-builder] build-button: use GtkShortcutsShortcut for tooltip



commit 7296256e8e21c770bad74483ff7319937e04e4ee
Author: Christian Hergert <chergert redhat com>
Date:   Sat Feb 18 09:14:04 2017 -0800

    build-button: use GtkShortcutsShortcut for tooltip
    
    This allows us to match the other tooltip text for the run button.

 libide/workbench/ide-omni-bar.c  |   67 +++++++++++++++++++++++++------------
 libide/workbench/ide-omni-bar.ui |    7 +++-
 2 files changed, 51 insertions(+), 23 deletions(-)
---
diff --git a/libide/workbench/ide-omni-bar.c b/libide/workbench/ide-omni-bar.c
index 7d8a130..cd1eeaf 100644
--- a/libide/workbench/ide-omni-bar.c
+++ b/libide/workbench/ide-omni-bar.c
@@ -105,28 +105,29 @@ struct _IdeOmniBar
   /*
    * The following are template children from the GtkBuilder template.
    */
-  GtkLabel       *branch_label;
-  GtkEventBox    *event_box;
-  GtkLabel       *project_label;
-  GtkBox         *branch_box;
-  GtkLabel       *build_result_mode_label;
-  GtkImage       *build_result_diagnostics_image;
-  GtkButton      *build_button;
-  GtkButton      *cancel_button;
-  GtkLabel       *config_name_label;
-  GtkStack       *message_stack;
-  GtkPopover     *popover;
-  GtkLabel       *popover_branch_label;
-  GtkButton      *popover_build_cancel_button;
-  GtkLabel       *popover_build_mode_label;
-  GtkLabel       *popover_build_running_time_label;
-  GtkListBox     *popover_configuration_list_box;
-  GtkRevealer    *popover_details_revealer;
-  GtkLabel       *popover_failed_label;
-  GtkLabel       *popover_last_build_time_label;
-  GtkStack       *popover_time_stack;
-  GtkButton      *popover_view_output_button;
-  GtkLabel       *popover_project_label;
+  GtkLabel             *branch_label;
+  GtkEventBox          *event_box;
+  GtkLabel             *project_label;
+  GtkBox               *branch_box;
+  GtkLabel             *build_result_mode_label;
+  GtkImage             *build_result_diagnostics_image;
+  GtkButton            *build_button;
+  GtkShortcutsShortcut *build_button_shortcut;
+  GtkButton            *cancel_button;
+  GtkLabel             *config_name_label;
+  GtkStack             *message_stack;
+  GtkPopover           *popover;
+  GtkLabel             *popover_branch_label;
+  GtkButton            *popover_build_cancel_button;
+  GtkLabel             *popover_build_mode_label;
+  GtkLabel             *popover_build_running_time_label;
+  GtkListBox           *popover_configuration_list_box;
+  GtkRevealer          *popover_details_revealer;
+  GtkLabel             *popover_failed_label;
+  GtkLabel             *popover_last_build_time_label;
+  GtkStack             *popover_time_stack;
+  GtkButton            *popover_view_output_button;
+  GtkLabel             *popover_project_label;
 };
 
 G_DEFINE_TYPE (IdeOmniBar, ide_omni_bar, GTK_TYPE_BOX)
@@ -578,6 +579,21 @@ ide_omni_bar__build_manager__build_finished (IdeOmniBar       *self,
 }
 
 static void
+ide_omni_bar__build_button__query_tooltip (IdeOmniBar *self,
+                                           gint        x,
+                                           gint        y,
+                                           gboolean    keyboard,
+                                           GtkTooltip *tooltip,
+                                           GtkButton  *button)
+{
+  g_assert (IDE_IS_OMNI_BAR (self));
+  g_assert (GTK_IS_TOOLTIP (tooltip));
+  g_assert (GTK_IS_BUTTON (button));
+
+  gtk_tooltip_set_custom (tooltip, GTK_WIDGET (self->build_button_shortcut));
+}
+
+static void
 ide_omni_bar_finalize (GObject *object)
 {
   IdeOmniBar *self = (IdeOmniBar *)object;
@@ -620,6 +636,7 @@ ide_omni_bar_class_init (IdeOmniBarClass *klass)
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, branch_box);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, branch_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, build_button);
+  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, build_button_shortcut);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, build_result_diagnostics_image);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, build_result_mode_label);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, cancel_button);
@@ -648,6 +665,12 @@ ide_omni_bar_init (IdeOmniBar *self)
 
   gtk_widget_set_direction (GTK_WIDGET (self->branch_box), GTK_TEXT_DIR_LTR);
 
+  g_signal_connect_object (self->build_button,
+                           "query-tooltip",
+                           G_CALLBACK (ide_omni_bar__build_button__query_tooltip),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   /*
    * IdeBuildManager bindings and signals.
    */
diff --git a/libide/workbench/ide-omni-bar.ui b/libide/workbench/ide-omni-bar.ui
index 263426f..3998fca 100644
--- a/libide/workbench/ide-omni-bar.ui
+++ b/libide/workbench/ide-omni-bar.ui
@@ -103,11 +103,11 @@
       <object class="GtkButton" id="build_button">
         <property name="action-name">build-manager.build</property>
         <property name="focus-on-click">false</property>
+        <property name="has-tooltip">yes</property>
         <property name="visible">true</property>
         <child>
           <object class="GtkImage">
             <property name="icon-name">builder-build-symbolic</property>
-            <property name="tooltip-text" translatable="yes">Build project (Ctrl+F7)</property>
             <property name="visible">true</property>
           </object>
         </child>
@@ -410,4 +410,9 @@
       </object>
     </child>
   </object>
+  <object class="GtkShortcutsShortcut" id="build_button_shortcut">
+    <property name="accelerator">&lt;primary&gt;F7</property>
+    <property name="title" translatable="yes">Build project</property>
+    <property name="visible">true</property>
+  </object>
 </interface>


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