Shows the name associated with the face
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 16 Aug 2008 21:19:47 +0000 (18:19 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 16 Aug 2008 21:19:47 +0000 (18:19 -0300)
gdk.c

diff --git a/gdk.c b/gdk.c
index d364a27..98981a8 100644 (file)
--- a/gdk.c
+++ b/gdk.c
@@ -28,6 +28,8 @@ struct ctx
   GArray *points;
   int i;
   gboolean move;
+  GdkGC *gc;
+  PangoAttrList *list;
 };
 
 #define FILENAME "/home/cascardo/fotos/debconf.jpg"
@@ -70,6 +72,14 @@ expose (GtkWidget *widget, GdkEventExpose *event, gpointer data)
   gdk_pixbuf_unref (screen);
   if (point.name)
     {
+      PangoLayout *layout;
+      int pw, ph;
+      layout = gtk_widget_create_pango_layout (ctx->draw, point.name);
+      pango_layout_set_attributes (layout, ctx->list);
+      pango_layout_get_pixel_size (layout, &pw, &ph);
+      gdk_draw_layout (widget->window, ctx->gc, (WIDTH - pw) / 2,
+                       HEIGHT - ph - 20, layout);
+      g_object_unref (layout);
       if (ctx->move)
         g_timeout_add (3000, queue, ctx);
     }
@@ -94,6 +104,9 @@ main (int argc, char **argv)
   int width, height;
   GtkWidget *window;
   struct ctx ctx;
+  GdkColor Yellow;
+  GdkColor Black;
+  PangoAttribute *attr;
   gtk_init (&argc, &argv);
   if (argc < 2)
     filename = FILENAME;
@@ -118,6 +131,20 @@ main (int argc, char **argv)
   gtk_widget_show_all (window);
   g_signal_connect (G_OBJECT (ctx.draw), "expose_event",
                     G_CALLBACK (expose), &ctx);
+  Yellow.red = 0xFFFF;
+  Yellow.green = 0xFFFF;
+  Yellow.blue = 0;
+  Black.red = 0;
+  Black.green = 0;
+  Black.blue = 0;
+  ctx.gc = gdk_gc_new (ctx.draw->window);
+  gdk_gc_set_rgb_fg_color (ctx.gc, &Yellow);
+  gdk_gc_set_rgb_bg_color (ctx.gc, &Black);
+  ctx.list = pango_attr_list_new ();
+  attr = pango_attr_size_new (32 * PANGO_SCALE);
+  pango_attr_list_insert (ctx.list, attr);
+  attr = pango_attr_weight_new (PANGO_WEIGHT_SEMIBOLD);
+  pango_attr_list_insert (ctx.list, attr);
   g_timeout_add (10, queue, &ctx);
   gtk_main ();
   gdk_pixbuf_unref (ctx.picture);