Mercurial > cropper
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:e359bea4c8ac | 3:6aaba3a61563 |
---|---|
4 #include "callbacks.h" | 4 #include "callbacks.h" |
5 #include "interface.h" | 5 #include "interface.h" |
6 #include "support.h" | 6 #include "support.h" |
7 | 7 |
8 | 8 |
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 } | |
9 | 15 |
10 void on_ratio_none_activate (GtkMenuItem* menuitem, gpointer user_data) { | 16 void on_ratio_none_activate (GtkMenuItem* menuitem, gpointer user_data) { |
11 ratio = 0; | 17 ratio = (double) 1; |
18 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
12 } | 19 } |
13 | 20 |
14 | 21 |
15 void on_ratio_square_activate (GtkMenuItem* menuitem, gpointer user_data) { | 22 void on_ratio_square_activate (GtkMenuItem* menuitem, gpointer user_data) { |
16 ratio = 1; | 23 ratio = (double) 1; |
24 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
17 } | 25 } |
18 | 26 |
19 | 27 |
20 void on_ratio_4x3_activate (GtkMenuItem* menuitem, gpointer user_data) { | 28 void on_ratio_4x3_activate (GtkMenuItem* menuitem, gpointer user_data) { |
21 ratio = 4/3; | 29 ratio = (double) 4/3; |
30 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
22 } | 31 } |
23 | 32 |
24 | 33 |
25 void on_ratio_3x2_activate (GtkMenuItem* menuitem, gpointer user_data) { | 34 void on_ratio_3x2_activate (GtkMenuItem* menuitem, gpointer user_data) { |
26 ratio = 3/2; | 35 ratio = (double) 3/2; |
36 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); | |
27 } | 37 } |
28 | 38 |
29 | 39 |
30 void on_ratio_custom_activate (GtkMenuItem* menuitem, gpointer user_data) { | 40 void on_ratio_custom_activate (GtkMenuItem* menuitem, gpointer user_data) { |
31 | 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")); | |
32 } | 43 } |
33 | 44 |
34 | 45 |
35 | 46 |
36 | 47 |
37 | 48 |
38 void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { | 49 void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { |
39 | 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); | |
40 } | 53 } |
41 | 54 |
42 | 55 |
43 void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { | 56 void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { |
44 | |
45 } | 57 } |
46 | 58 |
47 | 59 |
48 void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { | 60 void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { |
49 | |
50 } | 61 } |
51 | 62 |
52 | 63 |
53 void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { | 64 void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { |
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); | |
54 | 68 |
55 } | 69 } |
56 | 70 |
57 | 71 |
58 void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) { | 72 void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) { |
59 gint h; | |
60 | 73 |
61 h = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton")); | 74 ratio = 1.0 / ratio; |
62 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton"))); | 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"))); |
63 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), h); | 76 gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
77 | |
64 } | 78 } |
65 | 79 |
66 | 80 |
67 | 81 |
68 | 82 |