summaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorJeremy Bicha <jeremy.bicha@canonical.com>2022-04-01 12:48:03 -0400
committerJeremy Bicha <jeremy.bicha@canonical.com>2022-04-01 12:48:03 -0400
commitd649419599aeec083ecdb89af03f80d8cef9ff3c (patch)
tree91ae3c15a9acb477a2663f96a65ceb0b7a173a9f /src/tree.c
parentRevert "debian/control.in: WebKit builds fine again on sh4 re-add that archit... (diff)
parentNew upstream version 3.42.0 (diff)
downloadzenity-d649419599aeec083ecdb89af03f80d8cef9ff3c.tar.gz
zenity-d649419599aeec083ecdb89af03f80d8cef9ff3c.tar.bz2
zenity-d649419599aeec083ecdb89af03f80d8cef9ff3c.zip
Update upstream source from tag 'upstream/3.42.0'
Update to upstream version '3.42.0' with Debian dir 627ff2810bd2364a9763f5c65665e5c2e365a189
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/tree.c b/src/tree.c
index d94ce7e8..7d98ad2d 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -63,32 +63,28 @@ zenity_tree_dialog_untoggle (
}
static void
-zenity_tree_toggled_callback (
- GtkCellRendererToggle *cell, gchar *path_string, gpointer data) {
- GtkTreeModel *model;
+check_or_radio_label_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
GtkTreeIter iter;
- GtkTreePath *path;
gboolean value;
- model = GTK_TREE_MODEL (data);
-
/* Because this is a radio list, we should untoggle the previous toggle so
* that
* we only have one selection at any given time
*/
-
if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio")) == 1) {
gtk_tree_model_foreach (model, zenity_tree_dialog_untoggle, NULL);
}
- path = gtk_tree_path_new_from_string (path_string);
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &value, -1);
value = !value;
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1);
-
- gtk_tree_path_free (path);
}
static void
@@ -453,11 +449,23 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
- if (!(tree_data->radiobox || tree_data->checkbox))
+ if (tree_data->radiobox || tree_data->checkbox)
+ {
+ gtk_tree_view_set_activate_on_single_click (GTK_TREE_VIEW(tree_view),
+ TRUE);
+
+ g_signal_connect (tree_view,
+ "row-activated",
+ G_CALLBACK (check_or_radio_label_activated_cb),
+ data);
+ }
+ else
+ {
g_signal_connect (tree_view,
"row-activated",
G_CALLBACK (zenity_tree_row_activated),
data);
+ }
/* Create an empty list store */
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
@@ -486,7 +494,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
- if (!(tree_data->radiobox || tree_data->checkbox)) {
+ if (tree_data->radiobox || tree_data->checkbox)
+ {
+ gtk_tree_selection_set_mode (
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
+ GTK_SELECTION_SINGLE);
+ }
+ else
+ {
if (tree_data->multi)
gtk_tree_selection_set_mode (
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
@@ -495,10 +510,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
gtk_tree_selection_set_mode (
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
GTK_SELECTION_SINGLE);
- } else
- gtk_tree_selection_set_mode (
- gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
- GTK_SELECTION_NONE);
+ }
column_index = 0;
@@ -516,11 +528,6 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
G_OBJECT (model), "radio", GINT_TO_POINTER (1));
}
- g_signal_connect (cell_renderer,
- "toggled",
- G_CALLBACK (zenity_tree_toggled_callback),
- model);
-
column = gtk_tree_view_column_new_with_attributes (
tmp->data, cell_renderer, "active", column_index, NULL);
} else if (tree_data->imagebox) {
@@ -635,6 +642,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
tree_data->editable);
}
+ /* GTK will automatically pick the image column as the search column
+ * despite it not containing any user readable text.
+ * Set it to second column instead if it exists. */
+ if (tree_data->imagebox && n_columns > 1) {
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (tree_view),
+ 1);
+ }
+
zenity_util_show_dialog (dialog, data->attach);
if (tree_data->mid_search)
bgstack15