]> saetta.ns0.it Git - libzakgtkdecoder/commitdiff
Added test via Glade/GtkBuilder. master
authorAndrea Zagli <azagli@libero.it>
Sun, 20 Dec 2015 11:54:24 +0000 (12:54 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 20 Dec 2015 11:54:24 +0000 (12:54 +0100)
.gitignore
tests/Makefile.am
tests/decoder_xml.c [new file with mode: 0644]
tests/decoder_xml.ui [new file with mode: 0644]

index ce195c97c135808f92c6190ece74420a61243dc4..837cae6acbd0c94acfb002ca1269bb64b8bcb48d 100644 (file)
@@ -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]
index e5310bf6120d68eda218bf6b3734a49dfffe9a02..72da7afd1a848e85354c779a0132ef4c155f5628 100644 (file)
@@ -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 (file)
index 0000000..ce6cdd6
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ *
+ *  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 <gtk/gtk.h>
+
+#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 (file)
index 0000000..40981dd
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <requires lib="zakgtkdecoder" version="0.0"/>
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="ZakGtkDecoder" id="zakgtkdecoder1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="show_btn_clean">True</property>
+        <property name="show_btn_new">True</property>
+        <property name="show_btn_open">True</property>
+      </object>
+    </child>
+  </object>
+</interface>