[evolution] Remove EContactMarker.



commit 8d782da33dedb8cba308f716e2e84c7ffbdc523c
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Oct 31 16:20:20 2013 -0400

    Remove EContactMarker.
    
    ChamplainLabel does everything we need now.  Need to stash a contact UID
    for opening the Contact Editor on double-click, but not worth a subclass
    for just that.

 addressbook/gui/widgets/Makefile.am            |    2 -
 addressbook/gui/widgets/e-contact-map-window.c |   29 +-
 addressbook/gui/widgets/e-contact-map.c        |   81 +++-
 addressbook/gui/widgets/e-contact-marker.c     |  646 ------------------------
 addressbook/gui/widgets/e-contact-marker.h     |   81 ---
 5 files changed, 94 insertions(+), 745 deletions(-)
---
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index 1c7e8f0..79ab1fb 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -43,8 +43,6 @@ libeabwidgets_la_SOURCES =                    \
        e-contact-map.h                         \
        e-contact-map-window.c                  \
        e-contact-map-window.h                  \
-       e-contact-marker.c                      \
-       e-contact-marker.h                      \
        e-minicard.c                            \
        e-minicard.h                            \
        e-minicard-label.c                      \
diff --git a/addressbook/gui/widgets/e-contact-map-window.c b/addressbook/gui/widgets/e-contact-map-window.c
index 6dbc8d8..c83e2b8 100644
--- a/addressbook/gui/widgets/e-contact-map-window.c
+++ b/addressbook/gui/widgets/e-contact-map-window.c
@@ -31,7 +31,6 @@
 #include <champlain/champlain.h>
 
 #include "e-contact-map.h"
-#include "e-contact-marker.h"
 
 #define E_CONTACT_MAP_WINDOW_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
@@ -65,18 +64,25 @@ G_DEFINE_TYPE (
        e_contact_map_window,
        GTK_TYPE_WINDOW)
 
-static void
-marker_doubleclick_cb (ClutterActor *actor,
-                       gpointer user_data)
+static gboolean
+contact_map_marker_button_release_event_cb (ClutterActor *actor,
+                                            ClutterEvent *event,
+                                            EContactMapWindow *window)
 {
-       EContactMapWindow *window = user_data;
-       EContactMarker *marker;
        const gchar *contact_uid;
 
-       marker = E_CONTACT_MARKER (actor);
-       contact_uid = e_contact_marker_get_contact_uid (marker);
+       if (clutter_event_get_click_count (event) != 2)
+               return FALSE;
+
+       contact_uid = g_object_get_data (G_OBJECT (actor), "contact-uid");
+       g_return_val_if_fail (contact_uid != NULL, FALSE);
 
-       g_signal_emit (window, signals[SHOW_CONTACT_EDITOR], 0, contact_uid);
+       g_signal_emit (
+               window,
+               signals[SHOW_CONTACT_EDITOR], 0,
+               contact_uid);
+
+       return TRUE;
 }
 
 static void
@@ -173,8 +179,9 @@ contact_map_window_contact_added_cb (EContactMap *map,
        gtk_list_store_set (list_store, &iter, 0, name, -1);
 
        g_signal_connect (
-               marker, "double-clicked",
-               G_CALLBACK (marker_doubleclick_cb), window);
+               marker, "button-release-event",
+               G_CALLBACK (contact_map_marker_button_release_event_cb),
+               window);
 
        window->priv->tasks_cnt--;
        if (window->priv->tasks_cnt == 0) {
diff --git a/addressbook/gui/widgets/e-contact-map.c b/addressbook/gui/widgets/e-contact-map.c
index d874df5..dd67f76 100644
--- a/addressbook/gui/widgets/e-contact-map.c
+++ b/addressbook/gui/widgets/e-contact-map.c
@@ -39,8 +39,6 @@
 
 #include "e-util/e-util.h"
 
-#include "e-contact-marker.h"
-
 #define E_CONTACT_MAP_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_CONTACT_MAP, EContactMapPrivate))
@@ -55,7 +53,7 @@ struct _EContactMapPrivate {
 
 struct _AsyncContext {
        EContactMap *map;
-       EContactMarker *marker;
+       ClutterActor *marker;
 };
 
 enum {
@@ -78,6 +76,66 @@ async_context_free (AsyncContext *async_context)
        g_slice_free (AsyncContext, async_context);
 }
 
+static ClutterActor *
+texture_new_from_pixbuf (GdkPixbuf *pixbuf,
+                         GError **error)
+{
+       ClutterActor *texture = NULL;
+       const guchar *data;
+       gboolean has_alpha, success;
+       gint width, height, rowstride;
+       ClutterTextureFlags flags = 0;
+
+       data = gdk_pixbuf_get_pixels (pixbuf);
+       width = gdk_pixbuf_get_width (pixbuf);
+       height = gdk_pixbuf_get_height (pixbuf);
+       has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+       rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+
+       texture = clutter_texture_new ();
+       success = clutter_texture_set_from_rgb_data (
+               CLUTTER_TEXTURE (texture),
+               data, has_alpha, width, height, rowstride,
+               (has_alpha ? 4: 3), flags, NULL);
+
+       if (!success) {
+               clutter_actor_destroy (CLUTTER_ACTOR (texture));
+               texture = NULL;
+       }
+
+       return texture;
+}
+
+static ClutterActor *
+contact_map_photo_to_texture (EContactPhoto *photo)
+{
+       ClutterActor *texture = NULL;
+       GdkPixbuf *pixbuf = NULL;
+
+       if  (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) {
+               GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+
+               gdk_pixbuf_loader_write (
+                       loader, photo->data.inlined.data,
+                       photo->data.inlined.length, NULL);
+               gdk_pixbuf_loader_close (loader, NULL);
+               pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+               if (pixbuf != NULL)
+                       g_object_ref (pixbuf);
+               g_object_unref (loader);
+
+       } else if (photo->type == E_CONTACT_PHOTO_TYPE_URI) {
+               pixbuf = gdk_pixbuf_new_from_file (photo->data.uri, NULL);
+       }
+
+       if (pixbuf != NULL) {
+               texture = texture_new_from_pixbuf (pixbuf, NULL);
+               g_object_unref (pixbuf);
+       }
+
+       return texture;
+}
+
 static void
 contact_map_address_resolved_cb (GObject *source_object,
                                  GAsyncResult *result,
@@ -343,7 +401,7 @@ e_contact_map_add_marker (EContactMap *map,
                           EContactAddress *address,
                           EContactPhoto *photo)
 {
-       EContactMarker *marker;
+       ClutterActor *marker;
        GHashTable *hash_table;
        GeocodeForward *geocoder;
        AsyncContext *async_context;
@@ -353,7 +411,20 @@ e_contact_map_add_marker (EContactMap *map,
        g_return_if_fail (contact_uid != NULL);
        g_return_if_fail (address != NULL);
 
-       marker = e_contact_marker_new (name, contact_uid, photo);
+       marker = champlain_label_new ();
+       champlain_label_set_text (CHAMPLAIN_LABEL (marker), name);
+
+       if (photo != NULL) {
+               champlain_label_set_image (
+                       CHAMPLAIN_LABEL (marker),
+                       contact_map_photo_to_texture (photo));
+       }
+
+       /* Stash the contact UID for EContactMapWindow. */
+       g_object_set_data_full (
+               G_OBJECT (marker), "contact-uid",
+               g_strdup (contact_uid),
+               (GDestroyNotify) g_free);
 
        hash_table = address_to_xep (address);
        geocoder = geocode_forward_new_for_params (hash_table);


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