Improve UI
This commit is contained in:
parent
4663a8656d
commit
b01f0001ea
27
src/tree.c
27
src/tree.c
@ -61,12 +61,15 @@ zenity_tree_dialog_untoggle (
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_or_radio_label_activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
|
check_or_radio_label_activated_cb (
|
||||||
GtkTreeViewColumn *column, gpointer user_data) {
|
GtkCellRendererToggle *cell, gchar *path_string, gpointer data) {
|
||||||
GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
GtkTreePath *path;
|
||||||
gboolean value;
|
gboolean value;
|
||||||
|
|
||||||
|
model = GTK_TREE_MODEL (data);
|
||||||
|
|
||||||
/* Because this is a radio list, we should untoggle the previous toggle so
|
/* Because this is a radio list, we should untoggle the previous toggle so
|
||||||
* that
|
* that
|
||||||
* we only have one selection at any given time
|
* 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);
|
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_iter (model, &iter, path);
|
||||||
gtk_tree_model_get (model, &iter, 0, &value, -1);
|
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");
|
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,
|
g_signal_connect (tree_view,
|
||||||
"row-activated",
|
"row-activated",
|
||||||
G_CALLBACK (zenity_tree_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) {
|
if (tree_data->radiobox || tree_data->checkbox) {
|
||||||
gtk_tree_selection_set_mode (
|
gtk_tree_selection_set_mode (
|
||||||
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
||||||
GTK_SELECTION_SINGLE);
|
GTK_SELECTION_NONE);
|
||||||
} else {
|
} else {
|
||||||
if (tree_data->multi)
|
if (tree_data->multi)
|
||||||
gtk_tree_selection_set_mode (
|
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_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 (
|
column = gtk_tree_view_column_new_with_attributes (
|
||||||
tmp->data, cell_renderer, "active", column_index, NULL);
|
tmp->data, cell_renderer, "active", column_index, NULL);
|
||||||
} else if (tree_data->imagebox) {
|
} else if (tree_data->imagebox) {
|
||||||
|
Reference in New Issue
Block a user