*
* 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.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
*
* Authors: Xavier Claessens <xclaesse@gmail.com>
*/
#include "config.h"
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#include <libempathy/empathy-debug.h>
-
+#include <libempathy/empathy-utils.h>
#include "empathy-avatar-image.h"
#include "empathy-ui-utils.h"
-#define DEBUG_DOMAIN "AvatarImage"
+/**
+ * SECTION:empathy-avatar-image
+ * @title: EmpathyAvatarImage
+ * @short_description: A widget to display an avatar
+ * @include: libempathy-gtk/empathy-avatar-image.h
+ *
+ * #EmpathyAvatarImage is a widget which displays an avatar.
+ */
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImagePriv))
+/**
+ * EmpathyAvatarImage:
+ * @parent: parent object
+ *
+ * Widget which displays an avatar.
+ */
#define MAX_SMALL 64
#define MAX_LARGE 400
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAvatarImage)
typedef struct {
GtkWidget *image;
GtkWidget *popup;
static void
empathy_avatar_image_init (EmpathyAvatarImage *avatar_image)
{
- EmpathyAvatarImagePriv *priv;
-
- priv = GET_PRIV (avatar_image);
+ EmpathyAvatarImagePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (avatar_image,
+ EMPATHY_TYPE_AVATAR_IMAGE, EmpathyAvatarImagePriv);
+ avatar_image->priv = priv;
priv->image = gtk_image_new ();
gtk_container_add (GTK_CONTAINER (avatar_image), priv->image);
empathy_avatar_image_set (avatar_image, NULL);
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.
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;
return TRUE;
}
+/**
+ * empathy_avatar_image_new:
+ *
+ * Creates a new #EmpathyAvatarImage.
+ *
+ * Return value: a new #EmpathyAvatarImage
+ */
GtkWidget *
empathy_avatar_image_new (void)
{
return GTK_WIDGET (avatar_image);
}
+/**
+ * empathy_avatar_image_set:
+ * @avatar_image: an #EmpathyAvatarImage
+ * @avatar: the #EmpathyAvatar to set @avatar_image to
+ *
+ * Sets @avatar_image to display the avatar indicated by @avatar.
+ */
void
empathy_avatar_image_set (EmpathyAvatarImage *avatar_image,
EmpathyAvatar *avatar)
}
if (avatar) {
- priv->pixbuf = empathy_pixbuf_from_data (avatar->data, avatar->len);
+ priv->pixbuf = empathy_pixbuf_from_data ((gchar *) avatar->data,
+ avatar->len);
}
if (!priv->pixbuf) {