main: Add a --tab command line argument to force a given tab to be displayed.

Refs: http://pulseaudio.org/ticket/768
This commit is contained in:
Colin Guthrie 2010-04-22 01:03:54 +01:00
parent 870c3ddb2e
commit 97c9cc6197
1 changed files with 51 additions and 22 deletions

View File

@ -45,6 +45,7 @@
static pa_context* context = NULL;
static pa_mainloop_api* api = NULL;
static int n_outstanding = 0;
static int default_tab = 0;
void show_error(const char *txt) {
char buf[256];
@ -159,7 +160,8 @@ void source_output_cb(pa_context *, const pa_source_output_info *i, int eol, voi
if (n_outstanding > 0) {
/* At this point all notebook pages have been populated, so
* let's open one that isn't empty */
if (default_tab != -1) {
if (default_tab < 1 || default_tab > w->notebook->get_n_pages()) {
if (w->sinkInputWidgets.size() > 0)
w->notebook->set_current_page(0);
else if (w->sourceOutputWidgets.size() > 0)
@ -168,6 +170,11 @@ void source_output_cb(pa_context *, const pa_source_output_info *i, int eol, voi
w->notebook->set_current_page(3);
else
w->notebook->set_current_page(2);
} else {
w->notebook->set_current_page(default_tab - 1);
}
default_tab = -1;
}
}
dec_outstanding(w);
@ -552,7 +559,23 @@ int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN);
Gtk::Main kit(argc, argv);
Glib::OptionContext options;
options.set_summary("PulseAudio Volume Control");
options.set_help_enabled();
Glib::OptionGroup group("pulseaudio", "PAVUControl");
Glib::OptionEntry entry;
entry.set_long_name("tab");
entry.set_short_name('t');
entry.set_description(_("Select a specific tab on load."));
group.add_entry(entry, default_tab);
options.set_main_group(group);
try {
Gtk::Main kit(argc, argv, options);
ca_context_set_driver(ca_gtk_context_get(), "pulse");
@ -571,4 +594,10 @@ int main(int argc, char *argv[]) {
if (context)
pa_context_unref(context);
pa_glib_mainloop_free(m);
} catch ( const Glib::OptionError & e ) {
fprintf(stderr, options.get_help().c_str());
return 1;
}
return 0;
}