summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wallpapers.c15
-rw-r--r--walls.ui2
-rw-r--r--window_main.c28
3 files changed, 44 insertions, 1 deletions
diff --git a/wallpapers.c b/wallpapers.c
index a4bfb60..0d37f5e 100644
--- a/wallpapers.c
+++ b/wallpapers.c
@@ -223,3 +223,18 @@ GdkPixbuf *resize_pixbuf(GdkPixbuf *orig, gint win_width, gint win_height, gint
return pb;
}
+
+GdkPixbuf *zoom_pixbuf(GdkPixbuf *orig, gdouble zoom) {
+ GdkPixbuf *pb;
+ gint img_width, img_height, width, height;
+
+ img_width = gdk_pixbuf_get_width(orig);
+ img_height = gdk_pixbuf_get_height(orig);
+
+ width = img_width * zoom;
+ height = img_height * zoom;
+ pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+ gdk_pixbuf_scale(orig, pb, 0, 0, width, height, 0, 0,
+ (gdouble)width / (gdouble)img_width, (gdouble)height / (gdouble)img_height, GDK_INTERP_BILINEAR);
+ return pb;
+}
diff --git a/walls.ui b/walls.ui
index 7f3a410..cb6f3bd 100644
--- a/walls.ui
+++ b/walls.ui
@@ -133,6 +133,7 @@
<property name="label" translatable="yes">Zoom _In</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-in</property>
+ <signal name="clicked" handler="on_zoom_in_clicked"/>
</object>
<packing>
<property name="expand">False</property>
@@ -145,6 +146,7 @@
<property name="label" translatable="yes">Zoom _Out</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-out</property>
+ <signal name="clicked" handler="on_zoom_out_clicked"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/window_main.c b/window_main.c
index ff5200f..bd1de4f 100644
--- a/window_main.c
+++ b/window_main.c
@@ -27,6 +27,7 @@ gboolean layout_dragging = FALSE;
gdouble layout_dragx, layout_dragy;
enum zoom_mode_t zoom_mode = ZOOM_BESTFIT;
+gdouble zoom_factor = 1.0;
GtkWindow *window;
GtkImage *image = NULL;
@@ -186,8 +187,21 @@ static void set_image_pixbuf() {
set_image_pixbuf_resized(pb, win_width, win_height, width, height, ratio);
g_object_unref(pb);
- } else if(zoom_mode == ZOOM_NORMAL || zoom_mode == ZOOM_CUSTOM) {
+ } else if(zoom_mode == ZOOM_NORMAL) {
set_image_pixbuf_normal(orig_pixbuf, win_width, win_height, gdk_pixbuf_get_width(orig_pixbuf), gdk_pixbuf_get_height(orig_pixbuf));
+ } else if(zoom_mode == ZOOM_CUSTOM) {
+ pb = zoom_pixbuf(orig_pixbuf, zoom_factor);
+ if(!pb)
+ return;
+
+ width = gdk_pixbuf_get_width(pb);
+ height = gdk_pixbuf_get_height(pb);
+
+ set_image_pixbuf_normal(pb, win_width, win_height, width, height);
+
+ set_resize_msg(zoom_factor);
+
+ g_object_unref(pb);
}
}
@@ -921,6 +935,18 @@ void on_zoom_mode_toggled(GtkToggleToolButton *toolbutton, gpointer user_data) {
}
}
+void on_zoom_in_clicked(GtkToolButton *toolbutton, gpointer user_data) {
+ zoom_mode = ZOOM_CUSTOM;
+ zoom_factor *= 1.25;
+ set_image_pixbuf();
+}
+
+void on_zoom_out_clicked(GtkToolButton *toolbutton, gpointer user_data) {
+ zoom_mode = ZOOM_CUSTOM;
+ zoom_factor *= .80;
+ set_image_pixbuf();
+}
+
gboolean on_layout_button_press_event(GtkWindow *widget, GdkEventButton *event, gpointer user_data) {
GtkAdjustment *hadj, *vadj;