]> www.fi.muni.cz Git - evince.git/blobdiff - shell/main.c
Fix flickering on resizing
[evince.git] / shell / main.c
index 8ad8f284ceee9267109ec71a8199ff5f3f44e801..827c6968ca1baac77ccc96afd6381d4664bf863c 100644 (file)
 
 #include "config.h"
 
+#include "ev-application.h"
+
 #include <glib/gi18n.h>
 #include <gtk/gtkmain.h>
 #include <libgnome/gnome-program.h>
 #include <libgnomeui/gnome-ui-init.h>
+#include <libgnomeui/gnome-app-helper.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+
+#include "ev-stock-icons.h"
+#include "ev-debug.h"
+#include "ev-job-queue.h"
+#include "ev-file-helpers.h"
+
+static char *page_label;
 
 static struct poptOption popt_options[] =
 {
+       { "page-label", 'p', POPT_ARG_STRING, &page_label, 0, N_("The page of the document to display."), N_("PAGE")},
        { NULL, 0, 0, NULL, 0, NULL, NULL }
 };
 
+static void
+load_files (const char **files)
+{
+       GtkWidget *window;
+       int i;
+
+       if (!files) {
+               window = GTK_WIDGET (ev_application_new_window (EV_APP));
+               gtk_widget_show (window);
+               return;
+       }
+
+       for (i = 0; files[i]; i++) {
+               char *uri;
+
+               uri = gnome_vfs_make_uri_from_shell_arg (files[i]);             
+
+               window = GTK_WIDGET (ev_application_new_window (EV_APP));
+               gtk_widget_show (window);
+               ev_window_open (EV_WINDOW (window), uri);
+               
+               if (page_label != NULL)
+                       ev_window_open_page_label (EV_WINDOW (window), page_label);
+
+               g_free (uri);
+        }
+
+       g_free (page_label);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -48,19 +90,29 @@ main (int argc, char *argv[])
                                       LIBGNOMEUI_MODULE, argc, argv,
                                       GNOME_PARAM_POPT_TABLE, popt_options,
                                       GNOME_PARAM_HUMAN_READABLE_NAME, _("Evince"),
-                                     GNOME_PARAM_APP_DATADIR, DATADIR,
+                                     GNOME_PARAM_APP_DATADIR, GNOMEDATADIR,
                                       NULL);
 
-       g_set_application_name (_("Epiphany Web Browser"));
+       ev_job_queue_init ();
+       g_set_application_name (_("Evince Document Viewer"));
+
+       ev_file_helpers_init ();
+       ev_debug_init ();
+       ev_stock_icons_init ();
+       gtk_window_set_default_icon_name ("postscript-viewer");
 
        g_object_get_property (G_OBJECT (program),
                                GNOME_PARAM_POPT_CONTEXT,
                                g_value_init (&context_as_value, G_TYPE_POINTER));
         context = g_value_get_pointer (&context_as_value);
 
+       load_files (poptGetArgs (context));
+
        gtk_main ();
 
+       gnome_accelerators_sync ();
        poptFreeContext (context);
+       ev_file_helpers_shutdown ();
 
        return 0;
 }