cropper
changeset 2:e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
author | meillo@marmaro.de |
---|---|
date | Tue, 04 Dec 2007 23:20:51 +0100 |
parents | 80535e4deaa4 |
children | 6aaba3a61563 |
files | Makefile callbacks.c callbacks.h interface.c main.c main.h support.c |
diffstat | 7 files changed, 111 insertions(+), 121 deletions(-) [+] |
line diff
1.1 --- a/Makefile Tue Dec 04 20:23:25 2007 +0100 1.2 +++ b/Makefile Tue Dec 04 23:20:51 2007 +0100 1.3 @@ -17,4 +17,10 @@ 1.4 .c.o: 1.5 ${CC} ${CFLAGS} -c $< 1.6 1.7 + 1.8 +clean: 1.9 + rm ${OBJS} 1.10 + rm ${PACKAGE} 1.11 + 1.12 + 1.13 # end of file
2.1 --- a/callbacks.c Tue Dec 04 20:23:25 2007 +0100 2.2 +++ b/callbacks.c Tue Dec 04 23:20:51 2007 +0100 2.3 @@ -1,43 +1,38 @@ 2.4 #include <gtk/gtk.h> 2.5 2.6 +#include "main.h" 2.7 #include "callbacks.h" 2.8 #include "interface.h" 2.9 #include "support.h" 2.10 2.11 2.12 -void on_none1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.13 + 2.14 +void on_ratio_none_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.15 + ratio = 0; 2.16 +} 2.17 + 2.18 + 2.19 +void on_ratio_square_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.20 + ratio = 1; 2.21 +} 2.22 + 2.23 + 2.24 +void on_ratio_4x3_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.25 + ratio = 4/3; 2.26 +} 2.27 + 2.28 + 2.29 +void on_ratio_3x2_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.30 + ratio = 3/2; 2.31 +} 2.32 + 2.33 + 2.34 +void on_ratio_custom_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.35 2.36 } 2.37 2.38 2.39 -void on_square1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.40 2.41 -} 2.42 - 2.43 - 2.44 -void on_4x3__book__dvd_1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.45 - 2.46 -} 2.47 - 2.48 - 2.49 -void on_4x6__postcard_1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.50 - 2.51 -} 2.52 - 2.53 - 2.54 -void on_5x1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.55 - 2.56 -} 2.57 - 2.58 - 2.59 -void on_8x1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.60 - 2.61 -} 2.62 - 2.63 - 2.64 -void on_custom1_activate (GtkMenuItem* menuitem, gpointer user_data) { 2.65 - 2.66 -} 2.67 2.68 2.69 void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { 2.70 @@ -50,11 +45,6 @@ 2.71 } 2.72 2.73 2.74 -void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) { 2.75 - 2.76 -} 2.77 - 2.78 - 2.79 void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { 2.80 2.81 } 2.82 @@ -65,12 +55,23 @@ 2.83 } 2.84 2.85 2.86 +void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) { 2.87 + gint h; 2.88 + 2.89 + h = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton")); 2.90 + gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton"))); 2.91 + gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), h); 2.92 +} 2.93 + 2.94 + 2.95 + 2.96 + 2.97 + 2.98 gboolean on_cropper_window_delete_event (GtkWidget* widget, GdkEvent *event, gpointer user_data) { 2.99 - g_print("thanks for using the program - visit http://prog.marmaro.de\n"); 2.100 + /* g_print("thanks for using the program - visit http://prog.marmaro.de\n"); */ 2.101 return FALSE; 2.102 } 2.103 2.104 - 2.105 void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { 2.106 gtk_main_quit(); 2.107 }
3.1 --- a/callbacks.h Tue Dec 04 20:23:25 2007 +0100 3.2 +++ b/callbacks.h Tue Dec 04 23:20:51 2007 +0100 3.3 @@ -1,32 +1,19 @@ 3.4 #include <gtk/gtk.h> 3.5 3.6 +gdouble ratio; 3.7 3.8 -void on_none1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.9 +void on_ratio_none_activate(GtkMenuItem* menuitem, gpointer user_data); 3.10 +void on_ratio_square_activate(GtkMenuItem* menuitem, gpointer user_data); 3.11 +void on_ratio_4x3_activate(GtkMenuItem* menuitem, gpointer user_data); 3.12 +void on_ratio_3x2_activate(GtkMenuItem* menuitem, gpointer user_data); 3.13 +void on_ratio_custom_activate(GtkMenuItem* menuitem, gpointer user_data); 3.14 3.15 -void on_square1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.16 - 3.17 -void on_4x3__book__dvd_1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.18 - 3.19 -void on_4x6__postcard_1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.20 - 3.21 -void on_5x1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.22 - 3.23 -void on_8x1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.24 - 3.25 -void on_custom1_activate(GtkMenuItem* menuitem, gpointer user_data); 3.26 +void on_ratio_w_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data); 3.27 +void on_ratio_w_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data); 3.28 +void on_ratio_h_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data); 3.29 +void on_ratio_h_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data); 3.30 +void on_ratio_swap_button_clicked(GtkButton* button, gpointer user_data); 3.31 3.32 void on_cropper_window_destroy(GtkObject* object, gpointer user_data); 3.33 - 3.34 -void on_ratio_w_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data); 3.35 - 3.36 -void on_ratio_w_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data); 3.37 - 3.38 -void on_ratio_swap_button_clicked(GtkButton* button, gpointer user_data); 3.39 - 3.40 -void on_ratio_h_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data); 3.41 - 3.42 -void on_ratio_h_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data); 3.43 - 3.44 gboolean on_cropper_window_delete_event(GtkWidget* widget, GdkEvent *event, gpointer user_data); 3.45 3.46 -void on_cropper_window_destroy(GtkObject* object, gpointer user_data);
4.1 --- a/interface.c Tue Dec 04 20:23:25 2007 +0100 4.2 +++ b/interface.c Tue Dec 04 23:20:51 2007 +0100 4.3 @@ -62,13 +62,11 @@ 4.4 GtkWidget *ratio_h_spinbutton; 4.5 GtkWidget *ratio_optionmenu; 4.6 GtkWidget *menu1; 4.7 - GtkWidget *none1; 4.8 - GtkWidget *square1; 4.9 - GtkWidget *_4x3__book__dvd_1; 4.10 - GtkWidget *_4x6__postcard_1; 4.11 - GtkWidget *_5x1; 4.12 - GtkWidget *_8x1; 4.13 - GtkWidget *custom1; 4.14 + GtkWidget *ratio_none; 4.15 + GtkWidget *ratio_square; 4.16 + GtkWidget *ratio_4x3; 4.17 + GtkWidget *ratio_3x2; 4.18 + GtkWidget *ratio_custom; 4.19 GtkWidget *vbox5; 4.20 GtkWidget *frame1; 4.21 GtkWidget *vbox7; 4.22 @@ -298,40 +296,30 @@ 4.23 menu1 = gtk_menu_new (); 4.24 gtk_widget_set_name (menu1, "menu1"); 4.25 4.26 - none1 = gtk_menu_item_new_with_mnemonic ("None"); 4.27 - gtk_widget_set_name (none1, "none1"); 4.28 - gtk_widget_show (none1); 4.29 - gtk_container_add (GTK_CONTAINER (menu1), none1); 4.30 + ratio_none = gtk_menu_item_new_with_mnemonic ("None"); 4.31 + gtk_widget_set_name (ratio_none, "ratio_none"); 4.32 + gtk_widget_show (ratio_none); 4.33 + gtk_container_add (GTK_CONTAINER (menu1), ratio_none); 4.34 4.35 - square1 = gtk_menu_item_new_with_mnemonic ("Square"); 4.36 - gtk_widget_set_name (square1, "square1"); 4.37 - gtk_widget_show (square1); 4.38 - gtk_container_add (GTK_CONTAINER (menu1), square1); 4.39 + ratio_square = gtk_menu_item_new_with_mnemonic ("Square"); 4.40 + gtk_widget_set_name (ratio_square, "ratio_square"); 4.41 + gtk_widget_show (ratio_square); 4.42 + gtk_container_add (GTK_CONTAINER (menu1), ratio_square); 4.43 4.44 - _4x3__book__dvd_1 = gtk_menu_item_new_with_mnemonic ("4 x 3 (Book, DVD)"); 4.45 - gtk_widget_set_name (_4x3__book__dvd_1, "_4x3__book__dvd_1"); 4.46 - gtk_widget_show (_4x3__book__dvd_1); 4.47 - gtk_container_add (GTK_CONTAINER (menu1), _4x3__book__dvd_1); 4.48 + ratio_4x3 = gtk_menu_item_new_with_mnemonic ("4 x 3 (Book, DVD)"); 4.49 + gtk_widget_set_name (ratio_4x3, "ratio_4x3"); 4.50 + gtk_widget_show (ratio_4x3); 4.51 + gtk_container_add (GTK_CONTAINER (menu1), ratio_4x3); 4.52 4.53 - _4x6__postcard_1 = gtk_menu_item_new_with_mnemonic ("4 x 6 (Postcard)"); 4.54 - gtk_widget_set_name (_4x6__postcard_1, "_4x6__postcard_1"); 4.55 - gtk_widget_show (_4x6__postcard_1); 4.56 - gtk_container_add (GTK_CONTAINER (menu1), _4x6__postcard_1); 4.57 + ratio_3x2 = gtk_menu_item_new_with_mnemonic ("4 x 6 (Postcard)"); 4.58 + gtk_widget_set_name (ratio_3x2, "ratio_3x2"); 4.59 + gtk_widget_show (ratio_3x2); 4.60 + gtk_container_add (GTK_CONTAINER (menu1), ratio_3x2); 4.61 4.62 - _5x1 = gtk_menu_item_new_with_mnemonic ("5 x 7"); 4.63 - gtk_widget_set_name (_5x1, "_5x1"); 4.64 - gtk_widget_show (_5x1); 4.65 - gtk_container_add (GTK_CONTAINER (menu1), _5x1); 4.66 - 4.67 - _8x1 = gtk_menu_item_new_with_mnemonic ("8 x 10"); 4.68 - gtk_widget_set_name (_8x1, "_8x1"); 4.69 - gtk_widget_show (_8x1); 4.70 - gtk_container_add (GTK_CONTAINER (menu1), _8x1); 4.71 - 4.72 - custom1 = gtk_menu_item_new_with_mnemonic ("Custom"); 4.73 - gtk_widget_set_name (custom1, "custom1"); 4.74 - gtk_widget_show (custom1); 4.75 - gtk_container_add (GTK_CONTAINER (menu1), custom1); 4.76 + ratio_custom = gtk_menu_item_new_with_mnemonic ("Custom"); 4.77 + gtk_widget_set_name (ratio_custom, "ratio_custom"); 4.78 + gtk_widget_show (ratio_custom); 4.79 + gtk_container_add (GTK_CONTAINER (menu1), ratio_custom); 4.80 4.81 gtk_option_menu_set_menu (GTK_OPTION_MENU (ratio_optionmenu), menu1); 4.82 4.83 @@ -411,12 +399,17 @@ 4.84 gtk_container_add (GTK_CONTAINER (crop_zoom_fit_button), image1); 4.85 4.86 4.87 + 4.88 + 4.89 + 4.90 + 4.91 g_signal_connect ((gpointer) cropper_window, "delete_event", 4.92 G_CALLBACK (on_cropper_window_delete_event), 4.93 NULL); 4.94 g_signal_connect ((gpointer) cropper_window, "destroy", 4.95 G_CALLBACK (on_cropper_window_destroy), 4.96 NULL); 4.97 + 4.98 g_signal_connect ((gpointer) ratio_w_spinbutton, "value_changed", 4.99 G_CALLBACK (on_ratio_w_spinbutton_value_changed), 4.100 NULL); 4.101 @@ -432,27 +425,23 @@ 4.102 g_signal_connect ((gpointer) ratio_h_spinbutton, "value_changed", 4.103 G_CALLBACK (on_ratio_h_spinbutton_value_changed), 4.104 NULL); 4.105 - g_signal_connect ((gpointer) none1, "activate", 4.106 - G_CALLBACK (on_none1_activate), 4.107 + 4.108 + g_signal_connect ((gpointer) ratio_none, "activate", 4.109 + G_CALLBACK (on_ratio_none_activate), 4.110 NULL); 4.111 - g_signal_connect ((gpointer) square1, "activate", 4.112 - G_CALLBACK (on_square1_activate), 4.113 + g_signal_connect ((gpointer) ratio_square, "activate", 4.114 + G_CALLBACK (on_ratio_square_activate), 4.115 NULL); 4.116 - g_signal_connect ((gpointer) _4x3__book__dvd_1, "activate", 4.117 - G_CALLBACK (on_4x3__book__dvd_1_activate), 4.118 + g_signal_connect ((gpointer) ratio_4x3, "activate", 4.119 + G_CALLBACK (on_ratio_4x3_activate), 4.120 NULL); 4.121 - g_signal_connect ((gpointer) _4x6__postcard_1, "activate", 4.122 - G_CALLBACK (on_4x6__postcard_1_activate), 4.123 + g_signal_connect ((gpointer) ratio_3x2, "activate", 4.124 + G_CALLBACK (on_ratio_3x2_activate), 4.125 NULL); 4.126 - g_signal_connect ((gpointer) _5x1, "activate", 4.127 - G_CALLBACK (on_5x1_activate), 4.128 + g_signal_connect ((gpointer) ratio_custom, "activate", 4.129 + G_CALLBACK (on_ratio_custom_activate), 4.130 NULL); 4.131 - g_signal_connect ((gpointer) _8x1, "activate", 4.132 - G_CALLBACK (on_8x1_activate), 4.133 - NULL); 4.134 - g_signal_connect ((gpointer) custom1, "activate", 4.135 - G_CALLBACK (on_custom1_activate), 4.136 - NULL); 4.137 + 4.138 4.139 /* Store pointers to all widgets, for use by lookup_widget(). */ 4.140 GLADE_HOOKUP_OBJECT_NO_REF (cropper_window, cropper_window, "cropper_window"); 4.141 @@ -490,13 +479,11 @@ 4.142 GLADE_HOOKUP_OBJECT (cropper_window, ratio_h_spinbutton, "ratio_h_spinbutton"); 4.143 GLADE_HOOKUP_OBJECT (cropper_window, ratio_optionmenu, "ratio_optionmenu"); 4.144 GLADE_HOOKUP_OBJECT (cropper_window, menu1, "menu1"); 4.145 - GLADE_HOOKUP_OBJECT (cropper_window, none1, "none1"); 4.146 - GLADE_HOOKUP_OBJECT (cropper_window, square1, "square1"); 4.147 - GLADE_HOOKUP_OBJECT (cropper_window, _4x3__book__dvd_1, "_4x3__book__dvd_1"); 4.148 - GLADE_HOOKUP_OBJECT (cropper_window, _4x6__postcard_1, "_4x6__postcard_1"); 4.149 - GLADE_HOOKUP_OBJECT (cropper_window, _5x1, "_5x1"); 4.150 - GLADE_HOOKUP_OBJECT (cropper_window, _8x1, "_8x1"); 4.151 - GLADE_HOOKUP_OBJECT (cropper_window, custom1, "custom1"); 4.152 + GLADE_HOOKUP_OBJECT (cropper_window, ratio_none, "ratio_none"); 4.153 + GLADE_HOOKUP_OBJECT (cropper_window, ratio_square, "ratio_square"); 4.154 + GLADE_HOOKUP_OBJECT (cropper_window, ratio_4x3, "ratio_4x3"); 4.155 + GLADE_HOOKUP_OBJECT (cropper_window, ratio_3x2, "ratio_3x2"); 4.156 + GLADE_HOOKUP_OBJECT (cropper_window, ratio_custom, "ratio_custom"); 4.157 GLADE_HOOKUP_OBJECT (cropper_window, vbox5, "vbox5"); 4.158 GLADE_HOOKUP_OBJECT (cropper_window, frame1, "frame1"); 4.159 GLADE_HOOKUP_OBJECT (cropper_window, vbox7, "vbox7");
5.1 --- a/main.c Tue Dec 04 20:23:25 2007 +0100 5.2 +++ b/main.c Tue Dec 04 23:20:51 2007 +0100 5.3 @@ -1,10 +1,11 @@ 5.4 #include <gtk/gtk.h> 5.5 5.6 +#include "main.h" 5.7 #include "interface.h" 5.8 #include "support.h" 5.9 5.10 + 5.11 int main (int argc, char *argv[]) { 5.12 - GtkWidget *cropper_window; 5.13 5.14 gtk_set_locale (); 5.15 gtk_init (&argc, &argv);
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/main.h Tue Dec 04 23:20:51 2007 +0100 6.3 @@ -0,0 +1,8 @@ 6.4 +#ifndef _MAIN_H_ 6.5 +#define _MAIN_H_ 6.6 + 6.7 +#include <gtk/gtk.h> 6.8 + 6.9 +GtkWidget* cropper_window; 6.10 + 6.11 +#endif
7.1 --- a/support.c Tue Dec 04 20:23:25 2007 +0100 7.2 +++ b/support.c Tue Dec 04 23:20:51 2007 +0100 7.3 @@ -112,7 +112,7 @@ 7.4 7.5 /* This is used to set ATK action descriptions. */ 7.6 void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description) { 7.7 - gint n_actions 7.8 + gint n_actions; 7.9 gint i; 7.10 7.11 n_actions = atk_action_get_n_actions (action);