Patch - Scale nautilus icons from the properties dialog



Instead of waiting until someone implemented my proposals about the nautilus context menu, I tried to do it myself. It works, somehow, but there are still a lot of thing I need to do.

I hope you can give me some suggestions and hints for the attached patch. Maybe it gets included someday. Especialy the ui needs some work I think. It doesn't look good right now.

This patch adds the ability to scale the nautilus icons from within the properties dialog. It also works for multiple files, making it possible for multiple icons to have exactly the same size.

Though there are some issues: For some reason, the icon view does not get updated after the scale. And I'm not sure how to handle different icon-sizes. I guess I have to calculate the scale factor for every single file.

The scale limits are hard-coded right now. I probably should use NAUTILUS_ICON_SIZE_LARGEST and SMALLEST. This will be the next step.

Suggestions and help is appreciated,
Raphael
--- nautilus-2.7.4/src/file-manager/fm-properties-window.c	2004-08-16 12:23:29.000000000 +0200
+++ nautilus-2.7.4-work/src/file-manager/fm-properties-window.c	2004-09-07 22:46:51.422732152 +0200
@@ -93,6 +93,8 @@ struct FMPropertiesWindowDetails {	
 	GtkNotebook *notebook;
 	GtkWidget *remove_image_button;
 	GtkWidget *icon_selector_window;
+
+
 	
 	GtkTable *basic_table;
 	GtkTable *permissions_table;
@@ -104,6 +106,8 @@ struct FMPropertiesWindowDetails {	
 
 	GtkLabel *directory_contents_title_field;
 	GtkLabel *directory_contents_value_field;
+
+
 	guint update_directory_contents_timeout_id;
 	guint update_files_timeout_id;
 
@@ -452,6 +456,68 @@ reset_icon (FMPropertiesWindow *properti
 	gtk_widget_set_sensitive (properties_window->details->remove_image_button, FALSE);
 }
 
+static gboolean
+icon_size_set_initial_value(GtkRange *icon_scaler,
+		     FMPropertiesWindow *properties_window)
+{
+	GList *l;
+	gdouble value;
+	l = properties_window->details->original_files;
+	if(g_list_length(l) > 1) {
+		value = 1.0;
+	} else {
+		NautilusFile *file;
+		gchar *scale;
+		
+		file = NAUTILUS_FILE (l->data);
+	
+		scale = nautilus_file_get_metadata (file,
+					    NAUTILUS_METADATA_KEY_ICON_SCALE,
+					    NULL);
+		if(scale) {
+			g_printf("SCALE::: %s\n", scale);
+			value = atol(scale);		
+			g_free(scale);
+
+		} else {
+			value = 1.0;	
+		}
+						
+	}
+	gtk_range_set_value(icon_scaler, value);
+	
+	return TRUE;
+}
+
+
+
+static gboolean 
+icon_scaler_value_changed (GtkRange *icon_scaler,
+		     FMPropertiesWindow *properties_window)
+{
+	GList *l;
+	gdouble value = gtk_range_get_value(icon_scaler);
+	gchar scale[100];
+	g_ascii_dtostr(scale, 100, value);
+
+	g_printf("scale::%s\n", scale);						
+
+	for (l = properties_window->details->original_files; l != NULL; l = l->next) {
+		NautilusFile *file;
+		
+		file = NAUTILUS_FILE (l->data);
+
+		nautilus_file_set_metadata (file,
+					    NAUTILUS_METADATA_KEY_ICON_SCALE,
+					    NULL, scale);
+	
+	}
+
+
+	g_free(scale);	
+	return FALSE;
+}
+
 
 static void  
 fm_properties_window_drag_data_received (GtkWidget *widget, GdkDragContext *context,
@@ -735,6 +801,11 @@ name_field_focus_out (NautilusEntry *nam
 	return FALSE;
 }
 
+
+
+
+
+
 static void
 name_field_activate (NautilusEntry *name_field, gpointer callback_data)
 {
@@ -2227,7 +2298,12 @@ create_basic_page (FMPropertiesWindow *w
 	GtkWidget *icon_aligner;
 	GtkWidget *icon_pixmap_widget;
 
-	GtkWidget *hbox, *name_label;
+	GtkWidget *icon_size_scaler;
+	GtkWidget *icon_size_title_field;	
+
+
+	GtkWidget *hbox, *name_label, *vbox;
+	
 
 	create_page_with_table_in_vbox (window->details->notebook, 
 					_("Basic"), 
@@ -2238,7 +2314,9 @@ create_basic_page (FMPropertiesWindow *w
 	
 	/* Icon pixmap */
 	hbox = gtk_hbox_new (FALSE, 4);
+	vbox = gtk_vbox_new (FALSE, 4);
 	gtk_widget_show (hbox);
+	gtk_widget_show (vbox);
 	gtk_table_attach (table,
 			  hbox,
 			  TITLE_COLUMN, 
@@ -2254,7 +2332,29 @@ create_basic_page (FMPropertiesWindow *w
 	gtk_widget_show (icon_aligner);
 	
 	gtk_container_add (GTK_CONTAINER (icon_aligner), icon_pixmap_widget);
-	gtk_box_pack_start (GTK_BOX (hbox), icon_aligner, TRUE, TRUE, 0);
+
+	gtk_box_pack_start (GTK_BOX (vbox), icon_aligner, TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+
+	/* Resize file icon */
+	icon_size_scaler = gtk_hscale_new_with_range (	0.5, 5,	1);
+														
+	g_object_set(icon_size_scaler, "draw-value", FALSE);
+
+	icon_size_title_field = gtk_label_new (_("Icon Size"));
+	
+	eel_gtk_label_make_bold (GTK_LABEL (icon_size_title_field));	
+
+	gtk_box_pack_end (GTK_BOX (vbox), icon_size_scaler, TRUE, TRUE, 0);
+	gtk_box_pack_end (GTK_BOX (vbox), icon_size_title_field, TRUE, TRUE, 0);
+
+	icon_size_set_initial_value(GTK_RANGE(icon_size_scaler), window);
+
+	gtk_widget_show (icon_size_scaler);
+	gtk_widget_show (icon_size_title_field);
+	g_signal_connect(icon_size_scaler, "value-changed",
+				 G_CALLBACK (icon_scaler_value_changed), window);   	
 
 	/* Name label */
 	if (is_multi_file_window (window)) {
@@ -2306,6 +2406,8 @@ create_basic_page (FMPropertiesWindow *w
 		nautilus_entry_select_all (NAUTILUS_ENTRY (name_field));
 	        gtk_widget_grab_focus (GTK_WIDGET (name_field));
         }
+
+
         
 	if (should_show_file_type (window)) {
 		append_title_value_pair (window,


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