Mercurial > cropper
annotate callbacks.c @ 10:5e282003f0c1
minor changes; besser indenting
author | meillo@marmaro.de |
---|---|
date | Thu, 04 Mar 2010 13:54:17 +0100 |
parents | 7e1cf00de1df |
children | c18ba4ea1514 |
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> |
0 | 3 |
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 #include "callbacks.h" |
6 #include "support.h" | |
7 | |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
8 int image_width; |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
9 int image_height; |
10 | 10 float inc = 0.3; |
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
|
11 /* |
3 | 12 void update_spin_button_ratio(GtkWidget* spinbutton) { |
13 g_print("ratio change: %f\n", ratio); | |
14 on_ratio_w_spinbutton_value_changed(spinbutton, NULL); | |
15 } | |
0 | 16 |
17 | |
18 | |
19 | |
20 | |
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
|
21 void on_ratio_none_activate (GtkMenuItem* menuitem, gpointer user_data) { |
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
|
22 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
|
23 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
|
24 } |
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 |
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 void on_ratio_square_activate (GtkMenuItem* menuitem, gpointer user_data) { |
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 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
|
29 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
|
30 } |
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
|
31 |
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 |
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 void on_ratio_4x3_activate (GtkMenuItem* menuitem, gpointer user_data) { |
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 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
|
35 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
|
36 } |
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
|
37 |
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
|
38 |
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
|
39 void on_ratio_3x2_activate (GtkMenuItem* menuitem, gpointer user_data) { |
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 = 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
|
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 |
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
|
45 void on_ratio_custom_activate (GtkMenuItem* menuitem, gpointer user_data) { |
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
|
46 ratio = gtk_spin_button_get_value(lookup_widget(cropper_window, "ratio_w_spinbutton")) / gtk_spin_button_get_value(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
|
47 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
|
48 } |
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 */ |
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 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
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 |
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 static void ratio_optionmenu_changed_cb (GtkOptionMenu* optionmenu, gpointer unser_data) { |
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 int idx = gtk_option_menu_get_history (optionmenu); |
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 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
|
63 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
|
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 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 default: |
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 = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (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
|
91 h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (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
|
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 } |
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 |
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 gtk_widget_set_sensitive (lookup_widget(cropper_window, "custom_ratio_box"), idx == 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
|
96 set_spin_value (cropper_window, lookup_widget(cropper_window, "ratio_w_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
|
97 set_spin_value (cropper_window, lookup_widget(cropper_window, "ratio_h_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
|
98 |
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 gth_image_selector_set_ratio (GTH_IMAGE_SELECTOR (lookup_widget(cropper_window, "crop_image")), use_ratio, (double) 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
|
100 } |
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 |
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 |
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
|
103 static void ratio_value_changed_cb (GtkSpinButton* spin, gpointer unser_data) { |
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
|
104 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
|
105 |
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
|
106 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
|
107 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
|
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 gth_image_selector_set_ratio (GTH_IMAGE_SELECTOR (lookup_widget(cropper_window, "crop_image")), TRUE, (double) 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
|
110 } |
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
|
111 |
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
|
112 |
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
|
113 static void ratio_swap_button_cb (GtkButton* button, gpointer unser_data) { |
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 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
|
115 |
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
|
116 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
|
117 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
|
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 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
|
120 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
|
121 |
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
|
122 gth_image_selector_set_ratio(GTH_IMAGE_SELECTOR (lookup_widget(cropper_window, "crop_image")), TRUE, (double) h / 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
|
123 } |
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 |
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
|
125 */ |
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
|
126 |
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 |
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
|
128 |
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
|
129 |
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 |
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
|
133 |
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
|
134 /* |
1 | 135 void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { |
3 | 136 g_print("spinbutton W - ratio: %f\n", ratio); |
137 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_h_spinbutton"), gtk_spin_button_get_value(spinbutton) / ratio); | |
0 | 138 } |
139 | |
140 | |
1 | 141 void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { |
0 | 142 } |
143 | |
144 | |
1 | 145 void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { |
0 | 146 } |
147 | |
148 | |
1 | 149 void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { |
3 | 150 g_print("spinbutton H - ratio: %f\n", ratio); |
151 gtk_spin_button_set_value(lookup_widget(cropper_window, "ratio_w_spinbutton"), gtk_spin_button_get_value(spinbutton) * ratio); | |
0 | 152 |
153 } | |
154 | |
155 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
156 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
|
157 |
3 | 158 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
|
159 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 | 160 gtk_spin_button_update(lookup_widget(cropper_window, "ratio_w_spinbutton")); |
161 | |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
162 } |
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
|
163 */ |
2
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
164 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
165 |
e359bea4c8ac
added code for ratio swap; new names for ratio operations; added main.h; some more
meillo@marmaro.de
parents:
1
diff
changeset
|
166 |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
167 /* zoom */ |
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
|
168 void set_zoom() { |
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
|
169 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
|
170 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
|
171 |
10 | 172 pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, 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
|
173 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
|
174 } |
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
|
175 |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
176 void on_zoom_in_button_clicked(GtkObject* object, gpointer user_data) { |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
177 image_width *= 1 + inc; |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
178 image_height *= 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
|
179 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
180 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
181 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
182 void on_zoom_out_button_clicked(GtkObject* object, gpointer user_data) { |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
183 image_width *= 1 - inc; |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
184 image_height *= 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
|
185 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
186 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
187 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
188 void on_zoom_100_button_clicked(GtkObject* object, gpointer user_data) { |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
189 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
|
190 image_height = gdk_pixbuf_get_height(image_buffer); |
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
|
191 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
192 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
193 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
194 void on_zoom_fit_button_clicked(GtkObject* object, gpointer user_data) { |
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
|
195 int w, h; |
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
|
196 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
|
197 |
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
|
198 image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area"); |
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
|
199 gdk_drawable_get_size (image_a->window, &w, &h); |
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
|
200 |
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
|
201 image_width = w - 200; |
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
|
202 image_height = h - 150; |
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
|
203 set_zoom(); |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
204 } |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
205 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
206 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
207 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
208 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
209 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
210 |
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
211 |
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
|
212 void on_crop_clicked(GtkButton* button, gpointer user_data) { |
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
|
213 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
|
214 |
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
|
215 sprintf(crop_call, "echo \"convert -crop %ix%i+%i+%i %s cropped_%s\"", |
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
|
216 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_width_spinbutton")), |
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
|
217 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_height_spinbutton")), |
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_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "crop_x_spinbutton")), |
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 gtk_spin_button_get_value_as_int((GtkSpinButton*) lookup_widget(cropper_window, "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
|
220 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
|
221 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
|
222 ); |
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
|
223 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
|
224 gtk_main_quit(); |
0 | 225 } |
226 | |
9
7e1cf00de1df
completely refactored makefile; removed interface.h
meillo@marmaro.de
parents:
8
diff
changeset
|
227 void on_cropper_window_create(GtkObject* object, gpointer user_data) { |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
228 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
|
229 image_height = gdk_pixbuf_get_height(image_buffer); |
10 | 230 |
231 /* | |
232 image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL); | |
233 image_area = gtk_image_new_from_pixbuf(image_buffer); | |
234 | |
235 int w, h; | |
236 GtkWidget* image_a; | |
237 | |
238 image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area"); | |
239 gdk_drawable_get_size (image_a->window, &w, &h); | |
240 | |
241 image_width = w - 200; | |
242 image_height = h - 150; | |
243 set_zoom(); | |
244 */ | |
7
ec2d11d96fb0
image is now gdk-pixbuff; zoom implemented in a basic way
meillo@marmaro.de
parents:
4
diff
changeset
|
245 } |
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
|
246 |
9
7e1cf00de1df
completely refactored makefile; removed interface.h
meillo@marmaro.de
parents:
8
diff
changeset
|
247 void on_cropper_window_destroy(GtkObject* object, gpointer user_data) { |
0 | 248 gtk_main_quit(); |
249 } | |
250 |