Mercurial > cropper
comparison callbacks.c @ 7:ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
author | meillo@marmaro.de |
---|---|
date | Wed, 19 Mar 2008 23:01:43 +0100 |
parents | 2f11ab3e6047 |
children | b0824876d379 |
comparison
equal
deleted
inserted
replaced
6:f53ce3b28bb4 | 7:ec2d11d96fb0 |
---|---|
1 #include <gtk/gtk.h> | 1 #include <gtk/gtk.h> |
2 #include <gdk-pixbuf/gdk-pixbuf.h> | |
2 | 3 |
3 #include "main.h" | 4 #include "main.h" |
4 #include "callbacks.h" | 5 #include "callbacks.h" |
5 #include "interface.h" | 6 #include "interface.h" |
6 #include "support.h" | 7 #include "support.h" |
7 | 8 |
9 int image_width; | |
10 int image_height; | |
11 float inc = 0.1; | |
8 /* | 12 /* |
9 void update_spin_button_ratio(GtkWidget* spinbutton) { | 13 void update_spin_button_ratio(GtkWidget* spinbutton) { |
10 g_print("ratio change: %f\n", ratio); | 14 g_print("ratio change: %f\n", ratio); |
11 on_ratio_w_spinbutton_value_changed(spinbutton, NULL); | 15 on_ratio_w_spinbutton_value_changed(spinbutton, NULL); |
12 } | 16 } |
156 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton"))); | 160 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton"))); |
157 gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton")); | 161 gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
158 | 162 |
159 } | 163 } |
160 */ | 164 */ |
165 | |
166 | |
167 | |
168 /* zoom */ | |
169 void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) { | |
170 printf("zoom in clicked\n"); | |
171 image_width *= 1 + inc; | |
172 image_height *= 1 + inc; | |
173 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), | |
174 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); | |
175 } | |
176 | |
177 void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) { | |
178 printf("zoom out clicked\n"); | |
179 image_width *= 1 - inc; | |
180 image_height *= 1 - inc; | |
181 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), | |
182 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); | |
183 } | |
184 | |
185 void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) { | |
186 printf("zoom 100 clicked\n"); | |
187 image_width = gdk_pixbuf_get_width(image_buffer); | |
188 image_height = gdk_pixbuf_get_height(image_buffer); | |
189 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), | |
190 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); | |
191 } | |
192 | |
193 void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) { | |
194 printf("zoom fit clicked\n"); | |
195 image_width = gdk_pixbuf_get_width(image_buffer) + 200; /* FIXME */ | |
196 image_height = gdk_pixbuf_get_height(image_buffer) + 200; /* FIXME */ | |
197 gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"), | |
198 gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR)); | |
199 } | |
200 | |
201 | |
202 | |
203 | |
161 | 204 |
162 | 205 |
163 | 206 |
164 void on_crop_clicked(GtkButton* button, gpointer user_data) { | 207 void on_crop_clicked(GtkButton* button, gpointer user_data) { |
165 char crop_call[256]; | 208 char crop_call[256]; |
174 ); | 217 ); |
175 system(crop_call); | 218 system(crop_call); |
176 gtk_main_quit(); | 219 gtk_main_quit(); |
177 } | 220 } |
178 | 221 |
222 void on_cropper_window_create (GtkObject* object, gpointer user_data) { | |
223 image_width = gdk_pixbuf_get_width(image_buffer); | |
224 image_height = gdk_pixbuf_get_height(image_buffer); | |
225 } | |
179 | 226 |
180 void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { | 227 void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { |
181 gtk_main_quit(); | 228 gtk_main_quit(); |
182 } | 229 } |
183 | 230 |