[gnome-builder] run-button: use DzlShortcutTooltip



commit 9e583b33c2d30e3d0e99712a9d805cd1ffac9c9c
Author: Christian Hergert <chergert redhat com>
Date:   Tue Oct 2 23:49:56 2018 -0700

    run-button: use DzlShortcutTooltip

 src/libide/runner/ide-run-button.c  | 18 +++++++-----------
 src/libide/runner/ide-run-button.ui |  3 +++
 2 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/src/libide/runner/ide-run-button.c b/src/libide/runner/ide-run-button.c
index ac9ddb1bc..2281a6d2c 100644
--- a/src/libide/runner/ide-run-button.c
+++ b/src/libide/runner/ide-run-button.c
@@ -41,6 +41,7 @@ struct _IdeRunButton
   GtkButton            *stop_button;
   GtkShortcutsShortcut *run_shortcut;
   GtkLabel             *run_tooltip_message;
+  DzlShortcutTooltip   *tooltip;
 };
 
 G_DEFINE_TYPE (IdeRunButton, ide_run_button, GTK_TYPE_BOX)
@@ -154,21 +155,15 @@ ide_run_button_query_tooltip (IdeRunButton *self,
                                        NULL,
                                        NULL);
 
-          if (enabled)
-            {
-              g_object_set (self->run_shortcut,
-                            "accelerator", info->accel,
-                            "title", info->title,
-                            "visible", TRUE,
-                            NULL);
-              gtk_tooltip_set_custom (tooltip, GTK_WIDGET (self->run_shortcut));
-            }
-          else
+          if (!enabled)
             {
               gtk_tooltip_set_custom (tooltip, GTK_WIDGET (self->run_tooltip_message));
+              return TRUE;
             }
 
-          return TRUE;
+          /* The shortcut tooltip will set this up after us */
+          dzl_shortcut_tooltip_set_accel (self->tooltip, info->accel);
+          dzl_shortcut_tooltip_set_title (self->tooltip, info->title);
         }
     }
 
@@ -187,6 +182,7 @@ ide_run_button_class_init (IdeRunButtonClass *klass)
   gtk_widget_class_bind_template_child (widget_class, IdeRunButton, run_shortcut);
   gtk_widget_class_bind_template_child (widget_class, IdeRunButton, stop_button);
   gtk_widget_class_bind_template_child (widget_class, IdeRunButton, run_tooltip_message);
+  gtk_widget_class_bind_template_child (widget_class, IdeRunButton, tooltip);
 }
 
 static void
diff --git a/src/libide/runner/ide-run-button.ui b/src/libide/runner/ide-run-button.ui
index cc5a1dd45..e68678402 100644
--- a/src/libide/runner/ide-run-button.ui
+++ b/src/libide/runner/ide-run-button.ui
@@ -61,4 +61,7 @@
       </object>
     </child>
   </template>
+  <object class="DzlShortcutTooltip" id="tooltip">
+    <property name="widget">button</property>
+  </object>
 </interface>


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