Mercurial > cropper
annotate callbacks.c @ 16:88b8856fccf5
merged callbacks.h in main.h
author | meillo@marmaro.de |
---|---|
date | Thu, 04 Mar 2010 19:20:41 +0100 |
parents | 7dbf3879939a |
children |
rev | line source |
---|---|
0 | 1 #include <gtk/gtk.h> |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
2 #include <gdk-pixbuf/gdk-pixbuf.h> |
13 | 3 #include <gdk/gdkkeysyms.h> |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
4 #include "main.h" |
0 | 5 |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
6 int image_width; |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
7 int image_height; |
10 | 8 float inc = 0.3; |
13 | 9 float zoom = 1.0; |
11 | 10 |
11 | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
12 /* |
11 | 13 void |
14 update_spin_button_ratio(GtkWidget* spinbutton) | |
15 { | |
3 | 16 g_print("ratio change: %f\n", ratio); |
17 on_ratio_w_spinbutton_value_changed(spinbutton, NULL); | |
18 } | |
0 | 19 |
20 | |
11 | 21 void |
22 on_ratio_none_activate(GtkMenuItem* menuitem, gpointer user_data) | |
23 { | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
24 ratio = 1; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
25 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
26 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
27 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
28 |
11 | 29 void |
30 on_ratio_square_activate(GtkMenuItem* menuitem, gpointer user_data) | |
31 { | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
32 ratio = 1; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
33 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
34 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
35 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
36 |
11 | 37 void |
38 on_ratio_4x3_activate(GtkMenuItem* menuitem, gpointer user_data) | |
39 { | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
40 ratio = 4.0/3.0; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
41 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
42 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
43 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
44 |
11 | 45 void |
46 on_ratio_3x2_activate(GtkMenuItem* menuitem, gpointer user_data) | |
47 { | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
48 ratio = 1.5; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
49 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
50 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
51 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
52 |
11 | 53 void |
54 on_ratio_custom_activate(GtkMenuItem* menuitem, gpointer user_data) | |
55 { | |
56 ratio = gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_w_spinbutton")) | |
57 / gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_h_spinbutton")); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
58 update_spin_button_ratio(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
59 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
60 */ |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
61 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
62 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
63 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
64 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
65 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
66 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
67 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
68 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
69 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
70 /* |
11 | 71 static void |
72 ratio_optionmenu_changed_cb(GtkOptionMenu* optionmenu, gpointer unser_data) | |
73 { | |
74 int idx = gtk_option_menu_get_history(optionmenu); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
75 int w = 1, h = 1; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
76 gboolean use_ratio = TRUE; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
77 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
78 switch (idx) { |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
79 case GTH_CROP_RATIO_NONE: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
80 use_ratio = FALSE; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
81 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
82 case GTH_CROP_RATIO_SQUARE: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
83 w = h = 1; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
84 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
85 case GTH_CROP_RATIO_IMAGE: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
86 w = lookup_widget(cropper_window, "image_width"); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
87 h = lookup_widget(cropper_window, "image_height"); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
88 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
89 case GTH_CROP_RATIO_DISPLAY: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
90 w = lookup_widget(cropper_window, "display_width"); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
91 h = lookup_widget(cropper_window, "display_height"); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
92 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
93 case GTH_CROP_RATIO_4_3: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
94 w = 4; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
95 h = 3; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
96 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
97 case GTH_CROP_RATIO_4_6: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
98 w = 4; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
99 h = 6; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
100 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
101 case GTH_CROP_RATIO_CUSTOM: |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
102 default: |
11 | 103 w = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON( |
104 lookup_widget(cropper_window, "ratio_w_spinbutton"))); | |
105 h = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON( | |
106 lookup_widget(cropper_window, "ratio_h_spinbutton"))); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
107 break; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
108 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
109 |
11 | 110 gtk_widget_set_sensitive(lookup_widget(cropper_window, "custom_ratio_box"), |
111 idx == GTH_CROP_RATIO_CUSTOM); | |
112 set_spin_value(cropper_window, lookup_widget(cropper_window, "ratio_w_spinbutton"), w); | |
113 set_spin_value(cropper_window, lookup_widget(cropper_window, "ratio_h_spinbutton"), h); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
114 |
11 | 115 gth_image_selector_set_ratio(GTH_IMAGE_SELECTOR(lookup_widget(cropper_window, "crop_image")), |
116 use_ratio, (double) w / h); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
117 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
118 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
119 |
11 | 120 static void |
121 ratio_value_changed_cb(GtkSpinButton* spin, gpointer unser_data) | |
122 { | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
123 int w, h; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
124 |
11 | 125 w = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
126 h = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_h_spinbutton")); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
127 |
11 | 128 gth_image_selector_set_ratio(GTH_IMAGE_SELECTOR( |
129 lookup_widget(cropper_window, "crop_image")), TRUE, (double) w / h); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
130 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
131 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
132 |
11 | 133 static void |
134 ratio_swap_button_cb(GtkButton* button, gpointer unser_data) | |
135 { | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
136 int w, h; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
137 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
138 w = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
139 h = gtk_spin_button_get_value_as_int(lookup_widget(cropper_window, "ratio_h_spinbutton")); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
140 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
141 set_spin_value(cropper_window, lookup_widget(cropper_window, "ratio_w_spinbutton"), h); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
142 set_spin_value(cropper_window, lookup_widget(cropper_window, "ratio_h_spinbutton"), w); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
143 |
11 | 144 gth_image_selector_set_ratio(GTH_IMAGE_SELECTOR(lookup_widget(cropper_window, |
145 "crop_image")), TRUE, (double) h / w); | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
146 } |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
147 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
148 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
149 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
150 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
151 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
152 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
153 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
154 |
11 | 155 void |
156 on_ratio_w_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data) | |
157 { | |
3 | 158 g_print("spinbutton W - ratio: %f\n", ratio); |
11 | 159 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), |
160 gtk_spin_button_get_value(spinbutton) / ratio); | |
0 | 161 } |
162 | |
163 | |
11 | 164 void |
165 on_ratio_w_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) | |
166 { | |
0 | 167 } |
168 | |
169 | |
11 | 170 void |
171 on_ratio_h_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) | |
172 { | |
0 | 173 } |
174 | |
175 | |
11 | 176 void |
177 on_ratio_h_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data) | |
178 { | |
3 | 179 g_print("spinbutton H - ratio: %f\n", ratio); |
11 | 180 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), |
181 gtk_spin_button_get_value(spinbutton) * ratio); | |
0 | 182 |
183 } | |
184 | |
185 | |
11 | 186 void |
187 on_ratio_swap_button_clicked(GtkButton* button, gpointer user_data) | |
188 { | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
189 |
3 | 190 ratio = 1.0 / ratio; |
11 | 191 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), |
192 gtk_spin_button_get_value(lookup_widget(cropper_window, | |
193 "ratio_h_spinbutton"))); | |
3 | 194 gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
195 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
196 } |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
197 */ |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
198 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
199 |
13 | 200 void |
201 update_title(char* zoom) | |
202 { | |
203 char title[128]; | |
204 snprintf(title, 128, "cropper (%s) %dx%d+%d+%d", zoom, w, h, x, y); | |
205 gtk_window_set_title(GTK_WINDOW(cropper_window), title); | |
206 } | |
207 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
208 |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
209 /* zoom */ |
11 | 210 void |
211 set_zoom() | |
212 { | |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
213 static GdkPixbuf* pixbuf_new; |
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
214 g_object_unref(pixbuf_new); |
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
215 |
13 | 216 pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width*zoom, image_height*zoom, |
217 GDK_INTERP_BILINEAR); | |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
218 gtk_image_set_from_pixbuf((GtkImage*) lookup_widget(cropper_window, "image_area"), pixbuf_new); |
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
219 } |
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
220 |
11 | 221 void |
222 on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) | |
223 { | |
13 | 224 zoom *= 1 + inc; |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
225 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
226 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
227 |
11 | 228 void |
229 on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) | |
230 { | |
13 | 231 zoom *= 1 - inc; |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
232 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
233 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
234 |
11 | 235 void |
236 on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) | |
237 { | |
13 | 238 zoom = 1.0; |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
239 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
240 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
241 |
11 | 242 void |
243 on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) | |
244 { | |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
245 int w, h; |
13 | 246 float zw, zh; |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
247 GtkWidget* image_a; |
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
248 |
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
249 image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area"); |
11 | 250 gdk_drawable_get_size(image_a->window, &w, &h); |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
251 |
13 | 252 zw = w*1.0 / image_width; |
253 zh = h*1.0 / image_height; | |
254 | |
255 zoom = (zw < zh) ? zw : zh; | |
8
b0824876d379
memory is now freed aswell; added (a crappy) zoom2fit; did some casts to get rid of warnings
meillo@marmaro.de
parents:
7
diff
changeset
|
256 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
257 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
258 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
259 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
260 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
261 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
262 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
263 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
264 |
11 | 265 void |
14
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
266 crop(void) |
11 | 267 { |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
268 char crop_call[256]; |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
269 |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
270 sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"", |
11 | 271 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, |
272 "crop_width_spinbutton")), | |
273 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, | |
274 "crop_height_spinbutton")), | |
275 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, | |
276 "crop_x_spinbutton")), | |
277 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, | |
278 "crop_y_spinbutton")), | |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
279 image_filename, |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
280 image_filename |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
281 ); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
282 system(crop_call); |
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
283 gtk_main_quit(); |
0 | 284 } |
285 | |
11 | 286 |
287 void | |
288 on_cropper_window_create(GtkObject* object, gpointer user_data) | |
289 { | |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
290 image_width = gdk_pixbuf_get_width(image_buffer); |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
291 image_height = gdk_pixbuf_get_height(image_buffer); |
10 | 292 |
293 /* | |
11 | 294 image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL); |
295 image_area = gtk_image_new_from_pixbuf(image_buffer); | |
10 | 296 |
297 int w, h; | |
298 GtkWidget* image_a; | |
299 | |
300 image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area"); | |
11 | 301 gdk_drawable_get_size(image_a->window, &w, &h); |
10 | 302 |
303 image_width = w - 200; | |
304 image_height = h - 150; | |
305 set_zoom(); | |
306 */ | |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
307 } |
4
2f11ab3e6047
added option handling; added output for convert; commented all ratio code cause it is not really important now
meillo@marmaro.de
parents:
3
diff
changeset
|
308 |
11 | 309 void |
310 on_cropper_window_destroy(GtkObject* object, gpointer user_data) | |
311 { | |
0 | 312 gtk_main_quit(); |
313 } | |
314 | |
13 | 315 |
316 | |
317 | |
318 gboolean | |
319 on_key_press(GtkWidget* window, GdkEventKey* pKey, gpointer userdata) | |
320 { | |
321 if (pKey->type != GDK_KEY_PRESS) { | |
322 return FALSE; | |
323 } | |
324 switch (pKey->keyval) { | |
14
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
325 case GDK_q: |
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
326 gtk_main_quit(); |
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
327 break; |
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
328 case GDK_Return: |
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
329 crop(); |
da18f2d4f92f
removed all buttons and stuff from the window; cleaned up
meillo@marmaro.de
parents:
13
diff
changeset
|
330 break; |
13 | 331 case GDK_plus: |
332 on_zoom_in_button_clicked(NULL, userdata); | |
333 break; | |
334 case GDK_minus: | |
335 on_zoom_out_button_clicked(NULL, userdata); | |
336 break; | |
337 case GDK_0: | |
338 on_zoom_100_button_clicked(NULL, userdata); | |
339 break; | |
340 case GDK_f: | |
341 on_zoom_fit_button_clicked(NULL, userdata); | |
342 break; | |
343 } | |
344 return TRUE; | |
345 } | |
346 | |
347 |