cropper

changeset 19:762de8cee1e4 tip

fixed makefile; some cleanups
author meillo@marmaro.de
date Thu, 04 Mar 2010 19:44:28 +0100
parents 9d6e8105b145
children
files Makefile cropper.c
diffstat 2 files changed, 77 insertions(+), 102 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Thu Mar 04 19:34:39 2010 +0100
     1.2 +++ b/Makefile	Thu Mar 04 19:44:28 2010 +0100
     1.3 @@ -5,8 +5,8 @@
     1.4  LDFLAGS = `pkg-config --libs --cflags gtk+-2.0`
     1.5  
     1.6  
     1.7 -cropper: main.o
     1.8 -	${CC} -o cropper main.o ${LDFLAGS}
     1.9 +cropper: cropper.c
    1.10 +	${CC} -o cropper cropper.c ${LDFLAGS}
    1.11  
    1.12  
    1.13  clean:
     2.1 --- a/cropper.c	Thu Mar 04 19:34:39 2010 +0100
     2.2 +++ b/cropper.c	Thu Mar 04 19:44:28 2010 +0100
     2.3 @@ -29,12 +29,6 @@
     2.4  /* from callbacks.h */
     2.5  double ratio;
     2.6  
     2.7 -void crop(void);
     2.8 -gboolean on_key_press(GtkWidget* window, GdkEventKey* pKey, gpointer userdata);
     2.9 -void on_cropper_window_create(GtkObject* object, gpointer user_data);
    2.10 -void on_cropper_window_destroy(GtkObject* object, gpointer user_data);
    2.11 -
    2.12 -
    2.13  
    2.14  
    2.15  
    2.16 @@ -82,106 +76,24 @@
    2.17  
    2.18  
    2.19  
    2.20 -GtkWidget*
    2.21 -create_cropper_window(void)
    2.22 -{
    2.23 -  GtkWidget *cropper_window;
    2.24 -  GtkWidget *dialog_vbox1;
    2.25 -  GtkWidget *status;
    2.26 -  GtkWidget *label1;
    2.27 -  GtkWidget *label2;
    2.28  
    2.29  
    2.30 -  cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    2.31 -  gtk_widget_set_name(cropper_window, "cropper_window");
    2.32 -  gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6);
    2.33 -  gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2");
    2.34  
    2.35 -  dialog_vbox1 = gtk_vbox_new(FALSE, 6);
    2.36 -  gtk_widget_set_name(dialog_vbox1, "dialog_vbox1");
    2.37 -  gtk_widget_show(dialog_vbox1);
    2.38 -  gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1);
    2.39  
    2.40  
    2.41 -  status = gtk_hbox_new(FALSE, 0);
    2.42 -  gtk_widget_set_name(status, "status");
    2.43 -  gtk_widget_show(status);
    2.44 -  gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0);
    2.45  
    2.46 -  label1 = gtk_label_new("zoom:");
    2.47 -  gtk_widget_set_name(label1, "label1");
    2.48 -  gtk_widget_show(label1);
    2.49 -  gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0);
    2.50  
    2.51 -  label2 = gtk_label_new("1.0");
    2.52 -  gtk_widget_set_name(label2, "label2");
    2.53 -  gtk_widget_show(label2);
    2.54 -  gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0);
    2.55  
    2.56 -/* image_area */
    2.57 -  image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
    2.58 -  image_area = gtk_image_new_from_pixbuf(image_buffer);
    2.59  
    2.60 -  gtk_widget_set_name(image_area, "image_area");
    2.61 -  gtk_widget_show(image_area);
    2.62 -  gtk_box_pack_start(GTK_BOX(dialog_vbox1), image_area, TRUE, TRUE, 0);
    2.63  
    2.64  
    2.65  
    2.66  
    2.67  
    2.68 -g_signal_connect(G_OBJECT(cropper_window), "show",
    2.69 -                 G_CALLBACK(on_cropper_window_create), NULL);
    2.70  
    2.71 -g_signal_connect(G_OBJECT(cropper_window), "destroy",
    2.72 -                 G_CALLBACK(on_cropper_window_destroy), NULL);
    2.73  
    2.74 -g_signal_connect(cropper_window, "key-press-event",
    2.75 -                 G_CALLBACK(on_key_press), NULL);
    2.76  
    2.77  
    2.78 -  /* Store pointers to all widgets, for use by lookup_widget(). */
    2.79 -
    2.80 -  GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window");
    2.81 -  GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1");
    2.82 -
    2.83 -  GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1");
    2.84 -  GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2");
    2.85 -  GLADE_HOOKUP_OBJECT(cropper_window, status, "status");
    2.86 -  GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area");
    2.87 -  GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer");
    2.88 -
    2.89 -
    2.90 -  return cropper_window;
    2.91 -}
    2.92 -
    2.93 -
    2.94 -
    2.95 -
    2.96 -
    2.97 -
    2.98 -
    2.99 -
   2.100 -
   2.101 -
   2.102 -
   2.103 -
   2.104 -
   2.105 -
   2.106 -
   2.107 -
   2.108 -
   2.109 -
   2.110 -
   2.111 -
   2.112 -
   2.113 -void
   2.114 -update_title(char* zoom)
   2.115 -{
   2.116 -	char title[128];
   2.117 -	snprintf(title, 128, "cropper (%s) %dx%d+%d+%d", zoom, w, h, x, y);
   2.118 -	gtk_window_set_title(GTK_WINDOW(cropper_window), title);
   2.119 -}
   2.120  
   2.121  
   2.122  /* zoom */
   2.123 @@ -246,17 +158,7 @@
   2.124  	char crop_call[256];
   2.125  
   2.126  	sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"",
   2.127 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   2.128 -		                                 "crop_width_spinbutton")),
   2.129 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   2.130 -		                                 "crop_height_spinbutton")),
   2.131 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   2.132 -		                                 "crop_x_spinbutton")),
   2.133 -		gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window,
   2.134 -		                                 "crop_y_spinbutton")),
   2.135 -		image_filename,
   2.136 -		image_filename
   2.137 -	);
   2.138 +		w, h, x, y, image_filename, image_filename);
   2.139  	system(crop_call);
   2.140  	gtk_main_quit();
   2.141  }
   2.142 @@ -326,6 +228,80 @@
   2.143  
   2.144  
   2.145  
   2.146 +GtkWidget*
   2.147 +create_cropper_window(void)
   2.148 +{
   2.149 +	GtkWidget *cropper_window;
   2.150 +	GtkWidget *dialog_vbox1;
   2.151 +	GtkWidget *status;
   2.152 +	GtkWidget *label1;
   2.153 +	GtkWidget *label2;
   2.154 +	
   2.155 +	
   2.156 +	cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   2.157 +	gtk_widget_set_name(cropper_window, "cropper_window");
   2.158 +	gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6);
   2.159 +	gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2");
   2.160 +	
   2.161 +	dialog_vbox1 = gtk_vbox_new(FALSE, 6);
   2.162 +	gtk_widget_set_name(dialog_vbox1, "dialog_vbox1");
   2.163 +	gtk_widget_show(dialog_vbox1);
   2.164 +	gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1);
   2.165 +	
   2.166 +	
   2.167 +	status = gtk_hbox_new(FALSE, 0);
   2.168 +	gtk_widget_set_name(status, "status");
   2.169 +	gtk_widget_show(status);
   2.170 +	gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0);
   2.171 +	
   2.172 +	label1 = gtk_label_new("zoom:");
   2.173 +	gtk_widget_set_name(label1, "label1");
   2.174 +	gtk_widget_show(label1);
   2.175 +	gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0);
   2.176 +	
   2.177 +	label2 = gtk_label_new("1.0");
   2.178 +	gtk_widget_set_name(label2, "label2");
   2.179 +	gtk_widget_show(label2);
   2.180 +	gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0);
   2.181 +	
   2.182 +	/* image_area */
   2.183 +	image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
   2.184 +	image_area = gtk_image_new_from_pixbuf(image_buffer);
   2.185 +	
   2.186 +	gtk_widget_set_name(image_area, "image_area");
   2.187 +	gtk_widget_show(image_area);
   2.188 +	gtk_box_pack_start(GTK_BOX(dialog_vbox1), image_area, TRUE, TRUE, 0);
   2.189 +	
   2.190 +	
   2.191 +	
   2.192 +	
   2.193 +	
   2.194 +	g_signal_connect(G_OBJECT(cropper_window), "show",
   2.195 +	               G_CALLBACK(on_cropper_window_create), NULL);
   2.196 +	
   2.197 +	g_signal_connect(G_OBJECT(cropper_window), "destroy",
   2.198 +	               G_CALLBACK(on_cropper_window_destroy), NULL);
   2.199 +	
   2.200 +	g_signal_connect(cropper_window, "key-press-event",
   2.201 +	               G_CALLBACK(on_key_press), NULL);
   2.202 +	
   2.203 +	
   2.204 +	/* Store pointers to all widgets, for use by lookup_widget(). */
   2.205 +	
   2.206 +	GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window");
   2.207 +	GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1");
   2.208 +	
   2.209 +	GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1");
   2.210 +	GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2");
   2.211 +	GLADE_HOOKUP_OBJECT(cropper_window, status, "status");
   2.212 +	GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area");
   2.213 +	GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer");
   2.214 +	
   2.215 +	
   2.216 +	return cropper_window;
   2.217 +}
   2.218 +
   2.219 +
   2.220  
   2.221  
   2.222  
   2.223 @@ -348,4 +324,3 @@
   2.224  
   2.225  	return 0;
   2.226  }
   2.227 -