diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-02 13:27:03 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-02 13:27:03 -0700 |
commit | fa86f973a3f3cbd521b38f39475b291709b799b0 (patch) | |
tree | 815902ef40e45275174d97bcec897c56dd752f90 /equipment.c | |
parent | 9afcee3b17059fbe7947ec55fb9ed413848b0186 (diff) | |
download | subsurface-fa86f973a3f3cbd521b38f39475b291709b799b0.tar.gz |
cylinder list: set edit/delete button sensitivity
They are only sensitive when there is a cylinder selected.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'equipment.c')
-rw-r--r-- | equipment.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/equipment.c b/equipment.c index ca8c99651..453ecb273 100644 --- a/equipment.c +++ b/equipment.c @@ -234,6 +234,10 @@ void show_dive_equipment(struct dive *dive) break; } while (--max); + gtk_widget_set_sensitive(cylinder_list.edit, 0); + gtk_widget_set_sensitive(cylinder_list.del, 0); + gtk_widget_set_sensitive(cylinder_list.add, max < MAX_CYLINDERS); + for (i = 0; i < max; i++) { cylinder_t *cyl = dive->cylinder+i; @@ -552,9 +556,20 @@ static void percentage_data_func(GtkTreeViewColumn *col, g_object_set(renderer, "text", buffer, NULL); } +static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model) +{ + GtkTreeIter iter; + int selected; + + selected = gtk_tree_selection_get_selected(selection, NULL, &iter); + gtk_widget_set_sensitive(cylinder_list.edit, selected); + gtk_widget_set_sensitive(cylinder_list.del, selected); +} + static GtkWidget *cylinder_list_create(void) { GtkWidget *tree_view; + GtkTreeSelection *selection; GtkListStore *model; model = gtk_list_store_new(CYL_COLUMNS, @@ -569,6 +584,11 @@ static GtkWidget *cylinder_list_create(void) ); cylinder_list.model = model; tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); + gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE); + g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), model); + cylinder_list.desc = tree_view_column(tree_view, CYL_DESC, "Type", NULL, PANGO_ALIGN_LEFT, TRUE); cylinder_list.size = tree_view_column(tree_view, CYL_SIZE, "Size", size_data_func, PANGO_ALIGN_RIGHT, TRUE); cylinder_list.workp = tree_view_column(tree_view, CYL_WORKP, "MaxPress", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE); |