rev |
line source |
meillo@0
|
1 #include <sys/types.h>
|
meillo@0
|
2 #include <sys/stat.h>
|
meillo@0
|
3 #include <unistd.h>
|
meillo@0
|
4 #include <string.h>
|
meillo@0
|
5 #include <stdio.h>
|
meillo@0
|
6
|
meillo@0
|
7 #include <gdk/gdkkeysyms.h>
|
meillo@0
|
8 #include <gtk/gtk.h>
|
meillo@7
|
9 #include <gdk-pixbuf/gdk-pixbuf.h>
|
meillo@0
|
10
|
meillo@5
|
11 #include "main.h"
|
meillo@0
|
12
|
meillo@0
|
13 #define GLADE_HOOKUP_OBJECT(component,widget,name) \
|
meillo@11
|
14 g_object_set_data_full(G_OBJECT(component), name, \
|
meillo@11
|
15 gtk_widget_ref(widget),(GDestroyNotify) gtk_widget_unref)
|
meillo@0
|
16
|
meillo@0
|
17 #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
|
meillo@11
|
18 g_object_set_data(G_OBJECT(component), name, widget)
|
meillo@0
|
19
|
meillo@15
|
20
|
meillo@15
|
21 /*
|
meillo@15
|
22 * This function returns a widget in a component created by Glade.
|
meillo@15
|
23 * Call it with the toplevel widget in the component (i.e. a window/dialog),
|
meillo@15
|
24 * or alternatively any widget in the component, and the name of the widget
|
meillo@15
|
25 * you want returned.
|
meillo@15
|
26 */
|
meillo@15
|
27 GtkWidget*
|
meillo@15
|
28 lookup_widget(GtkWidget* widget, const gchar* widget_name)
|
meillo@15
|
29 {
|
meillo@15
|
30 GtkWidget* parent;
|
meillo@15
|
31 GtkWidget* found_widget;
|
meillo@15
|
32
|
meillo@15
|
33 for (;;) {
|
meillo@15
|
34 if (GTK_IS_MENU(widget)) {
|
meillo@15
|
35 parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
|
meillo@15
|
36 } else {
|
meillo@15
|
37 parent = widget->parent;
|
meillo@15
|
38 }
|
meillo@15
|
39 if (!parent) {
|
meillo@15
|
40 parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey");
|
meillo@15
|
41 }
|
meillo@15
|
42 if (parent == NULL) {
|
meillo@15
|
43 break;
|
meillo@15
|
44 }
|
meillo@15
|
45 widget = parent;
|
meillo@15
|
46 }
|
meillo@15
|
47
|
meillo@15
|
48 found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), widget_name);
|
meillo@15
|
49 if (!found_widget) {
|
meillo@15
|
50 g_warning("Widget not found: %s", widget_name);
|
meillo@15
|
51 }
|
meillo@15
|
52 return found_widget;
|
meillo@15
|
53 }
|
meillo@15
|
54
|
meillo@15
|
55
|
meillo@15
|
56
|
meillo@0
|
57 GtkWidget*
|
meillo@11
|
58 create_cropper_window(void)
|
meillo@0
|
59 {
|
meillo@0
|
60 GtkWidget *cropper_window;
|
meillo@0
|
61 GtkWidget *dialog_vbox1;
|
meillo@14
|
62 GtkWidget *status;
|
meillo@0
|
63 GtkWidget *label1;
|
meillo@0
|
64 GtkWidget *label2;
|
meillo@4
|
65
|
meillo@0
|
66
|
meillo@11
|
67 cropper_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
meillo@11
|
68 gtk_widget_set_name(cropper_window, "cropper_window");
|
meillo@11
|
69 gtk_container_set_border_width(GTK_CONTAINER(cropper_window), 6);
|
meillo@14
|
70 gtk_window_set_title(GTK_WINDOW(cropper_window), "cropper-0.2");
|
meillo@0
|
71
|
meillo@11
|
72 dialog_vbox1 = gtk_vbox_new(FALSE, 6);
|
meillo@11
|
73 gtk_widget_set_name(dialog_vbox1, "dialog_vbox1");
|
meillo@11
|
74 gtk_widget_show(dialog_vbox1);
|
meillo@11
|
75 gtk_container_add(GTK_CONTAINER(cropper_window), dialog_vbox1);
|
meillo@0
|
76
|
meillo@14
|
77
|
meillo@14
|
78 status = gtk_hbox_new(FALSE, 0);
|
meillo@14
|
79 gtk_widget_set_name(status, "status");
|
meillo@14
|
80 gtk_widget_show(status);
|
meillo@14
|
81 gtk_box_pack_end(GTK_BOX(dialog_vbox1), status, FALSE, FALSE, 0);
|
meillo@14
|
82
|
meillo@14
|
83 label1 = gtk_label_new("zoom:");
|
meillo@14
|
84 gtk_widget_set_name(label1, "label1");
|
meillo@14
|
85 gtk_widget_show(label1);
|
meillo@14
|
86 gtk_box_pack_start(GTK_BOX(status), label1, FALSE, FALSE, 0);
|
meillo@14
|
87
|
meillo@14
|
88 label2 = gtk_label_new("1.0");
|
meillo@14
|
89 gtk_widget_set_name(label2, "label2");
|
meillo@14
|
90 gtk_widget_show(label2);
|
meillo@14
|
91 gtk_box_pack_start(GTK_BOX(status), label2, FALSE, FALSE, 0);
|
meillo@14
|
92
|
meillo@14
|
93 /* image_area */
|
meillo@14
|
94 image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
|
meillo@14
|
95 image_area = gtk_image_new_from_pixbuf(image_buffer);
|
meillo@14
|
96
|
meillo@14
|
97 gtk_widget_set_name(image_area, "image_area");
|
meillo@14
|
98 gtk_widget_show(image_area);
|
meillo@14
|
99 gtk_box_pack_start(GTK_BOX(dialog_vbox1), image_area, TRUE, TRUE, 0);
|
meillo@14
|
100
|
meillo@14
|
101
|
meillo@14
|
102
|
meillo@14
|
103
|
meillo@14
|
104
|
meillo@14
|
105 g_signal_connect(G_OBJECT(cropper_window), "show",
|
meillo@14
|
106 G_CALLBACK(on_cropper_window_create), NULL);
|
meillo@14
|
107
|
meillo@14
|
108 g_signal_connect(G_OBJECT(cropper_window), "destroy",
|
meillo@14
|
109 G_CALLBACK(on_cropper_window_destroy), NULL);
|
meillo@14
|
110
|
meillo@14
|
111 g_signal_connect(cropper_window, "key-press-event",
|
meillo@14
|
112 G_CALLBACK(on_key_press), NULL);
|
meillo@14
|
113
|
meillo@14
|
114
|
meillo@14
|
115 /* Store pointers to all widgets, for use by lookup_widget(). */
|
meillo@14
|
116
|
meillo@14
|
117 GLADE_HOOKUP_OBJECT_NO_REF(cropper_window, cropper_window, "cropper_window");
|
meillo@14
|
118 GLADE_HOOKUP_OBJECT(cropper_window, dialog_vbox1, "dialog_vbox1");
|
meillo@14
|
119
|
meillo@14
|
120 GLADE_HOOKUP_OBJECT(cropper_window, label1, "label1");
|
meillo@14
|
121 GLADE_HOOKUP_OBJECT(cropper_window, label2, "label2");
|
meillo@14
|
122 GLADE_HOOKUP_OBJECT(cropper_window, status, "status");
|
meillo@14
|
123 GLADE_HOOKUP_OBJECT(cropper_window, image_area, "image_area");
|
meillo@14
|
124 GLADE_HOOKUP_OBJECT(cropper_window,(GtkWidget*) image_buffer, "image_buffer");
|
meillo@14
|
125
|
meillo@14
|
126
|
meillo@14
|
127 return cropper_window;
|
meillo@14
|
128 }
|
meillo@14
|
129
|
meillo@14
|
130
|
meillo@14
|
131
|
meillo@14
|
132
|
meillo@14
|
133
|
meillo@14
|
134
|
meillo@14
|
135
|
meillo@14
|
136
|
meillo@14
|
137
|
meillo@14
|
138 /*
|
meillo@11
|
139 gtk_container_set_border_width(GTK_CONTAINER(hbox1), 5);
|
meillo@0
|
140
|
meillo@11
|
141 label1 = gtk_label_new("<b>Selection</b>");
|
meillo@11
|
142 gtk_label_set_use_markup(GTK_LABEL(label1), TRUE);
|
meillo@11
|
143 gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);
|
meillo@0
|
144
|
meillo@11
|
145 gtk_table_set_row_spacings(GTK_TABLE(table2), 6);
|
meillo@11
|
146 gtk_table_set_col_spacings(GTK_TABLE(table2), 6);
|
meillo@0
|
147
|
meillo@11
|
148 gtk_table_attach(GTK_TABLE(table2), label3, 0, 1, 0, 1,(GtkAttachOptions)(GTK_FILL),
|
meillo@11
|
149 (GtkAttachOptions)(0), 0, 0);
|
meillo@11
|
150 gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
|
meillo@0
|
151
|
meillo@11
|
152 frame1 = gtk_frame_new(NULL);
|
meillo@11
|
153 gtk_widget_set_name(frame1, "frame1");
|
meillo@11
|
154 gtk_widget_show(frame1);
|
meillo@11
|
155 gtk_box_pack_start(GTK_BOX(vbox5), frame1, TRUE, TRUE, 0);
|
meillo@11
|
156 gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_NONE);
|
meillo@0
|
157
|
meillo@11
|
158 vbox7 = gtk_vbox_new(FALSE, 6);
|
meillo@11
|
159 gtk_widget_set_name(vbox7, "vbox7");
|
meillo@11
|
160 gtk_widget_show(vbox7);
|
meillo@11
|
161 gtk_container_add(GTK_CONTAINER(frame1), vbox7);
|
meillo@0
|
162
|
meillo@14
|
163 g_signal_connect(G_OBJECT(lookup_widget(cropper_window, "crop_x_spinbutton")), "value_changed",
|
meillo@14
|
164 G_CALLBACK(selection_x_value_changed_cb), data);
|
meillo@14
|
165 g_signal_connect(G_OBJECT(lookup_widget(cropper_window, "crop_image")), "selection_changed",
|
meillo@14
|
166 G_CALLBACK(selection_changed_cb), data);
|
meillo@14
|
167 g_signal_connect(G_OBJECT(lookup_widget(cropper_window, "ratio_swap_button")), "clicked",
|
meillo@14
|
168 G_CALLBACK(ratio_swap_button_cb), NULL);
|
meillo@14
|
169 g_signal_connect(G_OBJECT(lookup_widget(cropper_window, "ratio_optionmenu")), "changed",
|
meillo@14
|
170 G_CALLBACK(ratio_optionmenu_changed_cb), NULL);
|
meillo@11
|
171 g_signal_connect(G_OBJECT(ratio_none), "activate",
|
meillo@12
|
172 G_CALLBACK(on_ratio_none_activate), NULL);
|
meillo@4
|
173 */
|