cropper

diff cropper.c @ 19:762de8cee1e4

fixed makefile; some cleanups
author meillo@marmaro.de
date Thu, 04 Mar 2010 19:44:28 +0100
parents 9d6e8105b145
children
line diff
     1.1 --- a/cropper.c	Thu Mar 04 19:34:39 2010 +0100
     1.2 +++ b/cropper.c	Thu Mar 04 19:44:28 2010 +0100
     1.3 @@ -29,12 +29,6 @@
     1.4  /* from callbacks.h */
     1.5  double ratio;
     1.6  
     1.7 -void crop(void);
     1.8 -gboolean on_key_press(GtkWidget* window, GdkEventKey* pKey, gpointer userdata);
     1.9 -void on_cropper_window_create(GtkObject* object, gpointer user_data);
    1.10 -void on_cropper_window_destroy(GtkObject* object, gpointer user_data);
    1.11 -
    1.12 -
    1.13  
    1.14  
    1.15  
    1.16 @@ -82,106 +76,24 @@
    1.17  
    1.18  
    1.19  
    1.20 -GtkWidget*
    1.21 -create_cropper_window(void)
    1.22 -{
    1.23 -  GtkWidget *cropper_window;
    1.24 -  GtkWidget *dialog_vbox1;
    1.25 -  GtkWidget *status;
    1.26 -  GtkWidget *label1;
    1.27 -  GtkWidget *label2;
    1.28  
    1.29  
    1.30 -  cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    1.31 -  gtk_widget_set_name(cropper_window, "cropper_window");
    1.32 -  gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6);
    1.33 -  gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2");
    1.34  
    1.35 -  dialog_vbox1 = gtk_vbox_new(FALSE, 6);
    1.36 -  gtk_widget_set_name(dialog_vbox1, "dialog_vbox1");
    1.37 -  gtk_widget_show(dialog_vbox1);
    1.38 -  gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1);
    1.39  
    1.40  
    1.41 -  status = gtk_hbox_new(FALSE, 0);
    1.42 -  gtk_widget_set_name(status, "status");
    1.43 -  gtk_widget_show(status);
    1.44 -  gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0);
    1.45  
    1.46 -  label1 = gtk_label_new("zoom:");
    1.47 -  gtk_widget_set_name(label1, "label1");
    1.48 -  gtk_widget_show(label1);
    1.49 -  gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0);
    1.50  
    1.51 -  label2 = gtk_label_new("1.0");
    1.52 -  gtk_widget_set_name(label2, "label2");
    1.53 -  gtk_widget_show(label2);
    1.54 -  gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0);
    1.55  
    1.56 -/* image_area */
    1.57 -  image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
    1.58 -  image_area = gtk_image_new_from_pixbuf(image_buffer);
    1.59  
    1.60 -  gtk_widget_set_name(image_area, "image_area");
    1.61 -  gtk_widget_show(image_area);
    1.62 -  gtk_box_pack_start(GTK_BOX(dialog_vbox1), image_area, TRUE, TRUE, 0);
    1.63  
    1.64  
    1.65  
    1.66  
    1.67  
    1.68 -g_signal_connect(G_OBJECT(cropper_window), "show",
    1.69 -                 G_CALLBACK(on_cropper_window_create), NULL);
    1.70  
    1.71 -g_signal_connect(G_OBJECT(cropper_window), "destroy",
    1.72 -                 G_CALLBACK(on_cropper_window_destroy), NULL);
    1.73  
    1.74 -g_signal_connect(cropper_window, "key-press-event",
    1.75 -                 G_CALLBACK(on_key_press), NULL);
    1.76  
    1.77  
    1.78 -  /* Store pointers to all widgets, for use by lookup_widget(). */
    1.79 -
    1.80 -  GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window");
    1.81 -  GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1");
    1.82 -
    1.83 -  GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1");
    1.84 -  GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2");
    1.85 -  GLADE_HOOKUP_OBJECT(cropper_window, status, "status");
    1.86 -  GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area");
    1.87 -  GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer");
    1.88 -
    1.89 -
    1.90 -  return cropper_window;
    1.91 -}
    1.92 -
    1.93 -
    1.94 -
    1.95 -
    1.96 -
    1.97 -
    1.98 -
    1.99 -
   1.100 -
   1.101 -
   1.102 -
   1.103 -
   1.104 -
   1.105 -
   1.106 -
   1.107 -
   1.108 -
   1.109 -
   1.110 -
   1.111 -
   1.112 -
   1.113 -void
   1.114 -update_title(char* zoom)
   1.115 -{
   1.116 -	char title[128];
   1.117 -	snprintf(title, 128, "cropper (%s) %dx%d+%d+%d", zoom, w, h, x, y);
   1.118 -	gtk_window_set_title(GTK_WINDOW(cropper_window), title);
   1.119 -}
   1.120  
   1.121  
   1.122  /* zoom */
   1.123 @@ -246,17 +158,7 @@
   1.124  	char crop_call[256];
   1.125  
   1.126  	sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"",
   1.127 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   1.128 -		                                 "crop_width_spinbutton")),
   1.129 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   1.130 -		                                 "crop_height_spinbutton")),
   1.131 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   1.132 -		                                 "crop_x_spinbutton")),
   1.133 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   1.134 -		                                 "crop_y_spinbutton")),
   1.135 -		image_filename,
   1.136 -		image_filename
   1.137 -	);
   1.138 +		w, h, x, y, image_filename, image_filename);
   1.139  	system(crop_call);
   1.140  	gtk_main_quit();
   1.141  }
   1.142 @@ -326,6 +228,80 @@
   1.143  
   1.144  
   1.145  
   1.146 +GtkWidget*
   1.147 +create_cropper_window(void)
   1.148 +{
   1.149 +	GtkWidget *cropper_window;
   1.150 +	GtkWidget *dialog_vbox1;
   1.151 +	GtkWidget *status;
   1.152 +	GtkWidget *label1;
   1.153 +	GtkWidget *label2;
   1.154 +	
   1.155 +	
   1.156 +	cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   1.157 +	gtk_widget_set_name(cropper_window, "cropper_window");
   1.158 +	gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6);
   1.159 +	gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2");
   1.160 +	
   1.161 +	dialog_vbox1 = gtk_vbox_new(FALSE, 6);
   1.162 +	gtk_widget_set_name(dialog_vbox1, "dialog_vbox1");
   1.163 +	gtk_widget_show(dialog_vbox1);
   1.164 +	gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1);
   1.165 +	
   1.166 +	
   1.167 +	status = gtk_hbox_new(FALSE, 0);
   1.168 +	gtk_widget_set_name(status, "status");
   1.169 +	gtk_widget_show(status);
   1.170 +	gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0);
   1.171 +	
   1.172 +	label1 = gtk_label_new("zoom:");
   1.173 +	gtk_widget_set_name(label1, "label1");
   1.174 +	gtk_widget_show(label1);
   1.175 +	gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0);
   1.176 +	
   1.177 +	label2 = gtk_label_new("1.0");
   1.178 +	gtk_widget_set_name(label2, "label2");
   1.179 +	gtk_widget_show(label2);
   1.180 +	gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0);
   1.181 +	
   1.182 +	/* image_area */
   1.183 +	image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
   1.184 +	image_area = gtk_image_new_from_pixbuf(image_buffer);
   1.185 +	
   1.186 +	gtk_widget_set_name(image_area, "image_area");
   1.187 +	gtk_widget_show(image_area);
   1.188 +	gtk_box_pack_start(GTK_BOX(dialog_vbox1), image_area, TRUE, TRUE, 0);
   1.189 +	
   1.190 +	
   1.191 +	
   1.192 +	
   1.193 +	
   1.194 +	g_signal_connect(G_OBJECT(cropper_window), "show",
   1.195 +	               G_CALLBACK(on_cropper_window_create), NULL);
   1.196 +	
   1.197 +	g_signal_connect(G_OBJECT(cropper_window), "destroy",
   1.198 +	               G_CALLBACK(on_cropper_window_destroy), NULL);
   1.199 +	
   1.200 +	g_signal_connect(cropper_window, "key-press-event",
   1.201 +	               G_CALLBACK(on_key_press), NULL);
   1.202 +	
   1.203 +	
   1.204 +	/* Store pointers to all widgets, for use by lookup_widget(). */
   1.205 +	
   1.206 +	GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window");
   1.207 +	GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1");
   1.208 +	
   1.209 +	GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1");
   1.210 +	GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2");
   1.211 +	GLADE_HOOKUP_OBJECT(cropper_window, status, "status");
   1.212 +	GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area");
   1.213 +	GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer");
   1.214 +	
   1.215 +	
   1.216 +	return cropper_window;
   1.217 +}
   1.218 +
   1.219 +
   1.220  
   1.221  
   1.222  
   1.223 @@ -348,4 +324,3 @@
   1.224  
   1.225  	return 0;
   1.226  }
   1.227 -