From 3dd1a3f7ad959027ca16ea1e5cd7de865a91a2a2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 12 Jun 2008 11:26:06 +0000 Subject: show stream icons, don't show our own monitor streams, initialize client proplist properly git-svn-id: file:///home/lennart/svn/public/pavucontrol/trunk@82 c17c95f2-f111-0410-90bf-f30a9569010c --- src/pavucontrol.cc | 70 +- src/pavucontrol.glade | 1891 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 1298 insertions(+), 663 deletions(-) diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc index 582e9fa..19f7cf3 100644 --- a/src/pavucontrol.cc +++ b/src/pavucontrol.cc @@ -101,6 +101,7 @@ public: Gtk::Label *nameLabel, *boldNameLabel; Gtk::ToggleButton *streamToggleButton; Gtk::Menu menu; + Gtk::Image *iconImage; bool updating; @@ -303,6 +304,7 @@ public: void updateDeviceVisibility(); void createMonitorStream(uint32_t idx); + void setIconFromProplist(Gtk::Image *icon, pa_proplist *l, const char *name); Glib::ustring defaultSinkName, defaultSourceName; @@ -393,6 +395,7 @@ MinimalStreamWidget::MinimalStreamWidget(BaseObjectType* cobject, const Glib::Re x->get_widget("nameLabel", nameLabel); x->get_widget("boldNameLabel", boldNameLabel); x->get_widget("streamToggle", streamToggleButton); + x->get_widget("iconImage", iconImage); streamToggleButton->set_active(false); streamToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onStreamToggleButton)); @@ -932,6 +935,8 @@ void MainWindow::updateSink(const pa_sink_info &info) { w->nameLabel->set_markup(txt = g_markup_printf_escaped("%s", info.description)); g_free(txt); + w->iconImage->set_from_icon_name("audio-card", Gtk::ICON_SIZE_SMALL_TOOLBAR); + w->setVolume(info.volume); w->muteToggleButton->set_active(info.mute); @@ -967,8 +972,6 @@ static void read_callback(pa_stream *s, size_t length, void *userdata) { pa_stream_drop(s); - fprintf(stderr, "read(%lu) = %.2f\n", (unsigned long) length, v); - if (v < 0) v = 0; if (v > 1) @@ -1035,6 +1038,8 @@ void MainWindow::updateSource(const pa_source_info &info) { w->nameLabel->set_markup(txt = g_markup_printf_escaped("%s", info.description)); g_free(txt); + w->iconImage->set_from_icon_name("audio-input-microphone", Gtk::ICON_SIZE_SMALL_TOOLBAR); + w->setVolume(info.volume); w->muteToggleButton->set_active(info.mute); @@ -1046,6 +1051,47 @@ void MainWindow::updateSource(const pa_source_info &info) { w->updating = false; } +void MainWindow::setIconFromProplist(Gtk::Image *icon, pa_proplist *l, const char *def) { + const char *t; + + if ((t = pa_proplist_gets(l, PA_PROP_MEDIA_ICON_NAME))) + goto finish; + + if ((t = pa_proplist_gets(l, PA_PROP_WINDOW_ICON_NAME))) + goto finish; + + if ((t = pa_proplist_gets(l, PA_PROP_APPLICATION_ICON_NAME))) + goto finish; + + if ((t = pa_proplist_gets(l, PA_PROP_MEDIA_ROLE))) { + + if (strcmp(t, "video") == 0 || + strcmp(t, "phone") == 0) + goto finish; + + if (strcmp(t, "music") == 0) { + t = "audio"; + goto finish; + } + + if (strcmp(t, "game") == 0) { + t = "applications-games"; + goto finish; + } + + if (strcmp(t, "event") == 0) { + t = "dialog-information"; + goto finish; + } + } + + t = def; + +finish: + + icon->set_from_icon_name(t, Gtk::ICON_SIZE_SMALL_TOOLBAR); +} + void MainWindow::updateSinkInput(const pa_sink_input_info &info) { SinkInputWidget *w; bool is_new = false; @@ -1079,6 +1125,8 @@ void MainWindow::updateSinkInput(const pa_sink_input_info &info) { w->nameLabel->set_label(info.name); } + setIconFromProplist(w->iconImage, info.proplist, "audio-card"); + w->setVolume(info.volume); w->muteToggleButton->set_active(info.mute); @@ -1091,6 +1139,11 @@ void MainWindow::updateSinkInput(const pa_sink_input_info &info) { void MainWindow::updateSourceOutput(const pa_source_output_info &info) { SourceOutputWidget *w; bool is_new = false; + const char *app; + + if ((app = pa_proplist_gets(info.proplist, PA_PROP_APPLICATION_ID))) + if (strcmp(app, "org.PulseAudio.pavucontrol") == 0) + return; if (sourceOutputWidgets.count(info.index)) w = sourceOutputWidgets[info.index]; @@ -1120,6 +1173,8 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) { w->nameLabel->set_label(info.name); } + setIconFromProplist(w->iconImage, info.proplist, "audio-input-microphone"); + if (is_new) updateDeviceVisibility(); @@ -1622,9 +1677,18 @@ int main(int argc, char *argv[]) { g_assert(m); pa_mainloop_api *api = pa_glib_mainloop_get_api(m); g_assert(api); - context = pa_context_new(api, "PulseAudio Volume Control"); + + pa_proplist *proplist = pa_proplist_new(); + pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "PulseAudio Volume Control"); + pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "org.PulseAudio.pavucontrol"); + pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, "audio-card"); + pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION); + + context = pa_context_new_with_proplist(api, NULL, proplist); g_assert(context); + pa_proplist_free(proplist); + pa_context_set_state_callback(context, context_state_callback, mainWindow); if (pa_context_connect(context, NULL, (pa_context_flags_t) 0, NULL) < 0) { diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade index 5f4412a..bcf4ff3 100644 --- a/src/pavucontrol.glade +++ b/src/pavucontrol.glade @@ -1,672 +1,1243 @@ - - - + + + - - Volume Control - 500 - 400 - multimedia-volume-control - - - True - 12 - 12 - - - True - True - False - - - True - - - True - True - 12 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - - - True - GTK_SHADOW_NONE - - - True - - - True - False - 16 - 16 - <i>No application is currently playing audio.</i> - True - - - - - - - - - - - True - 12 - 12 - 12 - - - True - 6 - - - True - 1 - <b>_Show:</b> - True - True - - - - - True - All Streams + + + Volume Control + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 500 + 400 + True + False + multimedia-volume-control + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + 12 + True + False + 12 + + + + True + True + True + False + GTK_POS_TOP + False + False + + + + True + False + 0 + + + + 12 + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + False + <i>No application is currently playing audio.</i> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 16 + 16 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + 0 + True + True + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 12 + 12 + 12 + + + + True + False + 6 + + + + True + <b>_Show:</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + True + All Streams Applications Virtual Streams - - - False - 1 - - - - - - - False - False - 1 - - - - - - - True - _Playback - True - - - tab - False - - - - - True - - - True - True - 12 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - - - True - GTK_SHADOW_NONE - - - True - - - True - False - 16 - 16 - <i>No application is currently recording audio.</i> - True - - - - - - - - - - - True - 12 - 12 - 12 - - - True - 6 - - - True - 1 - <b>_Show:</b> - True - True - - - - - True - All Streams + False + True + + + 0 + False + True + + + + + + + 0 + False + False + + + + + False + True + + + + + + True + _Playback + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + True + False + 0 + + + + 12 + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + False + <i>No application is currently recording audio.</i> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 16 + 16 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + 0 + True + True + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 12 + 12 + 12 + + + + True + False + 6 + + + + True + <b>_Show:</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + True + All Streams Applications Virtual Streams - - - False - 1 - - - - - - - False - False - 1 - - - - - 1 - - - - - True - _Recording - True - - - tab - 1 - False - - - - - True - - - True - True - 12 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - - - True - GTK_SHADOW_NONE - - - True - - - True - False - 16 - 16 - <i>No output devices available</i> - True - - - - - - - - - - - True - 12 - 12 - 12 - - - True - 6 - - - True - 1 - <b>S_how:</b> - True - True - sinkTypeComboBox - - - - - True - All Output Devices + False + True + + + 0 + False + True + + + + + + + 0 + False + False + + + + + False + True + + + + + + True + _Recording + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + True + False + 0 + + + + 12 + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + False + <i>No output devices available</i> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 16 + 16 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + 0 + True + True + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 12 + 12 + 12 + + + + True + False + 6 + + + + True + <b>S_how:</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + sinkTypeComboBox + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + True + All Output Devices Hardware Output Devices Virtual Output Devices - - - False - 1 - - - - - - - False - 1 - - - - - 2 - - - - - True - _Output Devices - True - - - tab - 2 - False - - - - - True - - - True - True - 12 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - - - True - GTK_SHADOW_NONE - - - True - - - True - False - 16 - 16 - <i>No input devices available</i> - True - - - - - - - - - - - True - 12 - 12 - 12 - - - True - 6 - - - True - 1 - <b>Sho_w:</b> - True - True - sourceTypeComboBox - - - - - True - All Input Devices + False + True + + + 0 + False + True + + + + + + + 0 + False + True + + + + + False + True + + + + + + True + _Output Devices + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + True + False + 0 + + + + 12 + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + False + <i>No input devices available</i> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 16 + 16 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + + + + 0 + True + True + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 12 + 12 + 12 + + + + True + False + 6 + + + + True + <b>Sho_w:</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + sourceTypeComboBox + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + + + + + + True + All Input Devices All Except Monitors Hardware Input Devices Virtual Input Devices Monitors - - - False - 1 - - - - - - - False - 1 - - - - - 3 - - - - - True - _Input Devices - True - - - tab - 3 - False - - - - - - - - - True - window1 - - - True - - - True - - - True - 12 - 6 - - - True - - - True - True - - - False - False - - - - - True - 0 - Stream Title - True - PANGO_ELLIPSIZE_MIDDLE - - - 1 - - - - - True - 3 - - - True - True - Mute audio - GTK_RELIEF_NONE - 0 - - - True - 1 - audio-volume-muted - - - - - False - False - - - - - True - True - Lock channels together - GTK_RELIEF_NONE - 0 - True - - - True - 1 - stock_lock - - - - - False - False - 1 - - - - - True - True - Open menu - GTK_RELIEF_NONE - 0 - - - True - GTK_ARROW_DOWN - - - - - False - False - 2 - - - - - False - 2 - - - - - False - False - - - - - True - 6 - - - - - - - - - False - False - 1 - - - - - False - False - - - - - True - - - False - False - 1 - - - - - - - - - True - window2 - - - True - 6 - - - True - 0 - <b>left-front</b> - True - 15 - - - False - False - - - - - True - True - 44.2408370972 0 100 5 0 0 - 0 - False - - - 1 - - - - - True - 1 - 50% - 9 - - - False - False - 2 - - - - - - - True - window1 - - - True - - - True - - - True - 12 - 6 - - - True - - - True - True - - - False - False - - - - - True - 0 - Stream Title - True - PANGO_ELLIPSIZE_MIDDLE - - - 1 - - - - - True - True - GTK_RELIEF_NONE - 0 - - - True - GTK_ARROW_DOWN - - - - - False - False - GTK_PACK_END - 2 - - - - - False - False - - - - - False - False - - - - - True - - - False - False - 1 - - - - - - - + False + True + + + 0 + False + True + + + + + + + 0 + False + True + + + + + False + True + + + + + + True + _Input Devices + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + 0 + True + True + + + + + + + + True + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + True + False + + + + True + False + 0 + + + + 12 + True + False + 6 + + + + True + False + 6 + + + + True + gtk-missing-image + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + False + 0 + + + + True + + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + + True + Stream Title + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_MIDDLE + -1 + False + 0 + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + False + 3 + + + + True + Mute audio + True + GTK_RELIEF_NONE + True + False + False + + + + True + 1 + audio-volume-muted + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + Lock channels together + True + GTK_RELIEF_NONE + True + True + False + + + + True + 1 + stock_lock + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + Open menu + True + GTK_RELIEF_NONE + True + False + False + + + + True + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 0 + False + True + + + + + 0 + False + False + + + + + + True + False + 6 + + + + + + + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + + + 0 + False + False + + + + + + + + + + True + window2 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 6 + + + + True + <b>left-front</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 15 + False + 0 + + + 0 + False + False + + + + + + True + True + False + GTK_POS_TOP + 0 + GTK_UPDATE_CONTINUOUS + False + 44.2408370972 0 100 5 0 0 + + + 0 + True + True + + + + + + True + 50% + False + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 9 + False + 0 + + + 0 + False + False + + + + + + + + True + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + True + False + + + + True + False + 0 + + + + 12 + True + False + 6 + + + + True + False + 6 + + + + True + gtk-missing-image + 4 + 0 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + False + 0 + + + + True + + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + True + + + + + + True + Stream Title + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_MIDDLE + -1 + False + 0 + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + True + GTK_RELIEF_NONE + True + False + False + + + + True + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + True + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + + + 0 + False + False + + + + + + + + -- cgit