eog r4722 - in trunk: . src



Author: friemann
Date: Tue Sep  2 16:49:43 2008
New Revision: 4722
URL: http://svn.gnome.org/viewvc/eog?rev=4722&view=rev

Log:
2008-09-02  Felix Riemann  <friemann svn gnome org>

	* src/eog-window.c: (sort_recents_mru),
	(eog_window_update_recent_files_menu):
	Use Evince's recent files sorting code and modify it to use the
	timestamps made by EOG for sorting. This keeps other apps from
	affecting EOG's sort order. Fixes bug #550252.


Modified:
   trunk/ChangeLog
   trunk/src/eog-window.c

Modified: trunk/src/eog-window.c
==============================================================================
--- trunk/src/eog-window.c	(original)
+++ trunk/src/eog-window.c	Tue Sep  2 16:49:43 2008
@@ -3488,7 +3488,39 @@
 static gint
 sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
 {
-	return (gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a));
+	gboolean has_eog_a, has_eog_b;
+	
+	/* We need to check this first as gtk_recent_info_get_application_info
+	 * will treat it as a non-fatal error when the GtkRecentInfo doesn't
+	 * have the application registered. */
+	has_eog_a = gtk_recent_info_has_application (a,
+						     EOG_RECENT_FILES_APP_NAME);
+	has_eog_b = gtk_recent_info_has_application (b,
+						     EOG_RECENT_FILES_APP_NAME);
+	if (has_eog_a && has_eog_b) {
+		time_t time_a, time_b;
+
+		/* These should not fail as we already checked that 
+		 * the application is registered with the info objects */
+		gtk_recent_info_get_application_info (a,
+						      EOG_RECENT_FILES_APP_NAME,
+						      NULL,
+						      NULL,
+						      &time_a);
+		gtk_recent_info_get_application_info (b,
+						      EOG_RECENT_FILES_APP_NAME,
+						      NULL,
+						      NULL,
+						      &time_b);
+
+		return (time_b - time_a);
+	} else if (has_eog_a) {
+		return -1;
+	} else if (has_eog_b) {
+		return 1;
+	}
+
+	return 0;
 }
 
 static void
@@ -3530,8 +3562,10 @@
 		GtkRecentInfo *info = li->data;
 		gboolean is_rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL);
 
+		/* Sorting moves non-EOG files to the end of the list.
+		 * So no file of interest will follow if this test fails */
 		if (!gtk_recent_info_has_application (info, EOG_RECENT_FILES_APP_NAME))
-			continue;
+			break;
 
 		count_recent++;
 



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