Stretch/scale icon through the properties window



Hello again,

this is another try with my "resize the file icon through the properties window". I rewrote the whole patch to fit into the general coding style used in fm-properties-window.h.

It will allow a user to strech/resize the file's icon through the properties window. This has several advantages over the "old" way, though it's not so "direct manipulation" anymore. You can still resize the icons the old way, however.

- Multiple icons can be stretched at once
- Icons can have exactly the same size

It's also more accessible than the old method.

There is one issue I was unable to fix, though: The icons will now be updated. I asked for help a few month ago, but some minor annoyances (school) distraced me from actualy fixing this issue. Help is still appreciated.

Thanks,
Raphael
--- nautilus-2.9.91/src/file-manager/fm-properties-window.c	2005-02-08 18:19:06.000000000 +0100
+++ nautilus-work/src/file-manager/fm-properties-window.c	2005-03-02 00:25:34.839280208 +0100
@@ -452,6 +452,64 @@
 	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);
+		g_printf("scale::: %s\n", scale);				
+		if(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);
+
+	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,
@@ -1331,6 +1389,21 @@
 	return GTK_LABEL (label_field);
 }	      
 
+static void
+attach_widget (	GtkTable *table,
+				int row,
+				int column,
+				GtkWidget *widget)
+{
+	gtk_table_attach (table, widget,
+			  column, column + 1,
+			  row, row + 1,
+			  GTK_FILL,
+			  0,
+			  0, 0);
+
+}
+
 static GtkLabel *
 attach_value_label (GtkTable *table,
 	      		  int row,
@@ -1970,6 +2043,20 @@
 	return last_row;
 }
 
+static guint 
+append_title_and_widget (FMPropertiesWindow *window,
+					GtkTable *table,
+					const char *title,
+					GtkWidget *widget)
+{
+	guint last_row;
+	
+	last_row = append_title_field(table, title, NULL);
+	attach_widget (table, last_row, VALUE_COLUMN, widget);
+
+	return last_row;
+}     
+
 static guint
 append_title_and_ellipsizing_value (FMPropertiesWindow *window,
 				    GtkTable *table,
@@ -2169,6 +2256,14 @@
 }
 
 static gboolean
+should_show_icon_scaler (FMPropertiesWindow *window)
+{
+	/*Add conditions here */
+
+	return TRUE;
+}
+
+static gboolean
 should_show_file_type (FMPropertiesWindow *window) 
 {
 	/* The trash on the desktop is one-of-a-kind */
@@ -2240,6 +2335,7 @@
 	GtkWidget *name_field;
 	GtkWidget *icon_aligner;
 	GtkWidget *icon_pixmap_widget;
+	GtkWidget *icon_size_scaler;
 
 	GtkWidget *hbox, *name_label;
 
@@ -2270,6 +2366,9 @@
 	gtk_container_add (GTK_CONTAINER (icon_aligner), icon_pixmap_widget);
 	gtk_box_pack_start (GTK_BOX (hbox), icon_aligner, TRUE, TRUE, 0);
 
+
+
+
 	/* Name label */
 	if (is_multi_file_window (window)) {
 		name_label = gtk_label_new_with_mnemonic (_("_Names:"));
@@ -2296,6 +2395,16 @@
 	/* Update name field initially before hooking up changed signal. */
 	update_name_field (window);
 
+	/* Icon scaler*/
+	icon_size_scaler = gtk_hscale_new_with_range (	0.5, 7.0,	0.5);		
+	gtk_scale_set_draw_value(GTK_SCALE(icon_size_scaler), FALSE);
+
+	icon_size_set_initial_value(GTK_RANGE(icon_size_scaler), window);
+	g_signal_connect(icon_size_scaler, "value-changed",
+			 G_CALLBACK (icon_scaler_value_changed), window);
+
+
+
 /* FIXME bugzilla.gnome.org 42151:
  * With this (and one place elsewhere in this file, not sure which is the
  * trouble-causer) code in place, bug 2151 happens (crash on quit). Since
@@ -2385,6 +2494,14 @@
 					 FALSE);
 	}
 
+
+	/* Scale file icon */
+	if (should_show_icon_scaler (window)){
+		gtk_widget_show(icon_size_scaler);
+		append_title_and_widget (window, table, _("Icon Size:"),
+					icon_size_scaler);
+	}
+
 	if (should_show_custom_icon_buttons (window)) {
 		GtkWidget *button_box;
 		GtkWidget *temp_button;


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