From fba9880728c329ac44908a380cf0770926c9bdda Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 20 Dec 2015 12:54:24 +0100 Subject: [PATCH] Added test via Glade/GtkBuilder. --- .gitignore | 3 +- tests/Makefile.am | 3 +- tests/decoder_xml.c | 107 +++++++++++++++++++++++++++++++++++++++++++ tests/decoder_xml.ui | 18 ++++++++ 4 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 tests/decoder_xml.c create mode 100644 tests/decoder_xml.ui diff --git a/.gitignore b/.gitignore index ce195c9..837cae6 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ docs/reference/xml/ libtool stamp-h1 tests/decoder +tests/decoder_xml POTFILES mkinstalldirs stamp-it @@ -50,4 +51,4 @@ intltool-* Rules-quot *.exe *.csv -decodermarshal.[ch] \ No newline at end of file +decodermarshal.[ch] diff --git a/tests/Makefile.am b/tests/Makefile.am index e5310bf..72da7af 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,6 +10,7 @@ LIBS = $(ZAKGTKDECODER_LIBS) \ LDADD = $(top_builddir)/src/libzakgtkdecoder.la noinst_PROGRAMS = \ - decoder + decoder \ + decoder_xml EXTRA_DIST = diff --git a/tests/decoder_xml.c b/tests/decoder_xml.c new file mode 100644 index 0000000..ce6cdd6 --- /dev/null +++ b/tests/decoder_xml.c @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2015 Andrea Zagli + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +#include "zakgtkdecoder.h" + +GtkWidget *w; +GtkWidget *decoder; + +static gchar +*on_decode (gpointer instance, gchar *key, gpointer user_data) +{ + g_message ("Decoding."); + return g_strdup_printf ("Decode for key «%s»", key); +} + +static gboolean +on_btn_clean_clicked (gpointer instance, gpointer user_data) +{ + g_message ("Clean clicked."); + return FALSE; +} + +static gboolean +on_btn_new_clicked (gpointer instance, gpointer user_data) +{ + g_message ("New clicked."); + return FALSE; +} + +static gboolean +on_btn_open_clicked (gpointer instance, gpointer user_data) +{ + g_message ("Open clicked."); + return FALSE; +} + +static gboolean +on_btn_browse_clicked (gpointer instance, gpointer user_data) +{ + g_message ("Browse clicked."); + zak_gtk_decoder_set_key (ZAK_GTK_DECODER (decoder), "1"); + return FALSE; +} + +gboolean +on_w_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + return FALSE; +} + +int +main (int argc, char **argv) +{ + GtkBuilder *builder; + + + gtk_init (&argc, &argv); + + builder = gtk_builder_new (); + + gtk_builder_add_objects_from_file (builder, g_build_filename (GUIDIR, "decoder_xml.ui", NULL), + g_strsplit ("window1", "|" , -1), + NULL); + + w = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); + g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), NULL); + g_signal_connect (w, "destroy", gtk_main_quit, NULL); + + decoder = GTK_WIDGET (gtk_builder_get_object (builder, "zakgtkdecoder1")); + + g_signal_connect (G_OBJECT (decoder), "btn_clean_clicked", + G_CALLBACK (on_btn_clean_clicked), NULL); + g_signal_connect (G_OBJECT (decoder), "btn_new_clicked", + G_CALLBACK (on_btn_new_clicked), NULL); + g_signal_connect (G_OBJECT (decoder), "btn_open_clicked", + G_CALLBACK (on_btn_open_clicked), NULL); + g_signal_connect (G_OBJECT (decoder), "btn_browse_clicked", + G_CALLBACK (on_btn_browse_clicked), NULL); + + g_signal_connect (G_OBJECT (decoder), "decode", + G_CALLBACK (on_decode), NULL); + + gtk_widget_show_all (w); + + gtk_main (); + + return 0; +} diff --git a/tests/decoder_xml.ui b/tests/decoder_xml.ui new file mode 100644 index 0000000..40981dd --- /dev/null +++ b/tests/decoder_xml.ui @@ -0,0 +1,18 @@ + + + + + + + False + + + True + False + True + True + True + + + + -- 2.49.0