gnome-media r3871 - in trunk: . gst-mixer/src



Author: malureau
Date: Sun Jun  1 18:38:53 2008
New Revision: 3871
URL: http://svn.gnome.org/viewvc/gnome-media?rev=3871&view=rev

Log:
2008-06-01  Marc-Andrà Lureau  <marcandre lureau gmail com>

	* gst-mixer/src/element.{c,h}:
	* gst-mixer/src/preferences.c (get_gconf_key):
	* gst-mixer/src/window.c (gnome_volume_control_window_new):

	Fix wrong track list displayed on startup.
	(Closes #535058)

	Fix enable/disable the wrong tracks, again.
        (bug #528252)


Modified:
   trunk/ChangeLog
   trunk/gst-mixer/src/element.c
   trunk/gst-mixer/src/element.h
   trunk/gst-mixer/src/preferences.c
   trunk/gst-mixer/src/window.c

Modified: trunk/gst-mixer/src/element.c
==============================================================================
--- trunk/gst-mixer/src/element.c	(original)
+++ trunk/gst-mixer/src/element.c	Sun Jun  1 18:38:53 2008
@@ -61,13 +61,10 @@
 }
 
 GtkWidget *
-gnome_volume_control_element_new (GstElement   *element,
-				  GConfClient  *client)
+gnome_volume_control_element_new (GConfClient  *client)
 {
   GnomeVolumeControlElement *el;
 
-  g_return_val_if_fail (GST_IS_MIXER (element), NULL);
-
   /* element */
   el = g_object_new (GNOME_VOLUME_CONTROL_TYPE_ELEMENT, NULL);
   el->client = g_object_ref (G_OBJECT (client));
@@ -77,8 +74,6 @@
   gconf_client_notify_add (el->client, GNOME_VOLUME_CONTROL_KEY_DIR,
 			   cb_gconf, el, NULL, NULL);
 
-  gnome_volume_control_element_change (el, element);
-
   return GTK_WIDGET (el);
 }
 

Modified: trunk/gst-mixer/src/element.h
==============================================================================
--- trunk/gst-mixer/src/element.h	(original)
+++ trunk/gst-mixer/src/element.h	Sun Jun  1 18:38:53 2008
@@ -57,8 +57,7 @@
 } GnomeVolumeControlElementClass;
 
 GType		gnome_volume_control_element_get_type	(void);
-GtkWidget *	gnome_volume_control_element_new	(GstElement   *element,
-							 GConfClient  *client);
+GtkWidget *	gnome_volume_control_element_new	(GConfClient  *client);
 void		gnome_volume_control_element_change	(GnomeVolumeControlElement *el,
 							 GstElement  *element);
 

Modified: trunk/gst-mixer/src/preferences.c
==============================================================================
--- trunk/gst-mixer/src/preferences.c	(original)
+++ trunk/gst-mixer/src/preferences.c	Sun Jun  1 18:38:53 2008
@@ -255,13 +255,10 @@
   dev = g_object_get_data (G_OBJECT (mixer),
 			   "gnome-volume-control-name");
   if (track != NULL) {
-    if (g_object_class_find_property (G_OBJECT_GET_CLASS (track), "untranslated-label"))
-      g_object_get (track, "untranslated-label", &label, NULL);
-    if (label == NULL)
-      g_object_get (track, "label", &label, NULL);
-  }
-  if (label == NULL)
+    label = g_strdup (track->label);
+  } else {
     label = g_strdup ("");
+  }
 
   pos = strlen (GNOME_VOLUME_CONTROL_KEY_DIR) + 1;
   res = g_new (gchar, pos + strlen (dev) + 1 + strlen (label) + 1);

Modified: trunk/gst-mixer/src/window.c
==============================================================================
--- trunk/gst-mixer/src/window.c	(original)
+++ trunk/gst-mixer/src/window.c	Sun Jun  1 18:38:53 2008
@@ -150,51 +150,61 @@
 }
 
 static void
-cb_gconf (GConfClient *client,
-	  guint        connection_id,
-	  GConfEntry  *entry,
-	  gpointer     data)
+window_change_mixer_element (GnomeVolumeControlWindow *win,
+			     const gchar *el)
 {
-  GnomeVolumeControlWindow *win = GNOME_VOLUME_CONTROL_WINDOW (data);
-  GConfValue *value;
-  const gchar *el, *cur_el_str;
+  const char *cur_el_str;
+  GList *item;
 
-  if (g_str_equal (gconf_entry_get_key (entry),
-		   GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT) &&
-      (value = gconf_entry_get_value (entry)) != NULL &&
-      (value->type == GCONF_VALUE_STRING) &&
-      (el = gconf_value_get_string (value)) != NULL) {
-    GList *item;
+  g_return_if_fail (win != NULL);
+  g_return_if_fail (el != NULL);
 
-    for (item = win->elements; item != NULL; item = item->next) {
-      cur_el_str = g_object_get_data (item->data, "gnome-volume-control-name");
+  for (item = win->elements; item != NULL; item = item->next) {
+    cur_el_str = g_object_get_data (item->data, "gnome-volume-control-name");
 
-      g_return_if_fail (cur_el_str != NULL);
-      g_return_if_fail (el != NULL);
+    if (cur_el_str == NULL)
+      continue;
 
-      if (g_str_equal (cur_el_str, el)) {
-        GstElement *old_element = GST_ELEMENT (win->el->mixer);
-        gchar *title;
-
-        /* change element */
-        gst_element_set_state (item->data, GST_STATE_READY);
-        gnome_volume_control_element_change (win->el, item->data);
-        if (win->prefs)
-          gnome_volume_control_preferences_change (
-		GNOME_VOLUME_CONTROL_PREFERENCES (win->prefs), item->data);
-        gst_element_set_state (old_element, GST_STATE_NULL);
-
-        /* change window title */
-        title = g_strdup_printf (_("Volume Control: %s"), cur_el_str);
-        gtk_window_set_title (GTK_WINDOW (win), title);
-        g_free (title);
+    if (g_str_equal (cur_el_str, el)) {
+      GstElement *old_element = GST_ELEMENT (win->el->mixer);
+      gchar *title;
 
-        break;
-      }
+      /* change element */
+      gst_element_set_state (item->data, GST_STATE_READY);
+      gnome_volume_control_element_change (win->el, item->data);
+
+      if (win->prefs != NULL)
+	gnome_volume_control_preferences_change (GNOME_VOLUME_CONTROL_PREFERENCES (win->prefs), 
+						 item->data);
+
+      if (old_element != NULL)
+	gst_element_set_state (old_element, GST_STATE_NULL);
+
+      /* change window title */
+      title = g_strdup_printf (_("Volume Control: %s"), cur_el_str);
+      gtk_window_set_title (GTK_WINDOW (win), title);
+      g_free (title);
+
+      break;
     }
   }
 }
 
+static void
+cb_gconf (GConfClient *client,
+	  guint        connection_id,
+	  GConfEntry  *entry,
+	  gpointer     data)
+{
+  g_return_if_fail (gconf_entry_get_key (entry) != NULL);
+
+  if (g_str_equal (gconf_entry_get_key (entry),
+		   GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT)) {
+    window_change_mixer_element (GNOME_VOLUME_CONTROL_WINDOW (data),
+				 gconf_value_get_string (gconf_entry_get_value (entry)));
+  }
+}
+
 /*
  * Signal handlers.
  */
@@ -314,8 +324,9 @@
   accel_group = gtk_accel_group_new ();
 
   gtk_window_add_accel_group (GTK_WINDOW (win), accel_group);
-  gtk_accel_group_connect (accel_group, GDK_A, GDK_CONTROL_MASK, 0, 
+  gtk_accel_group_connect (accel_group, GDK_A, GDK_CONTROL_MASK, 0,
 			   g_cclosure_new_swap (G_CALLBACK (cb_show_about), win, NULL));
+
   /* get active element, if any (otherwise we use the default) */
   active_el_str = gconf_client_get_string (win->client,
 					   GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT,
@@ -360,13 +371,10 @@
   gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box), renderer, "text", 0);
   for (count = 0, item = elements; item != NULL; item = item->next, count++) {
     const gchar *name;
-    gchar *tip;
     gchar *label;
 
     name = g_object_get_data (item->data, "gnome-volume-control-name");
-    tip = g_strdup_printf (_("Change device to %s"), name);
     gtk_combo_box_append_text(GTK_COMBO_BOX (combo_box), name);
-    g_free (tip);
   }
   gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), active_element_num);
   g_signal_connect (combo_box, "changed", G_CALLBACK (cb_change), win);
@@ -378,13 +386,6 @@
   gconf_client_notify_add (win->client, GNOME_VOLUME_CONTROL_KEY_DIR,
 			   cb_gconf, win, NULL, NULL);
 
-  /* window title and menu selection */
-  title = g_strdup_printf (_("Volume Control: %s"),
-			   g_object_get_data (G_OBJECT (active_element),
-					      "gnome-volume-control-name"));
-  gtk_window_set_title (GTK_WINDOW (win), title);
-  g_free (title);
-
   win->use_default_mixer = (active_el_str == NULL);
 
   /* add the combo box to choose the device */
@@ -397,9 +398,7 @@
   gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);
 
   /* add content for this element */
-  gst_element_set_state (active_element, GST_STATE_READY);
-  el = gnome_volume_control_element_new (active_element,
-					 win->client);
+  el = gnome_volume_control_element_new (win->client);
   win->el = GNOME_VOLUME_CONTROL_ELEMENT (el);
 
   /* create the buttons box */
@@ -434,6 +433,10 @@
 
   gtk_widget_show_all (GTK_WIDGET (win));
 
+  /* refresh the control and window title with the default mixer */
+  window_change_mixer_element (win, g_object_get_data (G_OBJECT (active_element),
+						       "gnome-volume-control-name"));
+
   /* FIXME:
    * - set error handler (cb_error) after device activation:
    *     g_signal_connect (element, "error", G_CALLBACK (cb_error), win);.



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