summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-05-23 20:56:38 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-05-23 20:56:38 +0000
commiteaf60defac761cd8ff305c3fc3875346ad3478b2 (patch)
tree3361b4697eb719012737ba6c7177fa481f2e7b2c
parentaa0b15e0987ee9ad25495baf50b73af88c40c261 (diff)
download2012-violon-leds-eaf60defac761cd8ff305c3fc3875346ad3478b2.tar.gz
2012-violon-leds-eaf60defac761cd8ff305c3fc3875346ad3478b2.tar.bz2
2012-violon-leds-eaf60defac761cd8ff305c3fc3875346ad3478b2.zip
Ajout d'un test 4 avec un premier programme GTK.
Extrait du tuto file:///usr/share/doc/libgtk2.0-doc/gtk/gtk-General.html git-svn-id: file:///var/svn/2012-violon-leds/trunk@4 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
-rwxr-xr-xtests/test4/compil.sh3
-rw-r--r--tests/test4/test4.c29
-rw-r--r--tests/test4/tosee/gobk-sample.txt2
-rw-r--r--tests/test4/tosee/maman.c58
4 files changed, 83 insertions, 9 deletions
diff --git a/tests/test4/compil.sh b/tests/test4/compil.sh
new file mode 100755
index 0000000..4bab218
--- /dev/null
+++ b/tests/test4/compil.sh
@@ -0,0 +1,3 @@
+#!/bin/bash -ex
+gcc -g -c test4.c $(pkg-config --cflags gtk+-2.0)
+gcc -o test4 test4.o $(pkg-config --libs gtk+-2.0)
diff --git a/tests/test4/test4.c b/tests/test4/test4.c
index 4d7f1c5..e5bca86 100644
--- a/tests/test4/test4.c
+++ b/tests/test4/test4.c
@@ -1,11 +1,22 @@
+#include <gtk/gtk.h>
+//#include <locale.h>
+int main (int argc, char **argv)
+{
+ GtkWidget *mainwin;
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <signal.h>
-
-#include <pulse/pulseaudio.h>
-#include <pulse/glib-mainloop.h>
-
+ /* Initialize i18n support */
+ //setlocale(LC_ALL, ""); //(implicite)
+ /* Initialize the widget set */
+ gtk_init (&argc, &argv);
+ /* Create the main window */
+ mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ /* Set up our GUI elements */
+ //...
+ /* Show the application window */
+ gtk_widget_show_all (mainwin);
+ /* Enter the main event loop, and wait for user interaction */
+ gtk_main ();
+ /* The user lost interest */
+ return 0;
+}
diff --git a/tests/test4/tosee/gobk-sample.txt b/tests/test4/tosee/gobk-sample.txt
new file mode 100644
index 0000000..72f2e3c
--- /dev/null
+++ b/tests/test4/tosee/gobk-sample.txt
@@ -0,0 +1,2 @@
+file:///usr/share/doc/libgtk2.0-doc/gobject/howto-gobject.html
+
diff --git a/tests/test4/tosee/maman.c b/tests/test4/tosee/maman.c
new file mode 100644
index 0000000..530b30c
--- /dev/null
+++ b/tests/test4/tosee/maman.c
@@ -0,0 +1,58 @@
+#define MAMAN_TYPE_BAR (maman_bar_get_type ())
+#define MAMAN_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_BAR, MamanBar))
+#define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_BAR))
+#define MAMAN_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAMAN_TYPE_BAR, MamanBarClass))
+#define MAMAN_IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAMAN_TYPE_BAR))
+#define MAMAN_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAMAN_TYPE_BAR, MamanBarClass))
+
+typedef struct _MamanBar MamanBar;
+typedef struct _MamanBarClass MamanBarClass;
+
+struct _MamanBar
+{
+ GObject parent_instance;
+
+ /* instance members */
+};
+
+struct _MamanBarClass
+{
+ GObjectClass parent_class;
+
+ /* class members */
+};
+
+/* will create maman_bar_get_type and set maman_bar_parent_class */
+G_DEFINE_TYPE (MamanBar, maman_bar, G_TYPE_OBJECT);
+
+static GObject *
+maman_bar_constructor (GType gtype,
+ guint n_properties,
+ GObjectConstructParam *properties)
+{
+ GObject *obj;
+
+ {
+ /* Always chain up to the parent constructor */
+ obj = G_OBJECT_CLASS (maman_bar_parent_class)->constructor (gtype, n_properties, properties);
+ }
+
+ /* update the object state depending on constructor properties */
+
+ return obj;
+}
+
+static void
+maman_bar_class_init (MamanBarClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->constructor = maman_bar_constructor;
+}
+
+static void
+maman_bar_init (MamanBar *self)
+{
+ /* initialize the object */
+}
+