[cheese/three-point-oh] Made the UI change when the mode changes



commit b110629acff62499b8f5924af481ea73febec205
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date:   Thu Jun 3 04:39:28 2010 +0530

    Made the UI change when the mode changes

 data/cheese-actions.ui     |    6 ++++-
 data/cheese-main-window.ui |    7 +++--
 valasrc/cheese-window.vala |   52 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/data/cheese-actions.ui b/data/cheese-actions.ui
index 31f1766..6267493 100644
--- a/data/cheese-actions.ui
+++ b/data/cheese-actions.ui
@@ -193,6 +193,8 @@
 	    <property name="name">Photo</property>
 	    <property name="label">_Photo</property>
 	    <property name="group">photo_mode</property>
+	    <property name="value">0</property>
+	    <property name="active">True</property>
 	    <signal name="activate" handler="cheese_main_window_on_mode_change" />
 	  </object>
 	</child>
@@ -202,6 +204,7 @@
 	    <property name="name">Video</property>
 	    <property name="label">_Video</property>
 	    <property name="group">photo_mode</property>
+	    <property name="value">1</property>
 	    <signal name="activate" handler="cheese_main_window_on_mode_change" />
 	  </object>
 	</child>
@@ -211,6 +214,7 @@
 	    <property name="name">Burst</property>
 	    <property name="label">Burst</property>
 	    <property name="group">photo_mode</property>
+	    <property name="value">2</property>
 	    <signal name="activate" handler="cheese_main_window_on_mode_change" />
 	  </object>
 	</child>	
@@ -261,7 +265,7 @@
 	  <menuitem action="quit" />
 	</menu>
 	<menu action="edit_action">
-	  <menuitem action="effects" />
+	  <menuitem action="effects_toggle" />
 	  <separator />
 	  <menuitem action="move_to_trash" />
 	  <menuitem action="move_all_to_trash" />
diff --git a/data/cheese-main-window.ui b/data/cheese-main-window.ui
index 5c5a9b2..ed56cc1 100644
--- a/data/cheese-main-window.ui
+++ b/data/cheese-main-window.ui
@@ -73,7 +73,7 @@
 		  </packing>		  
 		</child>
 
-private Gtk.ToggleButton photo_toggle_button;		<child>
+		<child>
 		  <object class="GtkAlignment" id="action_button_alignment">
 		    <property name="xscale">0</property>
 		    <property name="yscale">0</property>
@@ -93,8 +93,9 @@ private Gtk.ToggleButton photo_toggle_button;		<child>
 			    </child>
 			    <child>
 			      <object class="GtkLabel" id="take_action_button_internal_label">
-				<property name="label" translatable="yes">_Take Photo</property>
-				<property name="use_underline">True</property>
+				<property name="label" translatable="yes">&lt;b&gt;_Take a Photo&lt;/b&gt;</property>
+				<property name="use-underline">True</property>
+				<property name="use-markup">True</property>
 			      </object>
 			      <packing>
 				  <property name="padding">15</property>
diff --git a/valasrc/cheese-window.vala b/valasrc/cheese-window.vala
index b4fddb8..f3f3279 100644
--- a/valasrc/cheese-window.vala
+++ b/valasrc/cheese-window.vala
@@ -7,8 +7,16 @@ using Eog;
 
 const int FULLSCREEN_TIMEOUT_INTERVAL = 5 * 1000;
 
+enum MODE {
+	PHOTO = 0,
+	VIDEO = 1,
+	BURST = 2
+}
+
 public class Cheese.MainWindow : Gtk.Window {
 
+	private MODE current_mode;
+	
 	private Gtk.Builder builder;
 	
 	private Widget thumbnails;
@@ -24,9 +32,14 @@ public class Cheese.MainWindow : Gtk.Window {
 	private Gtk.ToggleButton video_toggle_button;
 	private Gtk.ToggleButton burst_toggle_button;
 	private Gtk.Button take_action_button;
+	private Gtk.Label take_action_button_label;
 	private Gtk.ToggleButton effects_toggle_button;
 	private Gtk.Button leave_fullscreen_button;
 	private Gtk.HBox buttons_area;
+
+	private Gtk.Action take_photo_action;
+	private Gtk.Action take_video_action;
+	private Gtk.Action take_burst_action;
 	
 	private bool is_fullscreen;
 	private bool is_wide_mode;
@@ -65,6 +78,36 @@ public class Cheese.MainWindow : Gtk.Window {
 		set_fullscreen_mode(action.active);
 	}
 
+	[CCode (instance_pos = -1)]
+	internal void on_mode_change(RadioAction action) {
+		set_mode((MODE)action.value);
+	}
+
+	private void set_mode(MODE mode) {
+		this.current_mode = mode;
+		switch(this.current_mode) {
+		case MODE.PHOTO:
+			take_photo_action.sensitive = true;	
+			take_video_action.sensitive = false;
+			take_burst_action.sensitive = false;
+			take_action_button.related_action = take_photo_action;
+			break;
+		case MODE.VIDEO:
+			take_photo_action.sensitive = false;	
+			take_video_action.sensitive = true;
+			take_burst_action.sensitive = false;
+			take_action_button.related_action = take_video_action;
+			break;
+		case MODE.BURST:
+			take_photo_action.sensitive = false;	
+			take_video_action.sensitive = false;
+			take_burst_action.sensitive = true;
+			take_action_button.related_action = take_burst_action;
+			break;
+		}
+		take_action_button_label.label = "<b>" +  take_action_button.related_action.label + "</b>";
+	}
+
 	private TimeoutSource timeout;
 	private void clear_fullscreen_timeout() {
 		if (timeout != null) {
@@ -203,10 +246,16 @@ public class Cheese.MainWindow : Gtk.Window {
 		video_toggle_button = (Gtk.ToggleButton) builder.get_object("video_toggle_button");
 		burst_toggle_button = (Gtk.ToggleButton) builder.get_object("burst_toggle_button");
 		take_action_button = (Gtk.Button) builder.get_object("take_action_button");
+		take_action_button_label = (Gtk.Label) builder.get_object("take_action_button_internal_label");
 		effects_toggle_button = (Gtk.ToggleButton) builder.get_object("effects_toggle_button");
 		leave_fullscreen_button = (Gtk.Button) builder.get_object("leave_fullscreen_button");
 		buttons_area = (Gtk.HBox) builder.get_object("buttons_area");
 
+
+		take_photo_action = (Gtk.Action) builder.get_object("take_photo");
+		take_video_action = (Gtk.Action) builder.get_object("take_video");;
+		take_burst_action = (Gtk.Action) builder.get_object("take_burst");;
+	
 		// Array contains all 'buttons', for easier manipulation
 		// IMPORTANT: IF ANOTHER BUTTON IS ADDED UNDER THE VIEWPORT, ADD IT TO THIS ARRAY
 		buttons = {photo_toggle_button,
@@ -228,7 +277,10 @@ public class Cheese.MainWindow : Gtk.Window {
 		thumb_nav = new Eog.ThumbNav(thumb_view, false);
 		
 		viewport.show_all();
+		
 		set_wide_mode(false, true);
+		set_mode(MODE.PHOTO);
+		
 		this.add(main_vbox);
 			
 	}



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