gnome-media r4063 - in trunk/gnome-volume-control: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4063 - in trunk/gnome-volume-control: . src
- Date: Tue, 18 Nov 2008 20:26:48 +0000 (UTC)
Author: mccann
Date: Tue Nov 18 20:26:47 2008
New Revision: 4063
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4063&view=rev
Log:
2008-11-18 William Jon McCann <jmccann redhat com>
* src/gvc-mixer-control.c (gvc_mixer_control_set_default_sink),
(gvc_mixer_control_set_default_source), (_set_default_source),
(_set_default_sink), (_stream_has_name), (find_stream_for_name),
(update_default_source_from_name), (update_default_sink_from_name),
(update_server), (update_sink), (update_source),
(update_sink_input), (gvc_mixer_control_class_init):
* src/gvc-mixer-control.h:
* src/gvc-mixer-dialog.c (on_mixer_control_default_sink_changed),
(on_mixer_control_default_source_changed),
(gvc_mixer_dialog_set_mixer_control), (bar_set_stream),
(add_stream), (find_stream_by_id), (remove_stream),
(on_control_stream_removed), (create_stream_treeview),
(on_input_treeview_selection_changed),
(on_output_treeview_selection_changed),
(gvc_mixer_dialog_constructor):
* src/gvc-mixer-stream.c (gvc_mixer_stream_set_property),
(gvc_mixer_stream_get_property), (gvc_mixer_stream_class_init):
* src/gvc-mixer-stream.h:
Add support for changing the default sink and source.
Modified:
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/gvc-mixer-control.c
trunk/gnome-volume-control/src/gvc-mixer-control.h
trunk/gnome-volume-control/src/gvc-mixer-dialog.c
trunk/gnome-volume-control/src/gvc-mixer-stream.c
trunk/gnome-volume-control/src/gvc-mixer-stream.h
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.c Tue Nov 18 20:26:47 2008
@@ -70,6 +70,8 @@
READY,
STREAM_ADDED,
STREAM_REMOVED,
+ DEFAULT_SINK_CHANGED,
+ DEFAULT_SOURCE_CHANGED,
LAST_SIGNAL
};
@@ -94,6 +96,58 @@
return stream;
}
+gboolean
+gvc_mixer_control_set_default_sink (GvcMixerControl *control,
+ GvcMixerStream *stream)
+{
+ pa_operation *o;
+
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), FALSE);
+ g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
+
+ g_debug ("Setting default sink to '%s'",
+ gvc_mixer_stream_get_name (stream));
+
+ o = pa_context_set_default_sink (control->priv->pa_context,
+ gvc_mixer_stream_get_name (stream),
+ NULL,
+ NULL);
+ if (o == NULL) {
+ g_warning ("pa_context_set_default_sink() failed");
+ return FALSE;
+ }
+
+ pa_operation_unref (o);
+
+ return TRUE;
+}
+
+gboolean
+gvc_mixer_control_set_default_source (GvcMixerControl *control,
+ GvcMixerStream *stream)
+{
+ pa_operation *o;
+
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), FALSE);
+ g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
+
+ g_debug ("Setting default source to '%s'",
+ gvc_mixer_stream_get_name (stream));
+
+ o = pa_context_set_default_source (control->priv->pa_context,
+ gvc_mixer_stream_get_name (stream),
+ NULL,
+ NULL);
+ if (o == NULL) {
+ g_warning ("pa_context_set_default_source() failed");
+ return FALSE;
+ }
+
+ pa_operation_unref (o);
+
+ return TRUE;
+}
+
GvcMixerStream *
gvc_mixer_control_get_default_sink (GvcMixerControl *control)
{
@@ -243,21 +297,145 @@
return (control->priv->n_outstanding == 0);
}
+
+static void
+_set_default_source (GvcMixerControl *control,
+ GvcMixerStream *stream)
+{
+ guint new_id;
+
+ new_id = 0;
+
+ if (stream != NULL) {
+ new_id = gvc_mixer_stream_get_id (stream);
+ }
+
+ g_debug ("GvcMixerControl: setting new default source %u (was %u)", new_id, control->priv->default_source_id);
+
+ if (control->priv->default_source_id != new_id) {
+ control->priv->default_source_id = new_id;
+ control->priv->default_source_is_set = TRUE;
+ g_signal_emit (control,
+ signals[DEFAULT_SOURCE_CHANGED],
+ 0,
+ new_id);
+ }
+}
+
+static void
+_set_default_sink (GvcMixerControl *control,
+ GvcMixerStream *stream)
+{
+ guint new_id;
+
+ new_id = 0;
+
+ if (stream != NULL) {
+ new_id = gvc_mixer_stream_get_id (stream);
+ }
+
+ g_debug ("GvcMixerControl: setting new default sink %u (was %u)", new_id, control->priv->default_sink_id);
+
+ if (control->priv->default_sink_id != new_id) {
+ control->priv->default_sink_id = new_id;
+ control->priv->default_sink_is_set = TRUE;
+
+ g_signal_emit (control,
+ signals[DEFAULT_SINK_CHANGED],
+ 0,
+ new_id);
+ }
+}
+
+static gboolean
+_stream_has_name (gpointer key,
+ GvcMixerStream *stream,
+ const char *name)
+{
+ const char *t_name;
+
+ t_name = gvc_mixer_stream_get_name (stream);
+
+ if (t_name != NULL
+ && name != NULL
+ && strcmp (t_name, name) == 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static GvcMixerStream *
+find_stream_for_name (GvcMixerControl *control,
+ const char *name)
+{
+ GvcMixerStream *stream;
+
+ stream = g_hash_table_find (control->priv->all_streams,
+ (GHRFunc)_stream_has_name,
+ (char *)name);
+ return stream;
+}
+
+static void
+update_default_source_from_name (GvcMixerControl *control,
+ const char *name)
+{
+ gboolean changed;
+
+ g_debug ("Default source: %s", name);
+ if ((control->priv->default_source_name == NULL
+ && name != NULL)
+ || (control->priv->default_source_name != NULL
+ && name == NULL)
+ || strcmp (control->priv->default_source_name, name) != 0) {
+ changed = TRUE;
+ }
+
+ if (changed) {
+ GvcMixerStream *stream;
+ g_free (control->priv->default_source_name);
+ control->priv->default_source_name = g_strdup (name);
+
+ stream = find_stream_for_name (control, name);
+ _set_default_source (control, stream);
+ }
+}
+
+static void
+update_default_sink_from_name (GvcMixerControl *control,
+ const char *name)
+{
+ gboolean changed;
+
+ g_debug ("Default sink: %s", name);
+ if ((control->priv->default_sink_name == NULL
+ && name != NULL)
+ || (control->priv->default_sink_name != NULL
+ && name == NULL)
+ || strcmp (control->priv->default_sink_name, name) != 0) {
+ changed = TRUE;
+ }
+
+ if (changed) {
+ GvcMixerStream *stream;
+ g_free (control->priv->default_sink_name);
+ control->priv->default_sink_name = g_strdup (name);
+
+ stream = find_stream_for_name (control, name);
+ _set_default_sink (control, stream);
+ }
+}
+
static void
update_server (GvcMixerControl *control,
const pa_server_info *info)
{
if (info->default_source_name != NULL) {
- g_debug ("Default source: %s", info->default_source_name);
- g_free (control->priv->default_source_name);
- control->priv->default_source_name = g_strdup (info->default_source_name);
- /* FIXME: iterate over existing sources and update default flag */
+ update_default_source_from_name (control, info->default_source_name);
}
if (info->default_sink_name != NULL) {
- g_debug ("Default sink: %s", info->default_sink_name);
- g_free (control->priv->default_sink_name);
- control->priv->default_sink_name = g_strdup (info->default_sink_name);
- /* FIXME: iterate over existing sinks and update default flag */
+ update_default_sink_from_name (control, info->default_sink_name);
}
}
@@ -294,7 +472,6 @@
{
GvcMixerStream *stream;
gboolean is_new;
- gboolean is_default;
pa_volume_t avg_volume;
#if 0
g_debug ("Updating sink: index=%u name='%s' description='%s'",
@@ -309,7 +486,6 @@
}
is_new = FALSE;
- is_default = FALSE;
stream = g_hash_table_lookup (control->priv->sinks,
GUINT_TO_POINTER (info->index));
if (stream == NULL) {
@@ -319,11 +495,6 @@
is_new = TRUE;
}
- if (control->priv->default_sink_name != NULL
- && info->name != NULL
- && strcmp (control->priv->default_sink_name, info->name) == 0) {
- is_default = TRUE;
- }
avg_volume = pa_cvolume_avg (&info->volume);
gvc_mixer_stream_set_name (stream, info->name);
@@ -331,9 +502,6 @@
gvc_mixer_stream_set_icon_name (stream, "audio-card");
gvc_mixer_stream_set_volume (stream, (guint)avg_volume);
gvc_mixer_stream_set_is_muted (stream, info->mute);
- gvc_mixer_stream_set_is_default (stream, is_default);
-
- //w->type = info.flags & PA_SINK_HARDWARE ? SINK_HARDWARE : SINK_VIRTUAL;
if (is_new) {
g_hash_table_insert (control->priv->sinks,
@@ -342,11 +510,10 @@
add_stream (control, stream);
}
- if (is_default) {
- control->priv->default_sink_id = gvc_mixer_stream_get_id (stream);
- control->priv->default_sink_is_set = TRUE;
-
- /* FIXME: property w/ changed event */
+ if (control->priv->default_sink_name != NULL
+ && info->name != NULL
+ && strcmp (control->priv->default_sink_name, info->name) == 0) {
+ _set_default_sink (control, stream);
}
}
@@ -356,7 +523,6 @@
{
GvcMixerStream *stream;
gboolean is_new;
- gboolean is_default;
pa_volume_t avg_volume;
#if 0
g_debug ("Updating source: index=%u name='%s' description='%s'",
@@ -371,7 +537,6 @@
}
is_new = FALSE;
- is_default = FALSE;
stream = g_hash_table_lookup (control->priv->sources,
GUINT_TO_POINTER (info->index));
@@ -382,11 +547,6 @@
is_new = TRUE;
}
- if (control->priv->default_source_name != NULL
- && info->name != NULL
- && strcmp (control->priv->default_source_name, info->name) == 0) {
- is_default = TRUE;
- }
avg_volume = pa_cvolume_avg (&info->volume);
gvc_mixer_stream_set_name (stream, info->name);
@@ -394,9 +554,6 @@
gvc_mixer_stream_set_icon_name (stream, "audio-input-microphone");
gvc_mixer_stream_set_volume (stream, (guint)avg_volume);
gvc_mixer_stream_set_is_muted (stream, info->mute);
- gvc_mixer_stream_set_is_default (stream, is_default);
-
- //w->type = info.flags & PA_SINK_HARDWARE ? SINK_HARDWARE : SINK_VIRTUAL;
if (is_new) {
g_hash_table_insert (control->priv->sources,
@@ -405,11 +562,10 @@
add_stream (control, stream);
}
- if (is_default) {
- control->priv->default_source_id = gvc_mixer_stream_get_id (stream);
- control->priv->default_source_is_set = TRUE;
-
- /* FIXME: property w/ changed event */
+ if (control->priv->default_source_name != NULL
+ && info->name != NULL
+ && strcmp (control->priv->default_source_name, info->name) == 0) {
+ _set_default_source (control, stream);
}
}
@@ -467,7 +623,6 @@
{
GvcMixerStream *stream;
gboolean is_new;
- gboolean is_default;
pa_volume_t avg_volume;
#if 0
@@ -477,7 +632,6 @@
#endif
is_new = FALSE;
- is_default = FALSE;
stream = g_hash_table_lookup (control->priv->sink_inputs,
GUINT_TO_POINTER (info->index));
@@ -495,7 +649,6 @@
set_icon_name_from_proplist (stream, info->proplist, "applications-multimedia");
gvc_mixer_stream_set_volume (stream, (guint)avg_volume);
gvc_mixer_stream_set_is_muted (stream, info->mute);
- gvc_mixer_stream_set_is_default (stream, is_default);
if (is_new) {
g_hash_table_insert (control->priv->sink_inputs,
@@ -1283,6 +1436,22 @@
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals [DEFAULT_SINK_CHANGED] =
+ g_signal_new ("default-sink-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GvcMixerControlClass, default_sink_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals [DEFAULT_SOURCE_CHANGED] =
+ g_signal_new ("default-source-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GvcMixerControlClass, default_source_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
g_type_class_add_private (klass, sizeof (GvcMixerControlPrivate));
}
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.h
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.h (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.h Tue Nov 18 20:26:47 2008
@@ -45,11 +45,15 @@
{
GObjectClass parent_class;
- void (*ready) (GvcMixerControl *control);
- void (*stream_added) (GvcMixerControl *control,
- guint id);
- void (*stream_removed) (GvcMixerControl *control,
- guint id);
+ void (*ready) (GvcMixerControl *control);
+ void (*stream_added) (GvcMixerControl *control,
+ guint id);
+ void (*stream_removed) (GvcMixerControl *control,
+ guint id);
+ void (*default_sink_changed) (GvcMixerControl *control,
+ guint id);
+ void (*default_source_changed) (GvcMixerControl *control,
+ guint id);
} GvcMixerControlClass;
GType gvc_mixer_control_get_type (void);
@@ -68,10 +72,15 @@
GvcMixerStream * gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
guint id);
-GvcMixerStream * gvc_mixer_control_get_default_sink (GvcMixerControl *control);
-GvcMixerStream * gvc_mixer_control_get_default_source (GvcMixerControl *control);
+GvcMixerStream * gvc_mixer_control_get_default_sink (GvcMixerControl *control);
+GvcMixerStream * gvc_mixer_control_get_default_source (GvcMixerControl *control);
GvcMixerStream * gvc_mixer_control_get_event_sink_input (GvcMixerControl *control);
+gboolean gvc_mixer_control_set_default_sink (GvcMixerControl *control,
+ GvcMixerStream *stream);
+gboolean gvc_mixer_control_set_default_source (GvcMixerControl *control,
+ GvcMixerStream *stream);
+
G_END_DECLS
#endif /* __GVC_MIXER_CONTROL_H */
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 18 20:26:47 2008
@@ -63,10 +63,10 @@
};
enum {
- NAME_COL,
- DEVICE_COL,
- ID_COL,
- NUM_COLS
+ NAME_COLUMN,
+ DEVICE_COLUMN,
+ ID_COLUMN,
+ NUM_COLUMNS
};
enum
@@ -77,11 +77,43 @@
static void gvc_mixer_dialog_class_init (GvcMixerDialogClass *klass);
static void gvc_mixer_dialog_init (GvcMixerDialog *mixer_dialog);
-static void gvc_mixer_dialog_finalize (GObject *object);
+static void gvc_mixer_dialog_finalize (GObject *object);
+
+static void bar_set_stream (GvcMixerDialog *dialog,
+ GtkWidget *bar,
+ GvcMixerStream *stream);
G_DEFINE_TYPE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_DIALOG)
+
static void
+on_mixer_control_default_sink_changed (GvcMixerControl *control,
+ guint id,
+ GvcMixerDialog *dialog)
+{
+ GvcMixerStream *stream;
+
+ g_debug ("GvcMixerDialog: default sink changed: %u", id);
+
+ stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control,
+ id);
+ bar_set_stream (dialog, dialog->priv->output_bar, stream);
+}
+
+static void
+on_mixer_control_default_source_changed (GvcMixerControl *control,
+ guint id,
+ GvcMixerDialog *dialog)
+{
+ GvcMixerStream *stream;
+ g_debug ("GvcMixerDialog: default source changed: %u", id);
+
+ stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control,
+ id);
+ bar_set_stream (dialog, dialog->priv->input_bar, stream);
+}
+
+static void
gvc_mixer_dialog_set_mixer_control (GvcMixerDialog *dialog,
GvcMixerControl *control)
{
@@ -91,11 +123,26 @@
g_object_ref (control);
if (dialog->priv->mixer_control != NULL) {
+ g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control,
+ G_CALLBACK (on_mixer_control_default_sink_changed),
+ dialog);
+ g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control,
+ G_CALLBACK (on_mixer_control_default_source_changed),
+ dialog);
g_object_unref (dialog->priv->mixer_control);
}
dialog->priv->mixer_control = control;
+ g_signal_connect (dialog->priv->mixer_control,
+ "default-sink-changed",
+ G_CALLBACK (on_mixer_control_default_sink_changed),
+ dialog);
+ g_signal_connect (dialog->priv->mixer_control,
+ "default-source-changed",
+ G_CALLBACK (on_mixer_control_default_source_changed),
+ dialog);
+
g_object_notify (G_OBJECT (dialog), "mixer-control");
}
@@ -275,27 +322,26 @@
GtkAdjustment *adj;
gboolean is_muted;
- g_assert (stream != NULL);
-
- gtk_widget_set_sensitive (bar, TRUE);
+ g_assert (bar != NULL);
- is_muted = gvc_mixer_stream_get_is_muted (stream);
- gvc_channel_bar_set_is_muted (GVC_CHANNEL_BAR (bar), is_muted);
+ is_muted = FALSE;
- save_bar_for_stream (dialog, stream, bar);
+ gtk_widget_set_sensitive (bar, (stream != NULL));
adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (bar)));
- gtk_adjustment_set_value (adj,
- gvc_mixer_stream_get_volume (stream));
+ if (stream != NULL) {
+ is_muted = gvc_mixer_stream_get_is_muted (stream);
+ gvc_channel_bar_set_is_muted (GVC_CHANNEL_BAR (bar), is_muted);
+
+ save_bar_for_stream (dialog, stream, bar);
+
+ gtk_adjustment_set_value (adj,
+ gvc_mixer_stream_get_volume (stream));
+ }
g_object_set_data (G_OBJECT (bar), "gvc-mixer-dialog-stream", stream);
g_object_set_data (G_OBJECT (adj), "gvc-mixer-dialog-stream", stream);
- g_signal_connect (adj,
- "value-changed",
- G_CALLBACK (on_adjustment_value_changed),
- dialog);
- gtk_widget_show (bar);
}
static void
@@ -304,6 +350,7 @@
{
GtkWidget *bar;
gboolean is_muted;
+ GtkAdjustment *adj;
g_assert (stream != NULL);
@@ -336,9 +383,9 @@
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model),
&iter,
- NAME_COL, gvc_mixer_stream_get_description (stream),
- DEVICE_COL, "",
- ID_COL, gvc_mixer_stream_get_id (stream),
+ NAME_COLUMN, gvc_mixer_stream_get_description (stream),
+ DEVICE_COLUMN, "",
+ ID_COLUMN, gvc_mixer_stream_get_id (stream),
-1);
} else if (GVC_IS_MIXER_SINK (stream)) {
GtkTreeModel *model;
@@ -347,14 +394,21 @@
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model),
&iter,
- NAME_COL, gvc_mixer_stream_get_description (stream),
- DEVICE_COL, "",
- ID_COL, gvc_mixer_stream_get_id (stream),
+ NAME_COLUMN, gvc_mixer_stream_get_description (stream),
+ DEVICE_COLUMN, "",
+ ID_COLUMN, gvc_mixer_stream_get_id (stream),
-1);
}
if (bar != NULL) {
bar_set_stream (dialog, bar, stream);
+ adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (bar)));
+
+ g_signal_connect (adj,
+ "value-changed",
+ G_CALLBACK (on_adjustment_value_changed),
+ dialog);
+ gtk_widget_show (bar);
}
g_signal_connect (stream,
@@ -404,7 +458,7 @@
guint t_id;
gtk_tree_model_get (model, iter,
- ID_COL, &t_id, -1);
+ ID_COLUMN, &t_id, -1);
if (id == t_id) {
found_item = TRUE;
@@ -415,22 +469,28 @@
}
static void
-on_control_stream_removed (GvcMixerControl *control,
- guint id,
- GvcMixerDialog *dialog)
+remove_stream (GvcMixerDialog *dialog,
+ guint id)
{
GtkWidget *bar;
gboolean found;
GtkTreeIter iter;
GtkTreeModel *model;
+ /* remove bars for applications and reset fixed bars */
bar = g_hash_table_lookup (dialog->priv->bars, GUINT_TO_POINTER (id));
- if (bar != NULL) {
+ if (bar == dialog->priv->output_bar
+ || bar == dialog->priv->input_bar
+ || bar == dialog->priv->effects_bar) {
+ g_hash_table_remove (dialog->priv->bars, GUINT_TO_POINTER (id));
+ bar_set_stream (dialog, bar, NULL);
+ } else if (bar != NULL) {
g_hash_table_remove (dialog->priv->bars, GUINT_TO_POINTER (id));
gtk_container_remove (GTK_CONTAINER (bar->parent),
bar);
}
+ /* remove from any models */
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) {
@@ -444,6 +504,14 @@
}
static void
+on_control_stream_removed (GvcMixerControl *control,
+ guint id,
+ GvcMixerDialog *dialog)
+{
+ remove_stream (dialog, id);
+}
+
+static void
_gtk_label_make_bold (GtkLabel *label)
{
PangoFontDescription *font_desc;
@@ -474,7 +542,7 @@
treeview = gtk_tree_view_new ();
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
- store = gtk_list_store_new (NUM_COLS,
+ store = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_UINT);
@@ -484,35 +552,96 @@
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Name"),
renderer,
- "text", NAME_COL,
+ "text", NAME_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Device"),
renderer,
- "text", DEVICE_COL,
+ "text", DEVICE_COLUMN,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
return treeview;
}
+static void
+on_input_treeview_selection_changed (GtkTreeSelection *selection,
+ GvcMixerDialog *dialog)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ guint id;
+ GvcMixerStream *stream;
+
+ if (! gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ return;
+ }
+
+ id = 0;
+ gtk_tree_model_get (model, &iter, ID_COLUMN, &id, -1);
+
+ if (id == 0) {
+ return;
+ }
+
+ g_debug ("Default input selected: %u", id);
+ stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control, id);
+ if (stream == NULL) {
+ g_warning ("Unable to find stream for id: %u", id);
+ return;
+ }
+
+ gvc_mixer_control_set_default_source (dialog->priv->mixer_control, stream);
+}
+
+static void
+on_output_treeview_selection_changed (GtkTreeSelection *selection,
+ GvcMixerDialog *dialog)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ guint id;
+ GvcMixerStream *stream;
+
+ if (! gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ return;
+ }
+
+ id = 0;
+ gtk_tree_model_get (model, &iter, ID_COLUMN, &id, -1);
+
+ if (id == 0) {
+ return;
+ }
+
+ g_debug ("Default output selected: %u", id);
+ stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control, id);
+ if (stream == NULL) {
+ g_warning ("Unable to find stream for id: %u", id);
+ return;
+ }
+
+ gvc_mixer_control_set_default_sink (dialog->priv->mixer_control, stream);
+}
+
static GObject *
gvc_mixer_dialog_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_params)
{
- GObject *object;
- GvcMixerDialog *self;
- GtkWidget *main_vbox;
- GtkWidget *label;
- GtkWidget *alignment;
- GtkWidget *box;
- GtkWidget *notebook;
- GSList *streams;
- GSList *l;
- GvcMixerStream *stream;
+ GObject *object;
+ GvcMixerDialog *self;
+ GtkWidget *main_vbox;
+ GtkWidget *label;
+ GtkWidget *alignment;
+ GtkWidget *box;
+ GtkWidget *notebook;
+ GSList *streams;
+ GSList *l;
+ GvcMixerStream *stream;
+ GtkTreeSelection *selection;
object = G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->constructor (type, n_construct_properties, construct_params);
@@ -597,6 +726,13 @@
gtk_container_add (GTK_CONTAINER (box), self->priv->input_treeview);
gtk_container_add (GTK_CONTAINER (alignment), box);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->input_treeview));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ g_signal_connect (selection,
+ "changed",
+ G_CALLBACK (on_input_treeview_selection_changed),
+ self);
+
/* Output page */
self->priv->output_box = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (self->priv->output_box), 12);
@@ -625,6 +761,13 @@
gtk_container_add (GTK_CONTAINER (box), self->priv->output_treeview);
gtk_container_add (GTK_CONTAINER (alignment), box);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->output_treeview));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ g_signal_connect (selection,
+ "changed",
+ G_CALLBACK (on_output_treeview_selection_changed),
+ self);
+
/* Applications */
self->priv->applications_box = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (self->priv->applications_box), 12);
Modified: trunk/gnome-volume-control/src/gvc-mixer-stream.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-stream.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-stream.c Tue Nov 18 20:26:47 2008
@@ -46,7 +46,6 @@
char *description;
char *icon_name;
gboolean is_muted;
- gboolean is_default;
};
enum
@@ -61,7 +60,6 @@
PROP_ICON_NAME,
PROP_VOLUME,
PROP_IS_MUTED,
- PROP_IS_DEFAULT,
};
static void gvc_mixer_stream_class_init (GvcMixerStreamClass *klass);
@@ -141,13 +139,6 @@
}
gboolean
-gvc_mixer_stream_get_is_default (GvcMixerStream *stream)
-{
- g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
- return stream->priv->is_default;
-}
-
-gboolean
gvc_mixer_stream_set_is_muted (GvcMixerStream *stream,
gboolean is_muted)
{
@@ -161,20 +152,6 @@
return TRUE;
}
-gboolean
-gvc_mixer_stream_set_is_default (GvcMixerStream *stream,
- gboolean is_default)
-{
- g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
-
- if (is_default != stream->priv->is_default) {
- stream->priv->is_default = is_default;
- g_object_notify (G_OBJECT (stream), "is-default");
- }
-
- return TRUE;
-}
-
const char *
gvc_mixer_stream_get_name (GvcMixerStream *stream)
{
@@ -271,9 +248,6 @@
case PROP_IS_MUTED:
gvc_mixer_stream_set_is_muted (self, g_value_get_boolean (value));
break;
- case PROP_IS_DEFAULT:
- gvc_mixer_stream_set_is_default (self, g_value_get_boolean (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -316,9 +290,6 @@
case PROP_IS_MUTED:
g_value_set_boolean (value, self->priv->is_muted);
break;
- case PROP_IS_DEFAULT:
- g_value_set_boolean (value, self->priv->is_default);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -452,13 +423,6 @@
"Whether stream is muted",
FALSE,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
- g_object_class_install_property (gobject_class,
- PROP_IS_DEFAULT,
- g_param_spec_boolean ("is-default",
- "is default",
- "Whether stream is the default",
- FALSE,
- G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GvcMixerStreamPrivate));
}
Modified: trunk/gnome-volume-control/src/gvc-mixer-stream.h
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-stream.h (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-stream.h Tue Nov 18 20:26:47 2008
@@ -58,7 +58,6 @@
guint gvc_mixer_stream_get_index (GvcMixerStream *stream);
guint gvc_mixer_stream_get_id (GvcMixerStream *stream);
guint gvc_mixer_stream_get_num_channels (GvcMixerStream *stream);
-gboolean gvc_mixer_stream_get_is_default (GvcMixerStream *stream);
guint gvc_mixer_stream_get_volume (GvcMixerStream *stream);
gboolean gvc_mixer_stream_change_volume (GvcMixerStream *stream,
@@ -72,8 +71,6 @@
const char * gvc_mixer_stream_get_description (GvcMixerStream *stream);
/* private */
-gboolean gvc_mixer_stream_set_is_default (GvcMixerStream *stream,
- gboolean is_default);
gboolean gvc_mixer_stream_set_volume (GvcMixerStream *stream,
guint volume);
gboolean gvc_mixer_stream_set_is_muted (GvcMixerStream *stream,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]