summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2001-02-17 01:58:18 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2001-02-17 01:58:18 +0000
commit107192d0509ab41d80739a20b9e1a448a5c59457 (patch)
treefe826e7da0a0c0b85d098da8cb81bd2335059c7d /components
parent33e0bb3642a3e55291ced022d6da53af07caac45 (diff)
downloadnautilus-107192d0509ab41d80739a20b9e1a448a5c59457.tar.gz
fixed a bunch of problems in the image view, including making the initial
* components/image-viewer/nautilus-image-view.c: (zoomable_zoom_to_fit_callback), (rezoom_control), (control_size_allocate_callback), (image_fits_in_container), (scrolled_window_size_allocate_callback), (scrollable_control_factory): fixed a bunch of problems in the image view, including making the initial shrink-to-fit feature work again, made unneccessary scroll bars go away by using GTK_POLICY_AUTOMATIC, improved the scaling to Arlo's taste by using GDK_INTERP_BILINEAR, and tweaked the scale factors, plus other clean-ups. * src/nautilus-zoom-control.c: (create_zoom_menu_item): fixed bug 6288, bogus zoom levels displayed in zoom control, by making the rounding algorithm used in the menu consistent with the one used in the control.
Diffstat (limited to 'components')
-rw-r--r--components/image-viewer/nautilus-image-view.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/components/image-viewer/nautilus-image-view.c b/components/image-viewer/nautilus-image-view.c
index eca93eb82..989689e42 100644
--- a/components/image-viewer/nautilus-image-view.c
+++ b/components/image-viewer/nautilus-image-view.c
@@ -249,14 +249,14 @@ configure_size (bonobo_object_data_t *bod, GdkRectangle *rect)
}
static float preferred_zoom_levels[] = {
- 1.0 / 10.0, 1.0 / 9.0, 1.0 / 8.0, 1.0 / 7.0, 1.0 / 6.0,
- 1.0 / 5.0, 1.0 / 4.0, 1.0 / 3.0, 1.0 / 2.0, 1.0, 2.0,
- 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0
+ 1.0 / 10.0, 1.0 / 8.0, 1.0 / 6.0, 1.0 / 5.0,
+ 1.0 / 4.0, 1.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0, 1.0, 1.5, 2.0,
+ 3.0, 4.0, 5.0, 6.0, 8.0, 10.0
};
static const gchar *preferred_zoom_level_names[] = {
- "1:10", "1:9", "1:8", "1:7", "1:6", "1:5", "1:4", "1:3",
- "1:2", "1:1", "2:1", "3:1", "4:1", "5:1", "6:1", "7:1",
- "8:1", "9:1", "10:1"
+ "1:10", "1:8", "1:6", "1:5", "1:4", "1:3",
+ "1:2", "2:3", "1:1", "3:2", "2:1", "3:1", "4:1", "5:1", "6:1",
+ "8:1", "10:1"
};
static const gint max_preferred_zoom_levels = (sizeof (preferred_zoom_levels) /
@@ -355,13 +355,6 @@ zoomable_zoom_to_fit_callback (BonoboZoomable *zoomable, bonobo_object_data_t *b
y_level = vadj->page_size / height;
new_zoom_level = (x_level < y_level) ? x_level : y_level;
-
-#if 0
- g_message ("zoom_to_fit: (%g,%g) - (%g,%g) - (%g,%g) - %g",
- width, height, hadj->page_size, vadj->page_size,
- x_level, y_level, new_zoom_level);
-#endif
-
if (new_zoom_level > 0) {
gtk_signal_emit_by_name (GTK_OBJECT (zoomable), "set_zoom_level",
new_zoom_level);
@@ -415,7 +408,7 @@ rezoom_control (bonobo_object_data_t *bod, float new_zoom_level)
if (new_width >= 1 && new_height >= 1) {
bod->zoomed = gdk_pixbuf_scale_simple (pixbuf, new_width,
- new_height, ART_FILTER_NEAREST);
+ new_height, GDK_INTERP_BILINEAR);
}
resize_control (bod);
@@ -546,8 +539,7 @@ control_size_allocate_callback (GtkWidget *drawing_area, GtkAllocation *allocati
{
const GdkPixbuf *buf;
GdkPixbuf *control_buf;
- GdkInterpType type;
-
+
g_return_if_fail (bod != NULL);
g_return_if_fail (allocation != NULL);
@@ -579,17 +571,10 @@ control_size_allocate_callback (GtkWidget *drawing_area, GtkAllocation *allocati
control_buf = NULL;
}
}
-
- /* Too slow below this */
- if (allocation->width < gdk_pixbuf_get_width (buf) / 4 ||
- allocation->width < gdk_pixbuf_get_width (buf) / 4)
- type = ART_FILTER_NEAREST;
- else
- type = ART_FILTER_TILES;
-
+
if (allocation->width >= 1 && allocation->height >= 1) {
bod->scaled = gdk_pixbuf_scale_simple (buf, allocation->width,
- allocation->height, type);
+ allocation->height, GDK_INTERP_BILINEAR);
}
control_update (bod);
@@ -608,6 +593,24 @@ scrolled_control_size_allocate_callback (GtkWidget *drawing_area,
}
/*
+ * determine if the image is larger than the display area *
+ */
+static gboolean
+image_fits_in_container (bonobo_object_data_t *bod)
+{
+ GtkAdjustment *hadj, *vadj;
+ float width, height;
+
+ width = gdk_pixbuf_get_width (bod->pixbuf);
+ height = gdk_pixbuf_get_height (bod->pixbuf);
+
+ hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (bod->scrolled_window));
+ vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (bod->scrolled_window));
+
+ return width <= hadj->page_size && height <= vadj->page_size;
+}
+
+/*
* This callback will be invoked when the container assigns us a size.
*/
static void
@@ -619,10 +622,15 @@ scrolled_window_size_allocate_callback (GtkWidget *drawing_area,
* is complete, inspiring this hackish solution determining when; it should
* be replaced with a cleaner approach when the framework is improved.
*/
-
- if (bod->resize_flag && bod->initial_flag && allocation->width > 1 && allocation->height > 1) {
+
+ if (bod->resize_flag && bod->initial_flag && allocation->width > 1 && allocation->height > 1)
+ {
bod->initial_flag = FALSE;
- } else if (!bod->resize_flag && allocation->width == 1 && allocation->height == 1) {
+ if (!image_fits_in_container (bod)) {
+ zoomable_zoom_to_fit_callback (bod->zoomable, bod);
+ }
+ }
+ else if (!bod->resize_flag && allocation->width == 1 && allocation->height == 1) {
bod->resize_flag = TRUE;
}
}
@@ -746,8 +754,8 @@ scrollable_control_factory (void)
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_ALWAYS,
- GTK_POLICY_ALWAYS);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
bod = control_factory_common (scroll);