]> err.no Git - libchamplain/commitdiff
Have all the demos use the same markers
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sat, 11 Apr 2009 23:13:24 +0000 (19:13 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Sun, 12 Apr 2009 01:41:49 +0000 (21:41 -0400)
demos/Makefile.am
demos/launcher.c
demos/markers.c [new file with mode: 0644]
demos/markers.h [new file with mode: 0644]

index 1d01fd85ae0011deb17c4405df6f1b4a78e8d77e..2d539ce8d5c0682f2e90bbc1e8f3ac09798bbd44 100644 (file)
@@ -5,7 +5,7 @@ INCLUDES = -I$(top_srcdir)
 AM_CPPFLAGS = $(DEPS_CFLAGS) $(WARN_CFLAGS)
 AM_LDFLAGS = $(DEPS_LIBS)
 
-launcher_SOURCES = launcher.c
+launcher_SOURCES = launcher.c markers.c
 launcher_LDADD = $(DEPS_LIBS) ../champlain/libchamplain-0.3.la
 
 animated_marker_SOURCES = animated-marker.c
@@ -13,7 +13,7 @@ animated_marker_LDADD = $(DEPS_LIBS) ../champlain/libchamplain-0.3.la
 
 if ENABLE_GTK
 noinst_PROGRAMS += launcher-gtk
-launcher_gtk_SOURCES = launcher-gtk.c
+launcher_gtk_SOURCES = launcher-gtk.c markers.c
 launcher_gtk_CPPFLAGS = $(GTK_DEPS_CFLAGS)
 launcher_gtk_LDADD = $(GTK_DEPS_LIBS) $(DEPS_LIBS) \
                ../champlain-gtk/libchamplain-gtk-0.3.la \
index 16edeec64da84d2074016f671550fa6a580ce50b..f967e9910e4041313698bb167b266ccbcd66c279 100644 (file)
  */
 
 #include <champlain/champlain.h>
+#include "markers.h"
 
 #define PADDING 10
-ChamplainBaseMarker *markers [4];
 
 static gboolean
 map_view_button_release_cb (ClutterActor *actor,
-                            ClutterButtonEvent *event,
-                            ChamplainView * view)
+    ClutterButtonEvent *event,
+    ChamplainView * view)
 {
   gdouble lat, lon;
 
@@ -34,28 +34,15 @@ map_view_button_release_cb (ClutterActor *actor,
   g_print("Map was clicked at ");
   if (champlain_view_get_coords_from_event (view, (ClutterEvent*)event, &lat,
          &lon))
-    g_print("%f, %f \n", lat, lon);
-
-  return TRUE;
-}
-
-static gboolean
-marker_button_release_cb (ClutterActor *actor,
-                          ClutterButtonEvent *event,
-                          ChamplainView * view)
-{
-  if (event->button != 1 || event->click_count > 1)
-    return FALSE;
-
-  g_print("Montreal was clicked\n");
+    g_print("Map clicked at %f, %f \n", lat, lon);
 
   return TRUE;
 }
 
 static gboolean
 zoom_in (ClutterActor *actor,
-         ClutterButtonEvent *event,
-         ChamplainView * view)
+    ClutterButtonEvent *event,
+    ChamplainView * view)
 {
   champlain_view_zoom_in (view);
   return TRUE;
@@ -63,61 +50,13 @@ zoom_in (ClutterActor *actor,
 
 static gboolean
 zoom_out (ClutterActor *actor,
-          ClutterButtonEvent *event,
-          ChamplainView * view)
+    ClutterButtonEvent *event,
+    ChamplainView * view)
 {
   champlain_view_zoom_out (view);
   return TRUE;
 }
 
-static gboolean
-center (ClutterActor *actor,
-        ClutterButtonEvent *event,
-        ChamplainView * view)
-{
-  champlain_view_ensure_markers_visible (view, markers, TRUE);
-  return TRUE;
-}
-
-static ChamplainLayer *
-create_marker_layer (ChamplainView *view)
-{
-  ClutterActor *marker;
-  ChamplainLayer *layer;
-  //ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb };
-  //ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
-
-  layer = champlain_layer_new ();
-
-  marker = champlain_marker_new_with_text ("Montréal\n<span size=\"xx-small\">Québec</span>",
-      "Airmole 14", NULL, NULL);
-  champlain_marker_set_use_markup (CHAMPLAIN_MARKER (marker), TRUE);
-
-  markers[0] = CHAMPLAIN_BASE_MARKER (marker);
-  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
-      45.528178, -73.563788);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
-  clutter_actor_set_reactive (marker, TRUE);
-  g_signal_connect_after (marker, "button-release-event",
-      G_CALLBACK (marker_button_release_cb), view);
-
-  marker = champlain_marker_new_full ("New York", "/usr/share/icons/Tango/32x32/apps/system-users.png", NULL);
-  markers[1] = CHAMPLAIN_BASE_MARKER (marker);
-  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
-
-  marker = champlain_marker_new_with_image ("/usr/share/icons/Tango/32x32/apps/system-users.png", NULL);
-  markers[2] = CHAMPLAIN_BASE_MARKER (marker);
-  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885,
-      -70.764141);
-  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
-
-  markers[3] = NULL;
-
-  clutter_actor_show (CLUTTER_ACTOR (layer));
-  return layer;
-}
-
 static ClutterActor *
 make_button (char *text)
 {
@@ -145,7 +84,7 @@ make_button (char *text)
 
 int
 main (int argc,
-      char *argv[])
+    char *argv[])
 {
   ClutterActor* actor, *stage, *buttons, *button;
   ChamplainLayer *layer;
@@ -185,16 +124,6 @@ main (int argc,
       G_CALLBACK (zoom_out),
       actor);
 
-  button = make_button ("Center on markers");
-  clutter_container_add_actor (CLUTTER_CONTAINER (buttons), button);
-  clutter_actor_set_reactive (button, TRUE);
-  clutter_actor_set_position (button, total_width, 0);
-  clutter_actor_get_size (button, &width, NULL);
-  total_width += width + PADDING;
-  g_signal_connect (button, "button-release-event",
-      G_CALLBACK (center),
-      actor);
-
   clutter_container_add_actor (CLUTTER_CONTAINER (stage), buttons);
 
   /* Create the markers and marker layer */
diff --git a/demos/markers.c b/demos/markers.c
new file mode 100644 (file)
index 0000000..070f49e
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.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>
+#include <markers.h>
+
+static gboolean
+marker_button_release_cb (ClutterActor *actor,
+                          ClutterButtonEvent *event,
+                          ChamplainView * view)
+{
+  if (event->button != 1 || event->click_count > 1)
+    return FALSE;
+
+  g_print("Montreal was clicked\n");
+
+  return TRUE;
+}
+
+ChamplainLayer *
+create_marker_layer (ChamplainView *view)
+{
+  ClutterActor *marker;
+  ChamplainLayer *layer;
+
+  layer = champlain_layer_new ();
+
+  marker = champlain_marker_new_with_text ("Montréal\n<span size=\"xx-small\">Québec</span>",
+      "Airmole 14", NULL, NULL);
+  champlain_marker_set_use_markup (CHAMPLAIN_MARKER (marker), TRUE);
+
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker),
+      45.528178, -73.563788);
+  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+  clutter_actor_set_reactive (marker, TRUE);
+  g_signal_connect_after (marker, "button-release-event",
+      G_CALLBACK (marker_button_release_cb), view);
+
+  marker = champlain_marker_new_full ("New York", "/usr/share/icons/gnome/32x32/emblems/emblem-generic.png", NULL);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98);
+  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+
+  marker = champlain_marker_new_with_image ("/usr/share/icons/Tango/32x32/emblems/emblem-important.png", NULL);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885,
+      -70.764141);
+  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+
+  marker = champlain_marker_new_with_image ("/usr/share/icons/Tango/32x32/emblems/emblem-urgent.png", NULL);
+  champlain_marker_set_draw_background (CHAMPLAIN_MARKER (marker), FALSE);
+  champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47,
+      -80);
+  clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+
+  clutter_actor_show (CLUTTER_ACTOR (layer));
+  return layer;
+}
diff --git a/demos/markers.h b/demos/markers.h
new file mode 100644 (file)
index 0000000..5d1e16f
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.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>
+
+#ifndef MARKERS_H
+#define MARKERS_H
+
+ChamplainLayer * create_marker_layer (ChamplainView *view);
+
+#endif