Commit 5cef19bf authored by Laura Lucas Alday's avatar Laura Lucas Alday

Command line options for starting in wide and fullscreen modes, fixes bug #597820

parent 50ba1d1e
......@@ -30,13 +30,15 @@ public class Cheese.Main
static bool wide;
static string device;
static bool version;
static bool fullscreen;
static Cheese.MainWindow main_window;
const OptionEntry[] options = {
{"wide", 'w', 0, OptionArg.NONE, ref wide, N_("Enable wide mode"), null },
{"device", 'd', 0, OptionArg.FILENAME, ref device, N_("Device to use as a camera"), N_("DEVICE")},
{"version", 'v', 0, OptionArg.NONE, ref version, N_("Output version information and exit"), null },
{"wide", 'w', 0, OptionArg.NONE, ref wide, N_("Start in wide mode"), null },
{"device", 'd', 0, OptionArg.FILENAME, ref device, N_("Device to use as a camera"), N_("DEVICE")},
{"version", 'v', 0, OptionArg.NONE, ref version, N_("Output version information and exit"), null },
{"fullscreen", 'f', 0, OptionArg.NONE, ref fullscreen, N_("Start in fullscreen mode"), null },
{null}
};
......@@ -105,6 +107,17 @@ public class Cheese.Main
Gtk.IconTheme.get_default ().append_search_path (GLib.Path.build_filename (Config.PACKAGE_DATADIR, "icons"));
main_window.setup_ui ();
if (wide)
{
main_window.set_startup_wide_mode ();
}
if (fullscreen)
{
main_window.set_startup_fullscreen_mode ();
}
main_window.destroy.connect (Gtk.main_quit);
main_window.show ();
main_window.setup_camera (device);
......
......@@ -93,6 +93,7 @@ public class Cheese.MainWindow : Gtk.Window
private bool is_effects_selector_active;
private bool is_camera_actions_sensitive;
private bool action_cancelled;
private bool is_command_line_startup;
private Gtk.Button[] buttons;
......@@ -375,12 +376,24 @@ public class Cheese.MainWindow : Gtk.Window
[CCode (instance_pos = -1)]
public void on_layout_wide_mode (ToggleAction action)
{
if(!is_command_line_startup)
{
/* Don't save to settings when using -w mode from command-line, so
* command-line options change the mode for one run only. */
settings.set_boolean ("wide-mode", action.active);
}
set_wide_mode (action.active);
}
[CCode (instance_pos = -1)]
public void on_layout_fullscreen (ToggleAction action)
{
if(!is_command_line_startup)
{
/* Don't save to settings when using -f mode from command-line, so
* command-line options change the mode for one run only. */
settings.set_boolean ("fullscreen", action.active);
}
set_fullscreen_mode (action.active);
}
......@@ -488,7 +501,6 @@ public class Cheese.MainWindow : Gtk.Window
* So that the next time leave_fullscreen_button_container.show_all() is called, the button is actually shown
* FIXME: If this code can be made cleaner/clearer, please do */
settings.set_boolean ("fullscreen", fullscreen_mode);
is_fullscreen = fullscreen_mode;
if (fullscreen_mode)
{
......@@ -544,7 +556,6 @@ public class Cheese.MainWindow : Gtk.Window
private void set_wide_mode (bool wide_mode)
{
is_wide_mode = wide_mode;
settings.set_boolean ("wide-mode", wide_mode);
/* keep the viewport to its current size while rearranging the ui,
* so that thumbview moves from right to bottom and viceversa
......@@ -1015,6 +1026,26 @@ public class Cheese.MainWindow : Gtk.Window
}
}
public void set_startup_wide_mode ()
{
if (is_wide_mode)
{
/* Cheese was already in wide mode, avoid setting it again. */
return;
}
is_command_line_startup = true;
wide_mode_action.set_active (true);
is_command_line_startup = false;
}
public void set_startup_fullscreen_mode ()
{
is_command_line_startup = true;
fullscreen_action.set_active (true);
is_command_line_startup = false;
}
public void setup_ui ()
{
gtk_builder = new Gtk.Builder ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment