summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cvg.c39
-rw-r--r--cvg.ui16
2 files changed, 27 insertions, 28 deletions
diff --git a/cvg.c b/cvg.c
index da2062b..78f3c96 100644
--- a/cvg.c
+++ b/cvg.c
@@ -7,7 +7,6 @@
struct cvg {
GtkWidget *drawing_area1;
GtkWidget *drawing_area2;
- GtkButton *gauss_btn;
GtkButton *open_btn;
CvCapture *capture;
IplImage *image;
@@ -170,12 +169,6 @@ key_event(GtkWidget *widget, GdkEventKey *event, gpointer userdata)
switch (event->type) {
case GDK_KEY_RELEASE:
switch (event->keyval) {
- case GDK_KEY_g:
- g_signal_emit_by_name(cvg->gauss_btn, "released", NULL);
- if (cvg->last_press == event->keyval)
- g_signal_emit_by_name(cvg->gauss_btn, "clicked",
- NULL);
- break;
case GDK_KEY_o:
g_signal_emit_by_name(cvg->open_btn, "released", NULL);
if (cvg->last_press == event->keyval)
@@ -187,9 +180,6 @@ key_event(GtkWidget *widget, GdkEventKey *event, gpointer userdata)
case GDK_KEY_PRESS:
cvg->last_press = event->keyval;
switch (event->keyval) {
- case GDK_KEY_g:
- g_signal_emit_by_name(cvg->gauss_btn, "pressed", NULL);
- break;
case GDK_KEY_o:
g_signal_emit_by_name(cvg->open_btn, "pressed", NULL);
break;
@@ -265,15 +255,6 @@ none_filter(struct cvg *cvg, IplImage *image)
}
void
-on_gauss_button_click(GtkButton *button, gpointer userdata)
-{
- struct cvg *cvg = userdata;
-
- cvg->filter = gauss_filter;
- update_right_drawing_area(cvg);
-}
-
-void
destroy(GtkWidget *widget, gpointer userdata)
{
gtk_main_quit();
@@ -288,12 +269,29 @@ find_button(GtkWidget *widget, gpointer data)
*p = GTK_BUTTON(widget);
}
+void
+method_set(GtkComboBox *widget, gpointer userdata)
+{
+ struct cvg *cvg = userdata;
+ gchar *text;
+
+ text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widget));
+ if (text == NULL)
+ return;
+ if (strcmp(text, "Gauss") == 0)
+ cvg->filter = gauss_filter;
+ else if (strcmp(text, "None") == 0)
+ cvg->filter = none_filter;
+ update_right_drawing_area(cvg);
+}
+
int
main(int argc, char *argv[])
{
struct cvg cvg;
GtkBuilder *builder;
GObject *file_chooser;
+ GObject *comboxbox;
gchar *path, *file;
int index = 0;
@@ -330,7 +328,6 @@ main(int argc, char *argv[])
"drawingarea1"));
cvg.drawing_area2 = GTK_WIDGET(gtk_builder_get_object(builder,
"drawingarea2"));
- cvg.gauss_btn = GTK_BUTTON(gtk_builder_get_object(builder, "gauss"));
file_chooser = gtk_builder_get_object(builder, "file-chooser");
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser),
g_get_current_dir());
@@ -339,6 +336,8 @@ main(int argc, char *argv[])
*/
gtk_container_forall(GTK_CONTAINER(file_chooser),
find_button, &cvg.open_btn);
+ combobox = gtk_builder_get_object(builder, "comboboxtext1");
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
cvg.idle_source = g_idle_add(capture, &cvg);
cvg.filter = none_filter;
diff --git a/cvg.ui b/cvg.ui
index 302711d..15c4e8b 100644
--- a/cvg.ui
+++ b/cvg.ui
@@ -76,15 +76,15 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="gauss">
- <property name="label" translatable="yes">Gauss-Filter</property>
- <property name="use_action_appearance">False</property>
+ <object class="GtkComboBoxText" id="comboboxtext1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="hexpand">True</property>
- <property name="use_action_appearance">False</property>
- <signal name="clicked" handler="on_gauss_button_click" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="entry_text_column">0</property>
+ <items>
+ <item>None</item>
+ <item>Gauss</item>
+ </items>
+ <signal name="changed" handler="method_set" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>