[cheese/three-point-oh: 9/12] Signals Autoconnection works. Quit action implemented



commit 00bcdc1c5636fac9d8fa54a10ff97e4b18a4a6ee
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date:   Thu May 27 15:27:08 2010 +0530

    Signals Autoconnection works. Quit action implemented

 data/cheese.ui             |   41 +++---
 valasrc/Makefile.am        |    8 +-
 valasrc/cheese-main.vala   |    8 +-
 valasrc/cheese-window.vala |  290 ++------------------------------------------
 4 files changed, 40 insertions(+), 307 deletions(-)
---
diff --git a/data/cheese.ui b/data/cheese.ui
index b9b78aa..af181df 100644
--- a/data/cheese.ui
+++ b/data/cheese.ui
@@ -29,8 +29,9 @@
 	  <object class="GtkAction" id="quit">
 	    <property name="name">Quit</property>
 	    <property name="label">_Quit</property>
-	    <signal name="activate" handler="on_quit" />
+	    <signal name="activate" handler="cheese_main_window_on_quit" />
 	  </object>
+	  <accelerator key="q" modifiers="GDK_CONTROL_MASK" />
 	</child>	
       </object>
     </child>
@@ -42,7 +43,7 @@
 	    <property name="name">HelpContents</property>
 	    <property name="label">Help _Contents</property>
 	    <property name="stock_id">gtk-help</property>
-	    <signal name="activate" handler="on_help_contents" />
+	    <signal name="activate" handler="cheese_cheese_window_on_help_contents" />
 	  </object>
 	  <accelerator key="F1" />	  
 	</child>	
@@ -52,7 +53,7 @@
 	    <property name="name">About</property>
 	    <property name="label">_About</property>
 	    <property name="stock_id">gtk-about</property>
-	    <signal name="activate" handler="on_about" />
+	    <signal name="activate" handler="cheese_cheese_window_on_about" />
 	  </object>
 	</child>	
 	
@@ -65,7 +66,7 @@
 	    <property name="name">Open</property>
 	    <property name="label">_Open</property>
 	    <property name="stock_id">gtk-open</property>
-	    <signal name="activate" handler="on_file_open" />
+	    <signal name="activate" handler="cheese_cheese_window_on_file_open" />
 	  </object>
 	  <accelerator key="O" modifiers="GDK_CONTROL_MASK" />
 	</child>
@@ -75,7 +76,7 @@
 	    <property name="name">SaveAs</property>
 	    <property name="label">Save _As</property>
 	    <property name="stock_id">gtk-save-as</property>
-	    <signal name="activate" handler="on_file_save_as" />
+	    <signal name="activate" handler="cheese_cheese_window_on_file_save_as" />
 	  </object>
 	  <accelerator key="S" modifiers="GDK_CONTROL_MASK" />
 	</child>
@@ -85,7 +86,7 @@
 	    <property name="name">MoveToTrash</property>
 	    <property name="label">Move to _Trash</property>
 	    <property name="icon_name">user-trash</property>
-	    <signal name="activate" handler="on_file_move_to_trash" />
+	    <signal name="activate" handler="cheese_cheese_window_on_file_move_to_trash" />
 	  </object>
 	  <accelerator key="Delete" modifiers="" />
 	</child>
@@ -94,7 +95,7 @@
 	  <object class="GtkAction" id="delete">
 	    <property name="name">Delete</property>
 	    <property name="label">_Delete</property>
-	    <signal name="activate" handler="on_file_delete" />
+	    <signal name="activate" handler="cheese_cheese_window_on_file_delete" />
 	  </object>
 	  <accelerator key="Delete" modifiers="GDK_SHIFT_MASK" />
 	</child>
@@ -103,7 +104,7 @@
 	  <object class="GtkAction" id="move_all_to_trash">
 	    <property name="name">RemoveAll</property>
 	    <property name="label">Move All to Trash</property>
-	    <signal name="activate" handler="on_file_delete" />
+	    <signal name="activate" handler="cheese_cheese_window_on_file_delete" />
 	  </object>
 	</child>	
       </object>      
@@ -116,7 +117,7 @@
 	    <property name="name">Fullscreen</property>
 	    <property name="label">Fullscreen</property>
 	    <property name="stock_id">gtk-fullscreen</property>
-	    <signal name="activate" handler="on_layout_fullscreen" />
+	    <signal name="activate" handler="cheese_cheese_window_on_layout_fullscreen" />
 	  </object>
 	  <accelerator key="F11" modifiers="" />
 	</child>
@@ -125,7 +126,7 @@
 	  <object class="GtkToggleAction" id="wide_mode">
 	    <property name="name">WideMode</property>
 	    <property name="label">_Wide Mode</property>
-	    <signal name="activate" handler="on_layout_wide_mode" />
+	    <signal name="activate" handler="cheese_cheese_window_on_layout_wide_mode" />
 	  </object>
 	</child>	
       </object>
@@ -137,7 +138,7 @@
 	  <object class="GtkToggleAction" id="flash">
 	    <property name="name">Flash</property>
 	    <property name="label">Flash</property>
-	    <signal name="activate" handler="on_flash_toggle" />
+	    <signal name="activate" handler="cheese_cheese_window_on_flash_toggle" />
 	  </object>
 	</child>
 
@@ -145,7 +146,7 @@
 	  <object class="GtkToggleAction" id="countdown">
 	    <property name="name">Countdown</property>
 	    <property name="label">Countdown</property>
-	    <signal name="activate" handler="on_countdown_toggle" />
+	    <signal name="activate" handler="cheese_cheese_window_on_countdown_toggle" />
 	  </object>
 	</child>	
       </object>
@@ -158,7 +159,7 @@
 	  <object class="GtkAction" id="take_photo">
 	    <property name="name">TakePhoto</property>
 	    <property name="label">_Take a Photo</property>
-	    <signal name="activate" handler="on_take_action" />
+	    <signal name="activate" handler="cheese_cheese_window_on_take_action" />
 	  </object>
 	  <accelerator key="space" modifiers="" />
 	</child>
@@ -167,7 +168,7 @@
 	  <object class="GtkAction" id="take_video">
 	    <property name="name">TakeVideo</property>
 	    <property name="label">_Record a Video</property>
-	    <signal name="activate" handler="on_take_action" />
+	    <signal name="activate" handler="cheese_cheese_window_on_take_action" />
 	  </object>
 	  <accelerator key="space" modifiers="" />
 	</child>
@@ -176,7 +177,7 @@
 	  <object class="GtkAction" id="take_burst">
 	    <property name="name">TakeBurst</property>
 	    <property name="label">Take _Multiple Photos</property>
-	    <signal name="activate" handler="on_take_action" />
+	    <signal name="activate" handler="cheese_cheese_window_on_take_action" />
 	  </object>
 	  <accelerator key="space" modifiers="" />
 	</child>
@@ -191,7 +192,7 @@
 	    <property name="name">Photo</property>
 	    <property name="label">_Photo</property>
 	    <property name="group">photo_mode</property>
-	    <signal name="activate" handler="on_mode_change" />
+	    <signal name="activate" handler="cheese_cheese_window_on_mode_change" />
 	  </object>
 	</child>
 
@@ -200,7 +201,7 @@
 	    <property name="name">Video</property>
 	    <property name="label">_Video</property>
 	    <property name="group">photo_mode</property>
-	    <signal name="activate" handler="on_mode_change" />
+	    <signal name="activate" handler="cheese_cheese_window_on_mode_change" />
 	  </object>
 	</child>
 
@@ -209,7 +210,7 @@
 	    <property name="name">Burst</property>
 	    <property name="label">Burst</property>
 	    <property name="group">photo_mode</property>
-	    <signal name="activate" handler="on_mode_change" />
+	    <signal name="activate" handler="cheese_cheese_window_on_mode_change" />
 	  </object>
 	</child>	
       </object>
@@ -221,7 +222,7 @@
 	  <object class="GtkToggleAction" id="effects">
 	    <property name="name">Effects</property>
 	    <property name="label">_Effects</property>
-	    <signal name="activate" handler="on_effects_toggle" />
+	    <signal name="activate" handler="cheese_cheese_window_on_effects_toggle" />
 	  </object>
 	</child>	
       </object>      
@@ -233,7 +234,7 @@
 	  <object class="GtkToggleAction" id="preferences">
 	    <property name="name">Preferences</property>
 	    <property name="label">_Preferences</property>
-	    <signal name="activate" handler="on_preferences_dialog" />
+	    <signal name="activate" handler="cheese_cheese_window_on_preferences_dialog" />
 	  </object>
 	</child>
       </object>
diff --git a/valasrc/Makefile.am b/valasrc/Makefile.am
index bb15347..53e08ae 100644
--- a/valasrc/Makefile.am
+++ b/valasrc/Makefile.am
@@ -2,7 +2,8 @@ VALAFLAGS = \
 	--thread \
 	--vapidir vapi \
 	--pkg config \
-	--pkg gtk+-2.0 
+	--pkg gtk+-2.0 \
+	--pkg gmodule-2.0
 
 AM_CPPFLAGS = \
 	-DBINDIR=\"$(bindir)\"			 	\
@@ -13,7 +14,10 @@ AM_CPPFLAGS = \
 	-DPACKAGE_DATADIR=\""$(datadir)/cheese"\"	\
 	-DPACKAGE_LOCALEDIR=\""$(datadir)/locale"\"	\
 	$(CHEESE_CFLAGS) \
-	-include $(CONFIG_HEADER)
+	-include $(CONFIG_HEADER) 
+
+AM_CFLAGS = \
+	-export-dynamic
 
 bin_PROGRAMS = cheese
 
diff --git a/valasrc/cheese-main.vala b/valasrc/cheese-main.vala
index ca76c7e..495f064 100644
--- a/valasrc/cheese-main.vala
+++ b/valasrc/cheese-main.vala
@@ -48,10 +48,10 @@ public class Cheese.Main {
 		log_file = FileStream.open (Path.build_filename (log_file_dir, "cheese.log"), "w");
 		set_print_handler (print_handler);
 
-		CheeseWindow window = new CheeseWindow();
-		window.setup_ui();
-		window.destroy.connect(Gtk.main_quit);
-		window.show_all();
+		Cheese.MainWindow main_window = new Cheese.MainWindow();
+		main_window.setup_ui();
+		main_window.destroy.connect(Gtk.main_quit);
+		main_window.show_all();
 		
 		Gtk.main ();
 		
diff --git a/valasrc/cheese-window.vala b/valasrc/cheese-window.vala
index 3a8b129..8e0c158 100644
--- a/valasrc/cheese-window.vala
+++ b/valasrc/cheese-window.vala
@@ -1,293 +1,21 @@
 using Gtk;
 
-public class Cheese.CheeseWindow : Window {
+public class Cheese.MainWindow : Window {
 
-	enum Mode {
-		PHOTO,
-		VIDEO,
-		BURST
-	} 
-
-	bool is_recording = false;
-
-	Mode mode;
-
-	/* if you come up with a better name ping me */
-	Widget thewidget;
-	Widget video_area;
-	
-	Widget fullscreen_popup;
-	
-	Widget widget_alignment;
-	Widget notebook_bar;
-	Widget fullscreen_bar;
-	
-	VBox main_vbox;
-	VBox video_vbox;
-	
-	Widget netbook_alignment;
-	Widget toolbar_alignment;
-	Widget effect_button_alignment;
-	Widget info_bar_alignment;
-	Widget togglegroup_alignment;
-	
-	Widget effect_frame;
-	Widget effect_vbox;
-	Widget effect_alignment;
-	Widget effect_chooser;
-	Widget throbber_align;
-	Widget throbber_box;
-	Widget throbber;
-	Widget info_bar;
-	Widget countdown_frame;
-	Widget countdown_frame_fullscreen;
-	Widget countdown;
-	Widget countdown_fullscreen;
-	
-	Button button_effects;
-	Button button_photo;
-	Button button_video;
-	Button button_burst;
-	Button button_effects_fullscreen;
-	Button button_photo_fullscreen;
-	Button button_video_fullscreen;
-	Button button_burst_fullscreen;
-	Button button_exit_fullscreen;
-	
-	Widget image_take_photo;
-	Widget image_take_photo_fullscreen;
-	Label label_effects;
-	Label label_photo;
-	Label label_photo_fullscreen;
-	Label label_take_photo;
-	Label label_take_photo_fullscreen;
-	Label label_video;
-	Label label_video_fullscreen;
-	
-	Widget thumb_scrollwindow;
-	Widget thumb_nav;
-	Widget thumb_view;
-	Widget thumb_view_popup_menu;
-	
-	Button take_picture;
-	Button take_picture_fullscreen;
-	
-	ActionGroup actions_main;
-	ActionGroup actions_prefs;
-	ActionGroup actions_countdown;
-	ActionGroup actions_flash;
-	ActionGroup actions_effects;
-	ActionGroup actions_file;
-	ActionGroup actions_photo;
-	ActionGroup actions_toggle;
-	ActionGroup actions_video;
-	ActionGroup actions_burst;
-	ActionGroup actions_fullscreen;
-	ActionGroup actions_wide_mode;
-	ActionGroup actions_trash;
-	
-  	UIManager ui_manager;
-	private const ActionEntry[] action_entries_main = {
-		{"Cheese",       null,            N_("_Cheese")                       },
-		{"Edit",         null,            N_("_Edit")                         },
-		{"Help",         null,            N_("_Help")                         },
-		
-		{"Quit",         STOCK_QUIT,  null, null, null,  on_quit},
-		{"HelpContents", STOCK_HELP,  N_("_Contents"), "F1", N_("Help on this Application"),
-		 on_help_contents},
-		{"About",        STOCK_ABOUT, null, null, null,  on_about}
-	};
-	
-	const ActionEntry[] action_entries_prefs = {
-		{"Preferences",  STOCK_PREFERENCES, N_("Preferences"), null, null,  (on_preferences_window)}
-	};
-
-	const RadioActionEntry[] action_entries_toggle = {
-		{"Photo", null, N_("_Photo"), null, null, 0},
-		{"Video", null, N_("_Video"), null, null, 1},
-		{"Burst", null, N_("_Burst"), null, null, 2}
-	};
-	
-	const ToggleActionEntry[] action_entries_countdown = {
-		{"Countdown", null, N_("Countdown"), null, null,  (on_toggle_countdown), false}
-	};
-	const ToggleActionEntry[] action_entries_flash = {
-		{"Flash", null, N_("Flash"), null, null,  (on_toggle_flash), false}
-	};
-	
-	const ToggleActionEntry[] action_entries_effects = {
-		{"Effects", null, N_("_Effects"), null, null,  (on_effect_button_press), false}
-	};
-	
-	const ToggleActionEntry[] action_entries_fullscreen = {
-		{"Fullscreen", STOCK_FULLSCREEN, null, "F11", null,  (on_toggle_fullscreen), false}
-	};
-	const ToggleActionEntry[] action_entries_wide_mode = {
-		{"WideMode", null, N_("_Wide mode"), null, null,  (on_toggle_wide_mode), false}
-	};
-	
-	const ActionEntry[] action_entries_photo = {
-		{"TakePhoto", null, N_("_Take a Photo"), "space", null,  (on_action_button_clicked)}
-	};
-	const ToggleActionEntry[] action_entries_video = {
-		{"TakeVideo", null, N_("_Recording"), "space", null,  (on_action_button_clicked), false}
-	};
-	const ActionEntry[] action_entries_burst = {
-		{"TakeBurst", null, N_("_Take multiple Photos"), "space", null,  (on_action_button_clicked)}
-	};
-
-	const ActionEntry[] action_entries_file = {
-		{"Open",        STOCK_OPEN,    N_("_Open"),          "<control>O",    null,
-		 (on_file_open)},
-		{"SaveAs",      STOCK_SAVE_AS, N_("Save _Asâ?¦"),      "<control>S",    null,
-		 (on_file_save_as)},
-		{"MoveToTrash", "user-trash",      N_("Move to _Trash"), "Delete",        null,
-		 (on_file_move_to_trash)},
-		{"Delete",      null,              N_("Delete"),         "<shift>Delete", null,
-		 (on_file_delete)}
-	};
-	
-	const ActionEntry[] action_entries_trash = {
-		{"RemoveAll",    null,             N_("Move All to Trash"), null, null,
-		 (on_file_move_all_to_trash)}
-};
-	
-	
-	
-	ActionGroup add_radio_action_group (string name, RadioActionEntry[] entries) {
-		ActionGroup actions = new ActionGroup(name);
-		actions.set_translation_domain (Config.GETTEXT_PACKAGE);
-		actions.add_radio_actions (entries, 0, on_radio_change);
-		return actions;
-	}
-	
-	ActionGroup add_toggle_action_group (string name, ToggleActionEntry[] entries) {
-	ActionGroup actions = new ActionGroup(name);
-	actions.set_translation_domain (Config.GETTEXT_PACKAGE);
-	actions.add_toggle_actions (entries, this);
-	return actions;
-	}
-	
-	ActionGroup add_action_group(string name, ActionEntry[] entries) {
-		ActionGroup actions = new ActionGroup(name);
-		actions.set_translation_domain (Config.GETTEXT_PACKAGE);
-		actions.add_actions (entries, this);
-		return actions;
-	}
-	
-	void on_radio_change (Action action) {
-	}
-	
-	void on_quit (Action action) {
-	}
-	
-	void on_help_contents (Action action) {
+	[CCode (instance_pos = -1)]
+	internal void on_quit (Action action ) {
+		destroy();
 	}
 	
-	void on_about (Action action) {
-	}
-	
-	void on_preferences_window (Action action) {
-	}
-	
-	void on_toggle_countdown (Action action) {
-	}
-	
-	void on_toggle_flash (Action action) {
-	}
-	
-	void on_effect_button_press (Action action) {
-	}
-	
-	void on_toggle_fullscreen (Action action) {
-	}
-	
-	void on_toggle_wide_mode (Action action) {
-	}
-	
-	void on_action_button_clicked (Action action) {
-	}
-	
-	void on_file_open (Action action) {
-	}
-	
-	void on_file_save_as (Action action) {
-	}
-	
-	void on_file_move_to_trash (Action action) {
-	}
-	
-	void on_file_delete (Action action) {
-	}
-	
-	void on_file_move_all_to_trash (Action action) {
-	}
-	
-	
-	
-	
 	public	void setup_ui () {
 		Builder builder = new Builder();
-		
+		VBox main_vbox;
 		builder.add_from_file (Path.build_filename ("../data/", "cheese.ui"));
+		builder.connect_signals(this);
 		
-		button_effects              = (Button) builder.get_object ("button_effects");
-		button_photo                = (Button) builder.get_object ("button_photo");
-		button_video                = (Button) builder.get_object ("button_video");
-		button_burst                = (Button) builder.get_object ("button_burst");
-		image_take_photo            = (Image) builder.get_object ("image_take_photo");
-		label_effects               = (Label) builder.get_object ("label_effects");
-		label_photo                 = (Label) builder.get_object ("label_photo");
-		label_take_photo            = (Label) builder.get_object ("label_take_photo");
-		label_video                 = (Label) builder.get_object ("label_video");
-		main_vbox                   = (VBox) builder.get_object ("main_vbox");
-		netbook_alignment           = (Alignment) builder.get_object ("netbook_alignment");
-		togglegroup_alignment       = (Alignment) builder.get_object ("togglegroup_alignment");
-		effect_button_alignment     = (Alignment) builder.get_object ("effect_button_alignment");
-		info_bar_alignment          = (Alignment) builder.get_object ("info_bar_alignment");
-		toolbar_alignment           = (Alignment) builder.get_object ("toolbar_alignment");
-		video_vbox                  = (VBox) builder.get_object ("video_vbox");
-		widget_alignment            = (Alignment) builder.get_object ("widget_alignment");
-//			notebook_bar                = builder.get_object ("notebook_bar");
-		take_picture                = (Button) builder.get_object ("take_picture");
-//			thumb_scrollwindow          = builder.get_object ("thumb_scrollwindow");
-//			countdown_frame             = builder.get_object ("countdown_frame");
-//			effect_frame                = builder.get_object ("effect_frame");
-//			effect_vbox                = builder.get_object ("effect_vbox");
-//			effect_alignment            = builder.get_object ("effect_alignment");
-//			fullscreen_popup            = builder.get_object ("fullscreen_popup");
-//			fullscreen_bar              = builder.get_object ("fullscreen_notebook_bar");
-		button_effects_fullscreen   = (Button) builder.get_object ("button_effects_fullscreen");
-		button_photo_fullscreen     = (Button) builder.get_object ("button_photo_fullscreen");
-		button_video_fullscreen     = (Button) builder.get_object ("button_video_fullscreen");
-		button_burst_fullscreen     = (Button) builder.get_object ("button_burst_fullscreen");
-		take_picture_fullscreen     = (Button) builder.get_object ("take_picture_fullscreen");
-		label_take_photo_fullscreen = (Label) builder.get_object ("label_take_photo_fullscreen");
-		image_take_photo_fullscreen = (Image) builder.get_object ("image_take_photo_fullscreen");
-		label_photo_fullscreen      = (Label) builder.get_object ("label_photo_fullscreen");
-		label_video_fullscreen      = (Label) builder.get_object ("label_video_fullscreen");
-//			countdown_frame_fullscreen  = builder.get_object ("countdown_frame_fullscreen");
-		button_exit_fullscreen      = (Button) builder.get_object ("button_exit_fullscreen");
-
-		add(main_vbox);
+		main_vbox = (VBox) builder.get_object ("mainbox_normal");
 		
-		actions_main = add_action_group ("ActionsMain", action_entries_main);
-		actions_prefs = add_action_group ("ActionsPrefs", action_entries_prefs);
-		actions_countdown = add_toggle_action_group ("ActionsCountdown", action_entries_countdown);
-		actions_flash = add_toggle_action_group ("ActionsFlash", action_entries_flash);
-		actions_effects = add_toggle_action_group ("ActionsEffects", action_entries_effects);
-		actions_file = add_action_group ("ActionsFile", action_entries_file);
-		actions_photo = add_action_group ("ActionsPhoto", action_entries_photo);
-		actions_toggle = add_radio_action_group ("ActionsToggle", action_entries_toggle);
-		actions_video = add_toggle_action_group ("ActionsVideo", action_entries_video);
-		actions_burst = add_action_group ("ActionsBurst", action_entries_burst);
-		actions_fullscreen = add_toggle_action_group ("ActionsFullscreen", action_entries_fullscreen);
-		actions_wide_mode = add_toggle_action_group ("ActionsWideMode", action_entries_wide_mode);
-		actions_trash = add_action_group ("ActionsTrash", action_entries_trash);
-
-		ui_manager = new UIManager();
-		ui_manager.add_ui_from_file (Path.build_filename("../data", "cheese-ui.xml"));
-
-	
+		add(main_vbox);
+			
 	}
 }



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