[gnome-builder] workbench: use DzlShortcutTooltip
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] workbench: use DzlShortcutTooltip
- Date: Wed, 3 Oct 2018 09:05:25 +0000 (UTC)
commit b16b944a0a9931a711f7e4d5464e58acbc6ef79a
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 3 00:55:33 2018 -0700
workbench: use DzlShortcutTooltip
src/libide/workbench/ide-omni-bar.c | 15 +++++-----
src/libide/workbench/ide-omni-bar.ui | 4 +++
src/libide/workbench/ide-workbench-header-bar.c | 37 ++++++++++++++++++++++++
src/libide/workbench/ide-workbench-header-bar.ui | 4 +++
4 files changed, 53 insertions(+), 7 deletions(-)
---
diff --git a/src/libide/workbench/ide-omni-bar.c b/src/libide/workbench/ide-omni-bar.c
index 518a5a380..c3f8191ac 100644
--- a/src/libide/workbench/ide-omni-bar.c
+++ b/src/libide/workbench/ide-omni-bar.c
@@ -134,7 +134,7 @@ struct _IdeOmniBar
GtkImage *build_result_diagnostics_image;
GtkLabel *build_result_mode_label;
GtkButton *build_button;
- GtkShortcutsShortcut *build_button_shortcut;
+ DzlShortcutTooltip *build_button_tooltip;
GtkLabel *build_tooltip_message;
GtkButton *cancel_button;
GtkLabel *config_name_label;
@@ -623,12 +623,13 @@ ide_omni_bar__build_button__query_tooltip (IdeOmniBar *self,
NULL,
NULL);
- if (enabled)
- gtk_tooltip_set_custom (tooltip, GTK_WIDGET (self->build_button_shortcut));
- else
- gtk_tooltip_set_custom (tooltip, GTK_WIDGET (self->build_tooltip_message));
+ if (!enabled)
+ {
+ gtk_tooltip_set_custom (tooltip, GTK_WIDGET (self->build_tooltip_message));
+ return TRUE;
+ }
- return TRUE;
+ return FALSE;
}
static void
@@ -666,7 +667,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_button_tooltip);
gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, build_tooltip_message);
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);
diff --git a/src/libide/workbench/ide-omni-bar.ui b/src/libide/workbench/ide-omni-bar.ui
index 531d1c1dc..0a3b653cb 100644
--- a/src/libide/workbench/ide-omni-bar.ui
+++ b/src/libide/workbench/ide-omni-bar.ui
@@ -606,4 +606,8 @@
<widget name="warning_title"/>
</widgets>
</object>
+ <object class="DzlShortcutTooltip" id="build_button_tooltip">
+ <property name="command-id">org.gnome.builder.workbench.build</property>
+ <property name="widget">build_button</property>
+ </object>
</interface>
diff --git a/src/libide/workbench/ide-workbench-header-bar.c b/src/libide/workbench/ide-workbench-header-bar.c
index dade5d231..4f5f89318 100644
--- a/src/libide/workbench/ide-workbench-header-bar.c
+++ b/src/libide/workbench/ide-workbench-header-bar.c
@@ -21,6 +21,7 @@
#include "config.h"
#include <dazzle.h>
+#include <glib/gi18n.h>
#include "application/ide-application.h"
#include "runner/ide-run-button.h"
@@ -35,6 +36,7 @@ typedef struct
{
GtkToggleButton *fullscreen_button;
GtkImage *fullscreen_image;
+ DzlShortcutTooltip *fullscreen_tooltip;
GtkMenuButton *menu_button;
DzlPriorityBox *right_box;
DzlPriorityBox *left_box;
@@ -100,6 +102,34 @@ search_popover_position_func (DzlSuggestionEntry *entry,
#undef RIGHT_MARGIN
}
+static gboolean
+query_fullscreen_tooltip_cb (IdeWorkbenchHeaderBar *self,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ GtkWidget *widget)
+{
+ IdeWorkbenchHeaderBarPrivate *priv = ide_workbench_header_bar_get_instance_private (self);
+ g_autoptr(GVariant) state = NULL;
+ GtkWidget *window;
+
+ g_assert (IDE_IS_WORKBENCH_HEADER_BAR (self));
+ g_assert (GTK_IS_TOOLTIP (tooltip));
+ g_assert (GTK_IS_WIDGET (widget));
+
+ window = gtk_widget_get_toplevel (widget);
+
+ state = g_action_group_get_action_state (G_ACTION_GROUP (window), "fullscreen");
+
+ if (!g_variant_get_boolean (state))
+ dzl_shortcut_tooltip_set_title (priv->fullscreen_tooltip, _("Display the window in full screen"));
+ else
+ dzl_shortcut_tooltip_set_title (priv->fullscreen_tooltip, _("Exit full screen"));
+
+ return FALSE;
+}
+
static void
ide_workbench_header_bar_class_init (IdeWorkbenchHeaderBarClass *klass)
{
@@ -108,6 +138,7 @@ ide_workbench_header_bar_class_init (IdeWorkbenchHeaderBarClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-workbench-header-bar.ui");
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, fullscreen_button);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, fullscreen_image);
+ gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, fullscreen_tooltip);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, left_box);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, menu_button);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, omni_bar);
@@ -129,6 +160,12 @@ ide_workbench_header_bar_init (IdeWorkbenchHeaderBar *self)
dzl_suggestion_entry_set_position_func (DZL_SUGGESTION_ENTRY (priv->search_entry),
search_popover_position_func, NULL, NULL);
+ g_signal_connect_object (priv->fullscreen_button,
+ "query-tooltip",
+ G_CALLBACK (query_fullscreen_tooltip_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
apply_quirks (self);
}
diff --git a/src/libide/workbench/ide-workbench-header-bar.ui
b/src/libide/workbench/ide-workbench-header-bar.ui
index 8f31e39f8..3dd4bfc0f 100644
--- a/src/libide/workbench/ide-workbench-header-bar.ui
+++ b/src/libide/workbench/ide-workbench-header-bar.ui
@@ -109,4 +109,8 @@
</packing>
</child>
</template>
+ <object class="DzlShortcutTooltip" id="fullscreen_tooltip">
+ <property name="command-id">org.gnome.builder.workbench.fullscreen</property>
+ <property name="widget">fullscreen_button</property>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]