mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
do housekeeping each time selection is updated
This commit is contained in:
parent
b5affabc0c
commit
8ae5872787
1 changed files with 30 additions and 12 deletions
|
@ -31,6 +31,8 @@ typedef struct App
|
||||||
GtkListStore *model;
|
GtkListStore *model;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
GtkWidget *properties;
|
GtkWidget *properties;
|
||||||
|
GList *selected_objects;
|
||||||
|
int n_selected;
|
||||||
} App;
|
} App;
|
||||||
|
|
||||||
App *app_new (void);
|
App *app_new (void);
|
||||||
|
@ -43,6 +45,8 @@ GList *app_get_selected_objects (App * app);
|
||||||
|
|
||||||
void app_delete_objects (App * app, GList * objects);
|
void app_delete_objects (App * app, GList * objects);
|
||||||
|
|
||||||
|
void app_update_selection (App * app);
|
||||||
|
|
||||||
void window_destroy_cb (GtkObject * window, App * app);
|
void window_destroy_cb (GtkObject * window, App * app);
|
||||||
|
|
||||||
void quit_item_activate_cb (GtkMenuItem * item, App * app);
|
void quit_item_activate_cb (GtkMenuItem * item, App * app);
|
||||||
|
@ -94,11 +98,10 @@ add_file_item_activate_cb (GtkMenuItem * item, App * app)
|
||||||
void
|
void
|
||||||
app_selection_changed_cb (GtkTreeSelection * selection, App * app)
|
app_selection_changed_cb (GtkTreeSelection * selection, App * app)
|
||||||
{
|
{
|
||||||
int n;
|
app_update_selection (app);
|
||||||
n = gtk_tree_selection_count_selected_rows (selection);
|
|
||||||
|
|
||||||
/* some widgets should be disabled when we have an empty selection */
|
/* some widgets should be disabled when we have an empty selection */
|
||||||
gtk_widget_set_sensitive (app->properties, n > 0);
|
gtk_widget_set_sensitive (app->properties, app->n_selected > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* application methods ******************************************************/
|
/* application methods ******************************************************/
|
||||||
|
@ -106,6 +109,29 @@ app_selection_changed_cb (GtkTreeSelection * selection, App * app)
|
||||||
static void selection_foreach (GtkTreeModel * model, GtkTreePath * path,
|
static void selection_foreach (GtkTreeModel * model, GtkTreePath * path,
|
||||||
GtkTreeIter * iter, gpointer user);
|
GtkTreeIter * iter, gpointer user);
|
||||||
|
|
||||||
|
void
|
||||||
|
app_update_selection (App * app)
|
||||||
|
{
|
||||||
|
GList *cur;
|
||||||
|
|
||||||
|
/* clear old selection */
|
||||||
|
for (cur = app->selected_objects; cur; cur = cur->next) {
|
||||||
|
g_object_unref (cur->data);
|
||||||
|
cur->data = NULL;
|
||||||
|
}
|
||||||
|
g_list_free (app->selected_objects);
|
||||||
|
app->selected_objects = NULL;
|
||||||
|
app->n_selected = 0;
|
||||||
|
|
||||||
|
/* get new selection */
|
||||||
|
gtk_tree_selection_selected_foreach (GTK_TREE_SELECTION (app->selection),
|
||||||
|
selection_foreach, &app->selected_objects);
|
||||||
|
|
||||||
|
for (cur = app->selected_objects; cur; cur = cur->next) {
|
||||||
|
app->n_selected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
selection_foreach (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter
|
selection_foreach (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter
|
||||||
* iter, gpointer user)
|
* iter, gpointer user)
|
||||||
|
@ -122,14 +148,7 @@ selection_foreach (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter
|
||||||
GList *
|
GList *
|
||||||
app_get_selected_objects (App * app)
|
app_get_selected_objects (App * app)
|
||||||
{
|
{
|
||||||
GList *objects = NULL;
|
return g_list_copy (app->selected_objects);
|
||||||
|
|
||||||
g_print ("selection: %p\n", app->selection);
|
|
||||||
|
|
||||||
gtk_tree_selection_selected_foreach (GTK_TREE_SELECTION (app->selection),
|
|
||||||
selection_foreach, &objects);
|
|
||||||
|
|
||||||
return objects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -140,7 +159,6 @@ app_delete_objects (App * app, GList * objects)
|
||||||
for (cur = objects; cur; cur = cur->next) {
|
for (cur = objects; cur; cur = cur->next) {
|
||||||
ges_timeline_layer_remove_object (app->layer,
|
ges_timeline_layer_remove_object (app->layer,
|
||||||
GES_TIMELINE_OBJECT (cur->data));
|
GES_TIMELINE_OBJECT (cur->data));
|
||||||
g_object_unref ((GObject *) cur->data);
|
|
||||||
cur->data = NULL;
|
cur->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue