cheese r753 - in branches/cheese-vala: . src



Author: jhaitsma
Date: Thu Jun  5 20:56:56 2008
New Revision: 753
URL: http://svn.gnome.org/viewvc/cheese?rev=753&view=rev

Log:
Make webcam work

Modified:
   branches/cheese-vala/   (props changed)
   branches/cheese-vala/src/cheese-webcam.vala
   branches/cheese-vala/src/cheese-window.vala

Modified: branches/cheese-vala/src/cheese-webcam.vala
==============================================================================
--- branches/cheese-vala/src/cheese-webcam.vala	(original)
+++ branches/cheese-vala/src/cheese-webcam.vala	Thu Jun  5 20:56:56 2008
@@ -95,17 +95,7 @@
 		{Effect.WARP, "warptv", ColorSpace.RGB}
 	};
 	
-	Widget _video_window;
-	public Widget video_window {
-		get { //FIXME can be removed??
-			return _video_window;
-		}
-		set construct {
-			_video_window = video_window;
-			video_window.expose_event += on_expose;
-		}
-	}
-
+	public Widget video_window {get; construct; } 
 	public string udi { get; construct; }
 
 	int cur_device_num = -1;
@@ -143,7 +133,7 @@
 	public Webcam (Widget window) {
 		this.video_window = window;
 	}
-
+	
 	public void setup () {
 		detect_webcam_devices ();
 		print_devices ();
@@ -158,16 +148,23 @@
 		ok = video_display_bin.link (photo_save_bin);
 
 		var bus = pipeline.get_bus ();
-		bus.add_signal_watch ();
-		
+		bus.add_signal_watch ();		
 		bus.message += on_bus_message;
+		
+		video_window.expose_event += on_expose;
+
 		if (!ok)
 			error ("Unable link pipeline for photo");
 	}
 		
 	void print_devices () {
 		int i = 0;
-		print ("Following devices have been detected\n");
+		
+		if (devices.size == 0)
+			print ("No webcam/video devices have been the detected\n");
+		else
+			print ("Following devices have been detected\n");
+		
 		foreach (Device d in devices) {
 			print ("Device %d\n", i);
 			i++;
@@ -189,6 +186,7 @@
 	
 	public void play () {
 		pipeline.set_state (State.PLAYING);
+
 		set_x_overlay ();
 		pipeline_is_playing = true;		
 	}
@@ -245,7 +243,7 @@
 	}
 	
 	void set_x_overlay () {
-		XOverlay overlay = (XOverlay)pipeline.get_by_interface (typeof(XOverlay));
+		XOverlay overlay = (XOverlay)pipeline.get_by_interface (typeof(XOverlay));		
 		overlay.set_xwindow_id (x11_drawable_get_xid (video_window.window));
 	}
 

Modified: branches/cheese-vala/src/cheese-window.vala
==============================================================================
--- branches/cheese-vala/src/cheese-window.vala	(original)
+++ branches/cheese-vala/src/cheese-window.vala	Thu Jun  5 20:56:56 2008
@@ -27,7 +27,7 @@
 	const string[] authors = {
 		"daniel g. siegel <dgsiegel gmail com>",
 		"Jaap A. Haitsma <jaap haitsma org>",
-		null
+		null		
 	};
 
 	const string translators = N_("translator-credits");
@@ -84,7 +84,7 @@
 	Label label_video;
 
 
-	DrawingArea screen;
+	Widget screen;
 	Button take_picture;
 /*
 #ifdef HILDON
@@ -121,8 +121,6 @@
   		{"About", STOCK_ABOUT, null, null, null, on_about}
 	};
 
-
-
 	const ToggleActionEntry[] action_entries_countdown = {
   		{"Countdown", null, N_("Countdown"), null, null, on_set_countdown, false}
 	};
@@ -172,12 +170,10 @@
 		setup_ui ();
 
 		webcam = new Webcam (screen);
-
 		try {
 			Thread.create (setup_webcam, false);
 		} catch (ThreadError e) {
 			error ("Creating thread: " + e.message);
-    			return;
 		}
 	}
 	
@@ -214,6 +210,7 @@
 	}
 	
 	void on_quit (Action action) {
+		webcam.stop ();
 		main_quit ();
 	}
 
@@ -346,7 +343,7 @@
 			video_vbox = (VBox) get_object ("video_vbox");
 			notebook = (Notebook) get_object ("notebook");
 			notebook_bar = (Widget) get_object ("notebook_bar");
-			screen = (DrawingArea) get_object ("video_screen");
+			screen = (Widget) get_object ("video_screen");
 			take_picture = (Button) get_object ("take_picture");
 			thumb_container = (Container) get_object ("thumb_scrollwindow");
 			throbber_frame = (Widget) get_object ("throbber_frame");
@@ -471,8 +468,8 @@
 			actions_file.set_sensitive (false);
 
 
-			window.destroy += Gtk.main_quit;
-
+			window.destroy += t => {webcam.stop (); main_quit (); };
+			
 			take_picture.clicked += on_action_button;
 			button_effects.clicked += on_effects_button;
 



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