[gnome-text-editor] window: add tooltip to window title
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] window: add tooltip to window title
- Date: Fri, 12 Aug 2022 19:14:42 +0000 (UTC)
commit 823d2c5f1fa5d70c0525f1c540e589ace4d78eb1
Author: Christian Hergert <chergert redhat com>
Date: Fri Aug 12 12:14:14 2022 -0700
window: add tooltip to window title
src/editor-window.c | 31 +++++++++++++++++++++++++++++++
src/editor-window.ui | 4 ++++
2 files changed, 35 insertions(+)
---
diff --git a/src/editor-window.c b/src/editor-window.c
index 2933128..e0c9516 100644
--- a/src/editor-window.c
+++ b/src/editor-window.c
@@ -759,6 +759,36 @@ on_show_help_overlay_cb (GtkWidget *widget,
}
}
+static gboolean
+title_query_tooltip_cb (EditorWindow *self,
+ int x,
+ int y,
+ gboolean keyboard,
+ GtkTooltip *tooltip)
+{
+ g_autofree char *text = NULL;
+ EditorDocument *document;
+ EditorPage *page;
+ GFile *file;
+
+ g_assert (EDITOR_IS_WINDOW (self));
+ g_assert (GTK_IS_TOOLTIP (tooltip));
+
+ if (!(page = editor_window_get_visible_page (self)) ||
+ !(document = editor_page_get_document (page)) ||
+ !(file = editor_document_get_file (document)))
+ return FALSE;
+
+ if (g_file_is_native (file))
+ text = g_file_get_path (file);
+ else
+ text = g_file_get_uri (file);
+
+ gtk_tooltip_set_text (tooltip, text);
+
+ return TRUE;
+}
+
static gboolean
indicator_to_boolean (GBinding *binding,
const GValue *from_value,
@@ -894,6 +924,7 @@ editor_window_class_init (EditorWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, on_tab_view_close_page_cb);
gtk_widget_class_bind_template_callback (widget_class, on_tab_view_setup_menu_cb);
gtk_widget_class_bind_template_callback (widget_class, on_tab_view_create_window_cb);
+ gtk_widget_class_bind_template_callback (widget_class, title_query_tooltip_cb);
gtk_widget_class_install_action (widget_class, "win.alternate-help-overlay", NULL,
on_show_help_overlay_cb);
gtk_widget_class_install_action (widget_class, "win.undo-close-page", NULL, on_undo_close_page_cb);
diff --git a/src/editor-window.ui b/src/editor-window.ui
index 4eb375a..a602ec7 100644
--- a/src/editor-window.ui
+++ b/src/editor-window.ui
@@ -22,6 +22,8 @@
<child>
<object class="GtkCenterBox">
<property name="hexpand">true</property>
+ <property name="has-tooltip">true</property>
+ <signal name="query-tooltip" handler="title_query_tooltip_cb" object="EditorWindow"
swapped="true"/>
<child type="start">
<object class="GtkLabel" id="is_modified">
<property name="halign">end</property>
@@ -44,6 +46,8 @@
</child>
<child>
<object class="GtkCenterBox">
+ <property name="has-tooltip">true</property>
+ <signal name="query-tooltip" handler="title_query_tooltip_cb" object="EditorWindow"
swapped="true"/>
<child type="start">
<object class="GtkImage" id="indicator">
<property name="hexpand">true</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]