gtranslator r3507 - in trunk/src: . dialogs plugin-system



Author: psanxiao
Date: Tue Mar  4 00:24:23 2008
New Revision: 3507
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3507&view=rev

Log:
	* plugin-system/plugin.h:
	* plugin-system/plugins-engine.c:
	* plugin-system/module.c:
	* plugin-system/update-from-gedit.sh:
	* plugin-system/plugin-manager.c:
	* plugin-system/plugin-info.c:
	Now plugin-system uses g_message instead g_warning
	(By Ignacio Casal Quinteiro)

	* dialogs/file-dialogs.{c,h}:
	Now gtranslator checks when you save, if the file
	already exits. Fixed bug 423276
	(By Ignacio Casal Quinteiro)

	* application.{c,h}:
	* tab.{c,h}:
	* window.{c,h}:
	* statusbar.c:
	* message-table-model.h:
	* actions-file.c:
	* po.{c,h}:
	* msg.{c,h}:
	Fixed some bugs and memory leaks
	(By Ignacio Casal Quinteiro)


Modified:
   trunk/src/ChangeLog
   trunk/src/actions-file.c
   trunk/src/application.c
   trunk/src/application.h
   trunk/src/dialogs/file-dialogs.c
   trunk/src/dialogs/file-dialogs.h
   trunk/src/message-table-model.h
   trunk/src/msg.c
   trunk/src/msg.h
   trunk/src/plugin-system/module.c
   trunk/src/plugin-system/plugin-info.c
   trunk/src/plugin-system/plugin-manager.c
   trunk/src/plugin-system/plugin.h
   trunk/src/plugin-system/plugins-engine.c
   trunk/src/po.c
   trunk/src/po.h
   trunk/src/statusbar.c
   trunk/src/tab.c
   trunk/src/tab.h
   trunk/src/window.c
   trunk/src/window.h

Modified: trunk/src/actions-file.c
==============================================================================
--- trunk/src/actions-file.c	(original)
+++ trunk/src/actions-file.c	Tue Mar  4 00:24:23 2008
@@ -35,9 +35,10 @@
 #include "tab.h"
 #include "window.h"
 
+#define GTR_TAB_SAVE_AS "gtranslator-tab-save-as"
 
-static void gtranslator_save_file_dialog(GtkWidget *widget,
-					 GtranslatorWindow *window);
+static void load_file_list(GtranslatorWindow *window,
+			   const GSList *uris);
 
 
 /*
@@ -63,7 +64,7 @@
 	po = gtranslator_po_new();
 	gtranslator_po_parse(po, filename, error);
 	
-	if(*error != NULL)
+	if((*error != NULL) && (((GError *)*error)->code != GTR_PO_ERROR_RECOVERY))
 		return FALSE;
 
 	header = gtranslator_po_get_header(po);
@@ -97,39 +98,24 @@
 }
 
 static void 
-gtranslator_po_parse_file_from_dialog(GtkWidget * dialog,
-				      GtranslatorWindow *window)
+gtranslator_po_parse_files_from_dialog (GtkWidget * dialog,
+					GtranslatorWindow *window)
 {
-	gchar *po_file;
-	GError *error = NULL;
-	po_file = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
-
-	gtranslator_file_dialogs_store_directory(po_file);
+	GSList *po_files;
+	
+	po_files = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
 
 	/*
 	 * Open the file via our centralized opening function.
 	 */
-	if(!gtranslator_open(po_file, window, &error)) {
-		if(error) 
-		{
-			/*
-			 * We have to show the error in a dialog
-			 */
-			gtk_message_dialog_new(GTK_WINDOW(window),
-					       GTK_DIALOG_DESTROY_WITH_PARENT,
-					       GTK_MESSAGE_ERROR,
-					       GTK_BUTTONS_CLOSE,
-					       error->message);
-			g_error_free(error);
-		}
-	}
+	load_file_list (window, (const GSList *)po_files);
 
-	g_free(po_file);
+	g_slist_free (po_files);
 	
 	/*
 	 * Destroy the dialog 
 	 */
-	gtk_widget_destroy(dialog);
+	gtk_widget_destroy (dialog);
 }
 
 
@@ -144,10 +130,8 @@
 	switch (reply){
 		case GTK_RESPONSE_ACCEPT:
 			if (mode == FILESEL_OPEN){
-				gtranslator_po_parse_file_from_dialog(GTK_WIDGET(dialog),
-								      window);
-			} else {
-				gtranslator_save_file_dialog(GTK_WIDGET(dialog), window);
+				gtranslator_po_parse_files_from_dialog(GTK_WIDGET(dialog),
+								       window);
 			}
 			break;
 		case GTK_RESPONSE_CANCEL:
@@ -169,7 +153,7 @@
 gtranslator_open_file_dialog(GtkAction * action,
 			     GtranslatorWindow *window)
 {
-	GtkWindow *dialog = NULL;
+	GtkWidget *dialog = NULL;
 
 	if(dialog != NULL) {
 		gtk_window_present(GTK_WINDOW(dialog));
@@ -184,124 +168,148 @@
 	 * remote requests and use gnome-vfs to retrieve a temporary file to 
 	 * work on, and transmit it back when saved.
 	 */
-	gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
+	//gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
 
 	gtranslator_file_chooser_analyse((gpointer) dialog, FILESEL_OPEN, window);
 }
 
-
-/*
- * A callback for Overwrite in Save as
- */
 static void
-gtranslator_overwrite_file(GtkWidget * widget,
-			   GtranslatorWindow *window)
-{
-	GError *error;
-	//gtranslator_save_file(current_page->po,current_page->po->filename, &error);
-	/*
-	 * TODO: Should close the file and open the new saved file
-	 */
-	//gtranslator_open_file(current_page->po->filename);
-	//gtranslator_open(current_page->po->filename, window, &error);
-}
-
-/*
- * A callback for OK in Save as... dialog 
- */
-static void 
-gtranslator_save_file_dialog(GtkWidget *widget,
-			     GtranslatorWindow *window)
+save_dialog_response_cb (GtkDialog *dialog,
+                         gint                    response_id,
+                         GtranslatorWindow      *window)
 {
-	gchar *po_file,
-	      *po_file_normalized;
+	GError *error = NULL;
 	GtranslatorPo *po;
+	GtranslatorTab *tab;
+	gchar *filename;
 	
-	//po = gtranslator_window_get_active_po(window);
-	
- 	po_file = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
-	po_file_normalized = g_utf8_normalize( po_file, -1, G_NORMALIZE_DEFAULT_COMPOSE);
-	g_free(po_file);
-	po_file = po_file_normalized;
+	tab = GTR_TAB (g_object_get_data (G_OBJECT (dialog),
+					  GTR_TAB_SAVE_AS));
+				
+	g_return_if_fail (GTK_IS_FILE_CHOOSER (dialog));
+				     
+	po = gtranslator_tab_get_po (tab);
 
-	if (g_file_test(po_file, G_FILE_TEST_EXISTS))
+	if (response_id != GTK_RESPONSE_ACCEPT)
 	{
-		//gtranslator_po_set_filename(po, po_file);
+		gtk_widget_destroy (GTK_WIDGET (dialog));
+		return;
+	}
 		
-		GtkWidget *dialog, *button;
+	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+	g_return_if_fail (filename != NULL);
 	
-		dialog = gtk_message_dialog_new (NULL,
-						 GTK_DIALOG_MODAL,
-						 GTK_MESSAGE_QUESTION,
-						 GTK_BUTTONS_CANCEL,
-						 _("The file '%s' already exists. Do you want overwrite it?"),
-						 po_file);
-		
-		button = gtk_dialog_add_button (GTK_DIALOG (dialog), "Overwrite", 1);
-		
-		g_signal_connect (G_OBJECT (button), "clicked",
-			G_CALLBACK (gtranslator_overwrite_file), window);
+	gtk_widget_destroy (GTK_WIDGET (dialog));
+	
+	if (po != NULL)
+	{
+		gtranslator_po_set_filename (po, filename);
 		
-		gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
+		gtranslator_po_save_file (po, &error);
+	
+		if (error)
+		{
+			GtkWidget *dialog;
+			dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+							 GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_WARNING,
+							 GTK_BUTTONS_OK,
+							 error->message);
+			gtk_dialog_run(GTK_DIALOG(dialog));
+			gtk_widget_destroy(dialog);
+			g_clear_error(&error);
+			g_free (filename);
+			return;
+		}
+	
+		/* We have to change the state of the tab */
+		gtranslator_tab_set_state(tab, GTR_TAB_STATE_SAVED);	
+			
+		g_free (filename);
 	}
-	g_free(po_file);
-	gtk_widget_destroy(GTK_WIDGET(widget));
+}
+
+static GtkFileChooserConfirmation
+confirm_overwrite_callback (GtkFileChooser *dialog,
+			    gpointer        data)
+{
+	gchar *uri;
+	GtkFileChooserConfirmation res;
+
+	uri = gtk_file_chooser_get_uri (dialog);
+
+	/*
+	 * FIXME: We have to detect if the file is read-only
+	 */
+
+	/* fall back to the default confirmation dialog */
+	res = GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
+
+	g_free (uri);
+
+	return res;
 }
 
 /*
  * "Save as" dialog.
  */
 void
-gtranslator_save_file_as_dialog(GtkAction * action,
-				GtranslatorWindow *window)
+gtranslator_save_file_as_dialog (GtkAction * action,
+				 GtranslatorWindow *window)
 {
-	GtkWindow *dialog = NULL;
+	GtkWidget *dialog = NULL;
 	GtranslatorTab *current_page;
 	GtranslatorPo *po;
+	const gchar *filename;
+	gchar *uri = NULL;
+	gboolean uri_set = FALSE;
 	
-	if(dialog != NULL) {
-		gtk_window_present(GTK_WINDOW(dialog));
+	if (dialog != NULL) {
+		gtk_window_present (GTK_WINDOW (dialog));
 		return;
 	}
 
-	current_page = gtranslator_window_get_active_tab(window);
-	po = gtranslator_tab_get_po(current_page);
+	current_page = gtranslator_window_get_active_tab (window);
+	po = gtranslator_tab_get_po (current_page);
 	
-	if(gtranslator_po_get_write_perms(po)==FALSE ||
-	   strstr((const char*)gtranslator_po_get_filename, "/.gtranslator/"))
-	{
-		dialog = gtranslator_file_chooser_new(GTK_WINDOW(window),
-						      FILESEL_SAVE,
-						      _("Save file as..."));
-	}
-	else
-	{
-		dialog = gtranslator_file_chooser_new(GTK_WINDOW(window),
-						      FILESEL_SAVE,
-						      _("Save local copy of file as..."));
-		
-		/*
-		 * Set a local filename in the users home directory with the 
-		 *  same filename as the original but with a project prefix
-		 *   (e.g. "gtranslator-tr.po").
-		 */ 
-		gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog),
-						 gtranslator_po_get_filename(po));
-		gtranslator_file_dialogs_store_directory(gtranslator_po_get_filename(po));
-	}
-
-	/*
-	 * With the gettext parser/writer API, we can't currently read/write
-	 * to remote files with gnome-vfs. Eventually, we should intercept
-	 * remote requests and use gnome-vfs to retrieve a temporary file to 
-	 * work on, and transmit it back when saved.
-	 */
-	gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
+	dialog = gtranslator_file_chooser_new (GTK_WINDOW (window),
+					       FILESEL_SAVE,
+					       _("Save file as..."));
+	
+	gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
+							TRUE);
+	g_signal_connect (dialog,
+			  "confirm-overwrite",
+			  G_CALLBACK (confirm_overwrite_callback),
+			  NULL);
+			  
+	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+	
+	/*Set the suggested file */
+	filename = gtranslator_po_get_filename (po);
+	
+	uri = g_filename_to_uri (filename, NULL, NULL);
+	
+	if (uri)
+		uri_set = gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog),
+						    uri);
+	
+	g_free (uri);
+	
+	/*
+	 * FIXME: If we can't set the uri we should add a default path and name
+	 */
+	 
+	g_object_set_data (G_OBJECT (dialog),
+			   GTR_TAB_SAVE_AS,
+			   current_page);
+	 
+	g_signal_connect (dialog,
+			  "response",
+			  G_CALLBACK (save_dialog_response_cb),
+			  window);
 
-	gtranslator_file_chooser_analyse((gpointer) dialog, FILESEL_SAVE, window);
-	
-	//gtranslator_dialog_show(&dialog, "gtranslator -- save");
+	gtk_widget_show (GTK_WIDGET (dialog));
 }
 
 void 
@@ -315,18 +323,6 @@
 	current_page = gtranslator_window_get_active_tab(window);
 	nb = gtranslator_window_get_notebook(window);
 	g_assert(current_page != NULL);
-
-	/*
-	 * If user doesn't know what to do with changed file, return
-	 */
-	/*if (!gtranslator_should_the_file_be_saved_dialog(current_page))
-		return;*/
-
-	/*
-	 * "Remove" the stored "runtime/filename" key.
-	 * Is this really neccessary with tabs?
-	 */
-	//gtranslator_config_set_string("runtime/filename", "--- No file ---");
 	
 	i = gtk_notebook_page_num(GTK_NOTEBOOK(nb), GTK_WIDGET(current_page));
 	if (i != -1)
@@ -336,8 +332,8 @@
 }
 
 void
-gtranslator_file_quit(GtkAction *action,
-		      GtranslatorWindow *window)
+gtranslator_file_quit (GtkAction *action,
+		       GtranslatorWindow *window)
 {	
 	GtranslatorNotebook *nb;
 	gint pages;
@@ -354,86 +350,32 @@
 
 	
 	gtk_widget_destroy(GTK_WIDGET(window));
-	/*
-	 * Get the EPaned's position offset.
-	 */
-	//table_pane_position=gtk_paned_get_position(GTK_PANED(gtranslator_window_get_paned(window)));
-	/*
-	 * Store the pane position in the preferences.
-	 */
-	//gtranslator_config_set_int("interface/table_pane_position", table_pane_position);
-	
-	//gtranslator_utils_save_geometry();
-
-	/*
-	 * "Flush" our runtime config string for the current filename.
-	 */
-	//gtranslator_config_set_string("runtime/filename", "--- No file ---");
-
-	/*
-	 * Free the used GtrTranslator structure.
-	 */
-	//gtranslator_translator_free(gtranslator_translator);
-
-	/*
-	 * Free any lungering stuff 'round -- free prefs.
-	 */
-//	gtranslator_preferences_free();
-
-	/*
-	 * Remove any lungering temp. file.
-	 */
-	//gtranslator_utils_remove_temp_files();
-
-	/*
-	 * Free our used runtime config structure.
-	 */
-	//gtranslator_runtime_config_free(gtranslator_runtime_config);
-	
-	/*
-	 * Store the current date.
-	 */
-//	gtranslator_config_set_last_run_date();
-
-	/*
-	 * Shutdown the eventually (non-)initialized stuff from GnomeVFS.
-	 */
-	/*if(gnome_vfs_initialized())
-	{
-		gnome_vfs_shutdown();
-	}*/
-
-	/*
-	 * Quit with the normal Gtk+ quit.
-	 */
-	//gtk_main_quit();
 }
 
 /*
  * A callback for Save
  */
 void 
-gtranslator_save_current_file_dialog(GtkWidget * widget,
-				     GtranslatorWindow *window)
+gtranslator_save_current_file_dialog (GtkWidget * widget,
+				      GtranslatorWindow *window)
 {
-	GError *error;
+	GError *error = NULL;
 	GtranslatorTab *current;
 	GtranslatorPo *po;
 	
-	current = gtranslator_window_get_active_tab(window);
-	po = gtranslator_tab_get_po(current);
+	current = gtranslator_window_get_active_tab (window);
+	po = gtranslator_tab_get_po (current);
 	
-	//g_return_if_fail(current_page->po->file_changed);
-
-	if (!gtranslator_po_save_file(po, gtranslator_po_get_filename(po), &error)) {
+	gtranslator_po_save_file (po, &error);
+	
+	if (error)
+	{
 		GtkWidget *dialog;
-		g_assert(error != NULL);
-		dialog = gtk_message_dialog_new(
-			GTK_WINDOW(window),
-			GTK_DIALOG_DESTROY_WITH_PARENT,
-			GTK_MESSAGE_WARNING,
-			GTK_BUTTONS_OK,
-			error->message);
+		dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+						 GTK_DIALOG_DESTROY_WITH_PARENT,
+						 GTK_MESSAGE_WARNING,
+						 GTK_BUTTONS_OK,
+						 error->message);
 		gtk_dialog_run(GTK_DIALOG(dialog));
 		gtk_widget_destroy(dialog);
 		g_clear_error(&error);
@@ -467,9 +409,10 @@
 	const GSList  *l;
 	GError *error = NULL;
 	gchar *path;
+	GtkWidget *tab;
 	
 	g_return_if_fail ((uris != NULL) && (uris->data != NULL));
-		
+
 	/* Remove the uris corresponding to documents already open
 	 * in "window" and remove duplicates from "uris" list */
 	l = uris;
@@ -477,42 +420,30 @@
 	{
 		if (!is_duplicated_uri (uris_to_load, uris->data))
 		{
-			
 			/*We need to now if is already loaded in any tab*/
-			
-			/*tab = get_tab_from_uri (win_docs, (const gchar *)uris->data);
+			tab = gtranslator_window_get_tab_from_uri (window,
+								   (const gchar *)uris->data);
+
 			if (tab != NULL)
 			{
 				if (uris == l)
 				{
-					gedit_window_set_active_tab (window, tab);
-					jump_to = FALSE;
-
-					if (line_pos > 0)
-					{
-						GeditDocument *doc;
-						GeditView *view;
-
-						doc = gedit_tab_get_document (tab);
-						view = gedit_tab_get_view (tab);
-
-						gedit_document_goto_line (doc, line_pos);
-						gedit_view_scroll_to_cursor (view);
-					}
+					gtranslator_window_set_active_tab (window,
+									   tab);
 				}
 
-				++loaded_files;
 			}
 			else
-			{*/
+			{
 				uris_to_load = g_slist_prepend (uris_to_load, 
 								uris->data);
-			//}
+			}
+
 		}
 
 		uris = g_slist_next (uris);
 	}
-	
+
 	if (uris_to_load == NULL)
 		return;
 	
@@ -539,14 +470,18 @@
 	if(error != NULL)
 	{
 		g_free(path);
+		
+		GtkWidget *dialog;
 		/*
 		 * We have to show the error in a dialog
 		 */
-		gtk_message_dialog_new(GTK_WINDOW(window),
-				       GTK_DIALOG_DESTROY_WITH_PARENT,
-				       GTK_MESSAGE_ERROR,
-				       GTK_BUTTONS_CLOSE,
-				       error->message);
+		dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+						GTK_DIALOG_DESTROY_WITH_PARENT,
+						GTK_MESSAGE_ERROR,
+						GTK_BUTTONS_CLOSE,
+						error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
 		g_error_free(error);
 	}
 	

Modified: trunk/src/application.c
==============================================================================
--- trunk/src/application.c	(original)
+++ trunk/src/application.c	Tue Mar  4 00:24:23 2008
@@ -36,8 +36,6 @@
 
 G_DEFINE_TYPE(GtranslatorApplication, gtranslator_application, G_TYPE_OBJECT)
 
-#define CONFIG_DIRECTORY ".config/gtranslator"
-
 struct _GtranslatorApplicationPrivate
 {
 	GList *windows;
@@ -84,7 +82,6 @@
 	gchar *filename;
 
 	filename = get_accel_file ();
-	g_warning (filename);
 	if (filename != NULL)
 	{
 		gtk_accel_map_save (filename);
@@ -135,10 +132,7 @@
 	}
 
 	egg_toolbars_model_set_flags (priv->toolbars_model, 0,
-				      EGG_TB_MODEL_NOT_REMOVABLE);
-	
-	/* We build our config directory */
-	
+				      EGG_TB_MODEL_NOT_REMOVABLE);	
 	
 	load_accels ();
 }
@@ -183,7 +177,7 @@
 	return instance;
 }
 
-void
+GtranslatorWindow *
 gtranslator_application_open_window (GtranslatorApplication *app)
 {
 	GtranslatorWindow *window;
@@ -213,7 +207,9 @@
 	g_signal_connect(window, "destroy",
 			 G_CALLBACK(on_window_destroy_cb), GTR_APP);
 
-	gtk_widget_show(GTK_WIDGET(window));	
+	gtk_widget_show(GTK_WIDGET(window));
+	
+	return window;
 }
 				     
 
@@ -271,12 +267,24 @@
 	return res;
 }
 
+/**
+ * gtranslator_application_get_active_window:
+ * @app: a #GtranslatorApplication
+ * 
+ * Return value: the active #GtranslatorWindow
+ **/
 GtranslatorWindow *
 gtranslator_application_get_active_window(GtranslatorApplication * app)
 {
 	return GTR_WINDOW(app->priv->active_window);
 }
 
+/**
+ * gtranslator_application_get_windows:
+ * @app: a #GtranslatorApplication
+ * 
+ * Return value: a list of all opened windows.
+ **/
 const GList *
 gtranslator_application_get_windows (GtranslatorApplication *app)
 {

Modified: trunk/src/application.h
==============================================================================
--- trunk/src/application.h	(original)
+++ trunk/src/application.h	Tue Mar  4 00:24:23 2008
@@ -83,10 +83,11 @@
 							       gboolean original,
 							       gboolean translated);
 
+GtranslatorWindow *gtranslator_application_open_window (GtranslatorApplication *app);
+
 GtranslatorWindow *gtranslator_application_get_active_window  (GtranslatorApplication * app);
 
-const GList *
-gtranslator_application_get_windows (GtranslatorApplication *app);
+const GList      *gtranslator_application_get_windows (GtranslatorApplication *app);
 
 G_END_DECLS
 

Modified: trunk/src/dialogs/file-dialogs.c
==============================================================================
--- trunk/src/dialogs/file-dialogs.c	(original)
+++ trunk/src/dialogs/file-dialogs.c	Tue Mar  4 00:24:23 2008
@@ -26,26 +26,9 @@
 #include "window.h"
 
 /*
-  * Store the given filename's directory for our file dialogs completion-routine.
- */
-void
-gtranslator_file_dialogs_store_directory(const gchar *filename)
-{
-	gchar *directory;
-
-	g_return_if_fail(filename!=NULL);
-	
-	directory=g_path_get_dirname(filename);
-	
-//	gtranslator_config_set_string("informations/last_directory", directory);
-
-	g_free(directory);
-}
-
-/*
  * File chooser dialog
  */
-GtkWindow *
+GtkWidget *
 gtranslator_file_chooser_new (GtkWindow *parent,
 			      FileselMode mode,
 			      gchar *title)
@@ -61,26 +44,29 @@
 					     NULL);
 	gtk_dialog_set_default_response(GTK_DIALOG(dialog),GTK_RESPONSE_ACCEPT);
 	if (mode != FILESEL_SAVE)
-		{
-			filter = gtk_file_filter_new();
-			gtk_file_filter_set_name(filter,_("Gettext translation"));
-			gtk_file_filter_add_mime_type(filter,"text/x-gettext-translation");
-			gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
+	{
+		/* We set a multi selection dialog */
+		gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog),
+						      TRUE);
+		
+		/* Now we set the filters */
+		filter = gtk_file_filter_new();
+		gtk_file_filter_set_name(filter,_("Gettext translation"));
+		gtk_file_filter_add_mime_type(filter,"text/x-gettext-translation");
+		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
 	
-			filter = gtk_file_filter_new();
-			gtk_file_filter_set_name(filter,_("Gettext translation template"));
-			gtk_file_filter_add_mime_type(filter,"text/x-gettext-translation-template");
-			gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
-			
-			filter = gtk_file_filter_new();
-			gtk_file_filter_set_name(filter,_("All files"));
-			gtk_file_filter_add_pattern(filter,"*");
-			gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
-			
-//			gtranslator_file_dialogs_set_directory(&dialog);
-		} 
+		filter = gtk_file_filter_new();
+		gtk_file_filter_set_name(filter,_("Gettext translation template"));
+		gtk_file_filter_add_mime_type(filter,"text/x-gettext-translation-template");
+		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
+		
+		filter = gtk_file_filter_new();
+		gtk_file_filter_set_name(filter,_("All files"));
+		gtk_file_filter_add_pattern(filter,"*");
+		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
+	} 
 		
 	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
-	gtk_widget_show_all(GTK_WIDGET(dialog));
-	return GTK_WINDOW(dialog);
+	
+	return dialog;
 }

Modified: trunk/src/dialogs/file-dialogs.h
==============================================================================
--- trunk/src/dialogs/file-dialogs.h	(original)
+++ trunk/src/dialogs/file-dialogs.h	Tue Mar  4 00:24:23 2008
@@ -27,9 +27,7 @@
 	FILESEL_SAVE
 } FileselMode;
 
-void		gtranslator_file_dialogs_store_directory	(const gchar *filename);
-
-GtkWindow	*gtranslator_file_chooser_new			(GtkWindow *parent,
+GtkWidget	*gtranslator_file_chooser_new			(GtkWindow *parent,
 								 FileselMode mode,
 								 gchar *title);
 

Modified: trunk/src/message-table-model.h
==============================================================================
--- trunk/src/message-table-model.h	(original)
+++ trunk/src/message-table-model.h	Tue Mar  4 00:24:23 2008
@@ -84,8 +84,7 @@
 
 GType		  gtranslator_message_table_model_register_type	       (GTypeModule * module);
 
-GtranslatorMessageTableModel
-                 *gtranslator_message_table_model_new                  (void);
+GtranslatorMessageTableModel *gtranslator_message_table_model_new                  (void);
                  
 void              gtranslator_message_table_model_append             (GtranslatorMessageTableModel *model,
 								      GtranslatorMsg *msg,

Modified: trunk/src/msg.c
==============================================================================
--- trunk/src/msg.c	(original)
+++ trunk/src/msg.c	Tue Mar  4 00:24:23 2008
@@ -445,6 +445,9 @@
 	return po_message_msgctxt(msg->priv->message);
 }
 
+/*
+ * Functions to manage the gettext errors
+ */
 static void
 on_gettext_po_xerror(gint severity,
 		     po_message_t message,

Modified: trunk/src/msg.h
==============================================================================
--- trunk/src/msg.h	(original)
+++ trunk/src/msg.h	Tue Mar  4 00:24:23 2008
@@ -83,8 +83,7 @@
 void              gtranslator_msg_set_message          (GtranslatorMsg *msg,
 							po_message_t message);
 
-GtkTreeRowReference
-                 *gtranslator_msg_get_row_reference    (GtranslatorMsg *msg);
+GtkTreeRowReference *gtranslator_msg_get_row_reference    (GtranslatorMsg *msg);
 
 void              gtranslator_msg_set_row_reference    (GtranslatorMsg *msg,
 							GtkTreeRowReference *row_reference);
@@ -99,8 +98,7 @@
 void              gtranslator_msg_set_status           (GtranslatorMsg *msg,
 							GtranslatorMsgStatus status);
 
-GtranslatorMsgStatus
-                  gtranslator_msg_get_status           (GtranslatorMsg *msg);
+GtranslatorMsgStatus gtranslator_msg_get_status           (GtranslatorMsg *msg);
 
 const gchar      *gtranslator_msg_get_msgid            (GtranslatorMsg *msg);
 
@@ -123,10 +121,10 @@
 void              gtranslator_msg_set_comment          (GtranslatorMsg *msg,
 							const gchar *comment);
 
-gint		gtranslator_msg_get_po_position		(GtranslatorMsg *msg);
+gint              gtranslator_msg_get_po_position      (GtranslatorMsg *msg);
 
-void		gtranslator_msg_set_po_position		(GtranslatorMsg *msg,
-							 gint po_position);
+void              gtranslator_msg_set_po_position      (GtranslatorMsg *msg,
+							gint po_position);
 
 const gchar      *gtranslator_msg_get_extracted_comments
                                                        (GtranslatorMsg *msg);

Modified: trunk/src/plugin-system/module.c
==============================================================================
--- trunk/src/plugin-system/module.c	(original)
+++ trunk/src/plugin-system/module.c	Tue Mar  4 00:24:23 2008
@@ -101,7 +101,7 @@
 	GtranslatorModule *module = GTR_MODULE (gmodule);
 	GtranslatorModuleRegisterFunc register_func;
 
-	g_warning( "Loading %s", module->path);
+	g_message( "Loading %s", module->path);
 
 	module->library = g_module_open (module->path, 0);
 
@@ -148,7 +148,7 @@
 {
 	GtranslatorModule *module = GTR_MODULE (gmodule);
 
-	g_warning( "Unloading %s", module->path);
+	g_message( "Unloading %s", module->path);
 
 	g_module_close (module->library);
 
@@ -167,7 +167,7 @@
 GObject *
 gtranslator_module_new_object (GtranslatorModule *module)
 {
-	g_warning( "Creating object of type %s", g_type_name (module->type));
+	g_message( "Creating object of type %s", g_type_name (module->type));
 
 	if (module->type == 0)
 	{
@@ -180,7 +180,7 @@
 static void
 gtranslator_module_init (GtranslatorModule *module)
 {
-	g_warning( "GtranslatorModule %p initialising", module);
+	g_message( "GtranslatorModule %p initialising", module);
 }
 
 static void
@@ -188,7 +188,7 @@
 {
 	GtranslatorModule *module = GTR_MODULE (object);
 
-	g_warning( "GtranslatorModule %p finalising", module);
+	g_message( "GtranslatorModule %p finalising", module);
 
 	g_free (module->path);
 

Modified: trunk/src/plugin-system/plugin-info.c
==============================================================================
--- trunk/src/plugin-system/plugin-info.c	(original)
+++ trunk/src/plugin-system/plugin-info.c	Tue Mar  4 00:24:23 2008
@@ -63,7 +63,7 @@
 
 	if (info->plugin != NULL)
 	{
-		g_warning( "Unref plugin %s", info->name);
+		g_message( "Unref plugin %s", info->name);
 
 		g_object_unref (info->plugin);
 		
@@ -123,7 +123,7 @@
 
 	g_return_val_if_fail (file != NULL, NULL);
 
-	g_warning( "Loading plugin: %s", file);
+	g_message( "Loading plugin: %s", file);
 
 	info = g_new0 (GtranslatorPluginInfo, 1);
 	info->refcount = 1;
@@ -141,7 +141,7 @@
 				 "IAge",
 				 NULL))
 	{
-		g_warning(
+		g_message(
 				     "IAge key does not exist in file: %s", file);
 		goto error;
 	}
@@ -152,7 +152,7 @@
 				    "IAge",
 				    NULL) != 2)
 	{
-		g_warning(
+		g_message(
 				     "Wrong IAge in file: %s", file);
 		goto error;
 	}
@@ -181,7 +181,7 @@
 							 NULL);
 	if (info->dependencies == NULL)
 	{
-		g_warning( "Could not find 'Depends' in %s", file);
+		g_message( "Could not find 'Depends' in %s", file);
 		info->dependencies = g_new0 (gchar *, 1);
 	}
 
@@ -226,7 +226,7 @@
 	if (str)
 		info->desc = str;
 	else
-		g_warning( "Could not find 'Description' in %s", file);
+		g_message( "Could not find 'Description' in %s", file);
 
 	/* Get Icon */
 	str = g_key_file_get_locale_string (plugin_file,
@@ -236,7 +236,7 @@
 	if (str)
 		info->icon_name = str;
 	else
-		g_warning( "Could not find 'Icon' in %s, using 'plugin'", file);
+		g_message( "Could not find 'Icon' in %s, using 'plugin'", file);
 	
 
 	/* Get Authors */
@@ -246,7 +246,7 @@
 						    NULL,
 						    NULL);
 	if (info->authors == NULL)
-		g_warning( "Could not find 'Authors' in %s", file);
+		g_message( "Could not find 'Authors' in %s", file);
 
 
 	/* Get Copyright */
@@ -257,7 +257,7 @@
 	if (str)
 		info->copyright = str;
 	else
-		g_warning( "Could not find 'Copyright' in %s", file);
+		g_message( "Could not find 'Copyright' in %s", file);
 
 	/* Get Website */
 	str = g_key_file_get_string (plugin_file,
@@ -267,7 +267,7 @@
 	if (str)
 		info->website = str;
 	else
-		g_warning( "Could not find 'Website' in %s", file);
+		g_message( "Could not find 'Website' in %s", file);
 		
 	g_key_file_free (plugin_file);
 	
@@ -306,7 +306,7 @@
 gboolean
 gtranslator_plugin_info_is_configurable (GtranslatorPluginInfo *info)
 {
-	g_warning( "Is '%s' configurable?", info->name);
+	g_message( "Is '%s' configurable?", info->name);
 
 	g_return_val_if_fail (info != NULL, FALSE);
 

Modified: trunk/src/plugin-system/plugin-manager.c
==============================================================================
--- trunk/src/plugin-system/plugin-manager.c	(original)
+++ trunk/src/plugin-system/plugin-manager.c	Tue Mar  4 00:24:23 2008
@@ -142,7 +142,7 @@
 
 	g_return_if_fail (info != NULL);
 
-	g_warning( "Configuring: %s\n", 
+	g_message( "Configuring: %s\n", 
 			     gtranslator_plugin_info_get_name (info));
 
 	toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(pm)));
@@ -150,7 +150,7 @@
 	gtranslator_plugins_engine_configure_plugin (pm->priv->engine,
 					       info, toplevel);
 
-	g_warning( "Done");	
+	g_message( "Done");	
 }
 
 static void
@@ -336,7 +336,7 @@
 	{
 		/* activate the plugin */
 		if (!gtranslator_plugins_engine_activate_plugin (pm->priv->engine, info)) {
-			g_warning( "Could not activate %s.\n", 
+			g_message( "Could not activate %s.\n", 
 					     gtranslator_plugin_info_get_name (info));
 
 			res = FALSE;
@@ -346,7 +346,7 @@
 	{
 		/* deactivate the plugin */
 		if (!gtranslator_plugins_engine_deactivate_plugin (pm->priv->engine, info)) {
-			g_warning( "Could not deactivate %s.\n", 
+			g_message( "Could not deactivate %s.\n", 
 					     gtranslator_plugin_info_get_name (info));
 
 			res = FALSE;

Modified: trunk/src/plugin-system/plugin.h
==============================================================================
--- trunk/src/plugin-system/plugin.h	(original)
+++ trunk/src/plugin-system/plugin.h	Tue Mar  4 00:24:23 2008
@@ -152,7 +152,7 @@
 		(GInstanceInitFunc) plugin_name##_init				\
 	};									\
 										\
-	g_warning( "Registering " #PluginName);	\
+	g_message( "Registering " #PluginName);	\
 										\
 	/* Initialise the i18n stuff */						\
 	bindtextdomain (GETTEXT_PACKAGE, GTR_LOCALEDIR);			\
@@ -217,7 +217,7 @@
 		(GInstanceInitFunc) object_name##_init				\
 	};									\
 										\
-	g_warning( "Registering " #ObjectName);	\
+	g_message( "Registering " #ObjectName);	\
 										\
 	g_define_type_id = g_type_module_register_type (module,			\
 					   	        PARENT_TYPE,		\

Modified: trunk/src/plugin-system/plugins-engine.c
==============================================================================
--- trunk/src/plugin-system/plugins-engine.c	(original)
+++ trunk/src/plugin-system/plugins-engine.c	Tue Mar  4 00:24:23 2008
@@ -103,7 +103,7 @@
 	g_return_if_fail (engine->priv->gconf_client != NULL);
 	g_return_if_fail (dir != NULL);
 
-	g_warning( "DIR: %s", dir);
+	g_message( "DIR: %s", dir);
 
 	d = g_dir_open (dir, 0, &error);
 	if (!d)
@@ -150,7 +150,7 @@
 
 			engine->priv->plugin_list = g_list_prepend (engine->priv->plugin_list, info);
 
-			g_warning( "Plugin %s loaded", info->name);
+			g_message( "Plugin %s loaded", info->name);
 		}
 	}
 
@@ -196,7 +196,7 @@
 	if (pdirs_env == NULL)
 		pdirs_env = GTR_PLUGINDIR;
 
-	g_warning( "GTR_PLUGINS_PATH=%s", pdirs_env);
+	g_message( "GTR_PLUGINS_PATH=%s", pdirs_env);
 	pdirs = g_strsplit (pdirs_env, G_SEARCHPATH_SEPARATOR_S, 0);
 
 	for (i = 0; pdirs[i] != NULL; i++)
@@ -437,7 +437,7 @@
 	
 	g_type_module_unuse (info->module);
 
-	g_warning( "End");
+	g_message( "End");
 	
 	return TRUE;
 }
@@ -576,7 +576,7 @@
 		}
 	}
 	
-	g_warning( "End");
+	g_message( "End");
 }
 
 void
@@ -601,7 +601,7 @@
 		if (!info->available || !info->active)
 			continue;
 			
-	       	g_warning( "Updating UI of %s", info->name);
+	       	g_message( "Updating UI of %s", info->name);
 		
 		gtranslator_plugin_update_ui (info->plugin, window);
 	}

Modified: trunk/src/po.c
==============================================================================
--- trunk/src/po.c	(original)
+++ trunk/src/po.c	Tue Mar  4 00:24:23 2008
@@ -299,7 +299,7 @@
 	if(message_error != NULL) {
 		g_set_error(error,
 			    GTR_PO_ERROR,
-			    GTR_PO_ERROR_GETTEXT,
+			    GTR_PO_ERROR_RECOVERY,
 			    message_error);
 	}
 	
@@ -399,9 +399,21 @@
 		gtranslator_header_set_charset(priv->header, charset);
 		gtranslator_header_set_encoding(priv->header, encoding);
 		
-		g_free(translator_temp);
-		g_free(language_temp);
-		g_free(charset_temp);
+		g_free (translator_temp);
+		g_free (language_temp);
+		g_free (charset_temp);
+		g_free (comment);
+		g_free (prj_id_version);
+		g_free (rmbt);
+		g_free (pot_date);
+		g_free (po_date);
+		g_free (translator);
+		g_free (tr_email);
+		g_free (language);
+		g_free (lg_email);
+		g_free (mime_version);
+		g_free (charset);
+		g_free (encoding);
 	}
 	else {
 		/* Reset our pointer */
@@ -460,21 +472,19 @@
 /**
  * gtranslator_po_save_file:
  * @po: a #GtranslatorPo
- * @name: filename
- * @error: a variable to store the errors
- *
+ * @error: a GError to manage the exceptions
  * 
+ * It saves the po file and if there are any problem it stores the error
+ * in @error.
  **/
-gboolean 
+void
 gtranslator_po_save_file(GtranslatorPo *po,
-		      const gchar *name,
-		      GError **error)
+			     GError **error)
 {
-	po_xerror_handler_t gettext_error_handler;
-
+	struct po_xerror_handler handler;
 	po_message_iterator_t iter;
 	po_message_t message;
-
+	
 	GtranslatorHeader *header;	
 
 	const char *msgstr,
@@ -485,21 +495,27 @@
 	struct tm *now_here;
 	char t[22];
 	gchar *year=g_malloc(5);
-
-	/*if(g_str_has_suffix(name, ".pot"))
+	gchar *aux;
+	
+	/*
+	 * Initialice the handler error.
+	 */
+	handler.xerror = &on_gettext_po_xerror;
+	handler.xerror2 = &on_gettext_po_xerror2;
+	
+	if (g_str_has_suffix(po->priv->filename, ".pot"))
 	{
-		g_set_error(error,
-			GTR_PARSER_ERROR,
-			GTR_PARSER_ERROR_FILENAME,
-			_("You are saving a file with a .pot extension.\n\
-Pot files are generated by the compilation process.\n\
-Your file should likely be named '%s.po'."), 
-			gtranslator_translator->language->locale);
-		return FALSE;
-	}*/
+		g_set_error (error,
+			     GTR_PO_ERROR,
+			     GTR_PO_ERROR_FILENAME,
+			     _("You are saving a file with a .pot extension.\n"
+			     "Pot files are generated by the compilation process.\n"
+			     "Your file should likely be named '%s.po'."), 
+			     po->priv->filename);
+		g_free (year);
+		return;
+	}
 	
-	gtranslator_file_dialogs_store_directory(name);
-
 	/*
 	 * Get header's fields
 	 */
@@ -528,72 +544,72 @@
 	/*
          * Update the header's comment
          */
-	if (strcmp(prev_translator, g_strconcat(gtranslator_header_get_translator(header), " ", "<", 
-					gtranslator_header_get_tr_email(header), ">", NULL)))
+        aux = g_strconcat(gtranslator_header_get_translator(header), " ", "<", 
+			  gtranslator_header_get_tr_email(header), ">", NULL);
+	if (strcmp(prev_translator, aux))
 	{
+		gchar *aux2;
+		
 		header_comment = po_message_comments (message);
-		po_message_set_comments (message,
-		g_strconcat(header_comment, gtranslator_header_get_translator(header), " ", "<",
-			    gtranslator_header_get_tr_email(header), ">", ",", " ", year, NULL));
+		aux2 = g_strconcat(header_comment, gtranslator_header_get_translator(header), " ", "<",
+				   gtranslator_header_get_tr_email(header), ">", ",", " ", year, NULL);
+		
+		po_message_set_comments (message, aux2);
+		g_free (aux2);
 	}
+	g_free (aux);
 
 	/*
          * Write the header's fields
          */
-	msgstr = po_header_set_field (msgstr, "Project-Id-Version", gtranslator_header_get_prj_id_version(header));
-	msgstr = po_header_set_field (msgstr, "PO-Revision-Date", gtranslator_header_get_po_date(header));
-	msgstr = po_header_set_field (msgstr, "Last-Translator",
-	g_strconcat(gtranslator_header_get_translator(header), " ", "<",
-		    gtranslator_header_get_tr_email(header), ">", NULL));
-	msgstr = po_header_set_field (msgstr, "Language-Team",
-	g_strconcat(gtranslator_header_get_language(header), " ", "<", 
-		    gtranslator_header_get_lg_email(header), ">", NULL));
-	msgstr = po_header_set_field (msgstr, "Content-Type",
-	g_strconcat(" text/plain;", " charset=", gtranslator_header_get_charset(header),NULL));
-	msgstr = po_header_set_field (msgstr, "Content-Transfer-Encoding", gtranslator_header_get_encoding(header));
+	msgstr = po_header_set_field (msgstr, "Project-Id-Version",
+				      gtranslator_header_get_prj_id_version(header));
+	msgstr = po_header_set_field (msgstr, "PO-Revision-Date",
+				      gtranslator_header_get_po_date(header));
+	
+	aux = g_strconcat (gtranslator_header_get_translator(header), " ", "<",
+			   gtranslator_header_get_tr_email(header), ">", NULL);
+	msgstr = po_header_set_field (msgstr, "Last-Translator", aux);
+	g_free (aux);
+	
+	aux = g_strconcat (gtranslator_header_get_language(header), " ", "<", 
+			   gtranslator_header_get_lg_email(header), ">", NULL);
+	msgstr = po_header_set_field (msgstr, "Language-Team", aux);
+	g_free (aux);
+	
+	aux = g_strconcat(" text/plain;", " charset=",
+			  gtranslator_header_get_charset(header),NULL);
+	msgstr = po_header_set_field (msgstr, "Content-Type", aux);
+	g_free (aux);
+	
+	msgstr = po_header_set_field (msgstr, "Content-Transfer-Encoding",
+				      gtranslator_header_get_encoding(header));
 	po_message_set_msgstr (message, msgstr);
-
-	/*
-	 * Let gettext do the work here
-	 */
-	if(!po_file_write(gtranslator_po_get_po_file(po), name, gettext_error_handler))
-		return FALSE;
-
-	/*
-	 * If we do append a suffix to the autogenerated files, then we'd
-	 *  also not disable the file saving entry and we don't also disable
-	 *   the save entry on simple compile testing -- check for filename
-	 *    equality.
-	 */
-	/*if((GtrPreferences.autosave && GtrPreferences.autosave_with_suffix &&
-	    	(po->autosave_timeout > 1)) ||
-	    !nautilus_strcmp(po->filename, name))
+	
+	if (!po_file_write (gtranslator_po_get_po_file (po),
+			    po->priv->filename, &handler))
 	{
-		gtk_widget_set_sensitive(gtranslator_menuitems->save, FALSE);
-		gtk_widget_set_sensitive(gtranslator_menuitems->t_save, FALSE);
-	}*/
+		g_set_error (error,
+			     GTR_PO_ERROR,
+			     GTR_PO_ERROR_FILENAME,
+			     _("There was an error writing the PO file: %s"),
+			     message_error);
+		return;
+	}
 	
-	//po->file_changed = FALSE;
-
-	/* If user GtrPreferences to, warn it about fuzzy mesages left */
-	/*if(GtrPreferences.warn_if_fuzzy && po->fuzzy)
+	/*
+	 * If the warn if fuzzy option is enabled we have to show an error
+	 */
+	/*if (gtranslator_prefs_manager_get_warn_if_fuzzy () && po->priv->fuzzy)
 	{
-		GtkWidget *dialog;
-
-		dialog = gtk_message_dialog_new(
-			GTK_WINDOW(window),
-			GTK_DIALOG_DESTROY_WITH_PARENT,
-			GTK_MESSAGE_WARNING,
-			GTK_BUTTONS_OK,
-			ngettext("File %s\ncontains %d fuzzy message", 
-				 "File %s\ncontains %d fuzzy messages", 
-				 po->fuzzy),
-			po->filename, po->fuzzy);
-		gtk_dialog_run(GTK_DIALOG(dialog));
-		gtk_widget_destroy(dialog);
+		g_set_error (error,
+			     GTR_PO_ERROR,
+			     GTR_PO_ERROR_OTHER,
+			     ngettext ("File %s\ncontains %d fuzzy message", 
+				       "File %s\ncontains %d fuzzy messages",
+				       po->priv->fuzzy), 
+				       po->priv->fuzzy);
 	}*/
-
-	return TRUE;
 }
 
 /**
@@ -627,6 +643,9 @@
 	po->priv->filename = g_strdup(data);
 }
 
+/*
+ * FIXME: We are not using this func.
+ */
 gboolean
 gtranslator_po_get_write_perms(GtranslatorPo *po)
 {
@@ -787,102 +806,160 @@
  * or NULL if there are not previously untranslated message.
  **/
 GList *
-gtranslator_po_get_prev_untrans(GtranslatorPo *po)
+gtranslator_po_get_prev_untrans (GtranslatorPo *po)
 {
 	GList *msg;
 
 	msg = po->priv->current;
-	while (msg = g_list_previous(msg))
+	while (msg = g_list_previous (msg))
 	{
-		if(!gtranslator_msg_is_translated(msg->data))
+		if(!gtranslator_msg_is_translated (msg->data))
 			return msg;
 	}
 
 	return NULL;
 }
 
+/**
+ * gtranslator_po_get_header:
+ * @po: a #GtranslatorPo
+ *
+ * Return value: The #GtranslatorHeader of the @po.
+ **/
 GtranslatorHeader *
 gtranslator_po_get_header(GtranslatorPo *po)
 {
+	g_return_val_if_fail (GTR_IS_PO (po), NULL);
+	
 	return po->priv->header;
 }
 
+/**
+ * gtranslator_po_get_translated_count:
+ * @po: a #GtranslatorPo
+ * 
+ * Return value: the count of the translated messages.
+ **/
 gint
-gtranslator_po_get_translated_count(GtranslatorPo *po)
+gtranslator_po_get_translated_count (GtranslatorPo *po)
 {
+	g_return_val_if_fail (GTR_IS_PO (po), -1);
+	
 	return po->priv->translated;
 }
 
+/*
+ * This func decrease or increase the count of translated 
+ * messages in 1.
+ * This funcs must not be exported.
+ */
 void
-gtranslator_po_increase_decrease_translated(GtranslatorPo *po,
-					    gboolean increase)
+_gtranslator_po_increase_decrease_translated (GtranslatorPo *po,
+					      gboolean increase)
 {
-	g_return_if_fail(GTR_IS_PO(po));
+	g_return_if_fail (GTR_IS_PO (po));
 	
-	if(increase)
+	if (increase)
 		po->priv->translated++;
 	else po->priv->translated--;
 }
 
+/**
+ * gtranslator_po_get_fuzzy_count:
+ * @po: a #GtranslatorPo
+ * 
+ * Return value: the count of the fuzzy messages.
+ **/
 gint
-gtranslator_po_get_fuzzy_count(GtranslatorPo *po)
+gtranslator_po_get_fuzzy_count (GtranslatorPo *po)
 {
+	g_return_val_if_fail (GTR_IS_PO (po), -1);
+	
 	return po->priv->fuzzy;
 }
 
+/*
+ * This func decrease or increase the count of fuzzy 
+ * messages in 1.
+ * This funcs must not be exported.
+ */
 void
-gtranslator_po_increase_decrease_fuzzy(GtranslatorPo *po,
-				       gboolean increase)
+_gtranslator_po_increase_decrease_fuzzy (GtranslatorPo *po,
+					 gboolean increase)
 {
-	g_return_if_fail(GTR_IS_PO(po));
+	g_return_if_fail (GTR_IS_PO (po));
 	
-	if(increase)
+	if (increase)
 		po->priv->fuzzy++;
 	else po->priv->fuzzy--;
 }
 
+/**
+ * gtranslator_po_get_untranslated_count:
+ * @po: a #GtranslatorPo
+ * 
+ * Return value: the count of the untranslated messages.
+ **/
 gint
-gtranslator_po_get_untranslated_count(GtranslatorPo *po)
+gtranslator_po_get_untranslated_count (GtranslatorPo *po)
 {
-	return (g_list_length(po->priv->messages) - po->priv->translated - po->priv->fuzzy);
+	g_return_val_if_fail (GTR_IS_PO (po), -1);
+	
+	return (g_list_length (po->priv->messages) - po->priv->translated - po->priv->fuzzy);
 }
 
+/**
+ * gtranslator_po_get_messages_count:
+ * @po: a #GtranslatorPo
+ * 
+ * Return value: the number of messages messages.
+ **/
 gint
-gtranslator_po_get_messages_count(GtranslatorPo *po)
+gtranslator_po_get_messages_count (GtranslatorPo *po)
 {
-	return g_list_length(po->priv->messages);
+	g_return_val_if_fail (GTR_IS_PO (po), -1);
+	
+	return g_list_length (po->priv->messages);
 }
 
+/**
+ * gtranslator_po_get_message_position:
+ * @po: a #GtranslatorPo
+ * 
+ * Return value: the number of the current message.
+ **/
 gint
-gtranslator_po_get_message_position(GtranslatorPo *po)
+gtranslator_po_get_message_position (GtranslatorPo *po)
 {
-	return gtranslator_msg_get_po_position(GTR_MSG(po->priv->current->data));
+	g_return_val_if_fail (GTR_IS_PO (po), -1);
+	
+	return gtranslator_msg_get_po_position (GTR_MSG (po->priv->current->data));
 }
 
 /**
  * gtranslator_po_check_po_file:
  * @po: a #GtranslatorPo
  *
- * Test whether an entire file PO file is valid, like msgfmt does it.
+ * Test whether an entire PO file is valid, like msgfmt does it.
  * Return value: If it is invalid, returns the error.
  **/
 const gchar *
-gtranslator_po_check_po_file(GtranslatorPo *po)
+gtranslator_po_check_po_file (GtranslatorPo *po)
 {
 	struct po_xerror_handler handler;
 	
-	g_return_val_if_fail(po != NULL, NULL);
+	g_return_val_if_fail (po != NULL, NULL);
 
 	handler.xerror = &on_gettext_po_xerror;
 	handler.xerror2 = &on_gettext_po_xerror2;
 	
-	if(message_error != NULL)
+	if (message_error != NULL)
 	{
-		g_free(message_error);
+		g_free (message_error);
 		message_error = NULL;
 	}
 	
-	po_file_check_all(po->priv->gettext_po_file, &handler);
+	po_file_check_all (po->priv->gettext_po_file, &handler);
 
 	return message_error;
 }

Modified: trunk/src/po.h
==============================================================================
--- trunk/src/po.h	(original)
+++ trunk/src/po.h	Tue Mar  4 00:24:23 2008
@@ -70,27 +70,29 @@
 {
 	GTR_PO_ERROR_GETTEXT,
 	GTR_PO_ERROR_FILENAME,
+	GTR_PO_ERROR_RECOVERY,
 	GTR_PO_ERROR_OTHER,
 };
 
 /*
  * Public methods
  */
-GQuark          gtranslator_po_error_quark		(void);
+GQuark		gtranslator_po_error_quark		(void);
 
 GType		gtranslator_po_get_type			(void) G_GNUC_CONST;
 
 GType		gtranslator_po_register_type		(GTypeModule * module);
 
-GtranslatorPo   *gtranslator_po_new			(void);
+GtranslatorPo	*gtranslator_po_new			(void);
 
-void            gtranslator_po_parse			(GtranslatorPo *po,
+void		gtranslator_po_parse			(GtranslatorPo *po,
 							const gchar *filename,
 							GError **error);
 
-gboolean	gtranslator_po_save_file		(GtranslatorPo *po,
-		      					const gchar *name,
-		      					GError **error);
+void		gtranslator_po_save_file           	(GtranslatorPo *po,
+							GError **error);
+
+gchar           *gtranslator_po_get_filename		(GtranslatorPo *po);
 
 gchar           *gtranslator_po_get_filename		(GtranslatorPo *po);
 
@@ -101,7 +103,7 @@
 
 GList           *gtranslator_po_get_messages		(GtranslatorPo *po);
 
-void		gtranslator_po_set_messages		(GtranslatorPo *po,
+void             gtranslator_po_set_messages		(GtranslatorPo *po,
 							GList *messages);
 
 GList           *gtranslator_po_get_current_message	(GtranslatorPo *po);
@@ -118,9 +120,29 @@
 
 GList           *gtranslator_po_get_prev_untrans	(GtranslatorPo *po);
 
-GtranslatorHeader	
+GtranslatorHeader  
 		*gtranslator_po_get_header		(GtranslatorPo *po);
 
+gint             gtranslator_po_get_translated_count	(GtranslatorPo *po);
+
+gint             gtranslator_po_get_fuzzy_count		(GtranslatorPo *po);
+
+gint             gtranslator_po_get_untranslated_count	(GtranslatorPo *po);
+
+gint             gtranslator_po_get_messages_count	(GtranslatorPo *po);
+
+gint             gtranslator_po_get_message_position	(GtranslatorPo *po);
+
+const gchar     *gtranslator_po_check_po_file		(GtranslatorPo *po);
+
+/* Unexported funcs */
+void            _gtranslator_po_increase_decrease_translated
+                                                       (GtranslatorPo *po,
+							gboolean increase);
+
+void            _gtranslator_po_increase_decrease_fuzzy(GtranslatorPo *po,
+							gboolean increase);
+
 G_END_DECLS
 
 #endif /* __PO_H__ */

Modified: trunk/src/statusbar.c
==============================================================================
--- trunk/src/statusbar.c	(original)
+++ trunk/src/statusbar.c	Tue Mar  4 00:24:23 2008
@@ -29,7 +29,8 @@
 
 #include "statusbar.h"
 
-#define GTR_STATUSBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GTR_TYPE_STATUSBAR, GtranslatorStatusbarPrivate))
+#define GTR_STATUSBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object),\
+					  GTR_TYPE_STATUSBAR, GtranslatorStatusbarPrivate))
 
 struct _GtranslatorStatusbarPrivate
 {
@@ -76,20 +77,20 @@
 	gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL);
 	
 	frame = gtk_frame_new (NULL);
-	gtk_frame_set_shadow_type (GTK_FRAME(frame), shadow_type);
+	gtk_frame_set_shadow_type (GTK_FRAME (frame), shadow_type);
 	gtk_widget_show (frame);
 	
 	statusbar->priv->overwrite_mode_label = gtk_label_new ("");
 	gtk_label_set_single_line_mode (GTK_LABEL (statusbar->priv->overwrite_mode_label), TRUE);
 	gtk_misc_set_alignment (GTK_MISC (statusbar->priv->overwrite_mode_label), 0.0, 0.5);
-	gtk_label_set_width_chars(GTK_LABEL(statusbar->priv->overwrite_mode_label),
-				  MAX(g_utf8_strlen(_("INS"), -1)+1, g_utf8_strlen(_("OVR"), -1)+1));
+	gtk_label_set_width_chars (GTK_LABEL (statusbar->priv->overwrite_mode_label),
+				  MAX (g_utf8_strlen(_("INS"), -1)+1, g_utf8_strlen (_("OVR"), -1)+1));
 						    
 	
 	gtk_container_add (GTK_CONTAINER (frame), statusbar->priv->overwrite_mode_label);
 	gtk_widget_show (statusbar->priv->overwrite_mode_label);
 	
-	gtk_box_pack_start(GTK_BOX(statusbar), frame, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (statusbar), frame, FALSE, FALSE, 0);
 	
 }
 

Modified: trunk/src/tab.c
==============================================================================
--- trunk/src/tab.c	(original)
+++ trunk/src/tab.c	Tue Mar  4 00:24:23 2008
@@ -332,38 +332,38 @@
 
 	if((status == GTR_MSG_STATUS_FUZZY) && !gtranslator_msg_is_fuzzy(msg))
 	{
-		gtranslator_po_increase_decrease_fuzzy(tab->priv->po, FALSE);
+		_gtranslator_po_increase_decrease_fuzzy(tab->priv->po, FALSE);
 		if(gtranslator_msg_is_translated(msg))
 		{
 			status = GTR_MSG_STATUS_TRANSLATED;
-			gtranslator_po_increase_decrease_translated(tab->priv->po, TRUE);
+			_gtranslator_po_increase_decrease_translated(tab->priv->po, TRUE);
 		}
 		else {
 			status = GTR_MSG_STATUS_UNTRANSLATED;
-			gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
+			_gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
 		}
 	}
 	else if((status == GTR_MSG_STATUS_TRANSLATED) && !gtranslator_msg_is_translated(msg))
 	{
 		status = GTR_MSG_STATUS_UNTRANSLATED;
-		gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
+		_gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
 	}
 	else if((status == GTR_MSG_STATUS_TRANSLATED) && gtranslator_msg_is_fuzzy(msg))
 	{
 		status = GTR_MSG_STATUS_FUZZY;
-		gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
-		gtranslator_po_increase_decrease_fuzzy(tab->priv->po, TRUE);
+		_gtranslator_po_increase_decrease_translated(tab->priv->po, FALSE);
+		_gtranslator_po_increase_decrease_fuzzy(tab->priv->po, TRUE);
 	}
 	else if((status == GTR_MSG_STATUS_UNTRANSLATED) && gtranslator_msg_is_translated(msg))
 	{
 		if(gtranslator_msg_is_fuzzy(msg))
 		{
 			status = GTR_MSG_STATUS_FUZZY;
-			gtranslator_po_increase_decrease_fuzzy(tab->priv->po, TRUE);
+			_gtranslator_po_increase_decrease_fuzzy(tab->priv->po, TRUE);
 		}
 		else {
 			status = GTR_MSG_STATUS_TRANSLATED;
-			gtranslator_po_increase_decrease_translated(tab->priv->po, TRUE);
+			_gtranslator_po_increase_decrease_translated(tab->priv->po, TRUE);
 		}
 	}
 

Modified: trunk/src/tab.h
==============================================================================
--- trunk/src/tab.h	(original)
+++ trunk/src/tab.h	Tue Mar  4 00:24:23 2008
@@ -99,8 +99,7 @@
 
 gint                   gtranslator_tab_get_active_trans_tab(GtranslatorTab *tab);
 
-GtranslatorCommentPanel 
-                      *gtranslator_tab_get_comment_panel   (GtranslatorTab *tab);
+GtranslatorCommentPanel *gtranslator_tab_get_comment_panel   (GtranslatorTab *tab);
 
 GtranslatorView       *gtranslator_tab_get_active_view     (GtranslatorTab *tab);
 

Modified: trunk/src/window.c
==============================================================================
--- trunk/src/window.c	(original)
+++ trunk/src/window.c	Tue Mar  4 00:24:23 2008
@@ -1031,6 +1031,7 @@
 {
 	gchar *uri, *path;
 	GError *error = NULL;
+	GtkWidget *dialog;
 
 	uri = gtk_recent_chooser_get_current_uri (chooser);
 
@@ -1043,18 +1044,23 @@
 		return;
 	}
 	
-	
+	/*
+	 * FIXME: We have to detect if the file is already opened
+	 * If it is we should display a warning dialog.
+	 */
 	gtranslator_open (path, window, &error);
 	if(error)
 	{
 		/*
 		 * We have to show the error in a dialog
 		 */
-		gtk_message_dialog_new(GTK_WINDOW(window),          
-				      GTK_DIALOG_DESTROY_WITH_PARENT,
-				      GTK_MESSAGE_ERROR,
-				      GTK_BUTTONS_CLOSE,
-				      error->message);
+		dialog = gtk_message_dialog_new(GTK_WINDOW(window),          
+						GTK_DIALOG_DESTROY_WITH_PARENT,
+						GTK_MESSAGE_ERROR,
+						GTK_BUTTONS_CLOSE,
+						error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
 
 		if(error->code == GTR_PO_ERROR_FILENAME)
 			gtranslator_recent_remove (window, path);
@@ -1703,3 +1709,49 @@
 	
 	return G_OBJECT (window->priv->layout_manager);
 }
+
+GtkWidget *
+gtranslator_window_get_tab_from_uri (GtranslatorWindow *window,
+				     const gchar *uri)
+{
+	GList *tabs;
+	GtranslatorPo *po;
+	const gchar *po_uri;
+	
+	g_return_if_fail (GTR_IS_WINDOW (window));
+	
+	gchar *good_uri = g_filename_from_uri (uri, NULL, NULL);
+
+	tabs = gtranslator_window_get_all_tabs (window);
+	
+	while (tabs != NULL)
+	{
+		po = gtranslator_tab_get_po (GTR_TAB (tabs->data));
+		
+		po_uri = gtranslator_po_get_filename (po);
+	
+		if (g_utf8_collate (good_uri, po_uri) == 0)
+		{
+			g_free (good_uri);
+			return tabs->data;
+		}
+		
+		tabs = tabs->next;
+	}
+	
+	g_free (good_uri);
+	return NULL;
+}
+
+void
+gtranslator_window_set_active_tab (GtranslatorWindow *window,
+				   GtkWidget *tab)
+{
+	gint page;
+	
+	page = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
+				      tab);
+	
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
+				       page);
+}

Modified: trunk/src/window.h
==============================================================================
--- trunk/src/window.h	(original)
+++ trunk/src/window.h	Tue Mar  4 00:24:23 2008
@@ -91,10 +91,8 @@
 
 GList            *gtranslator_window_get_all_tabs     (GtranslatorWindow *window);
 
-GtranslatorNotebook
-                 *gtranslator_window_get_notebook     (GtranslatorWindow *window);
-GtranslatorHeader
-		*gtranslator_window_get_header_from_active_tab (GtranslatorWindow *window);
+GtranslatorNotebook *gtranslator_window_get_notebook     (GtranslatorWindow *window);
+GtranslatorHeader *gtranslator_window_get_header_from_active_tab (GtranslatorWindow *window);
 
 GtkStatusbar 	 *gtranslator_window_get_statusbar    (GtranslatorWindow *window);
 
@@ -129,6 +127,12 @@
 GObject *        _gtranslator_window_get_layout_manager
 						      (GtranslatorWindow *window);
 
+GtkWidget        *gtranslator_window_get_tab_from_uri (GtranslatorWindow *window,
+						       const gchar *uri);
+
+void              gtranslator_window_set_active_tab   (GtranslatorWindow *window,
+						       GtkWidget *tab);
+
 G_END_DECLS
 
 #endif /* __WINDOW_H__ */



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