[Patch] Resize icon slider for file properties (try no. 3)
- From: Raphael Bosshard <whistler bluewin ch>
- To: nautilus-list gnome org
- Subject: [Patch] Resize icon slider for file properties (try no. 3)
- Date: Thu, 07 Jul 2005 23:58:41 +0200
This is again an attempt to add a resize slider for file icons to the
file properties dialog, updated to work with nautilus-cvs.
The patch solves following problems:
- Help! I have to use a keyboard. How do I resize file icons like my
mate next door?
- Help! I want to have several icons exactly the same size. How to do that?
- Help! I want to stretch a file's icon in a folder, just like I do on
the desktop.
Screenshot:
http://home.zhwin.ch/~bosshrap/programming/Nautilus%20with%20icon%20scaler.jpg
However; this patch has (still) a problem; the view has to refreshed
manualy. I still don't know how to force the fm-icon-container to
reload. Any help from an experienced nautilus hacker on this topic is
appreciated.
Raphael
diff -ur nautilus/src/file-manager/fm-properties-window.c nautilus-work/src/file-manager/fm-properties-window.c
--- nautilus/src/file-manager/fm-properties-window.c 2005-06-02 18:16:56.000000000 +0200
+++ nautilus-work/src/file-manager/fm-properties-window.c 2005-07-07 21:07:52.905879208 +0200
@@ -78,6 +78,7 @@
#include <libnautilus-private/nautilus-mime-actions.h>
#include <libnautilus-private/nautilus-undo.h>
#include <string.h>
+#include <stdlib.h>
static GHashTable *windows;
static GHashTable *pending_lists;
@@ -88,6 +89,8 @@
GtkNotebook *notebook;
GtkWidget *remove_image_button;
+
+ GtkWidget *icon_size_scaler;
GtkWidget *icon_selector_window;
GtkTable *basic_table;
@@ -465,6 +468,62 @@
gtk_widget_set_sensitive (properties_window->details->remove_image_button, FALSE);
}
+static gboolean
+icon_size_set_initial_value(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) {
+ value = atol(scale);
+ g_free(scale);
+
+ } else {
+ value = 1.0;
+ }
+
+ }
+ gtk_range_set_value(GTK_RANGE(properties_window->details->icon_size_scaler), value);
+
+ return TRUE;
+}
+
+static gboolean
+icon_scaler_value_changed (GtkRange *icon_scaler,
+ FMPropertiesWindow *properties_window)
+{
+ GList *l;
+ gdouble value;
+ gchar scale[100];
+
+ value = gtk_range_get_value(icon_scaler);
+ g_ascii_dtostr(scale, 100, value);
+
+ for (l = properties_window->details->original_files; l != NULL; l = l->next) {
+
+ nautilus_file_set_metadata (NAUTILUS_FILE(l->data),
+ NAUTILUS_METADATA_KEY_ICON_SCALE,
+ NULL, scale);
+
+ }
+
+
+ return FALSE;
+}
+
static void
fm_properties_window_drag_data_received (GtkWidget *widget, GdkDragContext *context,
@@ -1399,6 +1458,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,
@@ -2038,6 +2112,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,
@@ -2237,6 +2325,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 */
@@ -2332,6 +2428,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:"));
@@ -2343,6 +2442,15 @@
gtk_box_pack_end (GTK_BOX (hbox), name_label, FALSE, FALSE, 0);
window->details->name_label = name_label;
+ /* Icon scaler*/
+ window->details->icon_size_scaler = gtk_hscale_new_with_range ( 0.5, 7.0, 0.5);
+ gtk_scale_set_draw_value(GTK_SCALE(window->details->icon_size_scaler), FALSE);
+
+ icon_size_set_initial_value(window);
+ g_signal_connect(window->details->icon_size_scaler, "value-changed",
+ G_CALLBACK (icon_scaler_value_changed), window);
+
+
/* Name field */
window->details->name_field = NULL;
update_name_field (window);
@@ -2417,6 +2525,14 @@
FALSE);
}
+
+ /* Scale file icon */
+ if (should_show_icon_scaler (window)){
+ gtk_widget_show(window->details->icon_size_scaler);
+ append_title_and_widget (window, table, _("Icon Size:"),
+ window->details->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]