10 #include <gdk/gdkkeysyms.h> 23 GtkWidget *button_change;
24 GtkWidget *button_run;
25 GtkWidget *button_clear;
26 GtkWidget *button_save;
27 GtkWidget *button_load;
30 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
31 gtk_object_set_data (GTK_OBJECT (window),
"window", window);
32 gtk_window_set_title (GTK_WINDOW (window),
"SVM Toy");
34 vbox1 = gtk_vbox_new (FALSE, 0);
35 gtk_widget_ref (vbox1);
36 gtk_object_set_data_full (GTK_OBJECT (window),
"vbox1", vbox1,
37 (GtkDestroyNotify) gtk_widget_unref);
38 gtk_widget_show (vbox1);
39 gtk_container_add (GTK_CONTAINER (window), vbox1);
41 draw_main = gtk_drawing_area_new ();
42 gtk_widget_ref (draw_main);
43 gtk_object_set_data_full (GTK_OBJECT (window),
"draw_main", draw_main,
44 (GtkDestroyNotify) gtk_widget_unref);
45 gtk_widget_show (draw_main);
46 gtk_box_pack_start (GTK_BOX (vbox1), draw_main, TRUE, TRUE, 0);
47 gtk_widget_set_usize (draw_main, 500, 500);
48 gtk_widget_set_events (draw_main, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
50 hbox1 = gtk_hbox_new (FALSE, 0);
51 gtk_widget_ref (hbox1);
52 gtk_object_set_data_full (GTK_OBJECT (window),
"hbox1", hbox1,
53 (GtkDestroyNotify) gtk_widget_unref);
54 gtk_widget_show (hbox1);
55 gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
57 button_change = gtk_button_new_with_label (
"Change");
58 gtk_widget_ref (button_change);
59 gtk_object_set_data_full (GTK_OBJECT (window),
"button_change", button_change,
60 (GtkDestroyNotify) gtk_widget_unref);
61 gtk_widget_show (button_change);
62 gtk_box_pack_start (GTK_BOX (hbox1), button_change, FALSE, FALSE, 0);
64 button_run = gtk_button_new_with_label (
"Run");
65 gtk_widget_ref (button_run);
66 gtk_object_set_data_full (GTK_OBJECT (window),
"button_run", button_run,
67 (GtkDestroyNotify) gtk_widget_unref);
68 gtk_widget_show (button_run);
69 gtk_box_pack_start (GTK_BOX (hbox1), button_run, FALSE, FALSE, 0);
71 button_clear = gtk_button_new_with_label (
"Clear");
72 gtk_widget_ref (button_clear);
73 gtk_object_set_data_full (GTK_OBJECT (window),
"button_clear", button_clear,
74 (GtkDestroyNotify) gtk_widget_unref);
75 gtk_widget_show (button_clear);
76 gtk_box_pack_start (GTK_BOX (hbox1), button_clear, FALSE, FALSE, 0);
78 button_save = gtk_button_new_with_label (
"Save");
79 gtk_widget_ref (button_save);
80 gtk_object_set_data_full (GTK_OBJECT (window),
"button_save", button_save,
81 (GtkDestroyNotify) gtk_widget_unref);
82 gtk_widget_show (button_save);
83 gtk_box_pack_start (GTK_BOX (hbox1), button_save, FALSE, FALSE, 0);
85 button_load = gtk_button_new_with_label (
"Load");
86 gtk_widget_ref (button_load);
87 gtk_object_set_data_full (GTK_OBJECT (window),
"button_load", button_load,
88 (GtkDestroyNotify) gtk_widget_unref);
89 gtk_widget_show (button_load);
90 gtk_box_pack_start (GTK_BOX (hbox1), button_load, FALSE, FALSE, 0);
92 entry_option = gtk_entry_new ();
93 gtk_widget_ref (entry_option);
94 gtk_object_set_data_full (GTK_OBJECT (window),
"entry_option", entry_option,
95 (GtkDestroyNotify) gtk_widget_unref);
96 gtk_widget_show (entry_option);
97 gtk_box_pack_start (GTK_BOX (hbox1), entry_option, TRUE, TRUE, 0);
99 gtk_signal_connect (GTK_OBJECT (window),
"destroy",
102 gtk_signal_connect (GTK_OBJECT (draw_main),
"button_press_event",
105 gtk_signal_connect (GTK_OBJECT (draw_main),
"expose_event",
108 gtk_signal_connect (GTK_OBJECT (button_change),
"clicked",
111 gtk_signal_connect (GTK_OBJECT (button_run),
"clicked",
114 gtk_signal_connect (GTK_OBJECT (button_clear),
"clicked",
117 gtk_signal_connect (GTK_OBJECT (button_save),
"clicked",
120 gtk_signal_connect (GTK_OBJECT (button_load),
"clicked",
123 gtk_signal_connect (GTK_OBJECT (entry_option),
"activate",
134 GtkWidget *filesel_ok;
135 GtkWidget *filesel_cancel;
137 fileselection = gtk_file_selection_new (
"Select File");
138 gtk_object_set_data (GTK_OBJECT (fileselection),
"fileselection", fileselection);
139 gtk_container_set_border_width (GTK_CONTAINER (fileselection), 10);
140 gtk_window_set_modal (GTK_WINDOW (fileselection), TRUE);
142 filesel_ok = GTK_FILE_SELECTION (fileselection)->ok_button;
143 gtk_object_set_data (GTK_OBJECT (fileselection),
"filesel_ok", filesel_ok);
144 gtk_widget_show (filesel_ok);
145 GTK_WIDGET_SET_FLAGS (filesel_ok, GTK_CAN_DEFAULT);
147 filesel_cancel = GTK_FILE_SELECTION (fileselection)->cancel_button;
148 gtk_object_set_data (GTK_OBJECT (fileselection),
"filesel_cancel", filesel_cancel);
149 gtk_widget_show (filesel_cancel);
150 GTK_WIDGET_SET_FLAGS (filesel_cancel, GTK_CAN_DEFAULT);
152 gtk_signal_connect (GTK_OBJECT (fileselection),
"destroy",
155 gtk_signal_connect (GTK_OBJECT (filesel_ok),
"clicked",
158 gtk_signal_connect (GTK_OBJECT (filesel_cancel),
"clicked",
GtkWidget * fileselection
gboolean on_draw_main_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
void on_button_load_clicked(GtkButton *button, gpointer user_data)
void on_fileselection_destroy(GtkObject *object, gpointer user_data)
void on_button_clear_clicked(GtkButton *button, gpointer user_data)
void on_filesel_ok_clicked(GtkButton *button, gpointer user_data)
void on_button_change_clicked(GtkButton *button, gpointer user_data)
GtkWidget * create_fileselection(void)
void on_button_run_clicked(GtkButton *button, gpointer user_data)
void on_button_save_clicked(GtkButton *button, gpointer user_data)
void on_filesel_cancel_clicked(GtkButton *button, gpointer user_data)
gboolean on_draw_main_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
GtkWidget * create_window(void)
void on_window1_destroy(GtkObject *object, gpointer user_data)