cheese r621 - in branches/cheese-vala: . data po src



Author: jhaitsma
Date: Tue Apr  1 22:33:52 2008
New Revision: 621
URL: http://svn.gnome.org/viewvc/cheese?rev=621&view=rev

Log:
first vala stuff

Added:
   branches/cheese-vala/.bzrignore
   branches/cheese-vala/src/cheese-window.vala
   branches/cheese-vala/src/cheese.vala
Removed:
   branches/cheese-vala/data/wscript_build
   branches/cheese-vala/po/.cvsignore
   branches/cheese-vala/po/wscript_build
   branches/cheese-vala/src/cheese-countdown.c
   branches/cheese-vala/src/cheese-countdown.h
   branches/cheese-vala/src/cheese-effect-chooser.c
   branches/cheese-vala/src/cheese-effect-chooser.h
   branches/cheese-vala/src/cheese-fileutil.c
   branches/cheese-vala/src/cheese-fileutil.h
   branches/cheese-vala/src/cheese-gconf.c
   branches/cheese-vala/src/cheese-gconf.h
   branches/cheese-vala/src/cheese-thumb-view.c
   branches/cheese-vala/src/cheese-thumb-view.h
   branches/cheese-vala/src/cheese-webcam.c
   branches/cheese-vala/src/cheese-webcam.h
   branches/cheese-vala/src/cheese-window.c
   branches/cheese-vala/src/cheese-window.h
   branches/cheese-vala/src/cheese.c
   branches/cheese-vala/src/eog-thumbnail.c
   branches/cheese-vala/src/eog-thumbnail.h
   branches/cheese-vala/src/ephy-spinner.c
   branches/cheese-vala/src/ephy-spinner.h
   branches/cheese-vala/src/gst-audio-play.c
   branches/cheese-vala/src/gst-audio-play.h
   branches/cheese-vala/src/wscript_build
   branches/cheese-vala/waf
   branches/cheese-vala/wscript
Modified:
   branches/cheese-vala/   (props changed)
   branches/cheese-vala/autogen.sh
   branches/cheese-vala/configure.ac
   branches/cheese-vala/src/Makefile.am

Added: branches/cheese-vala/.bzrignore
==============================================================================
--- (empty file)
+++ branches/cheese-vala/.bzrignore	Tue Apr  1 22:33:52 2008
@@ -0,0 +1,43 @@
+*.gmo
+*.o
+*.c
+*.h
+*.omf
+*.mo
+Makefile
+Makefile.in
+aclocal.m4
+intltool*
+stamp-h1
+*.stamp
+autom4te.cache
+config.*
+configure
+depcomp
+gnome-doc-utils.make
+install-sh
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+omf.make
+xmldocs.make
+*.desktop
+stamp-it
+src/cheese
+src/.libs
+src/.deps
+po/stamp-it
+po/POTFILES
+cheese-config.h.in
+data/cheese.desktop.in
+data/cheese.schemas
+help/el/cheese.xml
+help/es/cheese.xml
+help/fr/cheese.xml
+help/oc/cheese.xml
+help/ru/cheese.xml
+help/sv/cheese.xml
+po/.intltool-merge-cache
+po/Makefile.in.in
+

Modified: branches/cheese-vala/autogen.sh
==============================================================================
--- branches/cheese-vala/autogen.sh	(original)
+++ branches/cheese-vala/autogen.sh	Tue Apr  1 22:33:52 2008
@@ -6,7 +6,7 @@
 
 PKG_NAME="cheese"
 
-(test -f $srcdir/src/cheese.c) || {
+(test -f $srcdir/src/cheese.vala) || {
     echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
     echo " top-level $PKG_NAME directory"
     exit 1

Modified: branches/cheese-vala/configure.ac
==============================================================================
--- branches/cheese-vala/configure.ac	(original)
+++ branches/cheese-vala/configure.ac	Tue Apr  1 22:33:52 2008
@@ -3,9 +3,13 @@
 AC_INIT(cheese, 2.22.1)
 
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
-AM_CONFIG_HEADER(cheese-config.h)
+AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
+AC_PATH_PROG(VALAC, valac, valac)
+AC_SUBST(VALAC)
+
+
 dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
 AC_SUBST(ACLOCAL_AMFLAGS, "\${ACLOCAL_FLAGS}")
 

Modified: branches/cheese-vala/src/Makefile.am
==============================================================================
--- branches/cheese-vala/src/Makefile.am	(original)
+++ branches/cheese-vala/src/Makefile.am	Tue Apr  1 22:33:52 2008
@@ -1,4 +1,14 @@
-INCLUDES = 						\
+VALA_CFLAGS = \
+	-g \
+	--thread \
+	--vapidir ../vapi \
+	--pkg config \
+	--pkg gdk-2.0 \
+	--pkg gtk+-2.0 \
+	--pkg gstreamer-0.10 \
+	--pkg gconf-2.0
+	
+AM_CPPFLAGS = \
 	-DBINDIR=\"$(bindir)\"			 	\
 	-DDATADIR=\"$(datadir)\"			\
 	-DPREFIX=\""$(prefix)"\" 			\
@@ -6,38 +16,26 @@
 	-DLIBDIR=\""$(libdir)"\" 			\
 	-DPACKAGE_DATADIR=\""$(datadir)/cheese"\"	\
 	-DPACKAGE_LOCALEDIR=\""$(datadir)/locale"\"	\
-	$(CHEESE_CFLAGS)
+	$(CHEESE_CFLAGS) \
+	-include $(CONFIG_HEADER)
+
+BUILT_SOURCES = cheese.vala.stamp
 
 bin_PROGRAMS = cheese
 
+cheese_VALASOURCES = \
+	cheese.vala \
+	cheese-window.vala
+
 cheese_SOURCES = \
-	cheese.c \
-	cheese-countdown.c \
-	cheese-countdown.h \
-	cheese-effect-chooser.c \
-	cheese-effect-chooser.h \
-	cheese-fileutil.c \
-	cheese-fileutil.h \
-	cheese-gconf.c \
-	cheese-gconf.h \
-	cheese-thumb-view.c \
-	cheese-thumb-view.h \
-	cheese-webcam.c \
-	cheese-webcam.h \
-	cheese-window.c \
-	cheese-window.h \
-	eog-thumbnail.c \
-	eog-thumbnail.h \
-	ephy-spinner.c \
-	ephy-spinner.h \
-	gst-audio-play.c \
-	gst-audio-play.h 
+	$(cheese_VALASOURCES:.vala=.c) \
+	$(cheese_VALASOURCES:.vala=.h) 
+
+cheese.vala.stamp: $(cheese_VALASOURCES)
+	$(VALAC) $(VALA_CFLAGS) $^
+	touch $@
 
 cheese_LDADD = \
 	$(CHEESE_LIBS)
 
-if WITH_HILDON
-  INCLUDES += $(HILDON_CFLAGS) -DHILDON
-  cheese_LDADD += $(HILDON_LIBS)
-endif
 

Added: branches/cheese-vala/src/cheese-window.vala
==============================================================================
--- (empty file)
+++ branches/cheese-vala/src/cheese-window.vala	Tue Apr  1 22:33:52 2008
@@ -0,0 +1,438 @@
+/* cheese-window.vala
+ *
+ * Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
+ * Copyright (C) 2007,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/>.
+ */
+
+using GLib;
+using Gtk;
+
+public class Cheese.CheeseWindow : Builder {
+
+
+
+	const string[] authors = {
+		"daniel g. siegel <dgsiegel gmail com>",
+		"Jaap A. Haitsma <jaap haitsma org>",
+		null
+	};
+
+	const string translators = N_("translator-credits");
+
+	const string[] license = {
+		N_("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.\n"),
+		N_("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.\n"),
+		N_("You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.")
+	};
+
+	bool recording = false;
+
+  	string video_filename;
+  	string photo_filename;
+
+	int counter = 0;
+
+	//CheeseWebcam webcam;
+	//WebcamMode webcam_mode;
+
+	const string GCONF_COUNTDOWN_KEY = "/apps/cheese/countdown";
+	const string GCONF_WEBCAM_KEY = "/apps/cheese/webcam";
+	const string GCONF_SELECTED_EFFECTS_KEY = "/apps/cheese/selected_effects";
+
+	weak GConf.Client gconf_client = GConf.Client.get_default ();
+
+	Window window;
+	Widget notebook;
+	Widget notebook_bar;
+
+	VBox main_vbox;
+	VBox video_vbox;
+
+	Widget effect_frame;
+	Widget effect_chooser;
+	Widget throbber_frame;
+	Widget throbber;
+	Widget countdown_frame;
+	Widget countdown;
+
+	Button button_effects;
+	ToggleButton button_photo;
+	ToggleButton button_video;
+
+	Widget image_take_photo;
+	Label label_effects;
+	Label label_photo;
+	Label label_take_photo;
+	Label label_video;
+
+	Widget thumb_scrollwindow;
+	Widget thumb_view;
+	Widget thumb_view_popup_menu;
+
+	Widget screen;
+	Button take_picture;
+/*
+#ifdef HILDON
+	Widget main_hbox;
+	Widget subwindow;
+#endif      
+*/
+	ActionGroup actions_account_photo;
+	ActionGroup actions_countdown;
+	ActionGroup actions_effects;
+	ActionGroup actions_file;
+	ActionGroup actions_flickr;
+	ActionGroup actions_fspot;
+	ActionGroup actions_mail;
+	ActionGroup actions_main;
+	ActionGroup actions_photo;
+	ActionGroup actions_toggle;
+	ActionGroup actions_video;
+
+  	UIManager ui_manager;
+
+  	int audio_play_counter = 0;
+  	Rand rand = new Rand();
+
+
+	const ActionEntry[] action_entries_main = {
+  		{"Cheese", null, N_("_Cheese")},
+		{"Edit", null, N_("_Edit")},
+  		{"RemoveAll", null, N_("Move all to Trash"), null, null, (GLib.Callback)on_move_all_media_to_trash},
+
+		{"Help", null, N_("_Help")},
+
+  		{"Quit", STOCK_QUIT, null, null, null, (GLib.Callback)on_quit},
+  		{"HelpContents", STOCK_HELP, N_("_Contents"), "F1", N_("Help on this application"), (GLib.Callback)on_help},
+  		{"About", STOCK_ABOUT, null, null, null, (GLib.Callback)on_about}
+	};
+
+
+
+	const ToggleActionEntry[] action_entries_countdown = {
+  		{"Countdown", null, N_("Countdown"), null, null, (GLib.Callback)on_set_countdown, false}
+	};
+
+	const ToggleActionEntry[] action_entries_effects = {
+		{"Effects", null, N_("_Effects"), null, null, (GLib.Callback)on_effect_button, false}
+	};
+
+	const RadioActionEntry[] action_entries_toggle = {
+  		{"Photo", null, N_("_Photo"), null, null, 0},
+		{"Video", null, N_("_Video"), null, null, 1}
+	};
+
+	const ActionEntry[] action_entries_file = {
+		{"Open", STOCK_OPEN, N_("_Open"), "<control>O", null, (GLib.Callback)on_file_open},
+		{"SaveAs", STOCK_SAVE_AS, N_("Save _As..."), "<control>S", null, (GLib.Callback)on_file_save_as},
+  		{"MoveToTrash", "user-trash", N_("Move to _Trash"), "Delete", null, (GLib.Callback)on_move_to_trash}
+	};
+
+	const ActionEntry[] action_entries_photo = {
+		{"TakePhoto", null, N_("_Take a photo"), "space", null, (GLib.Callback)on_action_button}
+	};
+
+	const ToggleActionEntry[] action_entries_video = {
+		{"TakeVideo", null, N_("_Recording"), "space", null, (GLib.Callback)on_action_button, false}
+	};
+
+	const ActionEntry[] action_entries_account_photo = {
+  		{"SetAsAccountPhoto", null, N_("_Set As Account Photo"), null, null, (GLib.Callback)on_account_photo}
+	};
+
+	const ActionEntry[] action_entries_mail = {
+  		{"SendByMail", null, N_("Send by _Mail"), null, null, (GLib.Callback)on_send_by_mail}
+	};
+
+	const ActionEntry[] action_entries_fspot = {
+  		{"ExportToFSpot", null, N_("Export to F-_Spot"), null, null, (GLib.Callback)on_export_to_fspot}
+	};
+
+	const ActionEntry[] action_entries_flickr = {
+  		{"ExportToFlickr", null, N_("Export to _Flickr"), null, null, (GLib.Callback)on_export_to_flickr}
+	};
+
+
+
+	void on_move_all_media_to_trash (Action action) {
+	}
+	void on_quit (Action action) {
+		main_quit ();
+	}
+
+	void on_about (Action action) {
+
+  		string license_trans = license[0] + "\n" + license[1] + "\n" + license[2];
+
+  		show_about_dialog (window,
+                         	   "version", Config.VERSION,
+                         	   "copyright", "Copyright  2007, 2008\n daniel g. siegel <dgsiegel gmail com>",
+                                   "comments", _("A cheesy program to take photos and videos from your webcam"),
+                                   "authors", authors,
+                         	   "translator-credits", translators,
+                                   "website", "http://www.gnome.org/projects/cheese";,
+                                   "website-label", _("Cheese Website"),
+                                   "logo-icon-name", "cheese",
+                                   "wrap-license", true,
+                                   "license", license_trans,
+                         	   null);
+	}
+
+	void on_help (Action action) {
+	}
+
+	void on_set_countdown (ToggleAction action) {
+	}
+
+	void on_effect_button (ToggleAction action) {
+	}
+
+	void on_file_open (Action action) {
+	}
+
+	void on_file_save_as (Action action) {
+	}
+
+	void on_move_to_trash (Action action) {
+	}
+
+	void on_action_button (Action action) {
+	}
+
+	void on_account_photo (Action action) {
+	}
+
+	void on_send_by_mail (Action action) {
+	}
+
+	void on_export_to_fspot (Action action) {
+	}
+
+	void on_export_to_flickr (Action action) {
+	}
+
+	void on_radio_button (Action action, RadioAction current_action) {
+
+	}
+	bool ignore_callback = false;
+	void on_photo_video_toggle (ToggleButton button) {
+
+ 		/* When we call ToggleButton.set_active a "toggle" message is 
+		   generated we ignore that one */
+		if (ignore_callback) {
+			ignore_callback = false;
+			return;
+		}
+  		/* Set ignore_callback because we are call ToggleButton.set_active in 
+		   the next few lines */
+		ignore_callback = true;
+
+		if (button == button_photo) {
+			if (!button_photo.get_active ()) {
+				button_photo.set_active (true);
+			} else {
+				button_video.set_active (false);
+			}
+
+		} else if (button == button_video) {
+			if (!button_video.get_active ()) {
+				button_video.set_active (true);
+			} else {
+				button_photo.set_active (false);
+			}
+		} else {
+			assert_not_reached ();
+		}
+
+		if (button_photo.get_active ()) {
+			label_take_photo.set_text_with_mnemonic ("<b>" + _("_Take a photo") + "</b>");
+			label_take_photo.set_use_markup (true);
+			// TODO: add actions
+
+		} else {
+			label_take_photo.set_text_with_mnemonic ("<b>" + _("_Start recording") + "</b>");
+			label_take_photo.set_use_markup (true);
+		}
+	}
+
+	void on_effects_button (Button button) {
+	}
+
+
+	public void setup () {
+		setup_ui ();
+	}
+
+	void setup_ui () {
+		try {
+			add_from_file (Path.build_filename (Config.PACKAGE_DATADIR, "/cheese.ui"));
+
+			window = (Window) get_object ("cheese_window");
+			button_effects = (Button) get_object ("button_effects");
+			button_photo = (ToggleButton) get_object ("button_photo");
+			button_video = (ToggleButton) get_object ("button_video");
+			image_take_photo = (Widget) get_object ("image_take_photo");
+			label_effects = (Label) get_object ("label_effects");
+			label_photo = (Label) get_object ("label_photo");
+			label_take_photo = (Label) get_object ("label_take_photo");
+			label_video = (Label) get_object ("label_video");
+			main_vbox = (VBox) get_object ("main_vbox");
+			video_vbox = (VBox) get_object ("video_vbox");
+			notebook = (Widget) get_object ("notebook");
+			notebook_bar = (Widget) get_object ("notebook_bar");
+			screen = (Widget) get_object ("video_screen");
+			take_picture = (Button) get_object ("take_picture");
+			thumb_scrollwindow = (Widget) get_object ("thumb_scrollwindow");
+			throbber_frame = (Widget) get_object ("throbber_frame");
+			countdown_frame = (Widget) get_object ("countdown_frame");
+			effect_frame = (Widget) get_object ("effect_frame");
+		
+			label_take_photo.set_text_with_mnemonic ("<b>" + _("_Take a photo") + "</b>");
+			label_take_photo.set_use_markup (true);
+
+			take_picture.set_sensitive (false);
+
+/*
+  cheese_window->thumb_view = cheese_thumb_view_new ();
+  gtk_container_add (GTK_CONTAINER (cheese_window->thumb_scrollwindow), cheese_window->thumb_view);
+
+  char *gconf_effects;
+  g_object_get (cheese_window->gconf, "gconf_prop_selected_effects", &gconf_effects, null);
+  cheese_window->effect_chooser = cheese_effect_chooser_new (gconf_effects);
+  gtk_container_add (GTK_CONTAINER (cheese_window->effect_frame), cheese_window->effect_chooser);
+  g_free (gconf_effects);
+
+  cheese_window->throbber = ephy_spinner_new ();
+  ephy_spinner_set_size (EPHY_SPINNER (cheese_window->throbber), GTK_ICON_SIZE_DIALOG);
+  gtk_container_add (GTK_CONTAINER (cheese_window->throbber_frame), cheese_window->throbber);
+  gtk_widget_show (cheese_window->throbber);
+
+  cheese_window->countdown = cheese_countdown_new ();
+  gtk_container_add (GTK_CONTAINER (cheese_window->countdown_frame), cheese_window->countdown);
+  gtk_widget_show (cheese_window->countdown);
+*/
+
+			button_photo.set_active (true);
+			button_photo.toggled += on_photo_video_toggle;
+			button_video.set_active (false);
+			button_video.toggled += on_photo_video_toggle;
+
+			ui_manager = new UIManager ();
+
+			actions_main = new ActionGroup ("ActionsMain");
+			actions_main.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_main.add_actions (action_entries_main, this);
+			ui_manager.insert_action_group (actions_main, 0);
+
+			actions_toggle = new ActionGroup ("ActionsRadio");
+			actions_toggle.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_toggle.add_radio_actions (action_entries_toggle, 0, (GLib.Callback)on_radio_button, this);
+			ui_manager.insert_action_group (actions_toggle, 0);
+
+			actions_effects = new ActionGroup ("ActionsEffects");
+			actions_effects.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_effects.add_toggle_actions (action_entries_effects, this);
+			ui_manager.insert_action_group (actions_effects, 0);
+
+			actions_file = new ActionGroup ("ActionsFile");
+			actions_file.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_file.add_actions (action_entries_file, this);
+			ui_manager.insert_action_group (actions_file, 0);
+
+			actions_photo = new ActionGroup ("ActionsEffects");
+			actions_photo.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_photo.add_actions (action_entries_photo, this);
+			ui_manager.insert_action_group (actions_photo, 0);
+
+			actions_countdown = new ActionGroup ("ActionsCountdown");
+			actions_countdown.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_countdown.add_toggle_actions (action_entries_countdown, this);
+			ui_manager.insert_action_group (actions_countdown, 0);
+
+			actions_video = new ActionGroup ("ActionsVideo");
+			actions_video.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_video.add_toggle_actions (action_entries_video, this);
+			ui_manager.insert_action_group (actions_video, 0);
+
+			actions_mail = new ActionGroup ("ActionsMail");
+			actions_mail.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_mail.add_actions (action_entries_mail, this);
+			ui_manager.insert_action_group (actions_mail, 0);
+
+			actions_fspot = new ActionGroup ("ActionsFSpot");
+			actions_fspot.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_fspot.add_actions (action_entries_fspot, this);
+			ui_manager.insert_action_group (actions_fspot, 0);
+			actions_fspot.set_visible (Environment.find_program_in_path ("f-spot") != null);
+
+			actions_flickr = new ActionGroup ("ActionsFlickr");
+			actions_flickr.set_translation_domain (Config.GETTEXT_PACKAGE);
+			actions_flickr.add_actions (action_entries_flickr, this);
+			ui_manager.insert_action_group (actions_flickr, 0);
+			actions_fspot.set_visible (Environment.find_program_in_path ("f-spot") != null);
+
+			ui_manager.add_ui_from_file (Config.PACKAGE_DATADIR + Path.DIR_SEPARATOR_S + "cheese-ui.xml");
+
+			screen.add_events (Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK);
+
+			ToggleAction countdown_action = (ToggleAction)ui_manager.get_action ("/MainMenu/Cheese/CountdownToggle");
+
+			countdown_action.set_active (gconf_client.get_bool (GCONF_COUNTDOWN_KEY));
+
+			Widget menubar = ui_manager.get_widget ("/MainMenu");
+			main_vbox.pack_start (menubar, false, false, 0);
+
+			thumb_view_popup_menu = ui_manager.get_widget ("/ThumbnailPopup");
+  			
+			AccelGroup accel_group = ui_manager.get_accel_group ();
+			window.add_accel_group (accel_group);
+
+/*
+			accel_group.connect (Gdk.Escape, 0, 0
+	
+  gtk_accel_group_connect (gtk_ui_manager_get_accel_group (cheese_window->ui_manager),
+                           GDK_Escape, 0, 0,
+                           g_cclosure_new_swap (G_CALLBACK (cheese_window_cancel_cb),
+                                                cheese_window, NULL));
+*/
+			actions_file.set_sensitive (false);
+
+
+			window.destroy += Gtk.main_quit;
+
+/*
+  g_signal_connect (cheese_window->window, "delete_event", 
+                    G_CALLBACK(cheese_window_delete_event_cb), NULL);
+*/
+			take_picture.clicked += on_action_button;
+			button_effects.clicked += on_effects_button;
+
+/*
+  g_signal_connect (cheese_window->thumb_view, "button_press_event",
+                    G_CALLBACK (cheese_window_button_press_event_cb), cheese_window);
+*/
+
+
+			window.show_all ();
+
+		} catch (Error e) {
+			error (e.message);
+		}
+
+	}
+}

Added: branches/cheese-vala/src/cheese.vala
==============================================================================
--- (empty file)
+++ branches/cheese-vala/src/cheese.vala	Tue Apr  1 22:33:52 2008
@@ -0,0 +1,82 @@
+/* cheese.vala
+ *
+ * Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
+ * Copyright (C) 2007,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/>.
+ */
+using GLib;
+using Gtk;
+
+public class Cheese.Cheese {
+	static bool verbose;
+	static string hal_device_id;
+	static FileStream log_file;
+
+	const OptionEntry[] options = {
+		{ "verbose", 'v', 0, OptionArg.NONE, ref verbose, N_("Be verbose"), null},
+		{ "hal-device", 0, OptionFlags.HIDDEN, OptionArg.STRING, out hal_device_id, null, null},
+		{ null }
+	};
+
+	static void print_handler (string text) {
+		log_file.puts (text);
+		if (verbose) {
+			stdout.puts (text);
+		}
+	}
+
+	static int main (string[] args) {
+
+		Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALEDIR);
+  		//textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+		Intl.textdomain (Config.GETTEXT_PACKAGE);
+
+		Gdk.threads_init ();
+		try {
+			var context = new OptionContext (_("- Take photos and videos from your webcam"));
+			context.set_help_enabled (true);
+			context.add_main_entries (options, null);
+			context.add_group (Gtk.get_option_group (true));
+			OptionGroup *gst_opt_group = Gst.init_get_option_group ();
+			context.add_group (gst_opt_group);
+			context.parse (ref args);
+		} catch (OptionError e) {
+			stdout.printf ("%s\n", e.message);
+			stdout.printf (_("Run '%s --help' to see a full list of available command line options.\n"), args[0]);
+			return 1;
+		}
+
+ 		Environment.set_application_name (_("Cheese"));
+		Gtk.init (ref args);
+		Gst.init (ref args);
+
+		Window.set_default_icon_name ("cheese");
+		string log_file_dir = Path.build_filename (Environment.get_home_dir(), ".config", "cheese");
+		DirUtils.create_with_parents (log_file_dir, 0775);
+		log_file = FileStream.open (Path.build_filename (log_file_dir, "cheese.log"), "w");
+		set_print_handler (print_handler);
+
+		var cheese_window = new CheeseWindow ();
+		cheese_window.setup ();
+		Gdk.threads_enter ();
+		Gtk.main ();
+		Gdk.threads_leave ();
+		return 0;
+	}
+
+
+}



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