summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2008-09-03 00:03:59 +0300
committerMarc-André Lureau <marcandre.lureau@gmail.com>2008-09-03 00:16:10 +0300
commit529349e27fdb2c156b2a17943647ce2840f3ca66 (patch)
tree07b630d05f46af867a7fe6a7c175c377594e9e21
parent20d646d48e05ff6fc4c75686dcf8b722dcabbb10 (diff)
Support playing events with file specified
-rw-r--r--src/canberra-gtk-play.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/canberra-gtk-play.c b/src/canberra-gtk-play.c
index d1367bf..689a8f6 100644
--- a/src/canberra-gtk-play.c
+++ b/src/canberra-gtk-play.c
@@ -80,12 +80,13 @@ static void callback(ca_context *c, uint32_t id, int error, void *userdata) {
int main (int argc, char *argv[]) {
GOptionContext *oc;
- static gchar *event_id = NULL, *event_description = NULL, *cache_control = NULL;
+ static gchar *event_id = NULL, *filename = NULL, *event_description = NULL, *cache_control = NULL;
int r;
static gboolean version = FALSE;
static const GOptionEntry options[] = {
{ "id", 'i', 0, G_OPTION_ARG_STRING, &event_id, "Event sound identifier", "STRING" },
+ { "file", 'f', 0, G_OPTION_ARG_STRING, &filename, "Play file", "PATH" },
{ "description", 'd', 0, G_OPTION_ARG_STRING, &event_description, "Event sound description", "STRING" },
{ "cache-control", 'c', 0, G_OPTION_ARG_STRING, &cache_control, "Cache control (permanent, volatile, never)", "STRING" },
{ "loop", 'l', 0, G_OPTION_ARG_INT, &n_loops, "Loop how many times (detault: 1)", "INTEGER" },
@@ -100,6 +101,7 @@ int main (int argc, char *argv[]) {
oc = g_option_context_new("- canberra-gtk-play");
g_option_context_add_main_entries(oc, options, NULL);
+ g_option_context_add_group(oc, gtk_get_option_group(TRUE));
g_option_context_set_help_enabled(oc, TRUE);
g_option_context_parse(oc, &argc, &argv, NULL);
g_option_context_free(oc);
@@ -109,10 +111,8 @@ int main (int argc, char *argv[]) {
return 0;
}
- gtk_init(&argc, &argv);
-
- if (!event_id) {
- g_printerr("No event id specified.\n");
+ if (!event_id && !filename) {
+ g_printerr("No event id or file specified.\n");
return 1;
}
@@ -122,7 +122,12 @@ int main (int argc, char *argv[]) {
NULL);
ca_proplist_create(&proplist);
- ca_proplist_sets(proplist, CA_PROP_EVENT_ID, event_id);
+
+ if (event_id)
+ ca_proplist_sets(proplist, CA_PROP_EVENT_ID, event_id);
+
+ if (filename)
+ ca_proplist_sets(proplist, CA_PROP_MEDIA_FILENAME, filename);
if (cache_control)
ca_proplist_sets(proplist, CA_PROP_CANBERRA_CACHE_CONTROL, cache_control);