Index: mail/ChangeLog
===================================================================
--- mail/ChangeLog	(revision 37297)
+++ mail/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-02-20  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #572543
+
+	* em-popup.c: (emp_standard_menu_factory):
+	Always look for alternative apps for application/octet-stream.
+
 2009-02-11  Andre Klapper  <a9016009@gmx.de>
 
 	* em-folder-browser.c:
Index: mail/em-popup.c
===================================================================
--- mail/em-popup.c	(revision 37297)
+++ mail/em-popup.c	(working copy)
@@ -799,15 +799,23 @@ emp_standard_menu_factory(EPopup *emp, v
 		apps = g_app_info_get_all_for_type (cp ? cp : mime_type);
 		g_free (cp);
 
-		if (apps == NULL && strcmp (mime_type, "application/octet-stream") == 0) {
+		if (apps == NULL || strcmp (mime_type, "application/octet-stream") == 0) {
 			if (filename != NULL) {
+				GList *alt_apps;
 				gchar *name_type;
 
 				name_type = e_util_guess_mime_type (filename, FALSE);
 				cp = g_content_type_from_mime_type (name_type);
-				apps = g_app_info_get_all_for_type (cp ? cp : name_type);
+				alt_apps = g_app_info_get_all_for_type (cp ? cp : name_type);
 				g_free (cp);
 				g_free (name_type);
+
+				if (alt_apps) {
+					/* show alternative apps first */
+					alt_apps = g_list_concat (alt_apps, apps);
+					g_list_free (apps);
+					apps = alt_apps;
+				}
 			}
 		}
 
Index: calendar/gui/e-cal-popup.c
===================================================================
--- calendar/gui/e-cal-popup.c	(revision 37297)
+++ calendar/gui/e-cal-popup.c	(working copy)
@@ -401,15 +401,23 @@ ecalp_standard_menu_factory (EPopup *eca
 		apps = g_app_info_get_all_for_type (cp ? cp : mime_type);
 		g_free (cp);
 
-		if (apps == NULL && strcmp(mime_type, "application/octet-stream") == 0) {
+		if (apps == NULL || strcmp(mime_type, "application/octet-stream") == 0) {
 			if (filename) {
+				GList *alt_apps;
 				gchar *name_type;
 
 				name_type = e_util_guess_mime_type (filename, FALSE);
 				cp = g_content_type_from_mime_type (name_type);
-				apps = g_app_info_get_all_for_type (cp ? cp : name_type);
+				alt_apps = g_app_info_get_all_for_type (cp ? cp : name_type);
 				g_free (cp);
 				g_free (name_type);
+
+				if (alt_apps) {
+					/* show alternative apps first */
+					alt_apps = g_list_concat (alt_apps, apps);
+					g_list_free (apps);
+					apps = alt_apps;
+				}
 			}
 		}
 		g_free (mime_type);
Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 37297)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-02-20  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #572543
+
+	* gui/e-cal-popup.c: (ecalp_standard_menu_factory):
+	Always look for alternative apps for application/octet-stream.
+
 2009-02-19  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes part of bug #572348
