diff --git a/tests/examples/ges-ui.c b/tests/examples/ges-ui.c index 9c786d774a..6b9b7f4c52 100644 --- a/tests/examples/ges-ui.c +++ b/tests/examples/ges-ui.c @@ -30,6 +30,7 @@ typedef struct App GtkWidget *main_window; GtkListStore *model; GtkTreeSelection *selection; + GtkWidget *properties; } App; App *app_new (void); @@ -50,6 +51,8 @@ void delete_item_activate_cb (GtkMenuItem * item, App * app); void add_file_item_activate_cb (GtkMenuItem * item, App * app); +void app_selection_changed_cb (GtkTreeSelection * selection, App * app); + gboolean create_ui (App * app); static gboolean find_row_for_object (GtkListStore * model, GtkTreeIter * ret, @@ -88,6 +91,16 @@ add_file_item_activate_cb (GtkMenuItem * item, App * app) app_add_file (app, (gchar *) "/home/brandon/media/small-mvi_0008.avi"); } +void +app_selection_changed_cb (GtkTreeSelection * selection, App * app) +{ + int n; + n = gtk_tree_selection_count_selected_rows (selection); + + /* some widgets should be disabled when we have an empty selection */ + gtk_widget_set_sensitive (app->properties, n > 0); +} + /* application methods ******************************************************/ static void selection_foreach (GtkTreeModel * model, GtkTreePath * path, @@ -282,8 +295,9 @@ create_ui (App * app) app->main_window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); app->model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_OBJECT); + app->properties = GTK_WIDGET (gtk_builder_get_object (builder, "properties")); - if (!(app->main_window && app->model && timeline)) { + if (!(app->main_window && app->model && timeline && app->properties)) { g_print ("Could not retrieve all widgets from the XML"); goto fail; } @@ -293,6 +307,9 @@ create_ui (App * app) if (!app->selection) goto fail; + g_signal_connect (app->selection, "changed", + G_CALLBACK (app_selection_changed_cb), app); + gtk_tree_view_set_model (timeline, GTK_TREE_MODEL (app->model)); gtk_builder_connect_signals (builder, app);