[cheese] Enable handling of the fullscreen action
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Enable handling of the fullscreen action
- Date: Mon, 25 Jun 2012 21:41:48 +0000 (UTC)
commit 31f1756987999bfbb5015373fb0c0980f6245732
Author: David King <amigadave amigadave com>
Date: Sun Jun 24 15:13:17 2012 +0100
Enable handling of the fullscreen action
data/cheese-actions.ui | 8 --------
data/cheese-main-window.ui | 2 +-
src/cheese-main.vala | 34 ++++++++++++++++++++++++++++++++++
src/cheese-window.vala | 18 +++++-------------
4 files changed, 40 insertions(+), 22 deletions(-)
---
diff --git a/data/cheese-actions.ui b/data/cheese-actions.ui
index 2727afa..8f10992 100644
--- a/data/cheese-actions.ui
+++ b/data/cheese-actions.ui
@@ -58,14 +58,6 @@
<child>
<object class="GtkActionGroup" id="layout_actions">
<child>
- <object class="GtkToggleAction" id="fullscreen">
- <property name="name">Fullscreen</property>
- <property name="stock-id">gtk-fullscreen</property>
- <signal name="toggled" handler="cheese_main_window_on_layout_fullscreen"/>
- </object>
- <accelerator key="F11" modifiers=""/>
- </child>
- <child>
<object class="GtkToggleAction" id="wide_mode">
<property name="name">WideMode</property>
<property name="label" translatable="yes">_Wide Mode</property>
diff --git a/data/cheese-main-window.ui b/data/cheese-main-window.ui
index ba69160..9141265 100644
--- a/data/cheese-main-window.ui
+++ b/data/cheese-main-window.ui
@@ -183,7 +183,7 @@
<child>
<object class="GtkButton" id="leave_fullscreen_button">
<property name="use-action-appearance">False</property>
- <property name="related-action">fullscreen</property>
+ <property name="action-name">app.fullscreen</property>
<property name="tooltip_text" translatable="yes">Leave fullscreen</property>
<child>
<object class="GtkGrid" id="fullscreen_button_internal_hbox">
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 865a2be..0d1aca0 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -37,6 +37,7 @@ public class Cheese.Main : Gtk.Application
private const GLib.ActionEntry action_entries[] = {
{ "mode", on_action_radio, "s", "'photo'", on_mode_change },
+ { "fullscreen", on_action_toggle, null, "false", on_fullscreen_change },
{ "preferences", on_preferences },
{ "help", on_help },
{ "about", on_about },
@@ -107,6 +108,8 @@ public class Cheese.Main : Gtk.Application
section.append (_("_Quit"), "app.quit");
set_app_menu (menu);
+ // FIXME: Read fullscreen state from GSettings.
+
main_window.setup_ui ();
main_window.start_thumbview_monitors ();
@@ -225,6 +228,37 @@ public class Cheese.Main : Gtk.Application
}
/**
+ * Handle toggle actions by toggling the current state.
+ *
+ * @param action the action which was triggered
+ * @param parameter unused
+ */
+ private void on_action_toggle (SimpleAction action, Variant? parameter)
+ {
+ var state = action.get_state ();
+
+ // Toggle current state.
+ action.change_state (new Variant.boolean (!state.get_boolean ()));
+ }
+
+ /**
+ * Handle the fullscreen state being changed.
+ *
+ * @param action the action that emitted the signal
+ * @param value the state to switch to
+ */
+ private void on_fullscreen_change (SimpleAction action, Variant? value)
+ {
+ return_if_fail (value != null);
+
+ var state = value.get_boolean ();
+
+ main_window.set_fullscreen (state);
+
+ action.set_state (value);
+ }
+
+ /**
* Change the media capture mode (photo, video or burst).
*
* @param action the action that emitted the signal
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index affbc76..a2831b4 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -43,7 +43,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
// Actions for the app menu.
private const GLib.ActionEntry entries[] = {
{ "shoot", on_take_action },
- { "fullscreen", null, null, "false", on_layout_fullscreen },
{ "effects", null, null, "false", on_effects_toggle }
};
@@ -88,7 +87,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
private Gtk.ToggleAction effects_toggle_action;
private Gtk.ToggleAction wide_mode_action;
- private Gtk.ToggleAction fullscreen_action;
private Gtk.Action countdown_action;
private Gtk.Action effects_page_prev_action;
private Gtk.Action effects_page_next_action;
@@ -521,19 +519,19 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
/**
* Toggle fullscreen mode and save the preference to GSettings.
*
- * @param action the action that emitted the signal
+ * @param fullscreen whether the window should be fullscreean
*/
[CCode (instance_pos = -1)]
- public void on_layout_fullscreen (SimpleAction action, Variant value)
+ public void set_fullscreen (bool fullscreen)
{
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.enabled);
+ settings.set_boolean ("fullscreen", fullscreen);
}
- set_fullscreen_mode (action.state.get_boolean ());
+ set_fullscreen_mode (fullscreen);
}
/**
@@ -673,7 +671,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
{
thumbnails_bottom.hide ();
}
- this.set_show_menubar (false);
leave_fullscreen_button_container.no_show_all = false;
leave_fullscreen_button_container.show_all ();
@@ -697,7 +694,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
{
thumbnails_bottom.show_all ();
}
- this.set_show_menubar (true);
leave_fullscreen_button_container.hide ();
/* Make all buttons look, uhm, Normal */
@@ -1360,7 +1356,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
public void set_startup_fullscreen_mode ()
{
is_command_line_startup = true;
- fullscreen_action.set_active (true);
+ set_fullscreen (true);
is_command_line_startup = false;
}
@@ -1409,7 +1405,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
effects_toggle_action = gtk_builder.get_object ("effects_toggle") as Gtk.ToggleAction;
countdown_action = gtk_builder.get_object ("countdown") as Gtk.Action;
wide_mode_action = gtk_builder.get_object ("wide_mode") as Gtk.ToggleAction;
- fullscreen_action = gtk_builder.get_object ("fullscreen") as Gtk.ToggleAction;
effects_page_next_action = gtk_builder.get_object ("effects_page_next") as Gtk.Action;
effects_page_prev_action = gtk_builder.get_object ("effects_page_prev") as Gtk.Action;
share_action = gtk_builder.get_object ("share") as Gtk.Action;
@@ -1486,9 +1481,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
toggle_camera_actions_sensitivities (false);
this.key_release_event.connect (on_key_release);
-
- if (settings.get_boolean ("fullscreen"))
- fullscreen_action.active = true;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]