[PATCH] Use one icon container scale factor instead of two (scale_y, scale_x => scale)
- From: Christian Neumair <chris gnome-de org>
- To: nautilus-list <nautilus-list gnome org>
- Subject: [PATCH] Use one icon container scale factor instead of two (scale_y, scale_x => scale)
- Date: Sun, 30 Apr 2006 11:38:05 +0200
The attached patch is a simple cleanup that merges the x and y scale
factors into one variable, at least for the icon container. The icon
factory code still uses two variables.
--
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.414
diff -u -p -r1.414 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c 18 Apr 2006 16:54:31 -0000 1.414
+++ libnautilus-private/nautilus-icon-container.c 30 Apr 2006 09:30:54 -0000
@@ -361,12 +361,9 @@ icon_get_size (NautilusIconContainer *co
NautilusIcon *icon,
guint *size)
{
- g_assert (fabs (icon->scale_x - icon->scale_y) <= 0.001);
-
- /* ALEX TODO: Bogus. Should only have one scale, not _x and _y */
if (size != NULL) {
*size = MAX (nautilus_get_icon_size_for_zoom_level (container->details->zoom_level)
- * icon->scale_x, NAUTILUS_ICON_SIZE_SMALLEST);
+ * icon->scale, NAUTILUS_ICON_SIZE_SMALLEST);
}
}
@@ -395,7 +392,7 @@ icon_set_size (NautilusIconContainer *co
(container->details->zoom_level);
nautilus_icon_container_move_icon (container, icon,
icon->x, icon->y,
- scale, scale, FALSE,
+ scale, FALSE,
snap, update_position);
}
@@ -448,7 +445,7 @@ icon_toggle_selected (NautilusIconContai
nautilus_icon_container_move_icon (container,
icon,
icon->x, icon->y,
- icon->scale_x, icon->scale_y,
+ icon->scale,
FALSE, TRUE, TRUE);
}
@@ -1845,7 +1842,7 @@ void
nautilus_icon_container_move_icon (NautilusIconContainer *container,
NautilusIcon *icon,
int x, int y,
- double scale_x, double scale_y,
+ double scale,
gboolean raise,
gboolean snap,
gboolean update_position)
@@ -1862,9 +1859,8 @@ nautilus_icon_container_move_icon (Nauti
end_renaming_mode (container, TRUE);
}
- if (scale_x != icon->scale_x || scale_y != icon->scale_y) {
- icon->scale_x = scale_x;
- icon->scale_y = scale_y;
+ if (scale != icon->scale) {
+ icon->scale = scale;
nautilus_icon_container_update_icon (container, icon);
if (update_position) {
redo_layout (container);
@@ -1886,8 +1882,7 @@ nautilus_icon_container_move_icon (Nauti
if (emit_signal) {
position.x = icon->x;
position.y = icon->y;
- position.scale_x = scale_x;
- position.scale_y = scale_y;
+ position.scale = scale;
g_signal_emit (container,
signals[ICON_POSITION_CHANGED], 0,
icon->data, &position);
@@ -3465,7 +3460,7 @@ keyboard_stretching (NautilusIconContain
case GDK_KP_0:
nautilus_icon_container_move_icon (container, icon,
icon->x, icon->y,
- 1.0, 1.0,
+ 1.0,
FALSE, TRUE, TRUE);
break;
}
@@ -3494,8 +3489,7 @@ end_stretching (NautilusIconContainer *c
icon = container->details->drag_icon;
position.x = icon->x;
position.y = icon->y;
- position.scale_x = icon->scale_x;
- position.scale_y = icon->scale_y;
+ position.scale = icon->scale;
g_signal_emit (container,
signals[ICON_POSITION_CHANGED], 0,
icon->data, &position);
@@ -5560,7 +5554,7 @@ nautilus_icon_container_update_icon (Nau
emblem_pixbufs = NULL;
icon_size = MAX (nautilus_get_icon_size_for_zoom_level (container->details->zoom_level)
- * icon->scale_x, NAUTILUS_ICON_SIZE_SMALLEST);
+ * icon->scale, NAUTILUS_ICON_SIZE_SMALLEST);
for (p = emblem_icon_names; p != NULL; p = p->next) {
emblem_pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
(p->data,
@@ -5623,15 +5617,13 @@ assign_icon_position (NautilusIconContai
/* Get the stored position. */
have_stored_position = FALSE;
- position.scale_x = 1.0;
- position.scale_y = 1.0;
+ position.scale = 1.0;
g_signal_emit (container,
signals[GET_STORED_ICON_POSITION], 0,
icon->data,
&position,
&have_stored_position);
- icon->scale_x = position.scale_x;
- icon->scale_y = position.scale_y;
+ icon->scale = position.scale;
if (!container->details->auto_layout) {
if (have_stored_position) {
icon_set_position (icon, position.x, position.y);
@@ -5773,8 +5765,7 @@ nautilus_icon_container_add (NautilusIco
icon->x = ICON_UNPOSITIONED_VALUE;
icon->y = ICON_UNPOSITIONED_VALUE;
icon->has_lazy_position = has_lazy_position;
- icon->scale_x = 1.0;
- icon->scale_y = 1.0;
+ icon->scale = 1.0;
icon->item = NAUTILUS_ICON_CANVAS_ITEM
(eel_canvas_item_new (EEL_CANVAS_GROUP (EEL_CANVAS (container)->root),
nautilus_icon_canvas_item_get_type (),
@@ -6328,7 +6319,7 @@ nautilus_icon_container_is_stretched (Na
for (p = container->details->icons; p != NULL; p = p->next) {
icon = p->data;
- if (icon->is_selected && (icon->scale_x != 1.0 || icon->scale_y != 1.0)) {
+ if (icon->is_selected && icon->scale != 1.0) {
return TRUE;
}
}
@@ -6352,7 +6343,7 @@ nautilus_icon_container_unstretch (Nauti
if (icon->is_selected) {
nautilus_icon_container_move_icon (container, icon,
icon->x, icon->y,
- 1.0, 1.0,
+ 1.0,
FALSE, TRUE, TRUE);
}
}
@@ -6592,8 +6583,7 @@ nautilus_icon_container_freeze_icon_posi
position.x = icon->x;
position.y = icon->y;
- position.scale_x = icon->scale_x;
- position.scale_y = icon->scale_y;
+ position.scale = icon->scale;
g_signal_emit (container, signals[ICON_POSITION_CHANGED], 0,
icon->data, &position);
}
Index: libnautilus-private/nautilus-icon-container.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.h,v
retrieving revision 1.91
diff -u -p -r1.91 nautilus-icon-container.h
--- libnautilus-private/nautilus-icon-container.h 18 Apr 2006 16:54:31 -0000 1.91
+++ libnautilus-private/nautilus-icon-container.h 30 Apr 2006 09:30:54 -0000
@@ -51,8 +51,7 @@ typedef void (* NautilusIconCallback) (N
typedef struct {
int x;
int y;
- double scale_x;
- double scale_y;
+ double scale;
} NautilusIconPosition;
typedef enum {
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.153
diff -u -p -r1.153 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c 10 Apr 2006 20:09:36 -0000 1.153
+++ libnautilus-private/nautilus-icon-dnd.c 30 Apr 2006 09:31:00 -0000
@@ -853,7 +853,7 @@ handle_local_move (NautilusIconContainer
nautilus_icon_container_move_icon
(container, icon,
world_x + item->icon_x, world_y + item->icon_y,
- icon->scale_x, icon->scale_y,
+ icon->scale,
TRUE, TRUE, TRUE);
}
moved_icons = g_list_prepend (moved_icons, icon);
Index: libnautilus-private/nautilus-icon-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-private.h,v
retrieving revision 1.82
diff -u -p -r1.82 nautilus-icon-private.h
--- libnautilus-private/nautilus-icon-private.h 18 Apr 2006 16:54:31 -0000 1.82
+++ libnautilus-private/nautilus-icon-private.h 30 Apr 2006 09:31:00 -0000
@@ -45,8 +45,7 @@ typedef struct {
double x, y;
/* Scale factor (stretches icon). */
- /* ALEX TODO: only allow once scale */
- double scale_x, scale_y;
+ double scale;
/* Whether this item is selected. */
eel_boolean_bit is_selected : 1;
@@ -271,8 +270,7 @@ void nautilus_icon_container_mo
NautilusIcon *icon,
int x,
int y,
- double scale_x,
- double scale_y,
+ double scale,
gboolean raise,
gboolean snap,
gboolean update_position);
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.322
diff -u -p -r1.322 fm-icon-view.c
--- src/file-manager/fm-icon-view.c 30 Mar 2006 19:37:22 -0000 1.322
+++ src/file-manager/fm-icon-view.c 30 Apr 2006 09:31:11 -0000
@@ -287,20 +287,12 @@ get_stored_icon_position_callback (Nauti
scale_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_ICON_SCALE, "1");
scale_good = sscanf
- (scale_string, " %lf %c",
- &position->scale_x, &c) == 1;
- if (scale_good) {
- position->scale_y = position->scale_x;
- } else {
- scale_good = sscanf
- (scale_string, " %lf %lf %c",
- &position->scale_x,
- &position->scale_y, &c) == 2;
- if (!scale_good) {
- position->scale_x = 1.0;
- position->scale_y = 1.0;
- }
+ (scale_string, " %lf",
+ &position->scale) == 1;
+ if (!scale_good) {
+ position->scale = 1.0;
}
+
g_free (scale_string);
setlocale (LC_NUMERIC, locale);
@@ -2156,7 +2148,7 @@ icon_position_changed_callback (Nautilus
FMIconView *icon_view)
{
char *position_string;
- char *scale_string, *scale_string_x, *scale_string_y;
+ char *scale_string;
char *locale;
g_assert (FM_IS_ICON_VIEW (icon_view));
@@ -2199,16 +2191,7 @@ icon_position_changed_callback (Nautilus
* %.2f is not a good format for the scale factor. We'd like it to
* say "2" or "2x" instead of "2.00".
*/
- scale_string_x = g_strdup_printf ("%.2f", position->scale_x);
- scale_string_y = g_strdup_printf ("%.2f", position->scale_y);
- if (strcmp (scale_string_x, scale_string_y) == 0) {
- scale_string = scale_string_x;
- g_free (scale_string_y);
- } else {
- scale_string = g_strconcat (scale_string_x, ",", scale_string_y, NULL);
- g_free (scale_string_x);
- g_free (scale_string_y);
- }
+ scale_string = g_strdup_printf ("%.2f", position->scale);
nautilus_file_set_metadata
(file, NAUTILUS_METADATA_KEY_ICON_SCALE,
"1.00", scale_string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]