aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am8
-rw-r--r--src/empathy-main-window.c19
-rw-r--r--src/empathy-main-window.ui7
-rw-r--r--src/empathy-map-view.c217
-rw-r--r--src/empathy-map-view.h33
-rw-r--r--src/empathy-map-view.ui59
-rw-r--r--src/empathy.c8
7 files changed, 351 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 128ef88ee..a70e7e2de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,6 +73,14 @@ ui_DATA = \
empathy-preferences.ui \
empathy-status-icon.ui
+if HAVE_LIBCHAMPLAIN
+empathy_SOURCES += \
+ empathy-map-view.c empathy-map-view.h
+
+ui_DATA += \
+ empathy-map-view.ui
+endif
+
dist_man_MANS = \
empathy.1
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index d453fed44..b21464834 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -56,6 +56,7 @@
#include "empathy-preferences.h"
#include "empathy-about-dialog.h"
#include "empathy-new-chatroom-dialog.h"
+#include "empathy-map-view.h"
#include "empathy-chatrooms-window.h"
#include "empathy-event-manager.h"
#include "empathy-ft-manager.h"
@@ -714,6 +715,15 @@ main_window_view_show_offline_cb (GtkToggleAction *action,
//empathy_sound_set_enabled (TRUE);
}
+#if HAVE_LIBCHAMPLAIN
+static void
+main_window_view_show_map_cb (GtkCheckMenuItem *item,
+ EmpathyMainWindow *window)
+{
+ empathy_map_view_show (window->list_store);
+}
+#endif
+
static void
main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
{
@@ -1097,6 +1107,7 @@ empathy_main_window_show (void)
GtkWidget *sw;
GtkToggleAction *show_offline_widget;
GtkWidget *ebox;
+ GtkWidget *show_map_widget;
GtkToolItem *item;
gboolean show_offline;
gboolean show_avatars;
@@ -1121,6 +1132,7 @@ empathy_main_window_show (void)
"ui_manager", &window->ui_manager,
"view_show_offline", &show_offline_widget,
"view_history", &window->view_history,
+ "view_show_map", &show_map_widget,
"room_join_favorites", &window->room_join_favorites,
"presence_toolbar", &window->presence_toolbar,
"roster_scrolledwindow", &sw,
@@ -1139,6 +1151,9 @@ empathy_main_window_show (void)
"chat_add_contact", "activate", main_window_chat_add_contact_cb,
"view_show_ft_manager", "activate", main_window_view_show_ft_manager,
"view_show_offline", "toggled", main_window_view_show_offline_cb,
+#if HAVE_LIBCHAMPLAIN
+ "view_show_map", "activate", main_window_view_show_map_cb,
+#endif
"edit", "activate", main_window_edit_cb,
"edit_accounts", "activate", main_window_edit_accounts_cb,
"edit_personal_information", "activate", main_window_edit_personal_information_cb,
@@ -1153,6 +1168,10 @@ empathy_main_window_show (void)
g_object_ref (window->ui_manager);
g_object_unref (gui);
+#if !HAVE_LIBCHAMPLAIN
+ gtk_widget_hide (show_map_widget);
+#endif
+
window->mc = empathy_mission_control_dup_singleton ();
window->account_manager = empathy_account_manager_dup_singleton ();
diff --git a/src/empathy-main-window.ui b/src/empathy-main-window.ui
index 14660b75c..bbf8f1972 100644
--- a/src/empathy-main-window.ui
+++ b/src/empathy-main-window.ui
@@ -48,6 +48,12 @@
<accelerator key="H" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
+ <object class="GtkAction" id="view_show_map">
+ <property name="name">view_show_map</property>
+ <property name="label" translatable="yes">Show Contacts on a Map</property>
+ </object>
+ </child>
+ <child>
<object class="GtkAction" id="chat_quit">
<property name="stock_id">gtk-quit</property>
<property name="name">chat_quit</property>
@@ -162,6 +168,7 @@
<separator/>
<menuitem action="view_history"/>
<menuitem action="view_show_ft_manager"/>
+ <menuitem action="view_show_map"/>
</menu>
<menu action="room">
<menuitem action="room_join_new"/>
diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c
new file mode 100644
index 000000000..3e5482d2b
--- /dev/null
+++ b/src/empathy-map-view.c
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2008 Collabora Ltd.
+ *
+ * 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.
+ *
+ * Authors: Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ */
+
+#include <config.h>
+
+#include <sys/stat.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include <champlain/champlain.h>
+#include <champlain-gtk/champlain-gtk.h>
+#include <clutter-gtk/gtk-clutter-embed.h>
+
+#include <libempathy/empathy-contact.h>
+#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-chatroom-manager.h>
+#include <libempathy/empathy-chatroom.h>
+#include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-contact-factory.h>
+#include <libempathy/empathy-status-presets.h>
+
+#include <libempathy-gtk/empathy-contact-dialogs.h>
+#include <libempathy-gtk/empathy-contact-list-store.h>
+#include <libempathy-gtk/empathy-contact-list-view.h>
+#include <libempathy-gtk/empathy-presence-chooser.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
+#include <libempathy-gtk/empathy-geometry.h>
+#include <libempathy-gtk/empathy-conf.h>
+#include <libempathy-gtk/empathy-log-window.h>
+#include <libempathy-gtk/empathy-new-message-dialog.h>
+#include <libempathy-gtk/empathy-gtk-enum-types.h>
+
+#include "empathy-accounts-dialog.h"
+#include "empathy-map-view.h"
+#include "ephy-spinner.h"
+#include "empathy-preferences.h"
+#include "empathy-about-dialog.h"
+#include "empathy-new-chatroom-dialog.h"
+#include "empathy-chatrooms-window.h"
+#include "empathy-event-manager.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
+
+typedef struct {
+ EmpathyContactListStore *list_store;
+
+ GtkWidget *window;
+ GtkWidget *zoom_in;
+ GtkWidget *zoom_out;
+ ChamplainView *map_view;
+ ChamplainLayer *layer;
+
+} EmpathyMapView;
+
+static void map_view_destroy_cb (GtkWidget *widget,
+ EmpathyMapView *window);
+static void map_view_update_status (EmpathyMapView *window);
+static gboolean map_view_contacts_foreach (GtkTreeModel *model,
+ GtkTreePath *path, GtkTreeIter *iter, gpointer user_data);
+static void map_view_zoom_in_cb (GtkWidget *widget, EmpathyMapView *window);
+static void map_view_zoom_out_cb (GtkWidget *widget, EmpathyMapView *window);
+
+// FIXME: Make it so that only one window can be shown
+GtkWidget *
+empathy_map_view_show (EmpathyContactListStore *list_store)
+{
+ static EmpathyMapView *window = NULL;
+ GtkBuilder *gui;
+ GtkWidget *sw;
+ GtkWidget *embed;
+ gchar *filename;
+ GtkTreeModel *model;
+
+ /*
+ if (window)
+ {
+ empathy_window_present (GTK_WINDOW (window->window), TRUE);
+ return window->window;
+ }
+ */
+
+ window = g_new0 (EmpathyMapView, 1);
+
+ /* Set up interface */
+ filename = empathy_file_lookup ("empathy-map-view.ui", "src");
+ gui = empathy_builder_get_file (filename, "map_view",
+ &window->window, "zoom_in", &window->zoom_in, "zoom_out",
+ &window->zoom_out, "map_scrolledwindow", &sw, NULL);
+ g_free (filename);
+
+ empathy_builder_connect (gui, window, "map_view", "destroy",
+ map_view_destroy_cb, "zoom_in", "clicked", map_view_zoom_in_cb,
+ "zoom_out", "clicked", map_view_zoom_out_cb, NULL);
+
+ g_object_unref (gui);
+
+ window->list_store = list_store;
+
+ /* Set up map view */
+ window->map_view = CHAMPLAIN_VIEW (champlain_view_new (
+ CHAMPLAIN_VIEW_MODE_KINETIC));
+ g_object_set (G_OBJECT (window->map_view), "zoom-level", 1, NULL);
+ champlain_view_center_on (window->map_view, 36, 0);
+
+ embed = champlain_view_embed_new (window->map_view);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
+ GTK_WIDGET (embed));
+ gtk_widget_show_all (embed);
+
+ window->layer = champlain_layer_new ();
+ champlain_view_add_layer (CHAMPLAIN_VIEW (window->map_view), window->layer);
+
+ /* Set up contact list. */
+ model = GTK_TREE_MODEL (window->list_store);
+ gtk_tree_model_foreach (model, map_view_contacts_foreach, window);
+
+ map_view_update_status (window);
+
+ empathy_window_present (GTK_WINDOW (window->window), TRUE);
+ return window->window;
+}
+
+
+static void
+map_view_destroy_cb (GtkWidget *widget,
+ EmpathyMapView *window)
+{
+ g_free (window);
+}
+
+
+static void
+map_view_update_status (EmpathyMapView *window)
+{
+
+}
+
+
+static gboolean
+map_view_contacts_foreach (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ EmpathyMapView *window = (EmpathyMapView*) user_data;
+ EmpathyContact *contact;
+ ClutterActor *marker;
+ ClutterActor *texture;
+ GdkPixbuf *avatar;
+
+ gtk_tree_model_get (model, iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT,
+ &contact, -1);
+ if (!contact)
+ return FALSE;
+
+ marker = champlain_marker_new ();
+ texture = clutter_texture_new ();
+
+ avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
+
+ if (!avatar)
+ goto cleanup;
+
+ gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (texture), avatar);
+ clutter_actor_set_position (CLUTTER_ACTOR (texture), 5, 5);
+
+ clutter_container_add (CLUTTER_CONTAINER (marker), texture, NULL);
+
+ GRand* rand = g_rand_new ();
+ gdouble lon = g_rand_double_range (rand, -170.0, 170.0);
+ gdouble lat = g_rand_double_range (rand, -70.0, 70.0);
+ g_print("%f, %f\n", lat, lon);
+ champlain_marker_set_position (CHAMPLAIN_MARKER (marker), lat, lon);
+ clutter_actor_set_anchor_point (marker, 25, 50);
+
+ clutter_container_add (CLUTTER_CONTAINER (window->layer), marker, NULL);
+
+cleanup:
+ g_object_unref (contact);
+ return FALSE;
+}
+
+
+static void
+map_view_zoom_in_cb (GtkWidget *widget,
+ EmpathyMapView *window)
+{
+ champlain_view_zoom_in (window->map_view);
+}
+
+
+static void
+map_view_zoom_out_cb (GtkWidget *widget,
+ EmpathyMapView *window)
+{
+ champlain_view_zoom_out (window->map_view);
+}
diff --git a/src/empathy-map-view.h b/src/empathy-map-view.h
new file mode 100644
index 000000000..bad93da96
--- /dev/null
+++ b/src/empathy-map-view.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008 Collabora Ltd.
+ *
+ * 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.
+ *
+ * Authors: Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
+ */
+
+#ifndef __EMPATHY_MAP_VIEW_H__
+#define __EMPATHY_MAP_VIEW_H__
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+GtkWidget *empathy_map_view_show (EmpathyContactListStore *list_store);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_MAP_VIEW_H__ */
diff --git a/src/empathy-map-view.ui b/src/empathy-map-view.ui
new file mode 100644
index 000000000..8102761c2
--- /dev/null
+++ b/src/empathy-map-view.ui
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+ <object class="GtkWindow" id="map_view">
+ <property name="title" translatable="yes">Contact Map View</property>
+ <property name="role">map_view</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <property name="default_width">512</property>
+ <property name="default_height">384</property>
+ <child>
+ <object class="GtkVBox" id="main_vbox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkToolbar" id="toolbar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkToolButton" id="zoom_in">
+ <property name="visible">True</property>
+ <property name="stock_id">gtk-zoom-in</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="zoom_out">
+ <property name="visible">True</property>
+ <property name="stock_id">gtk-zoom-out</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="map_scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/empathy.c b/src/empathy.c
index fe122e01f..b66520ffa 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -31,6 +31,10 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#if HAVE_LIBCHAMPLAIN
+#include <clutter-gtk/gtk-clutter-embed.h>
+#endif
+
#include <libebook/e-book.h>
#include <libnotify/notify.h>
@@ -466,6 +470,10 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
+#if HAVE_LIBCHAMPLAIN
+ gtk_clutter_init(&argc, &argv);
+#endif
+
gtk_window_set_default_icon_name ("empathy");
textdomain (GETTEXT_PACKAGE);