2
* Copyright © 2010 Yuvaraj Pandian T <yuvipanda@yuvi.in>
3
* Copyright © 2010 daniel g. siegel <dgsiegel@gnome.org>
4
* Copyright © 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
6
* Licensed under the GNU General Public License Version 2
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
27
public class Cheese.Main : Gtk.Application
32
static bool fullscreen;
34
static Cheese.MainWindow main_window;
36
const OptionEntry[] options = {
37
{"wide", 'w', 0, OptionArg.NONE, ref wide, N_("Start in wide mode"), null },
38
{"device", 'd', 0, OptionArg.FILENAME, ref device, N_("Device to use as a camera"), N_("DEVICE")},
39
{"version", 'v', 0, OptionArg.NONE, ref version, N_("Output version information and exit"), null },
40
{"fullscreen", 'f', 0, OptionArg.NONE, ref fullscreen, N_("Start in fullscreen mode"), null },
44
public Main (string app_id, ApplicationFlags flags)
46
GLib.Object (application_id: app_id, flags: flags);
49
public void on_app_activate ()
51
if (get_windows () != null)
52
main_window.present ();
55
main_window = new Cheese.MainWindow ();
57
Environment.set_application_name (_("Cheese"));
58
Window.set_default_icon_name ("cheese");
60
Gtk.IconTheme.get_default ().append_search_path (GLib.Path.build_filename (Config.PACKAGE_DATADIR, "icons"));
62
main_window.setup_ui ();
65
main_window.set_startup_wide_mode ();
67
main_window.set_startup_fullscreen_mode ();
69
main_window.set_application (this);
70
main_window.destroy.connect (Gtk.main_quit);
72
main_window.setup_camera (device);
76
public override bool local_command_line ([CCode (array_null_terminated = true, array_length = false)]
77
ref unowned string[] arguments,
87
stdout.printf ("Error: %s\n", e.message);
92
// Workaround until bug 642885 is solved.
93
unowned string[] local_args = arguments;
95
// Check command line parameters.
96
int n_args = local_args.length;
99
Gst.init (ref local_args);
108
var context = new OptionContext (_("- Take photos and videos from your webcam"));
109
context.set_help_enabled (true);
110
context.add_main_entries (options, null);
111
context.add_group (Gtk.get_option_group (true));
112
context.add_group (Clutter.get_option_group ());
113
context.add_group (Gst.init_get_option_group ());
114
context.parse (ref local_args);
116
catch (OptionError e)
118
stdout.printf ("%s\n", e.message);
119
stdout.printf (_("Run '%s --help' to see a full list of available command line options.\n"), arguments[0]);
126
stdout.printf ("%s %s\n", Config.PACKAGE_NAME, Config.PACKAGE_VERSION);
131
//Remote instance process commands locally.
132
if (get_is_remote ())
134
stdout.printf (_("Another instance of Cheese is currently running\n"));
141
Gst.init (ref local_args);
150
public int main (string[] args)
152
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALEDIR);
153
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
154
Intl.textdomain (Config.GETTEXT_PACKAGE);
156
GtkClutter.init (ref args);
159
app = new Cheese.Main ("org.gnome.Cheese", ApplicationFlags.FLAGS_NONE);
161
app.activate.connect (app.on_app_activate);
162
int status = app.run (args);