diff options
author | Tim Wiederhake <twied@gmx.net> | 2011-01-25 22:21:58 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-01-25 16:33:00 -0500 |
commit | 9aad08e91bf41214bea9ecd25a5a2aaac7ae3de2 (patch) | |
tree | b14fe38320b33a6177d7aa6eba50a8e6a2c9febd | |
parent | 655467a5d264ba43550f9196f8cbcb86730dda63 (diff) |
clients/view: Allow relative paths
-rw-r--r-- | clients/view.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/clients/view.c b/clients/view.c index 1e0cbb0..d083034 100644 --- a/clients/view.c +++ b/clients/view.c @@ -193,6 +193,7 @@ view_create(struct display *display, uint32_t key, const char *filename) struct view *view; gchar *basename; gchar *title; + GFile *file = NULL; GError *error = NULL; view = malloc(sizeof *view); @@ -200,9 +201,22 @@ view_create(struct display *display, uint32_t key, const char *filename) return view; memset(view, 0, sizeof *view); - basename = g_path_get_basename(filename); - title = g_strdup_printf("Wayland View - %s", basename); - g_free(basename); + file = g_file_new_for_commandline_arg(filename); + basename = g_file_get_basename(file); + if(!basename) { + title = "Wayland View"; + } else { + title = g_strdup_printf("Wayland View - %s", basename); + g_free(basename); + } + + view->document = poppler_document_new_from_file(g_file_get_uri(file), + NULL, &error); + + if(error) { + title = "File not found"; + view->document = NULL; + } view->window = window_create(display, 500, 400); window_set_title(view->window, title); @@ -214,8 +228,6 @@ view_create(struct display *display, uint32_t key, const char *filename) window_set_keyboard_focus_handler(view->window, keyboard_focus_handler); window_set_button_handler(view->window, button_handler); - view->document = poppler_document_new_from_file(filename, - NULL, &error); view->page = 0; view_draw(view); |