gnome-launch-box r243 - in trunk: . src



Author: herzi
Date: Mon Mar  9 12:28:15 2009
New Revision: 243
URL: http://svn.gnome.org/viewvc/gnome-launch-box?rev=243&view=rev

Log:
2009-03-09  Sven Herzberg  <herzi lanedo com>

	Bug 566316 â Makes open in default application first action for file
	items
	GLB-22

	Patch written by David Siegel and fixed by Pietro Battiston

	* src/lb-module-files.c (module_files_add_actions): properly prefer
	the default application over others


Modified:
   trunk/ChangeLog
   trunk/src/lb-module-files.c

Modified: trunk/src/lb-module-files.c
==============================================================================
--- trunk/src/lb-module-files.c	(original)
+++ trunk/src/lb-module-files.c	Mon Mar  9 12:28:15 2009
@@ -228,8 +228,9 @@
 			  LbItem   *item)
 {
 	LbItemFile              *item_file;
-	GList                   *applications;
-	GList                   *list;
+	GList                   *applications = NULL;
+	GList                   *actions = NULL;
+	GList                   *list = NULL;
 	const gchar             *mime_type;
 	GnomeVFSMimeApplication *default_application;
 
@@ -287,21 +288,26 @@
 				  G_CALLBACK (module_files_activate_action),
 				  module);
 
-		lb_item_add_action (item, action);
-
-		g_object_unref (action);
-
-#if 0 /* FIXME: Should increase relevance of an action if it's the default
-	 action */
+		// We want the default application to be the first action so
+		// we construct a list of actions with the default at the
+		// head. We add the actions to the item later.
 		if (gnome_vfs_mime_application_equal (application, default_application)) {
-			default_action = action;
-		} else {
 			actions = g_list_prepend (actions, action);
+		} else {
+			actions = g_list_append (actions, action);
 		}
-#endif
 	}
-
 	g_list_free (applications);
+
+	// Now that we have the list of actions with the default application at
+	// the head of the list, add the actions to the item.
+	for (list = actions; list; list = list->next) {
+		LbAction	*action = LB_ACTION (list->data);
+
+		lb_item_add_action (item, action);
+		g_object_unref (action);
+	}
+	g_list_free (actions);
 }
 
 static void



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