[gnome-utils] [gsearchtool] clean up code



commit 597853fb81dd433c5f2c20fe6fa9313cc192a0fa
Author: Dennis Cranston <Dennis_Cranston yahoo com>
Date:   Wed Apr 29 21:30:21 2009 -0700

    [gsearchtool] clean up code
    
    gsearchtool-callbacks.c (build_popup_menu_for_file):  cleanup
    the code a little.
---
 gsearchtool/ChangeLog               |    5 +++
 gsearchtool/gsearchtool-callbacks.c |   52 +++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/gsearchtool/ChangeLog b/gsearchtool/ChangeLog
index c4dcf2a..da92f2c 100644
--- a/gsearchtool/ChangeLog
+++ b/gsearchtool/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-29  Dennis Cranston  <dennis_cranston yahoo com>
+
+	* gsearchtool-callbacks.c (build_popup_menu_for_file):  
+	Clean up the code.
+	
 2009-04-28  Dennis Cranston  <dennis_cranston yahoo com>
 
 	* gsearchtool-callbacks.c (build_popup_menu_for_file):  
diff --git a/gsearchtool/gsearchtool-callbacks.c b/gsearchtool/gsearchtool-callbacks.c
index 9dc0119..81de1d2 100644
--- a/gsearchtool/gsearchtool-callbacks.c
+++ b/gsearchtool/gsearchtool-callbacks.c
@@ -1033,18 +1033,33 @@ build_popup_menu_for_file (GSearchWindow * gsearch,
 		list = g_app_info_get_all_for_type (g_file_info_get_content_type (file_info));
 
 		list_length = g_list_length (list);
-	
-		if (list_length >= 3) { /* Sort all except first application by name */
-			GList * tmp;
 
-			tmp = g_list_first (list);
-			list = g_list_remove_link (list, tmp);
-			list = g_list_sort (list, open_with_list_sort);
-			list = g_list_prepend (list, tmp->data);
-			g_list_free (tmp);
+		if (list_length <= 0) {
+
+			/* Popup menu item: Open */
+			new1 = gtk_image_menu_item_new_with_mnemonic  (_("_Open"));
+			gtk_container_add (GTK_CONTAINER (gsearch->search_results_popup_menu), new1);
+			gtk_widget_show (new1);
+
+			image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
+			gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (new1), image1);
+			gtk_widget_show (image1);
+
+			g_signal_connect (G_OBJECT (new1),
+			                  "activate",
+			                  G_CALLBACK (open_file_cb),
+		        	          (gpointer) gsearch);
 		}
-		
-		if (list_length > 0) {
+		else {
+			if (list_length >= 3) { /* Sort all except first application by name */
+				GList * tmp;
+
+				tmp = g_list_first (list);
+				list = g_list_remove_link (list, tmp);
+				list = g_list_sort (list, open_with_list_sort);
+				list = g_list_prepend (list, tmp->data);
+				g_list_free (tmp);
+			}
 		
 			/* Popup menu item: Open with (default) */
 			str = g_strdup_printf ("_Open with \"%s\"",  g_app_info_get_name (list->data));
@@ -1118,21 +1133,6 @@ build_popup_menu_for_file (GSearchWindow * gsearch,
 				gtk_widget_show (separatormenuitem1);
 			}
 		}
-		else {
-			/* Popup menu item: Open */
-			new1 = gtk_image_menu_item_new_with_mnemonic  (_("_Open"));
-			gtk_container_add (GTK_CONTAINER (gsearch->search_results_popup_menu), new1);
-			gtk_widget_show (new1);
-
-			image1 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
-			gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (new1), image1);
-			gtk_widget_show (image1);
-
-			g_signal_connect (G_OBJECT (new1),
-			                  "activate",
-			                  G_CALLBACK (open_file_cb),
-		        	          (gpointer) gsearch);
-		}
 	}
 
 	/* Popup menu item: Open Folder */



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