*/
#include "config.h"
+#include "empathy-avatar-image.h"
#include <glib/gi18n-lib.h>
-#include <gdk/gdkkeysyms.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#include <tp-account-widgets/tpaw-pixbuf-utils.h>
-#include <libempathy/empathy-utils.h>
-#include "empathy-avatar-image.h"
#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
/**
* SECTION:empathy-avatar-image
priv = GET_PRIV (data);
- switch (xevent->type) {
- case PropertyNotify:
+ if (xevent->type == PropertyNotify) {
atom = gdk_x11_get_xatom_by_name ("_NET_CURRENT_DESKTOP");
if (xevent->xproperty.atom == atom) {
if (priv->popup) {
priv->popup = NULL;
}
}
- break;
}
return GDK_FILTER_CONTINUE;
static void
avatar_image_add_filter (EmpathyAvatarImage *avatar_image)
{
+ Display *display;
Window window;
- GdkWindow *gdkwindow;
gint mask;
+ XWindowAttributes attrs;
mask = PropertyChangeMask;
- window = GDK_ROOT_WINDOW ();
- gdkwindow = gdk_xid_table_lookup (window);
+ window = gdk_x11_get_default_root_xwindow ();
+ display = gdk_x11_get_default_xdisplay ();
gdk_error_trap_push ();
- if (gdkwindow) {
- XWindowAttributes attrs;
- XGetWindowAttributes (gdk_display, window, &attrs);
- mask |= attrs.your_event_mask;
- }
- XSelectInput (gdk_display, window, mask);
+ XGetWindowAttributes (display, window, &attrs);
+ mask |= attrs.your_event_mask;
+
+ XSelectInput (display, window, mask);
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
gdk_window_add_filter (NULL, avatar_image_filter_func, avatar_image);
}
gint popup_width, popup_height;
gint width, height;
GdkPixbuf *pixbuf;
+ GtkAllocation allocation;
priv = GET_PRIV (widget);
popup_width = gdk_pixbuf_get_width (priv->pixbuf);
popup_height = gdk_pixbuf_get_height (priv->pixbuf);
- width = priv->image->allocation.width;
- height = priv->image->allocation.height;
+ gtk_widget_get_allocation (priv->image, &allocation);
+ width = allocation.width;
+ height = allocation.height;
/* Don't show a popup if the popup is smaller then the currently avatar
* image.
return TRUE;
}
- pixbuf = empathy_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_LARGE);
+ pixbuf = tpaw_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_LARGE);
popup_width = gdk_pixbuf_get_width (pixbuf);
popup_height = gdk_pixbuf_get_height (pixbuf);
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
g_object_unref (pixbuf);
- gdk_window_get_origin (priv->image->window, &x, &y);
+ gdk_window_get_origin (gtk_widget_get_window (priv->image), &x, &y);
x = x - (popup_width - width) / 2;
y = y - (popup_height - height) / 2;
}
if (avatar) {
- priv->pixbuf = empathy_pixbuf_from_data (avatar->data, avatar->len);
+ priv->pixbuf = tpaw_pixbuf_from_data ((gchar *) avatar->data,
+ avatar->len);
}
if (!priv->pixbuf) {
- gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
- "stock_person",
- GTK_ICON_SIZE_DIALOG);
+ gtk_image_clear (GTK_IMAGE (priv->image));
return;
}
- scaled_pixbuf = empathy_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_SMALL);
+ scaled_pixbuf = tpaw_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_SMALL);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled_pixbuf);
if (scaled_pixbuf != priv->pixbuf) {