[cheese] Enable handling of the shoot action



commit dffac37831e5a5d5778ddda619cf4a2e0158da33
Author: David King <amigadave amigadave com>
Date:   Sun Jun 24 15:25:45 2012 +0100

    Enable handling of the shoot action

 data/cheese-main-window.ui |    1 +
 src/cheese-main.vala       |   10 +++++++++
 src/cheese-window.vala     |   49 ++++++++++++++++++--------------------------
 3 files changed, 31 insertions(+), 29 deletions(-)
---
diff --git a/data/cheese-main-window.ui b/data/cheese-main-window.ui
index b0bec1a..400678d 100644
--- a/data/cheese-main-window.ui
+++ b/data/cheese-main-window.ui
@@ -89,6 +89,7 @@
                         <property name="vexpand">False</property>
                         <child>
                           <object class="GtkButton" id="take_action_button">
+                            <property name="action-name">app.shoot</property>
                             <property name="tooltip_text" translatable="yes">Take a photo</property>
                             <child>
                               <object class="GtkGrid" id="take_action_button_internal_hbox">
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 1d80ef8..3c2705d 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -36,6 +36,7 @@ public class Cheese.Main : Gtk.Application
     private PreferencesDialog preferences_dialog;
 
     private const GLib.ActionEntry action_entries[] = {
+        { "shoot", on_shoot },
         { "mode", on_action_radio, "s", "'photo'", on_mode_change },
         { "fullscreen", on_action_toggle, null, "false", on_fullscreen_change },
         { "effects", on_action_toggle, null, "false", on_effects_change },
@@ -243,6 +244,15 @@ public class Cheese.Main : Gtk.Application
     }
 
     /**
+     * Handle the shoot action being activated.
+     */
+    private void on_shoot ()
+    {
+        // Shoot.
+        main_window.shoot ();
+    }
+
+    /**
      * Handle the fullscreen state being changed.
      *
      * @param action the action that emitted the signal
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 9f1a9eb..e1c1faf 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -40,11 +40,6 @@ const string SENDTO_EXEC = "nautilus-sendto";
 
 public class Cheese.MainWindow : Gtk.ApplicationWindow
 {
-    // Actions for the app menu.
-    private const GLib.ActionEntry entries[] = {
-        { "shoot", on_take_action }
-    };
-
     private MediaMode current_mode;
 
   private Gtk.Builder    gtk_builder;
@@ -1004,30 +999,28 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
     }
   }
 
-  /**
-   * Take a photo or burst of photos, or record a video, based on the current
-   * capture mode.
-   *
-   * @param action the action that emitted the signal
-   */
-  [CCode (instance_pos = -1)]
-  public void on_take_action (SimpleAction action, Variant? parameter)
-  {
-    if (current_mode == MediaMode.PHOTO)
-    {
-      this.take_photo ();
-    }
-    else
-    if (current_mode == MediaMode.VIDEO)
-    {
-      toggle_video_recording (!is_recording);
-    }
-    else
-    if (current_mode == MediaMode.BURST)
+    /**
+     * Take a photo or burst of photos, or record a video, based on the current
+     * capture mode.
+     */
+    [CCode (instance_pos = -1)]
+    public void shoot ()
     {
-      toggle_photo_bursting (!is_bursting);
+        switch (current_mode)
+        {
+            case MediaMode.PHOTO:
+                take_photo ();
+                break;
+            case MediaMode.VIDEO:
+                toggle_video_recording (!is_recording);
+                break;
+            case MediaMode.BURST:
+                toggle_photo_bursting (!is_bursting);
+                break;
+            default:
+                assert_not_reached ();
+        }
     }
-  }
 
     /**
      * Toggle the display of the effect selector.
@@ -1380,8 +1373,6 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
       error ("Error: %s", err.message);
     }
 
-    add_action_entries (entries, this);
-
     main_vbox                         = gtk_builder.get_object ("mainbox_normal") as Gtk.Grid;
     thumbnails                        = gtk_builder.get_object ("thumbnails") as Gtk.Widget;
     viewport_widget                   = gtk_builder.get_object ("viewport") as GtkClutter.Embed;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]