changeset 8:b0824876d379

memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
author meillo@marmaro.de
date Thu, 20 Mar 2008 19:31:44 +0100
parents ec2d11d96fb0
children 7e1cf00de1df
files callbacks.c interface.c
diffstat 2 files changed, 25 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/callbacks.c	Wed Mar 19 23:01:43 2008 +0100
+++ b/callbacks.c	Thu Mar 20 19:31:44 2008 +0100
@@ -166,36 +166,42 @@
 
 
 /* zoom */
+void set_zoom() {
+	static GdkPixbuf* pixbuf_new;
+	g_object_unref(pixbuf_new);
+
+	pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_HYPER);
+	gtk_image_set_from_pixbuf((GtkImage*) lookup_widget(cropper_window, "image_area"), pixbuf_new);
+}
+
 void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) {
-	printf("zoom in clicked\n");
 	image_width *= 1 + inc;
 	image_height *= 1 + inc;
-	gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"),
-			gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
+	set_zoom();
 }
 
 void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) {
-	printf("zoom out clicked\n");
 	image_width *= 1 - inc;
 	image_height *= 1 - inc;
-	gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"),
-			gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
+	set_zoom();
 }
 
 void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) {
-	printf("zoom 100 clicked\n");
 	image_width = gdk_pixbuf_get_width(image_buffer);
 	image_height = gdk_pixbuf_get_height(image_buffer);
-	gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"),
-			gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
+	set_zoom();
 }
 
 void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) {
-	printf("zoom fit clicked\n");
-	image_width = gdk_pixbuf_get_width(image_buffer) + 200; /* FIXME */
-	image_height = gdk_pixbuf_get_height(image_buffer) + 200; /* FIXME */
-	gtk_image_set_from_pixbuf(lookup_widget(cropper_window, "image_area"),
-			gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR));
+	int w, h;
+	GtkWidget* image_a;
+
+	image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area");
+	gdk_drawable_get_size (image_a->window, &w, &h);
+
+	image_width = w - 200;
+	image_height = h - 150;
+	set_zoom();
 }
 
 
@@ -208,10 +214,10 @@
 	char crop_call[256];
 
 	sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"",
-		gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_width_spinbutton")),
-		gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_height_spinbutton")),
-		gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_x_spinbutton")),
-		gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "crop_y_spinbutton")),
+		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_width_spinbutton")),
+		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_height_spinbutton")),
+		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_x_spinbutton")),
+		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_y_spinbutton")),
 		image_filename,
 		image_filename
 	);
--- a/interface.c	Wed Mar 19 23:01:43 2008 +0100
+++ b/interface.c	Thu Mar 20 19:31:44 2008 +0100
@@ -607,7 +607,7 @@
   GLADE_HOOKUP_OBJECT (cropper_window, vbox7, "vbox7");
   GLADE_HOOKUP_OBJECT (cropper_window, nav_container, "nav_container");
   GLADE_HOOKUP_OBJECT (cropper_window, image_area, "image_area");
-  GLADE_HOOKUP_OBJECT (cropper_window, image_buffer, "image_buffer");
+  GLADE_HOOKUP_OBJECT (cropper_window, (GtkWidget*) image_buffer, "image_buffer");
   GLADE_HOOKUP_OBJECT (cropper_window, hbox16, "hbox16");
   GLADE_HOOKUP_OBJECT (cropper_window, hbox17, "hbox17");
   GLADE_HOOKUP_OBJECT (cropper_window, crop_zoom_in_button, "crop_zoom_in_button");