|
|
ecdf9b |
From 5bcbdb44dd1cd4f0ed0a69a92a27634616e8df3e Mon Sep 17 00:00:00 2001
|
|
|
ecdf9b |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
ecdf9b |
Date: Wed, 12 Jun 2013 13:28:11 +0200
|
|
|
ecdf9b |
Subject: [PATCH 24/35] cheese: Use cheese_gtk_init_with_args
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Currently our --help output only shows gstreamer related info:
|
|
|
ecdf9b |
|
|
|
ecdf9b |
[hans@shalem cheese]$ cheese --help
|
|
|
ecdf9b |
Usage:
|
|
|
ecdf9b |
cheese [OPTION...] - GStreamer initialization
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Help Options:
|
|
|
ecdf9b |
-h, --help Show help options
|
|
|
ecdf9b |
--help-all Show all help options
|
|
|
ecdf9b |
--help-gst Show GStreamer Options
|
|
|
ecdf9b |
|
|
|
ecdf9b |
This is caused by this gstreamer bug:
|
|
|
ecdf9b |
https://bugzilla.gnome.org/show_bug.cgi?id=702089
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Besides suffering from this bug, our commandline parsing code also is not
|
|
|
ecdf9b |
exactly pretty, and not a good example of how to do commandline parsing
|
|
|
ecdf9b |
for other libcheese using applications.
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Also adding all the various option_groups manually is rather error prone
|
|
|
ecdf9b |
ie currently the cogl group is missing.
|
|
|
ecdf9b |
|
|
|
ecdf9b |
This patch fixes all this (including working around the --help issue)
|
|
|
ecdf9b |
by using cheese_gtk_init_with_args, resulting in much simpler code.
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
ecdf9b |
---
|
|
|
ecdf9b |
src/cheese-main.vala | 124 +++++++++++++--------------------------------------
|
|
|
ecdf9b |
1 file changed, 30 insertions(+), 94 deletions(-)
|
|
|
ecdf9b |
|
|
|
ecdf9b |
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
|
|
|
ecdf9b |
index ac5ba6f..5905597 100644
|
|
|
ecdf9b |
--- a/src/cheese-main.vala
|
|
|
ecdf9b |
+++ b/src/cheese-main.vala
|
|
|
ecdf9b |
@@ -24,12 +24,21 @@ using Gtk;
|
|
|
ecdf9b |
using Clutter;
|
|
|
ecdf9b |
using Gst;
|
|
|
ecdf9b |
|
|
|
ecdf9b |
+static bool wide;
|
|
|
ecdf9b |
+static string device;
|
|
|
ecdf9b |
+static bool version;
|
|
|
ecdf9b |
+static bool fullscreen;
|
|
|
ecdf9b |
+
|
|
|
ecdf9b |
+const OptionEntry[] options = {
|
|
|
ecdf9b |
+ {"wide", 'w', 0, OptionArg.NONE, ref wide, N_("Start in wide mode"), null },
|
|
|
ecdf9b |
+ {"device", 'd', 0, OptionArg.FILENAME, ref device, N_("Device to use as a camera"), N_("DEVICE")},
|
|
|
ecdf9b |
+ {"version", 'v', 0, OptionArg.NONE, ref version, N_("Output version information and exit"), null },
|
|
|
ecdf9b |
+ {"fullscreen", 'f', 0, OptionArg.NONE, ref fullscreen, N_("Start in fullscreen mode"), null },
|
|
|
ecdf9b |
+ {null}
|
|
|
ecdf9b |
+};
|
|
|
ecdf9b |
+
|
|
|
ecdf9b |
public class Cheese.Main : Gtk.Application
|
|
|
ecdf9b |
{
|
|
|
ecdf9b |
- static bool wide;
|
|
|
ecdf9b |
- static string device;
|
|
|
ecdf9b |
- static bool version;
|
|
|
ecdf9b |
- static bool fullscreen;
|
|
|
ecdf9b |
|
|
|
ecdf9b |
static MainWindow main_window;
|
|
|
ecdf9b |
|
|
|
ecdf9b |
@@ -47,14 +56,6 @@ public class Cheese.Main : Gtk.Application
|
|
|
ecdf9b |
{ "quit", on_quit }
|
|
|
ecdf9b |
};
|
|
|
ecdf9b |
|
|
|
ecdf9b |
- const OptionEntry[] options = {
|
|
|
ecdf9b |
- {"wide", 'w', 0, OptionArg.NONE, ref wide, N_("Start in wide mode"), null },
|
|
|
ecdf9b |
- {"device", 'd', 0, OptionArg.FILENAME, ref device, N_("Device to use as a camera"), N_("DEVICE")},
|
|
|
ecdf9b |
- {"version", 'v', 0, OptionArg.NONE, ref version, N_("Output version information and exit"), null },
|
|
|
ecdf9b |
- {"fullscreen", 'f', 0, OptionArg.NONE, ref fullscreen, N_("Start in fullscreen mode"), null },
|
|
|
ecdf9b |
- {null}
|
|
|
ecdf9b |
- };
|
|
|
ecdf9b |
-
|
|
|
ecdf9b |
public Main (string app_id, ApplicationFlags flags)
|
|
|
ecdf9b |
{
|
|
|
ecdf9b |
GLib.Object (application_id: app_id, flags: flags);
|
|
|
ecdf9b |
@@ -140,87 +141,6 @@ public class Cheese.Main : Gtk.Application
|
|
|
ecdf9b |
}
|
|
|
ecdf9b |
}
|
|
|
ecdf9b |
|
|
|
ecdf9b |
- /**
|
|
|
ecdf9b |
- * Overridden method of GApplication, to handle the arguments locally.
|
|
|
ecdf9b |
- *
|
|
|
ecdf9b |
- * @param arguments the command-line arguments
|
|
|
ecdf9b |
- * @param exit_status the exit status to return to the OS
|
|
|
ecdf9b |
- * @return true if the arguments were successfully processed, false otherwise
|
|
|
ecdf9b |
- */
|
|
|
ecdf9b |
- public override bool local_command_line ([CCode (array_null_terminated = true, array_length = false)]
|
|
|
ecdf9b |
- ref unowned string[] arguments,
|
|
|
ecdf9b |
- out int exit_status)
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- // Try to register.
|
|
|
ecdf9b |
- try
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- register();
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
- catch (Error e)
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- stdout.printf ("Error: %s\n", e.message);
|
|
|
ecdf9b |
- exit_status = 1;
|
|
|
ecdf9b |
- return true;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
-
|
|
|
ecdf9b |
- // Workaround until bug 642885 is solved.
|
|
|
ecdf9b |
- unowned string[] local_args = arguments;
|
|
|
ecdf9b |
-
|
|
|
ecdf9b |
- // Check command line parameters.
|
|
|
ecdf9b |
- int n_args = local_args.length;
|
|
|
ecdf9b |
- if (n_args <= 1)
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- Gst.init (ref local_args);
|
|
|
ecdf9b |
- activate ();
|
|
|
ecdf9b |
- exit_status = 0;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
- else
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- // Set parser.
|
|
|
ecdf9b |
- try
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- var context = new OptionContext (_("- Take photos and videos from your webcam"));
|
|
|
ecdf9b |
- context.set_translation_domain (Config.GETTEXT_PACKAGE);
|
|
|
ecdf9b |
- context.set_help_enabled (true);
|
|
|
ecdf9b |
- context.add_main_entries (options, null);
|
|
|
ecdf9b |
- context.add_group (Gtk.get_option_group (true));
|
|
|
ecdf9b |
- context.add_group (Clutter.get_option_group ());
|
|
|
ecdf9b |
- context.add_group (Gst.init_get_option_group ());
|
|
|
ecdf9b |
- context.parse (ref local_args);
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
- catch (OptionError e)
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- stdout.printf ("%s\n", e.message);
|
|
|
ecdf9b |
- stdout.printf (_("Run '%s --help' to see a full list of available command line options.\n"), arguments[0]);
|
|
|
ecdf9b |
- exit_status = 1;
|
|
|
ecdf9b |
- return true;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
-
|
|
|
ecdf9b |
- if (version)
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- stdout.printf ("%s %s\n", Config.PACKAGE_NAME, Config.PACKAGE_VERSION);
|
|
|
ecdf9b |
- exit_status = 1;
|
|
|
ecdf9b |
- return true;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
-
|
|
|
ecdf9b |
- //Remote instance process commands locally.
|
|
|
ecdf9b |
- if (get_is_remote ())
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- stdout.printf (_("Another instance of Cheese is currently running\n"));
|
|
|
ecdf9b |
- exit_status = 1;
|
|
|
ecdf9b |
- return true;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
- //Primary instance.
|
|
|
ecdf9b |
- else
|
|
|
ecdf9b |
- {
|
|
|
ecdf9b |
- Gst.init (ref local_args);
|
|
|
ecdf9b |
- activate ();
|
|
|
ecdf9b |
- exit_status=0;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
- return true;
|
|
|
ecdf9b |
- }
|
|
|
ecdf9b |
-
|
|
|
ecdf9b |
/**
|
|
|
ecdf9b |
* Setup the camera listed in GSettings.
|
|
|
ecdf9b |
*
|
|
|
ecdf9b |
@@ -543,8 +463,24 @@ public class Cheese.Main : Gtk.Application
|
|
|
ecdf9b |
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
|
|
|
ecdf9b |
Intl.textdomain (Config.GETTEXT_PACKAGE);
|
|
|
ecdf9b |
|
|
|
ecdf9b |
- if (!Cheese.gtk_init (ref args))
|
|
|
ecdf9b |
+ try
|
|
|
ecdf9b |
+ {
|
|
|
ecdf9b |
+ Cheese.gtk_init_with_args (ref args,
|
|
|
ecdf9b |
+ _("- Take photos and videos from your webcam"),
|
|
|
ecdf9b |
+ options, Config.GETTEXT_PACKAGE);
|
|
|
ecdf9b |
+ }
|
|
|
ecdf9b |
+ catch (OptionError e)
|
|
|
ecdf9b |
+ {
|
|
|
ecdf9b |
+ stdout.printf ("%s\n", e.message);
|
|
|
ecdf9b |
+ stdout.printf (_("Run '%s --help' to see a full list of available command line options.\n"), args[0]);
|
|
|
ecdf9b |
return Posix.EXIT_FAILURE;
|
|
|
ecdf9b |
+ }
|
|
|
ecdf9b |
+
|
|
|
ecdf9b |
+ if (version)
|
|
|
ecdf9b |
+ {
|
|
|
ecdf9b |
+ stdout.printf ("%s %s\n", Config.PACKAGE_NAME, Config.PACKAGE_VERSION);
|
|
|
ecdf9b |
+ return Posix.EXIT_SUCCESS;
|
|
|
ecdf9b |
+ }
|
|
|
ecdf9b |
|
|
|
ecdf9b |
Cheese.Main app;
|
|
|
ecdf9b |
app = new Cheese.Main ("org.gnome.Cheese", ApplicationFlags.FLAGS_NONE);
|
|
|
ecdf9b |
--
|
|
|
ecdf9b |
1.8.2.1
|
|
|
ecdf9b |
|