[cheese] Command line options for starting in wide and fullscreen modes, fixes bug #597820
- From: Laura Lucas Alday <lauralucas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Command line options for starting in wide and fullscreen modes, fixes bug #597820
- Date: Thu, 16 Dec 2010 20:03:33 +0000 (UTC)
commit 5cef19bf57a58d8ee20c20e33f625aec03befe71
Author: Laura Lucas Alday <lauralucasalday gmail com>
Date: Thu Dec 16 17:02:53 2010 -0300
Command line options for starting in wide and fullscreen modes, fixes bug #597820
src/cheese-main.vala | 19 ++++++++++++++++---
src/cheese-window.vala | 35 +++++++++++++++++++++++++++++++++--
2 files changed, 49 insertions(+), 5 deletions(-)
---
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 731b850..75f91ba 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -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);
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index ab980a7..ddaf1b6 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]