Shortening `Open with <foo>' buttons in sidebar (sample patch included)



One thing that I never likek about the appearance of the sidebar is that
the displayed `Open with <application>' buttons are often wider than the
sidebar itself.  The attached patch is meant to demonstrate a possible
solution to this problem.

Note 1: Because I just downloaded the source of nautilus today and didn't
        have the courage yet to compile it the patch is completely
        untested.

Note 2: Two of the changed lines only remove superfluous tabs from the end
        of the line.  I wasn't completely sure whether I could simply edit
        them out without messing up the patch.

Index: nautilus-sidebar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-sidebar.c,v
retrieving revision 1.210
diff -p -u -r1.210 nautilus-sidebar.c
--- nautilus-sidebar.c	5 Apr 2002 15:34:45 -0000	1.210
+++ nautilus-sidebar.c	27 Apr 2002 18:53:32 -0000
@@ -218,7 +218,7 @@ make_button_box (NautilusSidebar *sideba
 			    	     GTK_WIDGET (sidebar->details->button_box_centerer));
 
 	sidebar->details->button_box = GTK_VBOX (nautilus_keep_last_vertical_box_new (GNOME_PAD_SMALL));
-	gtk_container_set_border_width (GTK_CONTAINER (sidebar->details->button_box), GNOME_PAD);				
+	gtk_container_set_border_width (GTK_CONTAINER (sidebar->details->button_box), GNOME_PAD);
 	gtk_widget_show (GTK_WIDGET (sidebar->details->button_box));
 	gtk_box_pack_start (GTK_BOX (sidebar->details->button_box_centerer),
 			    GTK_WIDGET (sidebar->details->button_box),
@@ -1352,18 +1352,23 @@ add_command_buttons (NautilusSidebar *si
 {
 	char *id_string, *temp_str, *file_path;
 	GList *p;
+	GtkWidget *header_label;
 	GtkWidget *temp_button;
 	GnomeVFSMimeApplication *application;
 
-	/* There's always at least the "Open with..." button */
+	/* There's always at least the "An Application..." button */
 	sidebar->details->has_buttons = TRUE;
 
+	header_label = gtk_label_new (_("Open with:"));
+	gtk_widget_show(header_label);
+	gtk_misc_set_alignment(GTK_MISC (header_label), 0.5, 0.5);
+	gtk_box_pack_start (GTK_BOX (sidebar->details->button_box),
+			    header_label, FALSE, FALSE, 0);
+
 	for (p = application_list; p != NULL; p = p->next) {
 	        application = p->data;	        
 
-		temp_str = g_strdup_printf (_("Open with %s"), application->name);
-	        temp_button = gtk_button_new_with_label (temp_str);
-		g_free (temp_str);
+	        temp_button = gtk_button_new_with_label (application->name);
 		gtk_box_pack_start (GTK_BOX (sidebar->details->button_box), 
 				    temp_button, 
 				    FALSE, FALSE, 
@@ -1376,7 +1381,7 @@ add_command_buttons (NautilusSidebar *si
 		} 
 
 		temp_str = g_shell_quote (file_path);		
-		id_string = eel_str_replace_substring (application->id, "%s", temp_str); 		
+		id_string = eel_str_replace_substring (application->id, "%s", temp_str);
 		g_free (file_path);
 		g_free (temp_str);
 
@@ -1390,7 +1395,9 @@ add_command_buttons (NautilusSidebar *si
 	}
 
 	/* Catch-all button after all the others. */
-	temp_button = gtk_button_new_with_label (_("Open with..."));
+	temp_button = gtk_button_new_with_label (application_list == NULL
+						 ? _("An Application...")
+						 : _("Other Application..."));
 	g_signal_connect (temp_button, "clicked",
 			  G_CALLBACK (open_with_callback), NULL);
 	g_object_set_data (G_OBJECT (temp_button), "user_data", sidebar);
Gruss,
Lars

-- 
[ Lars Weber ]------< me @ lars.in-berlin.de >----[ GPG-ID: 1383B42E ]
+++ fingerprint: 44B1 1D23 DD53 E6B2 4AAB 4C36 0323 9141 1383 B42E +++
[ Using GNU ]----< www.gnu.org | www.debian.org >---[ Running Debian ]


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