# HG changeset patch # User meillo@marmaro.de # Date 1267728268 -3600 # Node ID 762de8cee1e4748613085b4b9e4d4bf8aae99309 # Parent 9d6e8105b145bdff86ac73c64fccb1085b2a4e09 fixed makefile; some cleanups diff -r 9d6e8105b145 -r 762de8cee1e4 Makefile --- a/Makefile Thu Mar 04 19:34:39 2010 +0100 +++ b/Makefile Thu Mar 04 19:44:28 2010 +0100 @@ -5,8 +5,8 @@ LDFLAGS = `pkg-config --libs --cflags gtk+-2.0` -cropper: main.o - ${CC} -o cropper main.o ${LDFLAGS} +cropper: cropper.c + ${CC} -o cropper cropper.c ${LDFLAGS} clean: diff -r 9d6e8105b145 -r 762de8cee1e4 cropper.c --- a/cropper.c Thu Mar 04 19:34:39 2010 +0100 +++ b/cropper.c Thu Mar 04 19:44:28 2010 +0100 @@ -29,12 +29,6 @@ /* from callbacks.h */ double ratio; -void crop(void); -gboolean on_key_press(GtkWidget* window, GdkEventKey* pKey, gpointer userdata); -void on_cropper_window_create(GtkObject* object, gpointer user_data); -void on_cropper_window_destroy(GtkObject* object, gpointer user_data); - - @@ -82,106 +76,24 @@ -GtkWidget* -create_cropper_window(void) -{ - GtkWidget *cropper_window; - GtkWidget *dialog_vbox1; - GtkWidget *status; - GtkWidget *label1; - GtkWidget *label2; - cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_widget_set_name(cropper_window, "cropper_window"); - gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6); - gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2"); - dialog_vbox1 = gtk_vbox_new(FALSE, 6); - gtk_widget_set_name(dialog_vbox1, "dialog_vbox1"); - gtk_widget_show(dialog_vbox1); - gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1); - status = gtk_hbox_new(FALSE, 0); - gtk_widget_set_name(status, "status"); - gtk_widget_show(status); - gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0); - label1 = gtk_label_new("zoom:"); - gtk_widget_set_name(label1, "label1"); - gtk_widget_show(label1); - gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0); - label2 = gtk_label_new("1.0"); - gtk_widget_set_name(label2, "label2"); - gtk_widget_show(label2); - gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0); -/* image_area */ - 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(dialog_vbox1), image_area, TRUE, TRUE, 0); -g_signal_connect(G_OBJECT(cropper_window), "show", - G_CALLBACK(on_cropper_window_create), NULL); -g_signal_connect(G_OBJECT(cropper_window), "destroy", - G_CALLBACK(on_cropper_window_destroy), NULL); -g_signal_connect(cropper_window, "key-press-event", - G_CALLBACK(on_key_press), NULL); - /* Store pointers to all widgets, for use by lookup_widget(). */ - - GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window"); - GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1"); - - GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1"); - GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2"); - GLADE_HOOKUP_OBJECT(cropper_window, status, "status"); - GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area"); - GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer"); - - - return cropper_window; -} - - - - - - - - - - - - - - - - - - - - - -void -update_title(char* zoom) -{ - char title[128]; - snprintf(title, 128, "cropper (%s) %dx%d+%d+%d", zoom, w, h, x, y); - gtk_window_set_title(GTK_WINDOW(cropper_window), title); -} /* zoom */ @@ -246,17 +158,7 @@ char crop_call[256]; sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"", - 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 - ); + w, h, x, y, image_filename, image_filename); system(crop_call); gtk_main_quit(); } @@ -326,6 +228,80 @@ +GtkWidget* +create_cropper_window(void) +{ + GtkWidget *cropper_window; + GtkWidget *dialog_vbox1; + GtkWidget *status; + GtkWidget *label1; + GtkWidget *label2; + + + cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_widget_set_name(cropper_window, "cropper_window"); + gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6); + gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2"); + + dialog_vbox1 = gtk_vbox_new(FALSE, 6); + gtk_widget_set_name(dialog_vbox1, "dialog_vbox1"); + gtk_widget_show(dialog_vbox1); + gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1); + + + status = gtk_hbox_new(FALSE, 0); + gtk_widget_set_name(status, "status"); + gtk_widget_show(status); + gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0); + + label1 = gtk_label_new("zoom:"); + gtk_widget_set_name(label1, "label1"); + gtk_widget_show(label1); + gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0); + + label2 = gtk_label_new("1.0"); + gtk_widget_set_name(label2, "label2"); + gtk_widget_show(label2); + gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0); + + /* image_area */ + 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(dialog_vbox1), image_area, TRUE, TRUE, 0); + + + + + + g_signal_connect(G_OBJECT(cropper_window), "show", + G_CALLBACK(on_cropper_window_create), NULL); + + g_signal_connect(G_OBJECT(cropper_window), "destroy", + G_CALLBACK(on_cropper_window_destroy), NULL); + + g_signal_connect(cropper_window, "key-press-event", + G_CALLBACK(on_key_press), NULL); + + + /* Store pointers to all widgets, for use by lookup_widget(). */ + + GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window"); + GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1"); + + GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1"); + GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2"); + GLADE_HOOKUP_OBJECT(cropper_window, status, "status"); + GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area"); + GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer"); + + + return cropper_window; +} + + @@ -348,4 +324,3 @@ return 0; } -