gtranslator r3707 - trunk/src/dialogs



Author: icq
Date: Mon Sep 22 09:44:05 2008
New Revision: 3707
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3707&view=rev

Log:
	* dialogs/preferences-dialog:
	(setup_tm_pages):
	Added check to know if there is active profile before
	fill the lang_tm_entry by default.
	* dialogs/profile-dialog:
	(save_new_profile):
	Added check to know if the profiles list is empty and if so
	creating it and set the profile as active.

	Now when there is no profile and try to access to preferences
	the program does not crash. (Fixed #548846).

Modified:
   trunk/src/dialogs/preferences-dialog.c
   trunk/src/dialogs/profile-dialog.c

Modified: trunk/src/dialogs/preferences-dialog.c
==============================================================================
--- trunk/src/dialogs/preferences-dialog.c	(original)
+++ trunk/src/dialogs/preferences-dialog.c	Mon Sep 22 09:44:05 2008
@@ -445,6 +445,8 @@
   gtk_list_store_clear (GTK_LIST_STORE (model));
   
   profiles_list = gtranslator_application_get_profiles (GTR_APP);
+
+  
   active_profile = gtranslator_application_get_active_profile (GTR_APP);
   
   for (l = profiles_list; l; l = l->next) {
@@ -524,7 +526,7 @@
 		"expand", 
 		TRUE,
 		NULL);
-
+	
   gtranslator_preferences_fill_profile_treeview (dlg,GTK_TREE_MODEL(model));
 }
 
@@ -839,21 +841,23 @@
 {
   GtranslatorProfile *profile;
   gchar *language_code;
-  const gchar *filename;
-
-  profile = gtranslator_application_get_active_profile (GTR_APP);
-  language_code = gtranslator_profile_get_language_code (profile);
-  filename = (const gchar*)g_strconcat (language_code, ".po", NULL);
-  
+  const gchar *filename = NULL;
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->show_tm_options_checkbutton),
 				gtranslator_prefs_manager_get_show_tm_options ());
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->use_lang_profile_in_tm),
 				gtranslator_prefs_manager_get_use_lang_profile ());
-
-  gtk_entry_set_text (GTK_ENTRY (dlg->priv->tm_lang_entry),
-		      filename);
+  
+  profile = gtranslator_application_get_active_profile (GTR_APP);
+  
+  if (profile != NULL) {
+    language_code = gtranslator_profile_get_language_code (profile);
+    filename = (const gchar*)g_strconcat (language_code, ".po", NULL);
+    
+    gtk_entry_set_text (GTK_ENTRY (dlg->priv->tm_lang_entry),
+			filename);
+  }
 
   gtranslator_prefs_manager_set_tm_lang_entry (filename);
   

Modified: trunk/src/dialogs/profile-dialog.c
==============================================================================
--- trunk/src/dialogs/profile-dialog.c	(original)
+++ trunk/src/dialogs/profile-dialog.c	Mon Sep 22 09:44:05 2008
@@ -250,7 +250,14 @@
     /*
      * Add new profile to profiles list in memory
      */
-    g_list_append (profiles_list, profile);
+    if (profiles_list == NULL) {
+      GList *initial_list = NULL;
+      initial_list = g_list_append (profiles_list, profile);
+      gtranslator_application_set_active_profile (GTR_APP, profile);
+      gtranslator_application_set_profiles (GTR_APP, initial_list); 
+    } else {
+      g_list_append (profiles_list, profile);
+    }   
   }
   
   /*



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