gnome-media r4048 - in trunk/gnome-volume-control: . src



Author: mccann
Date: Tue Nov 11 20:29:46 2008
New Revision: 4048
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4048&view=rev

Log:
2008-11-11  William Jon McCann  <jmccann redhat com>

	* src/gvc-mixer-dialog.c (add_stream), (find_stream_by_id),
	(on_control_stream_removed), (create_stream_treeview):
	Try to remove streams from models.



Modified:
   trunk/gnome-volume-control/ChangeLog
   trunk/gnome-volume-control/src/gvc-mixer-dialog.c

Modified: trunk/gnome-volume-control/src/gvc-mixer-dialog.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-dialog.c	(original)
+++ trunk/gnome-volume-control/src/gvc-mixer-dialog.c	Tue Nov 11 20:29:46 2008
@@ -71,7 +71,7 @@
 enum {
         NAME_COL,
         DEVICE_COL,
-        STREAM_COL,
+        ID_COL,
         NUM_COLS
 };
 
@@ -336,7 +336,7 @@
                                     &iter,
                                     NAME_COL, gvc_mixer_stream_get_name (stream),
                                     DEVICE_COL, "",
-                                    STREAM_COL, stream,
+                                    ID_COL, gvc_mixer_stream_get_id (stream),
                                     -1);
         } else if (GVC_IS_MIXER_SINK (stream)) {
                 GtkTreeModel *model;
@@ -347,7 +347,7 @@
                                     &iter,
                                     NAME_COL, gvc_mixer_stream_get_name (stream),
                                     DEVICE_COL, "",
-                                    STREAM_COL, stream,
+                                    ID_COL, gvc_mixer_stream_get_id (stream),
                                     -1);
         }
 
@@ -387,12 +387,42 @@
         }
 }
 
+static gboolean
+find_stream_by_id (GtkTreeModel *model,
+                   guint         id,
+                   GtkTreeIter  *iter)
+{
+        gboolean found_item;
+
+        found_item = FALSE;
+
+        if (!gtk_tree_model_get_iter_first (model, iter)) {
+                return FALSE;
+        }
+
+        do {
+                guint t_id;
+
+                gtk_tree_model_get (model, iter,
+                                    ID_COL, &t_id, -1);
+
+                if (id == t_id) {
+                        found_item = TRUE;
+                }
+        } while (!found_item && gtk_tree_model_iter_next (model, iter));
+
+        return found_item;
+}
+
 static void
 on_control_stream_removed (GvcMixerControl *control,
                            guint            id,
                            GvcMixerDialog  *dialog)
 {
-        GtkWidget      *bar;
+        GtkWidget    *bar;
+        gboolean      found;
+        GtkTreeIter   iter;
+        GtkTreeModel *model;
 
         g_debug ("GvcMixerDialog: Stream %u removed", id);
 
@@ -402,6 +432,17 @@
                 gtk_container_remove (GTK_CONTAINER (bar->parent),
                                       bar);
         }
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview));
+        found = find_stream_by_id (GTK_TREE_MODEL (model), id, &iter);
+        if (found) {
+                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+        }
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview));
+        found = find_stream_by_id (GTK_TREE_MODEL (model), id, &iter);
+        if (found) {
+                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+        }
 }
 
 static void
@@ -480,7 +521,7 @@
         store = gtk_list_store_new (NUM_COLS,
                                     G_TYPE_STRING,
                                     G_TYPE_STRING,
-                                    G_TYPE_OBJECT);
+                                    G_TYPE_UINT);
         gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
                                  GTK_TREE_MODEL (store));
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]