summaryrefslogtreecommitdiffstats
path: root/src/canberra-gtk-play.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/canberra-gtk-play.c')
-rw-r--r--src/canberra-gtk-play.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/canberra-gtk-play.c b/src/canberra-gtk-play.c
index 0b68dd9..689a8f6 100644
--- a/src/canberra-gtk-play.c
+++ b/src/canberra-gtk-play.c
@@ -80,14 +80,17 @@ 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", 0, 0, G_OPTION_ARG_STRING, &event_id, "Event sound identifier", "STRING" },
- { "description", 0, 0, G_OPTION_ARG_STRING, &event_description, "Event sound description", "STRING" },
- { "cache-control", 0, 0, G_OPTION_ARG_STRING, &cache_control, "Cache control (permanent, volatile, never)", "STRING" },
- { "loop", 0, 0, G_OPTION_ARG_INT, &n_loops, "Loop how many times (detault: 1)", "INTEGER" },
+ { "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" },
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display version number and quit", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@@ -96,16 +99,20 @@ int main (int argc, char *argv[]) {
g_type_init();
g_thread_init(NULL);
- oc = g_option_context_new("- libcanberra-gtk-play");
+ 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);
- gtk_init(&argc, &argv);
+ if (version) {
+ g_print("canberra-gtk-play from %s\n", PACKAGE_STRING);
+ return 0;
+ }
- 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;
}
@@ -115,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);