[gtk/gbsneto/filechooser-column-view: 60/105] filechooserwidget: Move tooltip text to column view
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gbsneto/filechooser-column-view: 60/105] filechooserwidget: Move tooltip text to column view
- Date: Wed, 12 Oct 2022 20:42:36 +0000 (UTC)
commit 05fc749adb95fdf3a8c62f22c3e1428989e15dda
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Oct 8 12:02:20 2022 -0300
filechooserwidget: Move tooltip text to column view
Use a closure binding to query the tooltip.
gtk/gtkfilechooserwidget.c | 74 ++++++++++++++----------------------------
gtk/ui/gtkfilechooserwidget.ui | 16 ++++++++-
2 files changed, 40 insertions(+), 50 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index f58c25a0a1..5f47f34a6b 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -2170,6 +2170,30 @@ column_view_get_time_visible (GtkListItem *item)
return impl->show_time;
}
+static char *
+column_view_get_tooltip_text (GtkListItem *list_item)
+{
+ GtkFileChooserWidget *impl;
+ GtkFileSystemItem *item;
+ GFile *file;
+
+ item = gtk_list_item_get_item (list_item);
+ if (!item)
+ return NULL;
+
+ impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (gtk_list_item_get_child (list_item),
+ GTK_TYPE_FILE_CHOOSER_WIDGET));
+ g_assert (impl != NULL);
+
+ if (impl->operation_mode == OPERATION_MODE_BROWSE)
+ return NULL;
+
+ item = gtk_list_item_get_item (list_item);
+ file = _gtk_file_system_item_get_file (item);
+
+ return g_file_get_path (file);
+}
+
typedef struct {
OperationMode operation_mode;
int general_column;
@@ -2186,54 +2210,6 @@ file_list_set_sort_column_ids (GtkFileChooserWidget *impl)
gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->browse_files_tree_view), -1);
}
-static gboolean
-file_list_query_tooltip_cb (GtkWidget *widget,
- int x,
- int y,
- gboolean keyboard_tip,
- GtkTooltip *tooltip,
- gpointer user_data)
-{
- GtkFileChooserWidget *impl = user_data;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- GFile *file;
- char *filename;
-
- if (impl->operation_mode == OPERATION_MODE_BROWSE)
- return FALSE;
-
-
- if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (impl->browse_files_tree_view),
- x, y,
- keyboard_tip,
- &model, &path, &iter))
- return FALSE;
-
- gtk_tree_model_get (model, &iter,
- MODEL_COL_FILE, &file,
- -1);
-
- if (file == NULL)
- {
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- filename = g_file_get_path (file);
- gtk_tooltip_set_text (tooltip, filename);
- gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (impl->browse_files_tree_view),
- tooltip,
- path);
-
- g_free (filename);
- g_object_unref (file);
- gtk_tree_path_free (path);
-
- return TRUE;
-}
-
static GtkWidget *
get_accept_action_widget (GtkDialog *dialog,
gboolean sensitive_only)
@@ -7443,7 +7419,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, box);
/* And a *lot* of callbacks to bind ... */
- gtk_widget_class_bind_template_callback (widget_class, file_list_query_tooltip_cb);
gtk_widget_class_bind_template_callback (widget_class, list_selection_changed);
gtk_widget_class_bind_template_callback (widget_class, browse_files_column_view_keynav_failed_cb);
gtk_widget_class_bind_template_callback (widget_class, filter_combo_changed);
@@ -7467,6 +7442,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_callback (widget_class, column_view_get_location);
gtk_widget_class_bind_template_callback (widget_class, column_view_get_size);
gtk_widget_class_bind_template_callback (widget_class, column_view_get_time_visible);
+ gtk_widget_class_bind_template_callback (widget_class, column_view_get_tooltip_text);
gtk_widget_class_bind_template_callback (widget_class, column_view_row_activated_cb);
gtk_widget_class_set_css_name (widget_class, I_("filechooser"));
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index 695bb94bc1..9f7b92da07 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -157,6 +157,9 @@
<template class="GtkListItem">
<property name="child">
<object class="GtkBox">
+ <binding name="tooltip-text">
+ <closure type="gchararray" function="column_view_get_tooltip_text" />
+ </binding>
<child>
<object class="GtkFileThumbnail">
<property name="margin-start">6</property>
@@ -210,6 +213,9 @@
<binding name="text">
<closure type="gchararray" function="column_view_get_location" />
</binding>
+ <binding name="tooltip-text">
+ <closure type="gchararray" function="column_view_get_tooltip_text" />
+ </binding>
</object>
</property>
</template>
@@ -240,6 +246,9 @@
</lookup>
</closure>
</binding>
+ <binding name="tooltip-text">
+ <closure type="gchararray" function="column_view_get_tooltip_text" />
+ </binding>
</object>
</property>
</template>
@@ -271,6 +280,9 @@
</lookup>
</closure>
</binding>
+ <binding name="tooltip-text">
+ <closure type="gchararray" function="column_view_get_tooltip_text" />
+ </binding>
</object>
</property>
</template>
@@ -293,6 +305,9 @@
<property name="child">
<object class="GtkBox">
<property name="spacing">6</property>
+ <binding name="tooltip-text">
+ <closure type="gchararray" function="column_view_get_tooltip_text" />
+ </binding>
<child>
<object class="GtkLabel">
<binding name="label">
@@ -372,7 +387,6 @@
<signal name="pressed" handler="click_cb" swapped="no"/>
</object>
</child>
- <signal name="query-tooltip"
handler="file_list_query_tooltip_cb" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<signal name="changed" handler="list_selection_changed"
swapped="no"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]