Files needed are now required as parameters.
[cascardo/movie.git] / gdk.c
diff --git a/gdk.c b/gdk.c
index 98981a8..6fadfda 100644 (file)
--- a/gdk.c
+++ b/gdk.c
@@ -29,10 +29,10 @@ struct ctx
   int i;
   gboolean move;
   GdkGC *gc;
+  GdkGC *gc2;
   PangoAttrList *list;
 };
 
-#define FILENAME "/home/cascardo/fotos/debconf.jpg"
 #define WIDTH 800
 #define HEIGHT 600
 
@@ -77,6 +77,8 @@ expose (GtkWidget *widget, GdkEventExpose *event, gpointer data)
       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_rectangle (widget->window, ctx->gc2, TRUE,
+                          (WIDTH - pw - 8) / 2, HEIGHT - ph - 20, pw + 8, ph);
       gdk_draw_layout (widget->window, ctx->gc, (WIDTH - pw) / 2,
                        HEIGHT - ph - 20, layout);
       g_object_unref (layout);
@@ -94,10 +96,18 @@ expose (GtkWidget *widget, GdkEventExpose *event, gpointer data)
 
 #define FPF 40
 
+void
+usage ()
+{
+  fprintf (stderr, "movie picture dotsfile\n");
+  exit (0);
+}
+
 int
 main (int argc, char **argv)
 {
   char *filename;
+  char *dotsfile;
   GdkColorspace colorspace;
   gboolean has_alpha;
   int bits_per_sample;
@@ -108,11 +118,16 @@ main (int argc, char **argv)
   GdkColor Black;
   PangoAttribute *attr;
   gtk_init (&argc, &argv);
-  if (argc < 2)
-    filename = FILENAME;
+  if (argc < 3)
+    {
+      usage ();
+    }
   else
-    filename = argv[1];
-  ctx.points = ReadPoints ("pro-gnu");
+    {
+      filename = argv[1];
+      dotsfile = argv[2];
+    }
+  ctx.points = ReadPoints (dotsfile);
   ctx.points = drop_dup_frames (ctx.points, FPF);
   rescale_points (ctx.points, get_scales (FPF));
   ctx.picture = gdk_pixbuf_new_from_file (filename, NULL);
@@ -139,7 +154,8 @@ main (int argc, char **argv)
   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.gc2 = gdk_gc_new (ctx.draw->window);
+  gdk_gc_set_rgb_fg_color (ctx.gc2, &Black);
   ctx.list = pango_attr_list_new ();
   attr = pango_attr_size_new (32 * PANGO_SCALE);
   pango_attr_list_insert (ctx.list, attr);