From: Tilman Sauerbeck Date: Sun, 22 Apr 2007 15:20:53 +0000 (+0200) Subject: Get the URI from the file dialog rather than the filename. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=ec9ee381ad4163b5257f7a86a0ea92dc667f3209;p=raktpdf.git Get the URI from the file dialog rather than the filename. That way we don't need to put the URI together ourselves. --- diff --git a/src/rakt-window.c b/src/rakt-window.c index dbd3c78..c1e1961 100644 --- a/src/rakt-window.c +++ b/src/rakt-window.c @@ -159,20 +159,14 @@ render_page (RaktWindow *window) } static void -open_document (RaktWindow *window, gchar *file) +open_document (RaktWindow *window, gchar *uri) { RaktWindowPriv *priv; GError *error = NULL; - gchar real[PATH_MAX], buf[16 + PATH_MAX]; priv = GET_PRIV (window); - realpath (file, real); - - g_strlcpy (buf, "file://", sizeof (buf)); - g_strlcat (buf, real, sizeof (buf)); - - priv->document = poppler_document_new_from_file (buf, NULL, &error); + priv->document = poppler_document_new_from_file (uri, NULL, &error); priv->page_no = 0; render_page (window); @@ -308,11 +302,11 @@ on_action_open (GtkAction *action, RaktWindow *window) n = gtk_dialog_run (GTK_DIALOG (dialog)); if (n == GTK_RESPONSE_ACCEPT) { - gchar *file; + gchar *uri; - file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - open_document (window, file); - g_free (file); + uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); + open_document (window, uri); + g_free (uri); } gtk_widget_destroy (dialog);