cropper

diff interface.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 61e5a1727231
children b0824876d379
line diff
     1.1 --- a/interface.c	Fri Dec 07 21:38:25 2007 +0100
     1.2 +++ b/interface.c	Wed Mar 19 23:01:43 2008 +0100
     1.3 @@ -6,6 +6,7 @@
     1.4  
     1.5  #include <gdk/gdkkeysyms.h>
     1.6  #include <gtk/gtk.h>
     1.7 +#include <gdk-pixbuf/gdk-pixbuf.h>
     1.8  
     1.9  #include "main.h"
    1.10  #include "callbacks.h"
    1.11 @@ -354,10 +355,11 @@
    1.12    gtk_box_pack_start (GTK_BOX (vbox7), nav_container, TRUE, TRUE, 0);
    1.13  
    1.14  /* image_area */
    1.15 -  image_area = gtk_image_new_from_file (image_filename);
    1.16 -  gtk_widget_set_name (image_area, "image_area");
    1.17 -  gtk_widget_show (image_area);
    1.18 -  gtk_box_pack_start (GTK_BOX (nav_container), image_area, TRUE, TRUE, 0);
    1.19 +  image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
    1.20 +  image_area = gtk_image_new_from_pixbuf(image_buffer);
    1.21 +  gtk_widget_set_name(image_area, "image_area");
    1.22 +  gtk_widget_show(image_area);
    1.23 +  gtk_box_pack_start(GTK_BOX(nav_container), image_area, TRUE, TRUE, 0);
    1.24  
    1.25    hbox16 = gtk_hbox_new (FALSE, 6);
    1.26    gtk_widget_set_name (hbox16, "hbox16");
    1.27 @@ -422,36 +424,39 @@
    1.28    gtk_box_pack_end (GTK_BOX (hbox16), okay_box, FALSE, TRUE, 0);
    1.29  */
    1.30  
    1.31 -	crop_okbutton = gtk_button_new (); 
    1.32 -	gtk_widget_set_name (crop_okbutton, "crop_okbutton"); 
    1.33 -	gtk_widget_show (crop_okbutton); 
    1.34 -	gtk_box_pack_end (GTK_BOX (dialog_vbox1), crop_okbutton, FALSE, FALSE, 0); 
    1.35 -	GTK_WIDGET_SET_FLAGS (crop_okbutton, GTK_CAN_DEFAULT); 
    1.36 +	crop_okbutton = gtk_button_new ();
    1.37 +	gtk_widget_set_name (crop_okbutton, "crop_okbutton");
    1.38 +	gtk_widget_show (crop_okbutton);
    1.39 +	gtk_box_pack_end (GTK_BOX (dialog_vbox1), crop_okbutton, FALSE, FALSE, 0);
    1.40 +	GTK_WIDGET_SET_FLAGS (crop_okbutton, GTK_CAN_DEFAULT);
    1.41  
    1.42 -	alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); 
    1.43 -	gtk_widget_set_name (alignment1, "alignment1"); 
    1.44 -	gtk_widget_show (alignment1); 
    1.45 -	gtk_container_add (GTK_CONTAINER (crop_okbutton), alignment1); 
    1.46 +	alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
    1.47 +	gtk_widget_set_name (alignment1, "alignment1");
    1.48 +	gtk_widget_show (alignment1);
    1.49 +	gtk_container_add (GTK_CONTAINER (crop_okbutton), alignment1);
    1.50  
    1.51 -	hbox11 = gtk_hbox_new (FALSE, 2); 
    1.52 -	gtk_widget_set_name (hbox11, "hbox11"); 
    1.53 -	gtk_widget_show (hbox11); 
    1.54 -	gtk_container_add (GTK_CONTAINER (alignment1), hbox11); 
    1.55 +	hbox11 = gtk_hbox_new (FALSE, 2);
    1.56 +	gtk_widget_set_name (hbox11, "hbox11");
    1.57 +	gtk_widget_show (hbox11);
    1.58 +	gtk_container_add (GTK_CONTAINER (alignment1), hbox11);
    1.59  
    1.60 -	crop_image = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON); 
    1.61 -	gtk_widget_set_name (crop_image, "crop_image"); 
    1.62 -	gtk_widget_show (crop_image); 
    1.63 -	gtk_box_pack_start (GTK_BOX (hbox11), crop_image, FALSE, FALSE, 0); 
    1.64 +	crop_image = gtk_image_new_from_stock ("gtk-ok", GTK_ICON_SIZE_BUTTON);
    1.65 +	gtk_widget_set_name (crop_image, "crop_image");
    1.66 +	gtk_widget_show (crop_image);
    1.67 +	gtk_box_pack_start (GTK_BOX (hbox11), crop_image, FALSE, FALSE, 0);
    1.68  
    1.69 -	label12 = gtk_label_new_with_mnemonic ("_Crop"); 
    1.70 -	gtk_widget_set_name (label12, "label12"); 
    1.71 -	gtk_widget_show (label12); 
    1.72 -	gtk_box_pack_start (GTK_BOX (hbox11), label12, FALSE, FALSE, 0); 
    1.73 +	label12 = gtk_label_new_with_mnemonic ("_Crop");
    1.74 +	gtk_widget_set_name (label12, "label12");
    1.75 +	gtk_widget_show (label12);
    1.76 +	gtk_box_pack_start (GTK_BOX (hbox11), label12, FALSE, FALSE, 0);
    1.77  
    1.78  
    1.79  
    1.80  
    1.81  
    1.82 +  g_signal_connect (G_OBJECT (cropper_window), "show",
    1.83 +                    G_CALLBACK (on_cropper_window_create),
    1.84 +                    NULL);
    1.85  /* destroy */
    1.86    g_signal_connect (G_OBJECT (cropper_window), "destroy",
    1.87                      G_CALLBACK (on_cropper_window_destroy),
    1.88 @@ -464,6 +469,20 @@
    1.89                      NULL);
    1.90  
    1.91  
    1.92 +/* zoom */
    1.93 +	g_signal_connect (G_OBJECT (crop_zoom_in_button), "clicked",
    1.94 +										G_CALLBACK (on_zoom_in_button_clicked),
    1.95 +										NULL);
    1.96 +	g_signal_connect (G_OBJECT (crop_zoom_out_button), "clicked",
    1.97 +										G_CALLBACK (on_zoom_out_button_clicked),
    1.98 +										NULL);
    1.99 +	g_signal_connect (G_OBJECT (crop_zoom_100_button), "clicked",
   1.100 +										G_CALLBACK (on_zoom_100_button_clicked),
   1.101 +										NULL);
   1.102 +	g_signal_connect (G_OBJECT (crop_zoom_fit_button), "clicked",
   1.103 +										G_CALLBACK (on_zoom_fit_button_clicked),
   1.104 +										NULL);
   1.105 +
   1.106  
   1.107  /* aspect ratio */
   1.108  /*
   1.109 @@ -528,22 +547,6 @@
   1.110  */
   1.111  
   1.112  
   1.113 -/* zoom */
   1.114 -/*
   1.115 -g_signal_connect (G_OBJECT (zoom_in_button), "clicked",
   1.116 -	G_CALLBACK (zoom_in_button_clicked_cb),
   1.117 -	data);
   1.118 -g_signal_connect (G_OBJECT (zoom_out_button), "clicked",
   1.119 -	G_CALLBACK (zoom_out_button_clicked_cb),
   1.120 -	data);
   1.121 -g_signal_connect (G_OBJECT (zoom_100_button), "clicked",
   1.122 -	G_CALLBACK (zoom_100_button_clicked_cb),
   1.123 -	data);
   1.124 -g_signal_connect (G_OBJECT (zoom_fit_button), "clicked",
   1.125 -	G_CALLBACK (zoom_fit_button_clicked_cb),
   1.126 -	data);
   1.127 -*/
   1.128 -
   1.129  
   1.130  
   1.131  
   1.132 @@ -604,6 +607,7 @@
   1.133    GLADE_HOOKUP_OBJECT (cropper_window, vbox7, "vbox7");
   1.134    GLADE_HOOKUP_OBJECT (cropper_window, nav_container, "nav_container");
   1.135    GLADE_HOOKUP_OBJECT (cropper_window, image_area, "image_area");
   1.136 +  GLADE_HOOKUP_OBJECT (cropper_window, image_buffer, "image_buffer");
   1.137    GLADE_HOOKUP_OBJECT (cropper_window, hbox16, "hbox16");
   1.138    GLADE_HOOKUP_OBJECT (cropper_window, hbox17, "hbox17");
   1.139    GLADE_HOOKUP_OBJECT (cropper_window, crop_zoom_in_button, "crop_zoom_in_button");
   1.140 @@ -615,7 +619,7 @@
   1.141    GLADE_HOOKUP_OBJECT (cropper_window, crop_zoom_fit_button, "crop_zoom_fit_button");
   1.142    GLADE_HOOKUP_OBJECT (cropper_window, image1, "image1");
   1.143  	/*GLADE_HOOKUP_OBJECT_NO_REF (cropper_window, dialog_action_area1, "dialog_action_area1"); */
   1.144 -	GLADE_HOOKUP_OBJECT (cropper_window, crop_okbutton, "crop_okbutton"); 
   1.145 +	GLADE_HOOKUP_OBJECT (cropper_window, crop_okbutton, "crop_okbutton");
   1.146  	GLADE_HOOKUP_OBJECT (cropper_window, alignment1, "alignment1");
   1.147  	GLADE_HOOKUP_OBJECT (cropper_window, hbox11, "hbox11");
   1.148  	GLADE_HOOKUP_OBJECT (cropper_window, crop_image, "crop_image");