~ubuntu-branches/debian/sid/cheese/sid

« back to all changes in this revision

Viewing changes to src/cheese-application.vala

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2014-04-02 21:39:33 UTC
  • mfrom: (1.5.1) (15.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20140402213933-r0w3gna0pv7q7085
Tags: 3.12.0-1
* New upstream release.
* Revert changes done in 3.10.1-3
  - i.e. lower gnome-desktop build-dependency again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
{
29
29
    private GLib.Settings settings;
30
30
 
31
 
    static bool wide;
32
31
    static string device;
33
 
    static bool version;
34
 
    static bool fullscreen;
35
32
 
36
33
    static MainWindow main_window;
37
34
 
52
49
    };
53
50
 
54
51
    const OptionEntry[] options = {
55
 
        { "wide", 'w', 0, OptionArg.NONE, ref wide, N_("Start in wide mode"),
 
52
        { "wide", 'w', 0, OptionArg.NONE, null, N_("Start in wide mode"),
56
53
          null  },
57
 
        { "device", 'd', 0, OptionArg.FILENAME, ref device,
 
54
        { "device", 'd', 0, OptionArg.FILENAME, null,
58
55
          N_("Device to use as a camera"), N_("DEVICE") },
59
 
        { "version", 'v', 0, OptionArg.NONE, ref version,
 
56
        { "version", 'v', 0, OptionArg.NONE, null,
60
57
          N_("Output version information and exit"), null },
61
 
        { "fullscreen", 'f', 0, OptionArg.NONE, ref fullscreen,
 
58
        { "fullscreen", 'f', 0, OptionArg.NONE, null,
62
59
          N_("Start in fullscreen mode"), null },
63
60
        { null }
64
61
    };
65
62
 
66
63
    public Application ()
67
64
    {
68
 
        GLib.Object (application_id: "org.gnome.Cheese");
 
65
        GLib.Object (application_id: "org.gnome.Cheese",
 
66
                     flags: ApplicationFlags.HANDLES_COMMAND_LINE);
 
67
 
 
68
        this.add_main_option_entries (options);
69
69
    }
70
70
 
71
71
    /**
112
112
            Environment.set_application_name (_("Cheese"));
113
113
            Window.set_default_icon_name ("cheese");
114
114
 
115
 
            Gtk.IconTheme.get_default ().append_search_path (GLib.Path.build_filename (Config.PACKAGE_DATADIR, "icons"));
116
 
 
117
115
            // Create the menus.
118
 
            var menu = new GLib.Menu ();
119
 
            var section = new GLib.Menu ();
120
 
            menu.append_section (null, section);
121
 
            var item = new GLib.MenuItem (_("_Shoot"), "app.shoot");
122
 
            item.set_attribute ("accel", "s", "space");
123
 
            section.append_item (item);
124
 
            section = new GLib.Menu ();
125
 
            menu.append_section (_("Mode:"), section);
126
 
            section.append (_("_Photo"), "app.mode::photo");
127
 
            section.append (_("_Video"), "app.mode::video");
128
 
            section.append (_("_Burst"), "app.mode::burst");
129
 
            section = new GLib.Menu ();
130
 
            menu.append_section (null, section);
131
 
            item = new GLib.MenuItem (_("_Fullscreen"), "app.fullscreen");
132
 
            item.set_attribute ("accel", "s", "F11");
133
 
            section.append_item (item);
134
 
            section = new GLib.Menu ();
135
 
            menu.append_section (null, section);
136
 
            section.append (_("_Effects"), "app.effects");
137
 
            section = new GLib.Menu ();
138
 
            menu.append_section (null, section);
139
 
            section.append (_("P_references"), "app.preferences");
140
 
            section = new GLib.Menu ();
141
 
            menu.append_section (null, section);
142
 
            item = new GLib.MenuItem (_("_Help"), "app.help");
143
 
            item.set_attribute ("accel", "s", "F1");
144
 
            section.append_item (item);
145
 
            section.append (_("_About"), "app.about");
146
 
            item = new GLib.MenuItem (_("_Quit"), "app.quit");
147
 
            item.set_attribute ("accel", "s", "<Primary>q");
148
 
            section.append_item (item);
149
 
            set_app_menu (menu);
 
116
            var builder = new Gtk.Builder.from_resource ("/org/gnome/Cheese/cheese-appmenu.ui");
 
117
            var appmenu = builder.get_object ("appmenu") as GLib.MenuModel;
 
118
            this.set_app_menu (appmenu);
 
119
 
 
120
            this.add_accelerator ("space", "app.shoot", null);
150
121
 
151
122
            // FIXME: Push these into the main window initialization.
152
123
            main_window.setup_ui ();
181
152
        }
182
153
    }
183
154
 
184
 
    /**
185
 
     * Overridden method of GApplication, to handle the arguments locally.
186
 
     *
187
 
     * @param arguments the command-line arguments
188
 
     * @param exit_status the exit status to return to the OS
189
 
     * @return true if the arguments were successfully processed, false
190
 
     * otherwise
191
 
     */
192
 
    protected override bool local_command_line ([CCode (array_null_terminated = true, array_length = false)]
193
 
                                                ref unowned string[] argv,
194
 
                                                out int exit_status)
195
 
    {
196
 
        // Try to register.
197
 
        try
198
 
        {
199
 
            register ();
200
 
        }
201
 
        catch (Error e)
202
 
        {
203
 
            warning ("Unable to register application: %s", e.message);
204
 
            exit_status = 1;
205
 
            return true;
206
 
        }
207
 
 
208
 
        // Workaround until bug 642885 is solved.
209
 
        unowned string[] arguments = argv;
210
 
        var n_args = arguments.length;
211
 
 
212
 
        if (n_args <= 1)
213
 
        {
214
 
            activate ();
215
 
            exit_status = 0;
216
 
        }
217
 
        else
218
 
        {
219
 
            try
220
 
            {
221
 
                var context = new OptionContext (_("- Take photos and videos from your webcam"));
222
 
                context.set_translation_domain (Config.GETTEXT_PACKAGE);
223
 
                context.set_help_enabled (true);
224
 
                context.add_main_entries (options, null);
225
 
                context.parse (ref arguments);
226
 
            }
227
 
            catch (OptionError e)
228
 
            {
229
 
                warning ("%s", e.message);
230
 
                stdout.printf (_("Run '%s --help' to see a full list of available command line options."),
231
 
                               arguments[0]);
232
 
                stdout.printf ("\n");
233
 
                exit_status = 1;
234
 
                return true;
235
 
            }
236
 
 
237
 
            if (version)
238
 
            {
239
 
                stdout.printf ("%s %s\n", Config.PACKAGE_NAME,
240
 
                               Config.PACKAGE_VERSION);
241
 
                exit_status = 1;
242
 
                return true;
243
 
            }
244
 
 
245
 
            if (device != null)
246
 
            {
247
 
                settings.set_string ("camera", device);
248
 
            }
249
 
 
250
 
            if (fullscreen)
251
 
            {
252
 
                activate_action ("fullscreen", null);
253
 
            }
254
 
 
255
 
            if (wide)
256
 
            {
257
 
                activate_action ("wide-mode", null);
258
 
            }
259
 
 
260
 
            activate ();
261
 
            exit_status = 0;
262
 
        }
263
 
 
264
 
        return base.local_command_line (ref arguments, out exit_status);
 
155
    protected override int command_line (ApplicationCommandLine cl)
 
156
    {
 
157
        var opts = cl.get_options_dict ();
 
158
 
 
159
        if (opts.lookup ("device", "^ay", out device, null))
 
160
        {
 
161
            settings.set_string ("camera", device);
 
162
        }
 
163
 
 
164
        if (opts.contains ("fullscreen"))
 
165
        {
 
166
            activate_action ("fullscreen", null);
 
167
        }
 
168
 
 
169
        if (opts.contains ("wide"))
 
170
        {
 
171
            activate_action ("wide-mode", null);
 
172
        }
 
173
 
 
174
        this.activate ();
 
175
 
 
176
        return 0;
 
177
    }
 
178
 
 
179
    protected override int handle_local_options (VariantDict opts)
 
180
    {
 
181
        if (opts.contains ("version"))
 
182
        {
 
183
            stdout.printf ("%s %s\n", Config.PACKAGE_NAME,
 
184
                           Config.PACKAGE_VERSION);
 
185
            return 0;
 
186
        }
 
187
 
 
188
        return -1;
265
189
    }
266
190
 
267
191
    /**
606
530
            "artists", artists,
607
531
            "authors", authors,
608
532
            "comments", _("Take photos and videos with your webcam, with fun graphical effects"),
609
 
            "copyright", "Copyright © 2007 - 2010 daniel g. siegel <dgsiegel@gnome.org>",
 
533
            "copyright", "Copyright © 2011 - 2014 David King <amigadave@amigadave.com>\nCopyright © 2007 - 2011 daniel g. siegel <dgsiegel@gnome.org>",
610
534
            "documenters", documenters,
611
535
            "license-type", Gtk.License.GPL_2_0,
612
536
            "logo-icon-name", Config.PACKAGE_TARNAME,