# HG changeset patch # User meillo@marmaro.de # Date 1205964103 -3600 # Node ID ec2d11d96fb0abaf6cc27126f1ca43b091a190d7 # Parent f53ce3b28bb493c0eb2282e5575c738729dcb857 image is now gdk-pixbuff; zoom implemented in a basic way diff -r f53ce3b28bb4 -r ec2d11d96fb0 callbacks.c --- a/callbacks.c Fri Dec 07 21:38:25 2007 +0100 +++ b/callbacks.c Wed Mar 19 23:01:43 2008 +0100 @@ -1,10 +1,14 @@ #include +#include #include "main.h" #include "callbacks.h" #include "interface.h" #include "support.h" +int image_width; +int image_height; +float inc = 0.1; /* void update_spin_button_ratio(GtkWidget* spinbutton) { g_print("ratio change: %f\n", ratio); @@ -161,6 +165,45 @@ +/* zoom */ +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)); +} + +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)); +} + +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)); +} + +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)); +} + + + + + + + void on_crop_clicked(GtkButton* button, gpointer user_data) { char crop_call[256]; @@ -176,6 +219,10 @@ gtk_main_quit(); } +void on_cropper_window_create (GtkObject* object, gpointer user_data) { + image_width = gdk_pixbuf_get_width(image_buffer); + image_height = gdk_pixbuf_get_height(image_buffer); +} void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { gtk_main_quit(); diff -r f53ce3b28bb4 -r ec2d11d96fb0 callbacks.h --- a/callbacks.h Fri Dec 07 21:38:25 2007 +0100 +++ b/callbacks.h Wed Mar 19 23:01:43 2008 +0100 @@ -25,8 +25,13 @@ void on_crop_clicked(GtkButton* button, gpointer user_data); +void on_cropper_window_create(GtkObject* object, gpointer user_data); void on_cropper_window_destroy(GtkObject* object, gpointer user_data); /*gboolean on_cropper_window_delete_event(GtkWidget* widget, GdkEvent *event, gpointer user_data);*/ +void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data); +void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data); +void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data); +void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data); #endif diff -r f53ce3b28bb4 -r ec2d11d96fb0 interface.c --- a/interface.c Fri Dec 07 21:38:25 2007 +0100 +++ b/interface.c Wed Mar 19 23:01:43 2008 +0100 @@ -6,6 +6,7 @@ #include #include +#include #include "main.h" #include "callbacks.h" @@ -354,10 +355,11 @@ gtk_box_pack_start (GTK_BOX (vbox7), nav_container, TRUE, TRUE, 0); /* image_area */ - image_area = gtk_image_new_from_file (image_filename); - gtk_widget_set_name (image_area, "image_area"); - gtk_widget_show (image_area); - gtk_box_pack_start (GTK_BOX (nav_container), image_area, TRUE, TRUE, 0); + image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL); + image_area = gtk_image_new_from_pixbuf(image_buffer); + gtk_widget_set_name(image_area, "image_area"); + gtk_widget_show(image_area); + gtk_box_pack_start(GTK_BOX(nav_container), image_area, TRUE, TRUE, 0); hbox16 = gtk_hbox_new (FALSE, 6); gtk_widget_set_name (hbox16, "hbox16"); @@ -422,36 +424,39 @@ gtk_box_pack_end (GTK_BOX (hbox16), okay_box, FALSE, TRUE, 0); */ - crop_okbutton = gtk_button_new (); - gtk_widget_set_name (crop_okbutton, "crop_okbutton"); - gtk_widget_show (crop_okbutton); - gtk_box_pack_end (GTK_BOX (dialog_vbox1), crop_okbutton, FALSE, FALSE, 0); - GTK_WIDGET_SET_FLAGS (crop_okbutton, GTK_CAN_DEFAULT); + crop_okbutton = gtk_button_new (); + gtk_widget_set_name (crop_okbutton, "crop_okbutton"); + gtk_widget_show (crop_okbutton); + gtk_box_pack_end (GTK_BOX (dialog_vbox1), crop_okbutton, FALSE, FALSE, 0); + GTK_WIDGET_SET_FLAGS (crop_okbutton, GTK_CAN_DEFAULT); - alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_set_name (alignment1, "alignment1"); - gtk_widget_show (alignment1); - gtk_container_add (GTK_CONTAINER (crop_okbutton), alignment1); + alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); + gtk_widget_set_name (alignment1, "alignment1"); + gtk_widget_show (alignment1); + gtk_container_add (GTK_CONTAINER (crop_okbutton), alignment1); - hbox11 = gtk_hbox_new (FALSE, 2); - gtk_widget_set_name (hbox11, "hbox11"); - gtk_widget_show (hbox11); - gtk_container_add (GTK_CONTAINER (alignment1), hbox11); + hbox11 = gtk_hbox_new (FALSE, 2); + gtk_widget_set_name (hbox11, "hbox11"); + gtk_widget_show (hbox11); + gtk_container_add (GTK_CONTAINER (alignment1), hbox11); - crop_image = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON); - gtk_widget_set_name (crop_image, "crop_image"); - gtk_widget_show (crop_image); - gtk_box_pack_start (GTK_BOX (hbox11), crop_image, FALSE, FALSE, 0); + crop_image = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON); + gtk_widget_set_name (crop_image, "crop_image"); + gtk_widget_show (crop_image); + gtk_box_pack_start (GTK_BOX (hbox11), crop_image, FALSE, FALSE, 0); - label12 = gtk_label_new_with_mnemonic ("_Crop"); - gtk_widget_set_name (label12, "label12"); - gtk_widget_show (label12); - gtk_box_pack_start (GTK_BOX (hbox11), label12, FALSE, FALSE, 0); + label12 = gtk_label_new_with_mnemonic ("_Crop"); + gtk_widget_set_name (label12, "label12"); + gtk_widget_show (label12); + gtk_box_pack_start (GTK_BOX (hbox11), label12, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (cropper_window), "show", + G_CALLBACK (on_cropper_window_create), + NULL); /* destroy */ g_signal_connect (G_OBJECT (cropper_window), "destroy", G_CALLBACK (on_cropper_window_destroy), @@ -464,6 +469,20 @@ NULL); +/* zoom */ + g_signal_connect (G_OBJECT (crop_zoom_in_button), "clicked", + G_CALLBACK (on_zoom_in_button_clicked), + NULL); + g_signal_connect (G_OBJECT (crop_zoom_out_button), "clicked", + G_CALLBACK (on_zoom_out_button_clicked), + NULL); + g_signal_connect (G_OBJECT (crop_zoom_100_button), "clicked", + G_CALLBACK (on_zoom_100_button_clicked), + NULL); + g_signal_connect (G_OBJECT (crop_zoom_fit_button), "clicked", + G_CALLBACK (on_zoom_fit_button_clicked), + NULL); + /* aspect ratio */ /* @@ -528,22 +547,6 @@ */ -/* zoom */ -/* -g_signal_connect (G_OBJECT (zoom_in_button), "clicked", - G_CALLBACK (zoom_in_button_clicked_cb), - data); -g_signal_connect (G_OBJECT (zoom_out_button), "clicked", - G_CALLBACK (zoom_out_button_clicked_cb), - data); -g_signal_connect (G_OBJECT (zoom_100_button), "clicked", - G_CALLBACK (zoom_100_button_clicked_cb), - data); -g_signal_connect (G_OBJECT (zoom_fit_button), "clicked", - G_CALLBACK (zoom_fit_button_clicked_cb), - data); -*/ - @@ -604,6 +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, hbox16, "hbox16"); GLADE_HOOKUP_OBJECT (cropper_window, hbox17, "hbox17"); GLADE_HOOKUP_OBJECT (cropper_window, crop_zoom_in_button, "crop_zoom_in_button"); @@ -615,7 +619,7 @@ GLADE_HOOKUP_OBJECT (cropper_window, crop_zoom_fit_button, "crop_zoom_fit_button"); GLADE_HOOKUP_OBJECT (cropper_window, image1, "image1"); /*GLADE_HOOKUP_OBJECT_NO_REF (cropper_window, dialog_action_area1, "dialog_action_area1"); */ - GLADE_HOOKUP_OBJECT (cropper_window, crop_okbutton, "crop_okbutton"); + GLADE_HOOKUP_OBJECT (cropper_window, crop_okbutton, "crop_okbutton"); GLADE_HOOKUP_OBJECT (cropper_window, alignment1, "alignment1"); GLADE_HOOKUP_OBJECT (cropper_window, hbox11, "hbox11"); GLADE_HOOKUP_OBJECT (cropper_window, crop_image, "crop_image"); diff -r f53ce3b28bb4 -r ec2d11d96fb0 interface.h --- a/interface.h Fri Dec 07 21:38:25 2007 +0100 +++ b/interface.h Wed Mar 19 23:01:43 2008 +0100 @@ -1,3 +1,6 @@ #include GtkWidget* create_cropper_window(void); + + +GdkPixbuf *image_buffer;