From d52997696ba8cb44de93b5e25e11fc2a335b24ac Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 21 Jun 2008 21:00:24 +0100 Subject: [PATCH] Working dream mode --- configure.ac | 2 +- src/bubblegen.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index abcbd38..286da34 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ AC_FUNC_MALLOC AC_CHECK_FUNCS([strtol]) # Check for pkg-config packages -modules="gtk+-2.0" +modules="gtk+-2.0 gdk-pixbuf-2.0" xcowsayd_modules="$modules dbus-glib-1 gthread-2.0" AC_ARG_ENABLE(dbus, [AS_HELP_STRING([--disable-dbus], [Do not build DBus daemon.])], diff --git a/src/bubblegen.c b/src/bubblegen.c index 4f3e68b..854c5fb 100644 --- a/src/bubblegen.c +++ b/src/bubblegen.c @@ -21,6 +21,7 @@ #include #include +#include #include "floating_shape.h" #include "settings.h" @@ -173,7 +174,29 @@ static int bubble_content_top() GdkPixbuf *make_dream_bubble(const char *file, int *p_width, int *p_height) { - return NULL; + bubble_t bubble; + GError *error = NULL; + GdkPixbuf *image = gdk_pixbuf_new_from_file(file, &error); + + if (NULL == image) { + fprintf(stderr, "Error: failed to load %s\n", file); + exit(1); + } + + bubble_size_from_content(&bubble, gdk_pixbuf_get_width(image), + gdk_pixbuf_get_height(image)); + *p_width = bubble.width; + *p_height = bubble.height; + + bubble_init(&bubble); + + gdk_draw_pixbuf(bubble.pixmap, bubble.gc, image, 0, 0, + bubble_content_left(), bubble_content_top(), + -1, -1, GDK_RGB_DITHER_NONE, 0, 0); + + gdk_pixbuf_unref(image); + + return bubble_tidy(&bubble); } GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height) -- 2.39.2