Improve UI

This commit is contained in:
TheBrokenRail 2022-03-12 22:49:56 -05:00
parent 4663a8656d
commit b01f0001ea

View File

@ -61,12 +61,15 @@ zenity_tree_dialog_untoggle (
}
static void
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);
check_or_radio_label_activated_cb (
GtkCellRendererToggle *cell, gchar *path_string, gpointer data) {
GtkTreeModel *model;
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
@ -75,6 +78,7 @@ check_or_radio_label_activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
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);
@ -441,15 +445,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
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 {
if (!tree_data->radiobox && !tree_data->checkbox) {
g_signal_connect (tree_view,
"row-activated",
G_CALLBACK (zenity_tree_row_activated),
@ -486,7 +482,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
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);
GTK_SELECTION_NONE);
} else {
if (tree_data->multi)
gtk_tree_selection_set_mode (
@ -514,6 +510,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) {
G_OBJECT (model), "radio", GINT_TO_POINTER (1));
}
g_signal_connect (cell_renderer,
"toggled",
G_CALLBACK (check_or_radio_label_activated_cb),
model);
column = gtk_tree_view_column_new_with_attributes (
tmp->data, cell_renderer, "active", column_index, NULL);
} else if (tree_data->imagebox) {