From: Tilman Sauerbeck Date: Tue, 18 Mar 2008 19:35:56 +0000 (+0100) Subject: A document filename is accepted on the command line now. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=5cdaeba17a21fc829f3483c1640374b34d40b21b;p=raktpdf.git A document filename is accepted on the command line now. --- diff --git a/src/main.c b/src/main.c index a849e97..be7bc27 100644 --- a/src/main.c +++ b/src/main.c @@ -21,6 +21,8 @@ # include #endif +#include +#include #include #include "rakt-window.h" @@ -29,6 +31,7 @@ int main (int argc, char **argv) { GtkWidget *window; + gchar rp[PATH_MAX], filename[PATH_MAX]; gtk_init (&argc, &argv); @@ -37,6 +40,13 @@ main (int argc, char **argv) window = rakt_window_new (); gtk_widget_show (window); + if (argc > 1) { + g_snprintf (filename, sizeof (filename), + "file://%s", realpath (argv[1], rp)); + + rakt_window_open_document (RAKT_WINDOW (window), filename); + } + gtk_main (); gtk_widget_destroy (window); diff --git a/src/rakt-window.c b/src/rakt-window.c index f83cb6e..d5ce251 100644 --- a/src/rakt-window.c +++ b/src/rakt-window.c @@ -189,8 +189,8 @@ render_page (RaktWindow *window) gtk_widget_queue_draw_area (priv->drawing_area, 0, 0, width, height); } -static void -open_document (RaktWindow *window, gchar *uri) +void +rakt_window_open_document (RaktWindow *window, const gchar *uri) { RaktWindowPriv *priv; GError *error = NULL; @@ -385,7 +385,7 @@ on_action_open (GtkAction *action, RaktWindow *window) gchar *uri; uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); - open_document (window, uri); + rakt_window_open_document (window, uri); g_free (uri); } diff --git a/src/rakt-window.h b/src/rakt-window.h index 4c7676f..0d4137b 100644 --- a/src/rakt-window.h +++ b/src/rakt-window.h @@ -49,6 +49,8 @@ typedef struct { GType rakt_window_get_type (void); GtkWidget *rakt_window_new (void); +void rakt_window_open_document (RaktWindow *window, const gchar *uri); + G_END_DECLS #endif