]> www.fi.muni.cz Git - evince.git/blob - shell/main.c
PageCache and EvJobs are moved from backend to shell. Two new jobs to
[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 <libgnomeui/gnome-app-helper.h>
30 #include <libgnomevfs/gnome-vfs-utils.h>
31
32 #include "ev-stock-icons.h"
33 #include "ev-debug.h"
34 #include "ev-job-queue.h"
35 #include "ev-file-helpers.h"
36
37 static char *page_label;
38
39 static struct poptOption popt_options[] =
40 {
41         { "page-label", 'p', POPT_ARG_STRING, &page_label, 0, N_("The page of the document to display."), N_("PAGE")},
42         { NULL, 0, 0, NULL, 0, NULL, NULL }
43 };
44
45 static void
46 load_files (const char **files)
47 {
48         GtkWidget *window;
49         int i;
50
51         if (!files) {
52                 window = GTK_WIDGET (ev_application_new_window (EV_APP));
53                 gtk_widget_show (window);
54                 return;
55         }
56
57         for (i = 0; files[i]; i++) {
58                 char *uri;
59
60                 uri = gnome_vfs_make_uri_from_shell_arg (files[i]);             
61
62                 window = GTK_WIDGET (ev_application_new_window (EV_APP));
63                 gtk_widget_show (window);
64                 ev_window_open_uri (EV_WINDOW (window), uri);
65                 
66                 if (page_label != NULL)
67                         ev_window_open_page_label (EV_WINDOW (window), page_label);
68
69                 g_free (uri);
70         }
71
72         g_free (page_label);
73 }
74
75 int
76 main (int argc, char *argv[])
77 {
78         poptContext context;
79         GValue context_as_value = { 0 };
80         GnomeProgram *program;
81
82 #ifdef ENABLE_NLS
83         /* Initialize the i18n stuff */
84         bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
85         bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
86         textdomain(GETTEXT_PACKAGE);
87 #endif
88
89         program = gnome_program_init (PACKAGE, VERSION,
90                                       LIBGNOMEUI_MODULE, argc, argv,
91                                       GNOME_PARAM_POPT_TABLE, popt_options,
92                                       GNOME_PARAM_HUMAN_READABLE_NAME, _("Evince"),
93                                       GNOME_PARAM_APP_DATADIR, GNOMEDATADIR,
94                                       NULL);
95
96         ev_job_queue_init ();
97         g_set_application_name (_("Evince Document Viewer"));
98
99         ev_file_helpers_init ();
100         ev_debug_init ();
101         ev_stock_icons_init ();
102         gtk_window_set_default_icon_name ("postscript-viewer");
103
104         g_object_get_property (G_OBJECT (program),
105                                GNOME_PARAM_POPT_CONTEXT,
106                                g_value_init (&context_as_value, G_TYPE_POINTER));
107         context = g_value_get_pointer (&context_as_value);
108
109         load_files (poptGetArgs (context));
110
111         gtk_main ();
112
113         gnome_accelerators_sync ();
114         poptFreeContext (context);
115         ev_file_helpers_shutdown ();
116
117         return 0;
118 }