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



Author: malureau
Date: Mon May 26 20:56:42 2008
New Revision: 3864
URL: http://svn.gnome.org/viewvc/gnome-media?rev=3864&view=rev

Log:
2008-05-26  Marc-Andrà Lureau  <marcandre lureau gmail com>

	Based on patch by: Louis-Francis RattÃ-Boulianne

	* gnome-volume-control-ui.xml: deleted.

	* src/button.{c,h}, src/element.{c,h}, src/track.{c,h},
	src/volume.{c,h}, src/window.{c,h}: Make g-v-c a capplet, with
	some custom accelerators.
	(Closes #349951)


Removed:
   trunk/gst-mixer/gnome-volume-control-ui.xml
Modified:
   trunk/ChangeLog
   trunk/gst-mixer/Makefile.am
   trunk/gst-mixer/src/button.c
   trunk/gst-mixer/src/button.h
   trunk/gst-mixer/src/element.c
   trunk/gst-mixer/src/element.h
   trunk/gst-mixer/src/track.c
   trunk/gst-mixer/src/track.h
   trunk/gst-mixer/src/volume.c
   trunk/gst-mixer/src/volume.h
   trunk/gst-mixer/src/window.c
   trunk/gst-mixer/src/window.h

Modified: trunk/gst-mixer/Makefile.am
==============================================================================
--- trunk/gst-mixer/Makefile.am	(original)
+++ trunk/gst-mixer/Makefile.am	Mon May 26 20:56:42 2008
@@ -1,7 +1,6 @@
 Desktopdir = $(datadir)/applications
 SUBDIRS = doc icons pixmaps src
 
-
 @INTLTOOL_DESKTOP_RULE@
 @INTLTOOL_SCHEMAS_RULE@
 
@@ -19,14 +18,7 @@
 install-data-local:
 endif
 
-uidir = $(pkgdatadir)
-ui_FILES = \
-	gnome-volume-control-ui.xml 
-
-ui_DATA = $(ui_FILES)
-
 EXTRA_DIST = $(Desktop_in_files) \
-	$(ui_FILES) \
 	gnome-volume-control.schemas.in 
 
 

Modified: trunk/gst-mixer/src/button.c
==============================================================================
--- trunk/gst-mixer/src/button.c	(original)
+++ trunk/gst-mixer/src/button.c	Mon May 26 20:56:42 2008
@@ -53,8 +53,6 @@
 
   gobject_class->dispose = gnome_volume_control_button_dispose;
   gtkbutton_class->clicked = gnome_volume_control_button_clicked;
-  gtkwidget_class->enter_notify_event = gnome_volume_control_button_mouseover;
-  gtkwidget_class->leave_notify_event = gnome_volume_control_button_mouseout;
 }
 
 static void
@@ -64,9 +62,6 @@
   button->inactive_icon = NULL;
 
   button->active = FALSE;
-
-  button->status_msg = NULL;
-  button->statusbar = NULL;
 }
 
 static void
@@ -74,19 +69,13 @@
 {
   GnomeVolumeControlButton *button = GNOME_VOLUME_CONTROL_BUTTON (object);
 
-  if (button->status_msg) {
-    g_free (button->status_msg);
-    button->status_msg = NULL;
-  }
-
   G_OBJECT_CLASS (gnome_volume_control_button_parent_class)->dispose (object);
 }
 
 GtkWidget *
 gnome_volume_control_button_new (gchar *active_icon,
 				 gchar *inactive_icon,
-				 GtkStatusbar *statusbar,
-				 gchar *status_msg)
+				 gchar *msg)
 {
   GnomeVolumeControlButton *button;
   GtkWidget *image;
@@ -102,8 +91,7 @@
   button->image = GTK_IMAGE (image);
   gtk_button_clicked (GTK_BUTTON (button));
 
-  button->statusbar = statusbar;
-  button->status_msg = g_strdup (status_msg);
+  gtk_widget_set_tooltip_text (GTK_WIDGET (button), g_strdup (msg));
 
   return GTK_WIDGET (button);
 }
@@ -152,29 +140,3 @@
     }
   }
 }
-
-/*
- * Statusbar stuff.
- */
-
-static gboolean
-gnome_volume_control_button_mouseover (GtkWidget *widget,
-				       GdkEventCrossing *event)
-{
-  GnomeVolumeControlButton *button = GNOME_VOLUME_CONTROL_BUTTON (widget);
-
-  gtk_statusbar_push (button->statusbar, 0, button->status_msg);
-
-  return GTK_WIDGET_CLASS (gnome_volume_control_button_parent_class)->enter_notify_event (widget, event);
-}
-
-static gboolean
-gnome_volume_control_button_mouseout (GtkWidget *widget,
-				      GdkEventCrossing *event)
-{
-  GnomeVolumeControlButton *button = GNOME_VOLUME_CONTROL_BUTTON (widget);
-
-  gtk_statusbar_pop (button->statusbar, 0);
-
-  return GTK_WIDGET_CLASS (gnome_volume_control_button_parent_class)->leave_notify_event (widget, event);
-}

Modified: trunk/gst-mixer/src/button.h
==============================================================================
--- trunk/gst-mixer/src/button.h	(original)
+++ trunk/gst-mixer/src/button.h	Mon May 26 20:56:42 2008
@@ -24,7 +24,6 @@
 
 #include <glib.h>
 #include <gtk/gtkbutton.h>
-#include <gtk/gtkstatusbar.h>
 
 G_BEGIN_DECLS
 
@@ -53,10 +52,6 @@
 
   /* image */
   GtkImage *image;
-
-  /* statusstuff */
-  gchar *status_msg;
-  GtkStatusbar *statusbar;
 } GnomeVolumeControlButton;
 
 typedef struct _GnomeVolumeControlButtonClass {
@@ -66,8 +61,7 @@
 GType		gnome_volume_control_button_get_type	(void);
 GtkWidget *	gnome_volume_control_button_new		(gchar   *active_icon,
 							 gchar   *inactive_icon,
-							 GtkStatusbar *statusbar,
-							 gchar   *status_msg);
+							 gchar   *msg);
 gboolean	gnome_volume_control_button_get_active	(GnomeVolumeControlButton *button);
 void		gnome_volume_control_button_set_active	(GnomeVolumeControlButton *button,
 							 gboolean active);

Modified: trunk/gst-mixer/src/element.c
==============================================================================
--- trunk/gst-mixer/src/element.c	(original)
+++ trunk/gst-mixer/src/element.c	Mon May 26 20:56:42 2008
@@ -58,13 +58,11 @@
 {
   el->client = NULL;
   el->mixer = NULL;
-  el->statusbar = NULL;
 }
 
 GtkWidget *
 gnome_volume_control_element_new (GstElement   *element,
-				  GConfClient  *client,
-				  GtkStatusbar *statusbar)
+				  GConfClient  *client)
 {
   GnomeVolumeControlElement *el;
 
@@ -73,7 +71,6 @@
   /* element */
   el = g_object_new (GNOME_VOLUME_CONTROL_TYPE_ELEMENT, NULL);
   el->client = g_object_ref (G_OBJECT (client));
-  el->statusbar = statusbar;
 
   gconf_client_add_dir (el->client, GNOME_VOLUME_CONTROL_KEY_DIR,
 			GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
@@ -189,8 +186,7 @@
 						    GstMixer      *mixer,
 						    GstMixerTrack *track,
 						    GtkWidget     *left_sep,
-						    GtkWidget     *right_sep,
-						    GtkStatusbar  *statusbar);
+						    GtkWidget     *right_sep);
   } content[4] = {
     { _("Playback"), NULL, NULL, NULL, FALSE, 0, 5, 1,
       gnome_volume_control_track_add_playback },
@@ -280,8 +276,7 @@
     /* widget */
     trkw = content[i].get_track_widget (GTK_TABLE (content[i].page),
 					content[i].pos++, el->mixer, track,
-					content[i].old_sep, content[i].new_sep,
-					el->statusbar);
+					content[i].old_sep, content[i].new_sep);
     gnome_volume_control_track_show (trkw, active);
 
     g_object_set_data (G_OBJECT (track),

Modified: trunk/gst-mixer/src/element.h
==============================================================================
--- trunk/gst-mixer/src/element.h	(original)
+++ trunk/gst-mixer/src/element.h	Mon May 26 20:56:42 2008
@@ -24,7 +24,6 @@
 
 #include <glib.h>
 #include <gtk/gtknotebook.h>
-#include <gtk/gtkstatusbar.h>
 #include <gconf/gconf-client.h>
 #include <gst/interfaces/mixer.h>
 
@@ -51,9 +50,6 @@
 
   /* gconf client inherited from our parent */
   GConfClient *client;
-
-  /* status bar */
-  GtkStatusbar *statusbar;
 } GnomeVolumeControlElement;
 
 typedef struct _GnomeVolumeControlElementClass {
@@ -62,8 +58,7 @@
 
 GType		gnome_volume_control_element_get_type	(void);
 GtkWidget *	gnome_volume_control_element_new	(GstElement   *element,
-							 GConfClient  *client,
-							 GtkStatusbar *statusbar);
+							 GConfClient  *client);
 void		gnome_volume_control_element_change	(GnomeVolumeControlElement *el,
 							 GstElement  *element);
 

Modified: trunk/gst-mixer/src/track.c
==============================================================================
--- trunk/gst-mixer/src/track.c	(original)
+++ trunk/gst-mixer/src/track.c	Mon May 26 20:56:42 2008
@@ -269,8 +269,7 @@
 static void
 gnome_volume_control_track_put_switch (GtkTable *table,
 				       gint      tab_pos,
-				       GnomeVolumeControlTrack *ctrl,
-				       GtkStatusbar *statusbar)
+				       GnomeVolumeControlTrack *ctrl)
 {
   GtkWidget *button;
   AtkObject *accessible;
@@ -287,7 +286,7 @@
   msg = g_strdup_printf (_("Mute/unmute %s"), ctrl->track->label);
   button = gnome_volume_control_button_new ("audio-volume-high",
 					    "audio-volume-muted",
-					    statusbar, msg);
+					     msg);
   ctrl->mute = GNOME_VOLUME_CONTROL_BUTTON (button);
   g_free (msg);
   gnome_volume_control_button_set_active (GNOME_VOLUME_CONTROL_BUTTON (button),
@@ -317,8 +316,7 @@
 					 GstMixer *mixer,
 					 GstMixerTrack *track,
 					 GtkWidget *l_sep,
-					 GtkWidget *r_sep,
-					 GtkStatusbar *statusbar)
+					 GtkWidget *r_sep)
 {
   GnomeVolumeControlTrack *ctrl;
   GtkWidget *slider;
@@ -334,20 +332,19 @@
 
   /* switch exception (no sliders) */
   if (track->num_channels == 0) {
-    gnome_volume_control_track_put_switch (table, tab_pos, ctrl, statusbar);
+    gnome_volume_control_track_put_switch (table, tab_pos, ctrl);
     return ctrl;
   }
 
   ctrl->sliderbox = gnome_volume_control_volume_new (ctrl->mixer,
-						     ctrl->track, 6,
-						     statusbar);
+						     ctrl->track, 6);
   gtk_table_attach (GTK_TABLE (table), ctrl->sliderbox,
 		    tab_pos, tab_pos + 1, 2, 3,
 		    GTK_EXPAND, GTK_EXPAND | GTK_FILL, 0, 0);
   gtk_widget_show (ctrl->sliderbox);
 
   /* mute button */
-  gnome_volume_control_track_put_switch (table, tab_pos, ctrl, statusbar);
+  gnome_volume_control_track_put_switch (table, tab_pos, ctrl);
 
   return ctrl;
 }
@@ -358,8 +355,7 @@
 					  GstMixer *mixer,
 					  GstMixerTrack *track,
 					  GtkWidget *l_sep,
-					  GtkWidget *r_sep,
-					  GtkStatusbar *statusbar)
+					  GtkWidget *r_sep)
 {
   GnomeVolumeControlTrack *ctrl;
   GtkWidget *button;
@@ -367,8 +363,7 @@
   gchar *accessible_name, *msg;
 
   ctrl = gnome_volume_control_track_add_playback (table, tab_pos, mixer,
-						  track, l_sep, r_sep,
-						  statusbar);
+						  track, l_sep, r_sep);
   if (track->num_channels == 0) {
     return ctrl;
   }
@@ -379,8 +374,7 @@
    * - there's something fishy about this button, it
    *     is always FALSE.
    */
-  button = gnome_volume_control_button_new ("audio-input-microphone", "audio-input-microphone-muted",
-					    statusbar, msg);
+  button = gnome_volume_control_button_new ("audio-input-microphone", "audio-input-microphone-muted", msg);
   ctrl->record = GNOME_VOLUME_CONTROL_BUTTON (button);
   g_free (msg);
   gnome_volume_control_button_set_active (GNOME_VOLUME_CONTROL_BUTTON (button),
@@ -412,8 +406,7 @@
 				       GstMixer *mixer,
 				       GstMixerTrack *track,
 				       GtkWidget *l_sep,
-				       GtkWidget *r_sep,
-				       GtkStatusbar *statusbar)
+				       GtkWidget *r_sep)
 {
   GnomeVolumeControlTrack *ctrl;
 
@@ -447,8 +440,7 @@
 				       GstMixer *mixer,
 				       GstMixerTrack *track,
 				       GtkWidget *l_sep,
-				       GtkWidget *r_sep,
-				       GtkStatusbar *statusbar)
+				       GtkWidget *r_sep)
 {
   GnomeVolumeControlTrack *ctrl;
   GstMixerOptions *options = GST_MIXER_OPTIONS (track);

Modified: trunk/gst-mixer/src/track.h
==============================================================================
--- trunk/gst-mixer/src/track.h	(original)
+++ trunk/gst-mixer/src/track.h	Mon May 26 20:56:42 2008
@@ -71,16 +71,14 @@
 						 GstMixer *mixer,
 						 GstMixerTrack *track,
 						 GtkWidget *l_sep,
-						 GtkWidget *r_sep,
-						 GtkStatusbar *statusbar);
+						 GtkWidget *r_sep);
 GnomeVolumeControlTrack *
 	gnome_volume_control_track_add_recording(GtkTable *table,
 						 gint      tab_pos,
 						 GstMixer *mixer,
 						 GstMixerTrack *track,
 						 GtkWidget *l_sep,
-						 GtkWidget *r_sep,
-						 GtkStatusbar *statusbar);
+						 GtkWidget *r_sep);
 
 GnomeVolumeControlTrack *
 	gnome_volume_control_track_add_switch	(GtkTable *table,
@@ -88,8 +86,7 @@
 						 GstMixer *mixer,
 						 GstMixerTrack *track,
 						 GtkWidget *l_sep,
-						 GtkWidget *r_sep,
-						 GtkStatusbar *statusbar);
+						 GtkWidget *r_sep);
 
 GnomeVolumeControlTrack *
 	gnome_volume_control_track_add_option	(GtkTable *table,
@@ -97,8 +94,7 @@
 						 GstMixer *mixer,
 						 GstMixerTrack *track,
 						 GtkWidget *l_sep,
-						 GtkWidget *r_sep,
-						 GtkStatusbar *statusbar);
+						 GtkWidget *r_sep);
 
 void	gnome_volume_control_track_free		(GnomeVolumeControlTrack *track);
 

Modified: trunk/gst-mixer/src/volume.c
==============================================================================
--- trunk/gst-mixer/src/volume.c	(original)
+++ trunk/gst-mixer/src/volume.c	Mon May 26 20:56:42 2008
@@ -78,73 +78,9 @@
   vol->scales = NULL;
   vol->button = NULL;
   vol->locked = FALSE;
-  vol->statusbar = NULL;
   vol->id = 0;
 }
 
-static gboolean
-cb_mouseover (GtkScale *scale,
-	      GdkEventCrossing *event,
-	      gpointer data)
-{
-  GnomeVolumeControlVolume *vol = data;
-  gchar *msg, *chan;
-  GList *items;
-  gint n = 0;
-
-  for (items = vol->scales; items != NULL; items = items->next, n++)
-    if (items->data == scale)
-      break;
-  g_assert (items != NULL);
-
-  /* somewhat dirty hack that will suffice for now. 1 chan
-   * means mono, two means stereo (left/right) and > 2 means
-   * alsa, where channel order is front, rear, center, lfe,
-   * side. */
-  if (vol->track->num_channels == 1) {
-    chan = _("mono");
-  } else if (vol->track->num_channels == 2) {
-    chan = (n == 0) ? _("left") : _("right");
-  } else {
-    switch (n) {
-      case 0:  chan = _("front left"); break;
-      case 1:  chan = _("front right"); break;
-      case 2:  chan = _("rear left"); break;
-      case 3:  chan = _("rear right"); break;
-      case 4:  chan = _("front center"); break;
-      /* Translators: This is the name of a surround sound channel. It
-       * stands for "Low-Frequency Effects". If you're not sure that
-       * this has an established and different translation in your
-       * language, leave it unchanged. */
-      case 5:  chan = _("LFE"); break;
-      case 6:  chan = _("side left"); break;
-      case 7:  chan = _("side right"); break;
-      default: chan = _("unknown"); break;
-    }
-  }
-
-  /* Here, we can actually tell people that this
-   * is a slider that will change channel X. */
-  msg = g_strdup_printf (_("Volume of %s channel on %s"),
-      chan, vol->track->label);
-  gtk_statusbar_push (vol->statusbar, 0, msg);
-  g_free (msg);
-
-  return FALSE;
-}
-
-static gboolean
-cb_mouseout (GtkScale *scale,
-	     GdkEventCrossing *event,
-	     gpointer data)
-{
-  GnomeVolumeControlVolume *vol = data;
-
-  gtk_statusbar_pop (vol->statusbar, 0);
-
-  return FALSE;
-}
-
 static GtkWidget *
 get_scale (GnomeVolumeControlVolume *vol,
 	   gint num_chan,
@@ -164,10 +100,6 @@
   slider = gtk_vscale_new (GTK_ADJUSTMENT (adj));
   gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
   gtk_range_set_inverted (GTK_RANGE (slider), TRUE);
-  g_signal_connect (slider, "enter-notify-event",
-		    G_CALLBACK (cb_mouseover), vol);
-  g_signal_connect (slider, "leave-notify-event",
-		    G_CALLBACK (cb_mouseout), vol);
 
   /* a11y */
   accessible = gtk_widget_get_accessible (slider);
@@ -202,7 +134,7 @@
   msg = g_strdup_printf (_("Lock channels for %s together"), vol->track->label);
   vol->button = gnome_volume_control_button_new ("chain.png",
 						 "chain-broken.png",
-						 vol->statusbar, msg);
+						 msg);
   g_free (msg);
   g_signal_connect (vol->button, "clicked",
 		    G_CALLBACK (cb_lock_toggled), vol);
@@ -227,18 +159,18 @@
 GtkWidget *
 gnome_volume_control_volume_new (GstMixer *mixer,
 				 GstMixerTrack *track,
-				 gint      padding,
-				 GtkStatusbar *statusbar)
+				 gint      padding)
 {
   GnomeVolumeControlVolume *vol;
   gint *volumes, n;
+  gchar *msg, *chan;
+  GList *items;
 
   /* volume */
   vol = g_object_new (GNOME_VOLUME_CONTROL_TYPE_VOLUME, NULL);
   gst_object_ref (GST_OBJECT (mixer));
   vol->mixer = mixer;
   vol->track = g_object_ref (G_OBJECT (track));
-  vol->statusbar = statusbar;
   if (padding >= 0)
     vol->padding = padding;
 
@@ -253,6 +185,39 @@
     gtk_fixed_put (GTK_FIXED (vol), slider, 0, 0);
     gtk_widget_show (slider);
     vol->scales = g_list_append (vol->scales, slider);
+
+    /* somewhat dirty hack that will suffice for now. 1 chan
+     * means mono, two means stereo (left/right) and > 2 means
+     * alsa, where channel order is front, rear, center, lfe,
+     * side. */
+    if (vol->track->num_channels == 1) {
+        chan = _("mono");
+    } else if (vol->track->num_channels == 2) {
+        chan = (n == 0) ? _("left") : _("right");
+    } else {
+        switch (n) {
+            case 0:  chan = _("front left"); break;
+            case 1:  chan = _("front right"); break;
+            case 2:  chan = _("rear left"); break;
+            case 3:  chan = _("rear right"); break;
+            case 4:  chan = _("front center"); break;
+            /* Translators: This is the name of a surround sound channel. It
+             * stands for "Low-Frequency Effects". If you're not sure that
+             * this has an established and different translation in your
+             * language, leave it unchanged. */
+            case 5:  chan = _("LFE"); break;
+            case 6:  chan = _("side left"); break;
+            case 7:  chan = _("side right"); break;
+            default: chan = _("unknown"); break;
+        }
+    }
+
+    /* Here, we can actually tell people that this
+     * is a slider that will change channel X. */
+    msg = g_strdup_printf (_("Volume of %s channel on %s"),
+            chan, vol->track->label);
+    gtk_widget_set_tooltip_text (slider, msg);
+    g_free (msg);
   }
 
   /* chainbutton */

Modified: trunk/gst-mixer/src/volume.h
==============================================================================
--- trunk/gst-mixer/src/volume.h	(original)
+++ trunk/gst-mixer/src/volume.h	Mon May 26 20:56:42 2008
@@ -23,7 +23,6 @@
 #define __GVC_VOLUME_H__
 
 #include <glib.h>
-#include <gtk/gtkstatusbar.h>
 #include <gtk/gtkfixed.h>
 #include <gst/interfaces/mixer.h>
 
@@ -61,9 +60,6 @@
    * infinite loops. */
   gboolean locked;
 
-  /* status bar */
-  GtkStatusbar *statusbar;
-
   /* signal ID */
   guint id;
 } GnomeVolumeControlVolume;
@@ -75,8 +71,7 @@
 GType		gnome_volume_control_volume_get_type	(void);
 GtkWidget *	gnome_volume_control_volume_new	(GstMixer *mixer,
 						 GstMixerTrack *track,
-						 gint      padding,
-						 GtkStatusbar *statusbar);
+						 gint      padding);
 void		gnome_volume_control_volume_sync (GnomeVolumeControlVolume *volume);
 void		gnome_volume_control_volume_ask (GnomeVolumeControlVolume *volume,
 						 gboolean * real_zero,

Modified: trunk/gst-mixer/src/window.c
==============================================================================
--- trunk/gst-mixer/src/window.c	(original)
+++ trunk/gst-mixer/src/window.c	Mon May 26 20:56:42 2008
@@ -26,6 +26,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "keys.h"
 #include "preferences.h"
@@ -33,42 +34,6 @@
 
 G_DEFINE_TYPE (GnomeVolumeControlWindow, gnome_volume_control_window, GTK_TYPE_WINDOW)
 
-static void
-menu_item_select_cb (GtkMenuItem *proxy, GtkStatusbar *statusbar)
-{
-  GtkAction *action;
-  char *message;
-
-  action = g_object_get_data (G_OBJECT (proxy), "gtk-action");
-
-  g_return_if_fail (action != NULL);
-
-  g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
-
-  if (message) {
-    gtk_statusbar_push (statusbar, 0, message);
-    g_free (message);
-  }
-}
-
-static void
-menu_item_deselect_cb (GtkMenuItem *proxy, GtkStatusbar *statusbar)
-{
-  gtk_statusbar_pop (statusbar, 0);
-}
-
-static void
-connect_proxy_cb (GtkUIManager *manager,
-                  GtkAction *action,
-                  GtkWidget *proxy,
-                  GtkStatusbar *statusbar)
-{
-  if (GTK_IS_MENU_ITEM (proxy)) {
-    g_signal_connect (proxy, "select", G_CALLBACK (menu_item_select_cb), statusbar);
-    g_signal_connect (proxy, "deselect", G_CALLBACK (menu_item_deselect_cb), statusbar);
-  }
-}
-
 void gnome_volume_control_window_set_page(GtkWidget *widget, const gchar *page)
 {
   GnomeVolumeControlWindow *win = GNOME_VOLUME_CONTROL_WINDOW (widget);
@@ -85,35 +50,22 @@
     gtk_notebook_set_current_page (GTK_NOTEBOOK (win->el), 0);
 }
 
-static void
-disconnect_proxy_cb (GtkUIManager *manager,
-                     GtkAction *action,
-                     GtkWidget *proxy,
-                     GtkStatusbar *statusbar)
-{
-  if (GTK_IS_MENU_ITEM (proxy)) {
-    g_signal_handlers_disconnect_by_func (proxy, G_CALLBACK (menu_item_select_cb), statusbar);
-    g_signal_handlers_disconnect_by_func (proxy, G_CALLBACK (menu_item_deselect_cb), statusbar);
-  }
-}
-
 
 /*
  * Menu actions.
  */
 
 static void
-cb_change (GtkToggleAction *action,
+cb_change (GtkComboBox *widget,
 	   GnomeVolumeControlWindow *win)
 {
   GConfValue *value;
   gchar *device_name;
 
-  if (gtk_toggle_action_get_active (action) == FALSE)
+  device_name = gtk_combo_box_get_active_text (widget);
+  if (device_name == NULL)
     return;
 
-  device_name = g_object_get_data (G_OBJECT (action), "device-name");
-
   value = gconf_value_new (GCONF_VALUE_STRING);
   gconf_value_set_string (value, device_name);
   gconf_client_set (win->client, GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, value, NULL);
@@ -149,8 +101,8 @@
   }
 }
 
-static void 
-open_uri (GtkWindow *parent, 
+static void
+open_uri (GtkWindow *parent,
           const char *uri)
 {
   GtkWidget *dialog;
@@ -163,7 +115,7 @@
   cmdline = g_strconcat ("xdg-open ", uri, NULL);
 
   if (gdk_spawn_command_line_on_screen (screen, cmdline, &error) == FALSE) {
-    dialog = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, 
+    dialog = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
                                      GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, error->message);
     gtk_dialog_run(GTK_DIALOG(dialog));
     gtk_widget_destroy(dialog);
@@ -181,15 +133,14 @@
 }
 
 static void
-cb_about (GtkAction *action,
-	  GnomeVolumeControlWindow *win)
+cb_show_about (GnomeVolumeControlWindow *win)
 {
   const gchar *authors[] = { "Ronald Bultje <rbultje ronald bitfreak net>",
 			     "Leif Johnson <leif ambient 2y net>",
 			     NULL };
   const gchar *documenters[] = { "Sun Microsystems",
 				 NULL};
-  
+
   gtk_show_about_dialog (GTK_WINDOW (win),
 			 "version", VERSION,
 			 "copyright", "Copyright \xc2\xa9 2003-2004 Ronald Bultje",
@@ -211,8 +162,8 @@
   GConfValue *value;
   const gchar *el, *cur_el_str;
 
-  if (!strcmp (gconf_entry_get_key (entry),
-	       GNOME_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT) &&
+  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) {
@@ -329,31 +280,6 @@
   gtk_window_set_default_size (GTK_WINDOW (win), width, height);
 }
 
-
-static const GtkActionEntry action_entries[] = {
-  { "File",  NULL, N_("_File") },
-  { "Edit",  NULL, N_("_Edit") },
-  { "Help",  NULL, N_("_Help") },
-
-  { "FileChangeDevice", NULL,  N_("_Change Device"), NULL, 
-    N_("Control volume on a different device"),
-    NULL },
-  { "FileQuit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q",  
-    N_("Quit the application"),
-    G_CALLBACK (cb_exit) },
-  { "EditPreferences", GTK_STOCK_PREFERENCES, N_("Prefere_nces"), NULL, 
-    N_("Configure the application"), 
-    G_CALLBACK (cb_preferences) },
-  { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", 
-    N_("Help on this application"),
-    G_CALLBACK (cb_help) },
-  { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, 
-    N_("About this application"),
-    G_CALLBACK (cb_about) }
-};
-
-
-
 GtkWidget *
 gnome_volume_control_window_new (GList *elements)
 {
@@ -361,14 +287,20 @@
   GstElement *active_element;
   GList *item;
   GnomeVolumeControlWindow *win;
+  GtkAccelGroup *accel_group;
+  GtkWidget *combo_box;
+  GtkWidget *label;
+  GtkWidget *hbox;
+  GtkWidget *buttons;
   GtkWidget *el;
+  GtkWidget *prefsbtn;
+  GtkWidget *closebtn;
+  GtkWidget *helpbtn;
   gint count = 0;
   gchar *title;
-  guint change_device_menu_id;
   GtkActionGroup *action_group;
   GtkWidget *vbox;
-  GtkWidget *menubar;
-  GSList *radio_group = NULL;
+  GtkCellRenderer *renderer;
   gint active_element_num;
 
   g_return_val_if_fail (elements != NULL, NULL);
@@ -378,30 +310,11 @@
   win = g_object_new (GNOME_VOLUME_CONTROL_TYPE_WINDOW, NULL);
   win->elements = elements;
 
-  win->statusbar = GTK_STATUSBAR (gtk_statusbar_new ());
-
-  win->ui_manager = gtk_ui_manager_new ();
-
-  /* Hookup menu tooltips to the statusbar */
-  g_signal_connect (win->ui_manager, "connect_proxy",
-	            G_CALLBACK (connect_proxy_cb), win->statusbar);
-  g_signal_connect (win->ui_manager, "disconnect_proxy",
-		    G_CALLBACK (disconnect_proxy_cb), win->statusbar);
-
-  action_group = gtk_action_group_new ("MenuActions");
-  gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-	
-  gtk_action_group_add_actions (action_group, action_entries, 
-                                G_N_ELEMENTS (action_entries), win);
-
-  gtk_ui_manager_insert_action_group (win->ui_manager, action_group, 0);
-
-  gtk_ui_manager_add_ui_from_file (win->ui_manager, DATA_DIR "/gnome-volume-control-ui.xml", NULL);
-
-  menubar = gtk_ui_manager_get_widget (win->ui_manager, "/MainMenu");
-
-
+  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, 
+			   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,
@@ -435,41 +348,24 @@
   }
   active_element_num = count;
 
-  change_device_menu_id = gtk_ui_manager_new_merge_id (win->ui_manager);
-
+  combo_box = gtk_combo_box_new_text ();
+  renderer = gtk_cell_renderer_text_new ();
+  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+  gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box));
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
+  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;
-    GtkRadioAction *radio_action;
 
     name = g_object_get_data (item->data, "gnome-volume-control-name");
     tip = g_strdup_printf (_("Change device to %s"), name);
-    label = g_strdup_printf ("_%d: %s", count, name);
-
-    radio_action = gtk_radio_action_new (name, label, tip, NULL, count);
-    g_object_set_data_full (G_OBJECT (radio_action), "device-name", 
-                            g_strdup (name), (GDestroyNotify)g_free);
-
+    gtk_combo_box_append_text(GTK_COMBO_BOX (combo_box), name);
     g_free (tip);
-    g_free (label);
-
-    gtk_radio_action_set_group (radio_action, radio_group);
-    radio_group = gtk_radio_action_get_group (radio_action);
-
-    g_signal_connect (radio_action, "activate", G_CALLBACK (cb_change), win);
-
-    if (count == active_element_num)
-      gtk_radio_action_set_current_value (radio_action, active_element_num);
-
-    gtk_action_group_add_action (action_group, GTK_ACTION (radio_action));
-    g_object_unref (radio_action);
-
-    gtk_ui_manager_add_ui (win->ui_manager, change_device_menu_id,
-                           "/MainMenu/File/FileChangeDevice/Devices Placeholder",
-                           name, name, GTK_UI_MANAGER_AUTO, FALSE);
-
   }
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), active_element_num);
+  g_signal_connect (combo_box, "changed", G_CALLBACK (cb_change), win);
 
 
   /* gconf */
@@ -487,20 +383,50 @@
 
   win->use_default_mixer = (active_el_str == NULL);
 
+  /* add the combo box to choose the device */
+  label = gtk_label_new (NULL);
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (label), _("_Device: "));
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
+
+  hbox = gtk_hbox_new (FALSE, 6);
+  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+  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,
-					 win->statusbar);
+					 win->client);
   win->el = GNOME_VOLUME_CONTROL_ELEMENT (el);
-  gtk_container_set_border_width (GTK_CONTAINER (el), 6);
 
-  /* Put the menubar, the elements and the statusbar in a vbox */
+  /* create the buttons box */
+  helpbtn = gtk_button_new_from_stock (GTK_STOCK_HELP);
+  prefsbtn = gtk_button_new_from_stock (GTK_STOCK_PREFERENCES);
+  closebtn = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+  g_signal_connect (helpbtn, "clicked", G_CALLBACK (cb_help), win);
+  g_signal_connect (prefsbtn, "clicked", G_CALLBACK (cb_preferences), win);
+  g_signal_connect (closebtn, "clicked", G_CALLBACK (cb_exit), win);
+  gtk_widget_add_accelerator (closebtn, "clicked", accel_group,
+			      GDK_Escape, 0, 0);
+  gtk_widget_add_accelerator (helpbtn, "clicked", accel_group,
+			      GDK_F1, 0, 0);
+  buttons = gtk_hbutton_box_new ();
+  gtk_box_pack_start (GTK_BOX (buttons), helpbtn, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (buttons), prefsbtn, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (buttons), closebtn, FALSE, FALSE, 0);
+  gtk_box_set_spacing (GTK_BOX (buttons), 6);
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (buttons), GTK_BUTTONBOX_END);
+  gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (buttons), helpbtn, TRUE);
+
+  /* Put the the elements in a vbox */
   vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER(win), vbox);
-  gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), el, TRUE, TRUE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET(win->statusbar), FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 6);
+  gtk_box_pack_start (GTK_BOX (vbox), el, TRUE, TRUE, 6);
+  gtk_box_pack_start (GTK_BOX (vbox), buttons, FALSE, FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+
+  /* set tooltips */
+  gtk_widget_set_tooltip_text (combo_box, _("Control volume on a different device"));
 
   gtk_widget_show_all (GTK_WIDGET (win));
 

Modified: trunk/gst-mixer/src/window.h
==============================================================================
--- trunk/gst-mixer/src/window.h	(original)
+++ trunk/gst-mixer/src/window.h	Mon May 26 20:56:42 2008
@@ -55,9 +55,6 @@
   /* contents */
   GnomeVolumeControlElement *el;
 
-  GtkUIManager *ui_manager;
-  GtkStatusbar *statusbar;
-
   /* preferences window, if opened */
   GtkWidget *prefs;
 



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