cheese r741 - in branches/cheese-vala: . src
- From: jhaitsma svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r741 - in branches/cheese-vala: . src
- Date: Sun, 1 Jun 2008 22:05:23 +0000 (UTC)
Author: jhaitsma
Date: Sun Jun 1 22:05:22 2008
New Revision: 741
URL: http://svn.gnome.org/viewvc/cheese?rev=741&view=rev
Log:
really add cheese-flash.vala and start with cheese-audio.vala
Added:
branches/cheese-vala/src/cheese-audio.vala
branches/cheese-vala/src/cheese-flash.vala
Modified:
branches/cheese-vala/ (props changed)
branches/cheese-vala/src/Makefile.am
branches/cheese-vala/src/cheese-thumb-view.vala
branches/cheese-vala/src/cheese-webcam.vala
branches/cheese-vala/src/cheese-window.vala
Modified: branches/cheese-vala/src/Makefile.am
==============================================================================
--- branches/cheese-vala/src/Makefile.am (original)
+++ branches/cheese-vala/src/Makefile.am Sun Jun 1 22:05:22 2008
@@ -33,6 +33,7 @@
cheese_VALASOURCES = \
cheese.vala \
+ cheese-audio.vala \
cheese-window.vala \
cheese-thumb-view.vala \
cheese-webcam.vala
Added: branches/cheese-vala/src/cheese-audio.vala
==============================================================================
--- (empty file)
+++ branches/cheese-vala/src/cheese-audio.vala Sun Jun 1 22:05:22 2008
@@ -0,0 +1,91 @@
+/* cheese-audio.vala
+ *
+ * Copyright (C) 2008 Jaap Haitsma <jaap haitsma org>
+ *
+ * Based on gst-audio-play.c
+ * Copyright (C) 2007 Mathias Hasselmann <mathias hasselmann gmx de>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using GLib, Gst;
+
+public class Cheese.Audio : GLib.Object {
+ Pipeline pipeline;
+ Element playbin;
+
+ public string filename {get; construct;}
+
+ public signal void done ();
+
+ construct {
+ pipeline = new Pipeline ("pipeline");
+ playbin = ElementFactory.make ("playbin", "playbin");
+ var bus = pipeline.get_bus ();
+ bus.add_watch (on_bus_message);
+ playbin.set ("uri", Filename.to_uri (filename));
+ }
+
+ public Audio (string filename) {
+ this.filename = filename;
+ }
+
+ public static bool play_file (string filename) {
+ var audio = new Audio (filename);
+ audio.start ();
+ return true;
+ }
+
+ public void start () {
+ pipeline.set_state (State.PLAYING);
+ }
+
+ public void stop () {
+ pipeline.set_state (State.NULL);
+ }
+
+ bool on_bus_message (Bus bus, Gst.Message message) {
+
+ return true;
+ }
+/*
+ GstAudioPlay *self = GST_AUDIO_PLAY (data);
+ GError *error = NULL;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_EOS:
+ g_signal_emit (self, signals[SIGNAL_DONE], 0, NULL);
+
+ gst_audio_play_stop (self);
+ g_object_unref (self);
+
+ break;
+
+ case GST_MESSAGE_ERROR:
+ gst_message_parse_error (message, &error, NULL);
+ g_signal_emit (self, signals[SIGNAL_DONE], 0, error);
+ g_clear_error (&error);
+
+ gst_audio_play_stop (self);
+ g_object_unref (self);
+
+ break;
+
+ default:
+ break;
+ }
+ return TRUE; */
+}
Added: branches/cheese-vala/src/cheese-flash.vala
==============================================================================
--- (empty file)
+++ branches/cheese-vala/src/cheese-flash.vala Sun Jun 1 22:05:22 2008
@@ -0,0 +1,111 @@
+/* cheese-flash.vala
+ *
+ * Copyright  2008 Alexander âweejâ Jones <alex weej com>
+ * Copyright  2008 Thomas Perl <thp perli net>
+ * Copyright  2008 Jaap Haitsma <jaap haitsma org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This is a "flash" object that you can create and invoke a method "flash" on to
+ flood the screen with white temporarily */
+
+using GLib, Gtk, Gdk, Cairo;
+
+public class Cheese.Flash : GLib.Object {
+
+ /* How long to hold the flash for */
+ const uint FLASH_DURATION = 250;
+
+ /* The factor which defines how much the flash fades per frame */
+ const float FLASH_FADE_FACTOR = 0.95;
+
+ /* How many frames per second */
+ const uint FLASH_ANIMATION_RATE = 50;
+
+ /* When to consider the flash finished so we can stop fading */
+ const float FLASH_LOW_THRESHOLD = 0.01;
+
+ Gtk.Window window;
+ uint flash_timeout_tag;
+ uint fade_timeout_tag;
+
+ construct {
+ flash_timeout_tag = 0;
+ fade_timeout_tag = 0;
+
+ window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
+
+ /* make it so it doesn't look like a window on the desktop (+fullscreen) */
+ window.set_decorated (false);
+ window.set_skip_taskbar_hint (true);
+ window.set_skip_pager_hint (true);
+ window.fullscreen ();
+ window.set_keep_above (true);
+
+ /* Don't take focus */
+ window.set_accept_focus (false);
+
+ /* Don't consume input */
+ window.realize ();
+
+ var input_region = new Region ();
+ window.window.input_shape_combine_region (input_region, 0, 0);
+
+ window.expose_event += on_expose_event;
+ }
+
+ public void fire () {
+ if (flash_timeout_tag != 0)
+ Source.remove (flash_timeout_tag);
+ if (fade_timeout_tag != 0)
+ Source.remove (fade_timeout_tag);
+ window.set_opacity (1);
+ window.show_all ();
+ flash_timeout_tag = Timeout.add (FLASH_DURATION, start_fade);
+ }
+
+ bool opacity_fade () {
+ double opacity = window.get_opacity ();
+
+ window.set_opacity (opacity * FLASH_FADE_FACTOR);
+ if (opacity <= FLASH_LOW_THRESHOLD) {
+ /* the flasher has finished when we reach the quit value */
+ window.hide ();
+ return false;
+ }
+ return true;
+ }
+
+ bool start_fade () {
+ /* If the screen is non-composited, just hide and finish up */
+ if (!(window.get_screen().is_composited ()))
+ window.hide ();
+ else
+ fade_timeout_tag = Timeout.add ((uint)(1000.0 / FLASH_ANIMATION_RATE), opacity_fade);
+
+ return false;
+ }
+
+ bool on_expose_event (Widget widget, EventExpose event) {
+ Context ctx = Gdk.cairo_create (widget.window);
+ ctx.set_source_rgb (1, 1, 1);
+ ctx.rectangle (event.area.x, event.area.y, event.area.width, event.area.height);
+ ctx.fill ();
+ return true;
+ }
+
+}
Modified: branches/cheese-vala/src/cheese-thumb-view.vala
==============================================================================
--- branches/cheese-vala/src/cheese-thumb-view.vala (original)
+++ branches/cheese-vala/src/cheese-thumb-view.vala Sun Jun 1 22:05:22 2008
@@ -19,11 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using GLib;
-using Gtk;
-using Gdk;
-using Gee;
-using Gnome;
+using GLib, Gtk, Gdk, Gee, Gnome;
public class Cheese.ThumbView : IconView {
const int THUMB_VIEW_HEIGHT = 120;
Modified: branches/cheese-vala/src/cheese-webcam.vala
==============================================================================
--- branches/cheese-vala/src/cheese-webcam.vala (original)
+++ branches/cheese-vala/src/cheese-webcam.vala Sun Jun 1 22:05:22 2008
@@ -107,6 +107,7 @@
}
public string udi { get; construct; }
+
int cur_device_num = -1;
VideoFormat cur_video_format;
FrameRate cur_frame_rate;
Modified: branches/cheese-vala/src/cheese-window.vala
==============================================================================
--- branches/cheese-vala/src/cheese-window.vala (original)
+++ branches/cheese-vala/src/cheese-window.vala Sun Jun 1 22:05:22 2008
@@ -166,10 +166,18 @@
{"ExportToFlickr", null, N_("Export to _Flickr"), null, null, on_export_to_flickr}
};
-
+ public void setup () {
+ media_path = Path.build_filename (Environment.get_home_dir(), ".local", "share", "cheese", "media");
+ DirUtils.create_with_parents (media_path, 0775);
+ setup_ui ();
+ webcam = new Webcam (screen);
+ webcam.setup ();
+ }
void on_move_all_media_to_trash (Action action) {
+
}
+
void on_quit (Action action) {
main_quit ();
}
@@ -284,16 +292,7 @@
void on_handle_email_link (AboutDialog about, string link) {
}
-
-
- public void setup () {
- media_path = Path.build_filename (Environment.get_home_dir(), ".local", "share", "cheese", "media");
- DirUtils.create_with_parents (media_path, 0775);
- setup_ui ();
- webcam = new Webcam (screen);
- webcam.setup ();
- }
-
+
void setup_ui () {
try {
add_from_file (Path.build_filename (Config.PACKAGE_DATADIR, "/cheese.ui"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]