Code

tpdfview: Set window title to 'tpdfview: <filename>'.
authorSebastian Harl <sh@tokkee.org>
Fri, 21 Oct 2011 13:07:45 +0000 (15:07 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 21 Oct 2011 13:07:45 +0000 (15:07 +0200)
… applying basename() to the filename specified on the command-line.

src/tpdfview.c

index d46aef030a44a977ebd72a4ed0d5b0f1aa40ca27..b92d5440799e212cf3314c8be6da87d544b0ade4 100644 (file)
@@ -168,8 +168,12 @@ main(int argc, char **argv)
        GtkWidget *win   = NULL;
        GtkWidget *tpdfv = NULL;
 
+       char win_title[1024];
+
        GdkColor bg_color;
 
+       char *filename;
+
        gtk_init(&argc, &argv);
 
        while (42) {
@@ -195,7 +199,9 @@ main(int argc, char **argv)
                exit_usage(argv[0], 1);
        }
 
-       tpdfv = gtk_tpdfv_new(argv[optind]);
+       filename = argv[optind];
+
+       tpdfv = gtk_tpdfv_new(filename);
        if (! tpdfv)
                return 1;
 
@@ -203,6 +209,10 @@ main(int argc, char **argv)
        if (! win)
                return 1;
 
+       snprintf(win_title, sizeof(win_title), "tpdfview: %s",
+                       basename(filename));
+       gtk_window_set_title(GTK_WINDOW(win), win_title);
+
        gtk_container_add(GTK_CONTAINER(win), tpdfv);
 
        g_signal_connect(G_OBJECT(win), "destroy",