gtranslator r3820 - in trunk: . src



Author: psanxiao
Date: Tue Oct 14 19:09:22 2008
New Revision: 3820
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3820&view=rev

Log:
	* src/utils.{ch}:
	Added function to shorten a path

	* src/window.c:
	Use the shorten path of the file to
	show it in the recent files menu.



Modified:
   trunk/ChangeLog
   trunk/src/utils.c
   trunk/src/utils.h
   trunk/src/window.c

Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c	(original)
+++ trunk/src/utils.c	Tue Oct 14 19:09:22 2008
@@ -928,3 +928,21 @@
 		}
 	}
 }
+
+gchar *
+gtranslator_utils_reduce_path (const gchar *path)
+{
+  gchar *new_str;
+  gchar **array;
+  
+  array = g_strsplit (path, "/", -1);
+
+  new_str = g_strconcat (array[1], "/../", array[g_strv_length (array)-1], NULL);
+  
+  if (strlen (new_str) >= 30)
+    {
+      g_free (new_str);
+      new_str = g_strconcat ("../", array[g_strv_length (array)-1], NULL);
+    }
+  return new_str;
+}

Modified: trunk/src/utils.h
==============================================================================
--- trunk/src/utils.h	(original)
+++ trunk/src/utils.h	Tue Oct 14 19:09:22 2008
@@ -83,14 +83,16 @@
 						       
 gchar         *gtranslator_utils_get_user_config_dir  (void);
 
-gchar         *gtranslator_utils_get_current_date (void);
+gchar         *gtranslator_utils_get_current_date     (void);
 
-gchar         *gtranslator_utils_get_current_time (void);
+gchar         *gtranslator_utils_get_current_time     (void);
 
-gchar         *gtranslator_utils_get_current_year (void);
+gchar         *gtranslator_utils_get_current_year     (void);
 
-void           gtranslator_utils_scan_dir              (GFile *dir,
-							GSList **list,
-							const gchar *po_name);
+void           gtranslator_utils_scan_dir             (GFile *dir,
+						       GSList **list,
+						       const gchar *po_name);
+
+gchar *        gtranslator_utils_reduce_path        (const gchar *path);
 
 #endif

Modified: trunk/src/window.c
==============================================================================
--- trunk/src/window.c	(original)
+++ trunk/src/window.c	Tue Oct 14 19:09:22 2008
@@ -1079,12 +1079,16 @@
 	GtkRecentData *recent_data;
 	gchar *uri;
 	GError *error = NULL;
+	gchar *path;
+	gchar *display_name;
 
 	uri = g_file_get_uri (location);
+	path = g_file_get_path (location);
+	display_name = gtranslator_utils_reduce_path ((const gchar *)path);
 
 	recent_data = g_slice_new (GtkRecentData);
 
-	recent_data->display_name   = project_id;
+	recent_data->display_name   = display_name;
 	recent_data->description    = NULL;
 	recent_data->mime_type      = "text/x-gettext-translation";
 	recent_data->app_name       = (gchar *) g_get_application_name ();
@@ -1100,6 +1104,8 @@
 	}
 
 	g_free (uri);
+	g_free (path);
+	g_free (display_name);
 	g_free (recent_data->app_exec);
 	g_slice_free (GtkRecentData, recent_data);
 }
@@ -1165,6 +1171,7 @@
 	gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (recent_menu), FALSE);
 	gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu), GTK_RECENT_SORT_MRU);
 	gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (recent_menu), TRUE);
+	gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (recent_menu), TRUE);
 
 	filter = gtk_recent_filter_new ();
 	gtk_recent_filter_add_application (filter, g_get_application_name());



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