Mercurial > cropper
annotate callbacks.c @ 3:6aaba3a61563
added ratio control code
author | meillo@marmaro.de |
---|---|
date | Wed, 05 Dec 2007 00:08:39 +0100 |
parents | e359bea4c8ac |
children | 2f11ab3e6047 |
rev | line source |
---|---|
0 | 1 #include <gtk/gtk.h> |
2 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
3 #include "main.h" |
0 | 4 #include "callbacks.h" |
5 #include "interface.h" | |
6 #include "support.h" | |
7 | |
8 | |
3 | 9 void update_spin_button_ratio(GtkWidget* spinbutton) { |
10 g_print("ratio change: %f\n", ratio); | |
11 /*gtk_spin_button_set_value((spinbutton), gtk_spin_button_get_value(spinbutton));*/ | |
12 /*gtk_spin_button_update(spinbutton);*/ | |
13 on_ratio_w_spinbutton_value_changed(spinbutton, NULL); | |
14 } | |
0 | 15 |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
16 void on_ratio_none_activate (GtkMenuItem* menuitem, gpointer user_data) { |
3 | 17 ratio = (double) 1; |
18 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
19 } |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
20 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
21 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
22 void on_ratio_square_activate (GtkMenuItem* menuitem, gpointer user_data) { |
3 | 23 ratio = (double) 1; |
24 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
0 | 25 } |
26 | |
27 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
28 void on_ratio_4x3_activate (GtkMenuItem* menuitem, gpointer user_data) { |
3 | 29 ratio = (double) 4/3; |
30 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
0 | 31 } |
32 | |
33 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
34 void on_ratio_3x2_activate (GtkMenuItem* menuitem, gpointer user_data) { |
3 | 35 ratio = (double) 3/2; |
36 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
37 } |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
38 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
39 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
40 void on_ratio_custom_activate (GtkMenuItem* menuitem, gpointer user_data) { |
3 | 41 ratio = (double) gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton")) / gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_h_spinbutton")); |
42 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
0 | 43 } |
44 | |
45 | |
46 | |
47 | |
48 | |
1 | 49 void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { |
3 | 50 /*gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), gtk_spin_button_get_value(spinbutton) / ratio);*/ |
51 g_print("spinbutton W - ratio: %f\n", ratio); | |
52 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), gtk_spin_button_get_value(spinbutton) / ratio); | |
0 | 53 } |
54 | |
55 | |
1 | 56 void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { |
0 | 57 } |
58 | |
59 | |
1 | 60 void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { |
0 | 61 } |
62 | |
63 | |
1 | 64 void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { |
3 | 65 /*gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(spinbutton) * ratio);*/ |
66 g_print("spinbutton H - ratio: %f\n", ratio); | |
67 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(spinbutton) * ratio); | |
0 | 68 |
69 } | |
70 | |
71 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
72 void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) { |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
73 |
3 | 74 ratio = 1.0 / ratio; |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
75 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton"))); |
3 | 76 gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
77 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
78 } |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
79 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
80 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
81 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
82 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
83 |
1 | 84 gboolean on_cropper_window_delete_event (GtkWidget* widget, GdkEvent *event, gpointer user_data) { |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
85 /* g_print("thanks for using the program - visit http://prog.marmaro.de\n"); */ |
1 | 86 return FALSE; |
0 | 87 } |
88 | |
1 | 89 void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { |
0 | 90 gtk_main_quit(); |
91 } | |
92 |