]> www.fi.muni.cz Git - evince.git/blob - shell/main.c
use gnome_vfs_make_uri_from_shell_arg so that relative paths work from the
[evince.git] / shell / main.c
1 /*
2  *  Copyright (C) 2004 Marco Pesenti Gritti
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2, or (at your option)
7  *  any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  *  $Id$
19  */
20
21 #include "config.h"
22
23 #include "ev-application.h"
24
25 #include <glib/gi18n.h>
26 #include <gtk/gtkmain.h>
27 #include <libgnome/gnome-program.h>
28 #include <libgnomeui/gnome-ui-init.h>
29 #include <libgnomevfs/gnome-vfs-utils.h>
30
31 #include "ev-stock-icons.h"
32
33 static struct poptOption popt_options[] =
34 {
35         { NULL, 0, 0, NULL, 0, NULL, NULL }
36 };
37
38 static void
39 load_files (const char **files)
40 {
41         GtkWidget *window;
42         int i;
43
44         if (!files) {
45                 window = GTK_WIDGET (ev_application_new_window (EV_APP));
46                 gtk_widget_show (window);
47                 return;
48         }
49
50         for (i = 0; files[i]; i++) {
51                 char *uri;
52
53                 uri = gnome_vfs_make_uri_from_shell_arg (files[i]);             
54
55                 window = GTK_WIDGET (ev_application_new_window (EV_APP));
56                 gtk_widget_show (window);
57                 ev_window_open (EV_WINDOW (window), uri);
58
59                 g_free (uri);
60         }
61 }
62
63 int
64 main (int argc, char *argv[])
65 {
66         poptContext context;
67         GValue context_as_value = { 0 };
68         GnomeProgram *program;
69
70 #ifdef ENABLE_NLS
71         /* Initialize the i18n stuff */
72         bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
73         bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
74         textdomain(GETTEXT_PACKAGE);
75 #endif
76
77         program = gnome_program_init (PACKAGE, VERSION,
78                                       LIBGNOMEUI_MODULE, argc, argv,
79                                       GNOME_PARAM_POPT_TABLE, popt_options,
80                                       GNOME_PARAM_HUMAN_READABLE_NAME, _("Evince"),
81                                       GNOME_PARAM_APP_DATADIR, DATADIR,
82                                       NULL);
83
84         g_set_application_name (_("Evince Document Viewer"));
85
86         ev_stock_icons_init ();
87
88         g_object_get_property (G_OBJECT (program),
89                                GNOME_PARAM_POPT_CONTEXT,
90                                g_value_init (&context_as_value, G_TYPE_POINTER));
91         context = g_value_get_pointer (&context_as_value);
92
93         load_files (poptGetArgs (context));
94
95         gtk_main ();
96
97         poptFreeContext (context);
98
99         return 0;
100 }