~ubuntu-branches/ubuntu/natty/gst123/natty

« back to all changes in this revision

Viewing changes to src/options.cc

  • Committer: Bazaar Package Importer
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy), Rogério Brito
  • Date: 2010-05-29 11:23:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100529112351-z1ffbyinvriludew
Tags: 0.1.0-1
* New upstream release.
* debian/control:
  + Added good & base plugins to Depends
  + Added ffmpeg, ugly & bad plugins to Recommends
  + Added libgtk2.0-dev, libgstreamer-plugins-base0.10-dev to Build-Deps
* debian/copyright:
  + Updated copyrights
  + Updated my email address

[ Rogério Brito ]
* Include a missing comma in the depends field

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GST123 - GStreamer based command line media player
 
2
 * Copyright (C) 2006-2010 Stefan Westerfeld
 
3
 * Copyright (C) 2010 أحمد المحمودي (Ahmed El-Mahmoudy)
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General
 
16
 * Public License along with this library; if not, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
#include <assert.h>
 
21
#include <gst/gst.h>
 
22
#include <gtk/gtk.h>
 
23
#include <X11/Xlib.h>
 
24
 
 
25
#include "config.h"
 
26
#include "options.h"
 
27
#include "gtkinterface.h"
 
28
 
 
29
Options *Options::instance = NULL;
 
30
 
 
31
Options::Options ()
 
32
{
 
33
  assert (!instance);
 
34
  instance = this; // singleton
 
35
 
 
36
  program_name = "gst123";
 
37
  shuffle = FALSE;
 
38
  verbose = FALSE;
 
39
  novideo = FALSE;
 
40
  uris = NULL;
 
41
}
 
42
 
 
43
void
 
44
Options::parse (int argc, char **argv)
 
45
{
 
46
  GOptionContext *context = g_option_context_new ("<URI>... - Play video and audio clips");
 
47
  const GOptionEntry all_options[] = {
 
48
    {"list", '@', G_OPTION_FLAG_FILENAME, G_OPTION_ARG_CALLBACK,
 
49
      (GOptionParseFunc*) Options::add_playlist,
 
50
      "read playlist of files and URIs from <filename>", "<filename>"},
 
51
    {"version", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
 
52
      (GOptionParseFunc*) Options::print_version, "print version", NULL },
 
53
    {"verbose", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &instance->verbose,
 
54
      "print GStreamer pipeline used to play files", NULL},
 
55
    {"shuffle", 'z', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &instance->shuffle,
 
56
      "play files in pseudo random order", NULL},
 
57
    {"novideo", 'x', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &instance->novideo,
 
58
      "do not play the video stream", NULL},
 
59
    {G_OPTION_REMAINING, '\0', G_OPTION_FLAG_FILENAME, G_OPTION_ARG_FILENAME_ARRAY, &instance->uris, "Movies to play", NULL},
 
60
    {NULL} /* end the list */
 
61
  };
 
62
  g_option_context_add_main_entries (context, all_options, NULL);
 
63
  g_option_context_add_group (context, gst_init_get_option_group());
 
64
 
 
65
  if (GtkInterface::have_x11_display())
 
66
    g_option_context_add_group (context, gtk_get_option_group (TRUE));
 
67
 
 
68
  GError *error = NULL;
 
69
  bool option_parse_ret = g_option_context_parse (context, &argc, &argv, &error);
 
70
  usage = g_option_context_get_help (context, TRUE, NULL);
 
71
  if (!option_parse_ret)
 
72
    {
 
73
      g_print ("%s\n%s", error->message, usage.c_str());
 
74
      g_error_free (error);
 
75
      g_option_context_free (context);
 
76
      exit (1);
 
77
    }
 
78
  g_option_context_free (context);
 
79
}
 
80
 
 
81
void
 
82
Options::print_version ()
 
83
{
 
84
  printf ("%s %s\n", instance->program_name.c_str(), VERSION);
 
85
  exit (0);
 
86
}
 
87
 
 
88
void
 
89
Options::add_playlist (const gchar *option_name, const gchar *value)
 
90
{
 
91
  instance->playlists.push_back (value);
 
92
}