summaryrefslogtreecommitdiff
path: root/libeog
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-07-27 20:41:12 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2000-07-27 20:41:12 +0000
commitb34c23f4270d7f52bbb47a0383a72fd4db224da3 (patch)
tree1809bf1458b505045aea499889e9cb85aacb0b02 /libeog
parentab8df7af15abc7cbe6c5d5d4ea67a1375cc8f8b7 (diff)
downloadeog-b34c23f4270d7f52bbb47a0383a72fd4db224da3.tar.gz
Use rounding to get better results.
2000-07-27 Federico Mena Quintero <federico@helixcode.com> * zoom.c (zoom_fit_size): Use rounding to get better results. * ui-image.c (ui_image_zoom_fit): Do not subtract the frame thickness if the shadow type is GTK_SHADOW_NONE. * gtkscrollframe.c (gtk_scroll_frame_get_policy): New function. (gtk_scroll_frame_get_shadow_type): New function. * image-view.c (image_view_set_zoom): Do not change the zoom factor if it is the same as the current one.
Diffstat (limited to 'libeog')
-rw-r--r--libeog/gtkscrollframe.c48
-rw-r--r--libeog/gtkscrollframe.h6
-rw-r--r--libeog/image-view.c3
-rw-r--r--libeog/ui-image.c9
-rw-r--r--libeog/zoom.c6
5 files changed, 68 insertions, 4 deletions
diff --git a/libeog/gtkscrollframe.c b/libeog/gtkscrollframe.c
index 611e1640..8bd71923 100644
--- a/libeog/gtkscrollframe.c
+++ b/libeog/gtkscrollframe.c
@@ -1127,6 +1127,33 @@ gtk_scroll_frame_set_policy (GtkScrollFrame *sf,
}
/**
+ * gtk_scroll_frame_get_policy:
+ * @sf: A scroll frame widget.
+ * @hsb_policy: Return value for the horizontal scrollbar's policy.
+ * @vsb_policy: Return value for the vertical scrollbar's policy.
+ *
+ * Queries the scrollbar policies of a scroll frame widget.
+ **/
+void
+gtk_scroll_frame_get_policy (GtkScrollFrame *sf,
+ GtkPolicyType *hsb_policy,
+ GtkPolicyType *vsb_policy)
+{
+ ScrollFramePrivate *priv;
+
+ g_return_if_fail (sf != NULL);
+ g_return_if_fail (GTK_IS_SCROLL_FRAME (sf));
+
+ priv = sf->priv;
+
+ if (hsb_policy)
+ *hsb_policy = priv->hsb_policy;
+
+ if (vsb_policy)
+ *vsb_policy = priv->vsb_policy;
+}
+
+/**
* gtk_scroll_frame_set_placement:
* @sf: A scroll frame widget.
* @frame_placement: Placement for the frame.
@@ -1178,6 +1205,27 @@ gtk_scroll_frame_set_shadow_type (GtkScrollFrame *sf, GtkShadowType shadow_type)
}
/**
+ * gtk_scroll_frame_get_shadow_type:
+ * @sf: A scroll frame widget.
+ *
+ * Queries the shadow type of a scroll frame widget.
+ *
+ * Return value: Shadow type.
+ **/
+GtkShadowType
+gtk_scroll_frame_get_shadow_type (GtkScrollFrame *sf)
+{
+ ScrollFramePrivate *priv;
+
+ g_return_val_if_fail (sf != NULL, GTK_SHADOW_NONE);
+ g_return_val_if_fail (GTK_IS_SCROLL_FRAME (sf), GTK_SHADOW_NONE);
+
+ priv = sf->priv;
+
+ return priv->shadow_type;
+}
+
+/**
* gtk_scroll_frame_set_scrollbar_spacing:
* @sf: A scroll frame widget.
* @spacing: Desired spacing in pixels.
diff --git a/libeog/gtkscrollframe.h b/libeog/gtkscrollframe.h
index facb59da..23a3b4fd 100644
--- a/libeog/gtkscrollframe.h
+++ b/libeog/gtkscrollframe.h
@@ -77,9 +77,15 @@ GtkAdjustment *gtk_scroll_frame_get_vadjustment (GtkScrollFrame *sf);
void gtk_scroll_frame_set_policy (GtkScrollFrame *sf,
GtkPolicyType hsb_policy,
GtkPolicyType vsb_policy);
+void gtk_scroll_frame_get_policy (GtkScrollFrame *sf,
+ GtkPolicyType *hsb_policy,
+ GtkPolicyType *vsb_policy);
void gtk_scroll_frame_set_placement (GtkScrollFrame *sf, GtkCornerType frame_placement);
+
void gtk_scroll_frame_set_shadow_type (GtkScrollFrame *sf, GtkShadowType shadow_type);
+GtkShadowType gtk_scroll_frame_get_shadow_type (GtkScrollFrame *sf);
+
void gtk_scroll_frame_set_scrollbar_spacing (GtkScrollFrame *sf, guint spacing);
void gtk_scroll_frame_add_with_viewport (GtkScrollFrame *sf, GtkWidget *child);
diff --git a/libeog/image-view.c b/libeog/image-view.c
index a30905d3..5c45303d 100644
--- a/libeog/image-view.c
+++ b/libeog/image-view.c
@@ -1622,6 +1622,9 @@ image_view_set_zoom (ImageView *view, double zoom)
priv = view->priv;
+ if (priv->zoom == zoom)
+ return;
+
if (!priv->need_zoom_change) {
priv->old_zoom = priv->zoom;
priv->need_zoom_change = TRUE;
diff --git a/libeog/ui-image.c b/libeog/ui-image.c
index 708f01e1..565eab50 100644
--- a/libeog/ui-image.c
+++ b/libeog/ui-image.c
@@ -233,8 +233,13 @@ ui_image_zoom_fit (UIImage *ui)
w = GTK_WIDGET (ui)->allocation.width;
h = GTK_WIDGET (ui)->allocation.height;
- xthick = GTK_WIDGET (ui)->style->klass->xthickness;
- ythick = GTK_WIDGET (ui)->style->klass->ythickness;
+
+ if (gtk_scroll_frame_get_shadow_type (GTK_SCROLL_FRAME (ui)) == GTK_SHADOW_NONE)
+ xthick = ythick = 0;
+ else {
+ xthick = GTK_WIDGET (ui)->style->klass->xthickness;
+ ythick = GTK_WIDGET (ui)->style->klass->ythickness;
+ }
if (image->pixbuf) {
iw = gdk_pixbuf_get_width (image->pixbuf);
diff --git a/libeog/zoom.c b/libeog/zoom.c
index 036bafea..ea21d996 100644
--- a/libeog/zoom.c
+++ b/libeog/zoom.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <config.h>
+#include <math.h>
#include "zoom.h"
@@ -62,11 +64,11 @@ zoom_fit_size (guint dest_width, guint dest_height,
}
w = dest_width;
- h = (src_height * w) / src_width;
+ h = floor ((double) (src_height * w) / src_width + 0.5);
if (h > dest_height) {
h = dest_height;
- w = (src_width * h) / src_height;
+ w = floor ((double) (src_width * h) / src_height + 0.5);
}
g_assert (w <= dest_width);