[emerillon] Add Map Position plugin
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [emerillon] Add Map Position plugin
- Date: Sat, 10 Oct 2009 18:36:26 +0000 (UTC)
commit 71142f121794f6f85e83401b42e7ed9b6a86650d
Author: Pierre-Luc Beaudoin <pierre-luc beaudoin novopia com>
Date: Fri Oct 9 12:51:35 2009 -0400
Add Map Position plugin
This plugin displays the map location in the
statusbar
plugins/Makefile.am | 14 +++
plugins/map-position/map-position.c | 123 ++++++++++++++++++++
.../map-position/map-position.emerillon-plugin.in | 8 ++
plugins/map-position/map-position.h | 58 +++++++++
4 files changed, 203 insertions(+), 0 deletions(-)
---
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 0b2a8ca..f07b880 100755
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -47,6 +47,20 @@ copy_link_libcopy_link_la_SOURCES = \
copy_link_libcopy_link_la_LIBADD = \
$(EMERILLON_LIBS)
+# MousePosition plugin
+plugins_LTLIBRARIES += \
+ map-position/libmap-position.la
+
+plugins_in_files += \
+ map-position/map-position.emerillon-plugin.in
+
+map_position_libmap_position_la_SOURCES = \
+ map-position/map-position.h \
+ map-position/map-position.c
+
+map_position_libmap_position_la_LIBADD = \
+ $(EMERILLON_LIBS)
+
# Search plugin
if ENABLE_SEARCH
plugins_LTLIBRARIES += \
diff --git a/plugins/map-position/map-position.c b/plugins/map-position/map-position.c
new file mode 100644
index 0000000..40d2390
--- /dev/null
+++ b/plugins/map-position/map-position.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2009 Novopia Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "map-position.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "emerillon/emerillon.h"
+
+G_DEFINE_TYPE (MousePositionPlugin, map_position_plugin, ETHOS_TYPE_PLUGIN)
+
+struct _MousePositionPluginPrivate
+{
+ EmerillonWindow *window;
+ ChamplainView *map_view;
+
+ GtkStatusbar *statusbar;
+ guint signal_id;
+};
+
+static void
+moved_cb (GObject *gobject,
+ GParamSpec *pspec,
+ MousePositionPlugin *plugin)
+{
+ gdouble lat, lon;
+ gchar *position;
+ MousePositionPluginPrivate *priv;
+
+ priv = MOUSE_POSITION_PLUGIN (plugin)->priv;
+ g_object_get (priv->map_view,
+ "latitude", &lat,
+ "longitude", &lon,
+ NULL);
+
+ position = g_strdup_printf ("%f; %f", lat, lon);
+
+ gtk_statusbar_pop (priv->statusbar, 0);
+ gtk_statusbar_push (priv->statusbar, 0, position);
+
+ g_free (position);
+}
+
+static void
+activated (EthosPlugin *plugin)
+{
+ MousePositionPluginPrivate *priv;
+
+ priv = MOUSE_POSITION_PLUGIN (plugin)->priv;
+ priv->window = EMERILLON_WINDOW (emerillon_window_dup_default ());
+ priv->map_view = emerillon_window_get_map_view (priv->window);
+
+ priv->statusbar = GTK_STATUSBAR (emerillon_window_get_statusbar (priv->window));
+
+ priv->signal_id = g_signal_connect (priv->map_view,
+ "notify::latitude",
+ G_CALLBACK (moved_cb),
+ plugin);
+
+ moved_cb (NULL, NULL, MOUSE_POSITION_PLUGIN (plugin));
+}
+
+static void
+deactivated (EthosPlugin *plugin)
+{
+ MousePositionPluginPrivate *priv;
+
+ priv = MOUSE_POSITION_PLUGIN (plugin)->priv;
+ g_signal_handler_disconnect (priv->map_view, priv->signal_id);
+}
+
+static void
+map_position_plugin_class_init (MousePositionPluginClass *klass)
+{
+ EthosPluginClass *plugin_class;
+
+ g_type_class_add_private (klass, sizeof (MousePositionPluginPrivate));
+
+ plugin_class = ETHOS_PLUGIN_CLASS (klass);
+ plugin_class->activated = activated;
+ plugin_class->deactivated = deactivated;
+}
+
+static void
+map_position_plugin_init (MousePositionPlugin *plugin)
+{
+ plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
+ MOUSE_POSITION_TYPE_PLUGIN,
+ MousePositionPluginPrivate);
+}
+
+EthosPlugin*
+map_position_plugin_new (void)
+{
+ return g_object_new (MOUSE_POSITION_TYPE_PLUGIN, NULL);
+}
+
+G_MODULE_EXPORT EthosPlugin*
+ethos_plugin_register (void)
+{
+ return map_position_plugin_new ();
+}
diff --git a/plugins/map-position/map-position.emerillon-plugin.in b/plugins/map-position/map-position.emerillon-plugin.in
new file mode 100644
index 0000000..b8a96f6
--- /dev/null
+++ b/plugins/map-position/map-position.emerillon-plugin.in
@@ -0,0 +1,8 @@
+[Emerillon Plugin]
+_Name=Map Position
+Module=map-position
+_Description=Display in the statusbar the coordinates at the center of the map
+IAge=1
+Authors=Pierre-Luc Beaudoin <pierre-luc beaudoin novopia com>
+Copyright=Copyright © 2009 Novopia Inc.
+
diff --git a/plugins/map-position/map-position.h b/plugins/map-position/map-position.h
new file mode 100644
index 0000000..a84c072
--- /dev/null
+++ b/plugins/map-position/map-position.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2009 Novopia Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __MOUSE_POSITION_PLUGIN_H__
+#define __MOUSE_POSITION_PLUGIN_H__
+
+#include <glib-object.h>
+#include <ethos/ethos.h>
+#include <ethos/ethos-ui.h>
+
+G_BEGIN_DECLS
+
+#define MOUSE_POSITION_TYPE_PLUGIN (map_position_plugin_get_type())
+#define MOUSE_POSITION_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOUSE_POSITION_TYPE_PLUGIN, MousePositionPlugin))
+#define MOUSE_POSITION_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOUSE_POSITION_TYPE_PLUGIN, MousePositionPluginClass))
+#define MOUSE_POSITION_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOUSE_POSITION_TYPE_PLUGIN))
+#define MOUSE_POSITION_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOUSE_POSITION_TYPE_PLUGIN))
+#define MOUSE_POSITION_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOUSE_POSITION_TYPE_PLUGIN, MousePositionPluginClass))
+
+typedef struct _MousePositionPlugin MousePositionPlugin;
+typedef struct _MousePositionPluginClass MousePositionPluginClass;
+typedef struct _MousePositionPluginPrivate MousePositionPluginPrivate;
+
+struct _MousePositionPlugin
+{
+ EthosPlugin parent;
+
+ /*< private >*/
+ MousePositionPluginPrivate *priv;
+};
+
+struct _MousePositionPluginClass
+{
+ EthosPluginClass parent_class;
+};
+
+GType map_position_plugin_get_type (void);
+EthosPlugin* map_position_plugin_new (void);
+
+G_END_DECLS
+
+#endif /* __MOUSE_POSITION_PLUGIN_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]