[libchamplain] Add minimal demos



commit 4e963c9af3a59b9da886742c6b485b84960e42b9
Author: JiÅ?í Techet <techet gmail com>
Date:   Sat May 22 00:38:49 2010 +0200

    Add minimal demos
    
    Signed-off-by: JiÅ?í Techet <techet gmail com>

 demos/Makefile.am   |   17 ++++++++++----
 demos/minimal-gtk.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++
 demos/minimal.c     |   43 ++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 5 deletions(-)
---
diff --git a/demos/Makefile.am b/demos/Makefile.am
index d095960..8816e82 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -1,10 +1,13 @@
-noinst_PROGRAMS = launcher animated-marker polygons url-marker
+noinst_PROGRAMS = minimal launcher animated-marker polygons url-marker
 
 INCLUDES = -I$(top_srcdir)
 
 AM_CPPFLAGS = $(DEPS_CFLAGS) $(WARN_CFLAGS)
 AM_LDFLAGS = $(DEPS_LIBS)
 
+minimal_SOURCES = minimal.c
+minimal_LDADD = $(DEPS_LIBS) ../champlain/libchamplain- CHAMPLAIN_API_VERSION@.la
+
 launcher_SOURCES = launcher.c markers.c
 launcher_LDADD = $(DEPS_LIBS) ../champlain/libchamplain- CHAMPLAIN_API_VERSION@.la
 
@@ -19,6 +22,13 @@ url_marker_CPPFLAGS = $(DEPS_CFLAGS) $(SOUP_CFLAGS)
 url_marker_LDADD = $(SOUP_LIBS) $(DEPS_LIBS) ../champlain/libchamplain- CHAMPLAIN_API_VERSION@.la
 
 if ENABLE_GTK
+noinst_PROGRAMS += minimal-gtk
+minimal_gtk_SOURCES = minimal-gtk.c
+minimal_gtk_CPPFLAGS = $(GTK_CFLAGS)
+minimal_gtk_LDADD = $(GTK_LIBS) $(DEPS_LIBS) \
+		../champlain-gtk/libchamplain-gtk- CHAMPLAIN_API_VERSION@.la \
+		../champlain/libchamplain- CHAMPLAIN_API_VERSION@.la
+
 noinst_PROGRAMS += launcher-gtk
 launcher_gtk_SOURCES = launcher-gtk.c markers.c
 launcher_gtk_CPPFLAGS = $(GTK_CFLAGS)
@@ -36,8 +46,5 @@ local_rendering_LDADD = $(GTK_LIBS) $(MEMPHIS_LIBS) $(DEPS_LIBS) \
 endif
 endif
 
-EXTRA_DIST = markers.h
+EXTRA_DIST = markers.h launcher.js
 
-if HAVE_INTROSPECTION
-EXTRA_DIST += launcher.js
-endif
diff --git a/demos/minimal-gtk.c b/demos/minimal-gtk.c
new file mode 100644
index 0000000..29b84cd
--- /dev/null
+++ b/demos/minimal-gtk.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Jiri Techet <techet gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+/* include the libchamplain header */
+#include <champlain-gtk/champlain-gtk.h>
+
+#include <clutter-gtk/clutter-gtk.h>
+
+int
+main (int argc, char *argv[])
+{
+  GtkWidget *window, *widget, *vbox;
+
+  /* initialize threads and clutter */
+  g_thread_init (NULL);
+  gtk_clutter_init (&argc, &argv);
+
+  /* create the top-level window and quit the main loop when it's closed */
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit),
+      NULL);
+
+  /* create the libchamplain widget and set its size */
+  widget = gtk_champlain_embed_new ();
+  gtk_widget_set_size_request (widget, 640, 480);
+
+  ChamplainView *view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget));
+  g_object_set (G_OBJECT (view), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+          "zoom-level", 5, NULL);
+  champlain_view_center_on(CHAMPLAIN_VIEW(view), 45.466, -73.75);
+
+  /* insert it into the widget you wish */
+  vbox = gtk_vbox_new(FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (window), vbox);
+
+  /* show everything */
+  gtk_widget_show_all (window);
+
+  /* start the main loop */
+  gtk_main ();
+
+  return 0;
+}
diff --git a/demos/minimal.c b/demos/minimal.c
new file mode 100644
index 0000000..1578de9
--- /dev/null
+++ b/demos/minimal.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 Jiri Techet <techet gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <champlain/champlain.h>
+
+int
+main (int argc, char *argv[])
+{
+  ClutterActor* actor, *stage;
+
+  g_thread_init (NULL);
+  clutter_init (&argc, &argv);
+
+  stage = clutter_stage_get_default ();
+  clutter_actor_set_size (stage, 800, 600);
+
+  /* Create the map view */
+  actor = champlain_view_new ();
+  clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600);
+  clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
+
+  clutter_actor_show (stage);
+  clutter_main ();
+
+  clutter_actor_destroy (actor);
+    
+  return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]