1
/* cheese-main.c generated by valac 0.12.0, the Vala compiler
2
* generated from cheese-main.vala, do not modify */
5
* Copyright © 2010 Yuvaraj Pandian T <yuvipanda@yuvi.in>
6
* Copyright © 2010 daniel g. siegel <dgsiegel@gnome.org>
7
* Copyright © 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
9
* Licensed under the GNU General Public License Version 2
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
#include <glib-object.h>
31
#include <glib/gi18n-lib.h>
32
#include <cheese-config.h>
35
#include <clutter/clutter.h>
36
#include <clutter-gtk/clutter-gtk.h>
39
#define CHEESE_TYPE_MAIN (cheese_main_get_type ())
40
#define CHEESE_MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_MAIN, CheeseMain))
41
#define CHEESE_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_MAIN, CheeseMainClass))
42
#define CHEESE_IS_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_MAIN))
43
#define CHEESE_IS_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_MAIN))
44
#define CHEESE_MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_MAIN, CheeseMainClass))
46
typedef struct _CheeseMain CheeseMain;
47
typedef struct _CheeseMainClass CheeseMainClass;
48
typedef struct _CheeseMainPrivate CheeseMainPrivate;
50
#define CHEESE_TYPE_MAIN_WINDOW (cheese_main_window_get_type ())
51
#define CHEESE_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_MAIN_WINDOW, CheeseMainWindow))
52
#define CHEESE_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_MAIN_WINDOW, CheeseMainWindowClass))
53
#define CHEESE_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_MAIN_WINDOW))
54
#define CHEESE_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_MAIN_WINDOW))
55
#define CHEESE_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_MAIN_WINDOW, CheeseMainWindowClass))
57
typedef struct _CheeseMainWindow CheeseMainWindow;
58
typedef struct _CheeseMainWindowClass CheeseMainWindowClass;
59
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
60
#define _g_free0(var) (var = (g_free (var), NULL))
61
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
62
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
65
GtkApplication parent_instance;
66
CheeseMainPrivate * priv;
69
struct _CheeseMainClass {
70
GtkApplicationClass parent_class;
74
static gpointer cheese_main_parent_class = NULL;
75
static gboolean cheese_main_wide;
76
static gboolean cheese_main_wide = FALSE;
77
static gchar* cheese_main_device;
78
static gchar* cheese_main_device = NULL;
79
static gboolean cheese_main_version;
80
static gboolean cheese_main_version = FALSE;
81
static gboolean cheese_main_fullscreen;
82
static gboolean cheese_main_fullscreen = FALSE;
83
static CheeseMainWindow* cheese_main_main_window;
84
static CheeseMainWindow* cheese_main_main_window = NULL;
86
GType cheese_main_get_type (void) G_GNUC_CONST;
88
CHEESE_MAIN_DUMMY_PROPERTY
90
GType cheese_main_window_get_type (void) G_GNUC_CONST;
91
CheeseMain* cheese_main_new (const gchar* app_id, GApplicationFlags flags);
92
CheeseMain* cheese_main_construct (GType object_type, const gchar* app_id, GApplicationFlags flags);
93
void cheese_main_on_app_activate (CheeseMain* self);
94
CheeseMainWindow* cheese_main_window_new (void);
95
CheeseMainWindow* cheese_main_window_construct (GType object_type);
96
void cheese_main_window_setup_ui (CheeseMainWindow* self);
97
void cheese_main_window_set_startup_wide_mode (CheeseMainWindow* self);
98
void cheese_main_window_set_startup_fullscreen_mode (CheeseMainWindow* self);
99
static void _gtk_main_quit_gtk_widget_destroy (GtkWidget* _sender, gpointer self);
100
void cheese_main_window_setup_camera (CheeseMainWindow* self, const gchar* uri);
101
static gboolean cheese_main_real_local_command_line (GApplication* base, gchar*** arguments, gint* exit_status);
102
static void cheese_main_finalize (GObject* obj);
103
gint _vala_main (gchar** args, int args_length1);
104
static void _cheese_main_on_app_activate_g_application_activate (GApplication* _sender, gpointer self);
105
static gint _vala_array_length (gpointer array);
107
static const GOptionEntry CHEESE_MAIN_options[5] = {{"wide", 'w', 0, G_OPTION_ARG_NONE, &cheese_main_wide, "Start in wide mode", NULL}, {"device", 'd', 0, G_OPTION_ARG_FILENAME, &cheese_main_device, "Device to use as a camera", "DEVICE"}, {"version", 'v', 0, G_OPTION_ARG_NONE, &cheese_main_version, "Output version information and exit", NULL}, {"fullscreen", 'f', 0, G_OPTION_ARG_NONE, &cheese_main_fullscreen, "Start in fullscreen mode", NULL}, {NULL}};
109
CheeseMain* cheese_main_construct (GType object_type, const gchar* app_id, GApplicationFlags flags) {
110
CheeseMain * self = NULL;
111
g_return_val_if_fail (app_id != NULL, NULL);
112
self = (CheeseMain*) g_object_new (object_type, "application-id", app_id, "flags", flags, NULL);
117
CheeseMain* cheese_main_new (const gchar* app_id, GApplicationFlags flags) {
118
return cheese_main_construct (CHEESE_TYPE_MAIN, app_id, flags);
122
static void _gtk_main_quit_gtk_widget_destroy (GtkWidget* _sender, gpointer self) {
127
void cheese_main_on_app_activate (CheeseMain* self) {
128
GList* _tmp0_ = NULL;
129
g_return_if_fail (self != NULL);
130
_tmp0_ = gtk_application_get_windows ((GtkApplication*) self);
131
if (_tmp0_ != NULL) {
132
gtk_window_present ((GtkWindow*) cheese_main_main_window);
134
CheeseMainWindow* _tmp1_ = NULL;
135
const gchar* _tmp2_ = NULL;
136
GtkIconTheme* _tmp3_ = NULL;
137
gchar* _tmp4_ = NULL;
139
_tmp1_ = cheese_main_window_new ();
140
_g_object_unref0 (cheese_main_main_window);
141
cheese_main_main_window = g_object_ref_sink (_tmp1_);
142
_tmp2_ = _ ("Cheese");
143
g_set_application_name (_tmp2_);
144
gtk_window_set_default_icon_name ("cheese");
145
_tmp3_ = gtk_icon_theme_get_default ();
146
_tmp4_ = g_build_filename (PACKAGE_DATADIR, "icons", NULL);
148
gtk_icon_theme_append_search_path (_tmp3_, _tmp5_);
150
cheese_main_window_setup_ui (cheese_main_main_window);
151
if (cheese_main_wide) {
152
cheese_main_window_set_startup_wide_mode (cheese_main_main_window);
154
if (cheese_main_fullscreen) {
155
cheese_main_window_set_startup_fullscreen_mode (cheese_main_main_window);
157
gtk_window_set_application ((GtkWindow*) cheese_main_main_window, (GtkApplication*) self);
158
g_signal_connect ((GtkWidget*) cheese_main_main_window, "destroy", (GCallback) _gtk_main_quit_gtk_widget_destroy, NULL);
159
gtk_widget_show ((GtkWidget*) cheese_main_main_window);
160
cheese_main_window_setup_camera (cheese_main_main_window, cheese_main_device);
165
static gboolean cheese_main_real_local_command_line (GApplication* base, gchar*** arguments, gint* exit_status) {
167
gint _exit_status = 0;
168
gboolean result = FALSE;
170
gint local_args_length1;
171
gint _local_args_size_;
173
GError * _inner_error_ = NULL;
174
self = (CheeseMain*) base;
175
g_application_register ((GApplication*) self, NULL, &_inner_error_);
176
if (_inner_error_ != NULL) {
177
goto __catch0_g_error;
184
_inner_error_ = NULL;
185
fprintf (stdout, "Error: %s\n", e->message);
190
*exit_status = _exit_status;
195
if (_inner_error_ != NULL) {
196
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
197
g_clear_error (&_inner_error_);
200
local_args = *arguments;
201
local_args_length1 = _vala_array_length (*arguments);
202
_local_args_size_ = _vala_array_length (*arguments);
203
n_args = local_args_length1;
205
gst_init (&local_args_length1, &local_args);
206
g_application_activate ((GApplication*) self);
209
const gchar* _tmp0_ = NULL;
210
GOptionContext* _tmp1_ = NULL;
211
GOptionContext* context;
212
GOptionGroup* _tmp2_ = NULL;
213
GOptionGroup* _tmp3_ = NULL;
214
GOptionGroup* _tmp4_ = NULL;
216
_tmp0_ = _ ("- Take photos and videos from your webcam");
217
_tmp1_ = g_option_context_new (_tmp0_);
219
g_option_context_set_help_enabled (context, TRUE);
220
g_option_context_add_main_entries (context, CHEESE_MAIN_options, NULL);
221
_tmp2_ = gtk_get_option_group (TRUE);
222
g_option_context_add_group (context, _tmp2_);
223
_tmp3_ = clutter_get_option_group ();
224
g_option_context_add_group (context, _tmp3_);
225
_tmp4_ = gst_init_get_option_group ();
226
g_option_context_add_group (context, _tmp4_);
227
g_option_context_parse (context, &local_args_length1, &local_args, &_inner_error_);
228
if (_inner_error_ != NULL) {
229
_g_option_context_free0 (context);
230
if (_inner_error_->domain == G_OPTION_ERROR) {
231
goto __catch1_g_option_error;
233
_g_option_context_free0 (context);
234
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
235
g_clear_error (&_inner_error_);
238
_g_option_context_free0 (context);
240
__catch1_g_option_error:
243
const gchar* _tmp5_ = NULL;
245
_inner_error_ = NULL;
246
fprintf (stdout, "%s\n", e->message);
247
_tmp5_ = _ ("Run '%s --help' to see a full list of available command line options.\n");
248
fprintf (stdout, _tmp5_, (*arguments)[0]);
253
*exit_status = _exit_status;
258
if (_inner_error_ != NULL) {
259
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
260
g_clear_error (&_inner_error_);
263
if (cheese_main_version) {
264
fprintf (stdout, "%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
268
*exit_status = _exit_status;
272
_tmp6_ = g_application_get_is_remote ((GApplication*) self);
274
const gchar* _tmp7_ = NULL;
275
_tmp7_ = _ ("Another instance of Cheese is currently running\n");
276
fprintf (stdout, "%s", _tmp7_);
280
*exit_status = _exit_status;
284
gst_init (&local_args_length1, &local_args);
285
g_application_activate ((GApplication*) self);
291
*exit_status = _exit_status;
297
static void cheese_main_class_init (CheeseMainClass * klass) {
298
cheese_main_parent_class = g_type_class_peek_parent (klass);
299
G_APPLICATION_CLASS (klass)->local_command_line = cheese_main_real_local_command_line;
300
G_OBJECT_CLASS (klass)->finalize = cheese_main_finalize;
304
static void cheese_main_instance_init (CheeseMain * self) {
308
static void cheese_main_finalize (GObject* obj) {
310
self = CHEESE_MAIN (obj);
311
G_OBJECT_CLASS (cheese_main_parent_class)->finalize (obj);
315
GType cheese_main_get_type (void) {
316
static volatile gsize cheese_main_type_id__volatile = 0;
317
if (g_once_init_enter (&cheese_main_type_id__volatile)) {
318
static const GTypeInfo g_define_type_info = { sizeof (CheeseMainClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) cheese_main_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CheeseMain), 0, (GInstanceInitFunc) cheese_main_instance_init, NULL };
319
GType cheese_main_type_id;
320
cheese_main_type_id = g_type_register_static (GTK_TYPE_APPLICATION, "CheeseMain", &g_define_type_info, 0);
321
g_once_init_leave (&cheese_main_type_id__volatile, cheese_main_type_id);
323
return cheese_main_type_id__volatile;
327
static void _cheese_main_on_app_activate_g_application_activate (GApplication* _sender, gpointer self) {
328
cheese_main_on_app_activate (self);
332
gint _vala_main (gchar** args, int args_length1) {
334
CheeseMain* app = NULL;
335
CheeseMain* _tmp0_ = NULL;
338
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
339
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
340
textdomain (GETTEXT_PACKAGE);
341
gtk_clutter_init (&args_length1, &args);
342
_tmp0_ = cheese_main_new ("org.gnome.Cheese", G_APPLICATION_FLAGS_NONE);
343
_g_object_unref0 (app);
345
g_signal_connect_object ((GApplication*) app, "activate", (GCallback) _cheese_main_on_app_activate_g_application_activate, app, 0);
346
_tmp1_ = g_application_run ((GApplication*) app, args_length1, args);
349
_g_object_unref0 (app);
354
int main (int argc, char ** argv) {
355
g_thread_init (NULL);
357
return _vala_main (argv, argc);
361
static gint _vala_array_length (gpointer array) {
365
while (((gpointer*) array)[length]) {