From 489a21b927c312fc09ad6eea4c98e596f29cec2b Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 25 May 2012 08:31:00 +0200 Subject: cvg: Replace gauss button with a GtkComboxBox --- cvg.c | 39 +++++++++++++++++++-------------------- cvg.ui | 16 ++++++++-------- 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; @@ -264,15 +254,6 @@ none_filter(struct cvg *cvg, IplImage *image) return NULL; } -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) { @@ -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 @@ - - Gauss-Filter - False + True - True - True - True - False - + False + 0 + + None + Gauss + + 1 -- cgit