Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/Makefile.am24
-rw-r--r--shell/ev-application.c196
-rw-r--r--shell/ev-application.h63
-rw-r--r--shell/ev-window.c509
-rw-r--r--shell/ev-window.h62
-rw-r--r--shell/global-params.cc36
-rw-r--r--shell/global-params.h36
-rw-r--r--shell/main.c66
8 files changed, 992 insertions, 0 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am
new file mode 100644
index 0000000..571792c
--- /dev/null
+++ b/shell/Makefile.am
@@ -0,0 +1,24 @@
+NULL=
+
+INCLUDES= \
+ -DDATADIR=\"$(pkgdatadir)\" \
+ -I$(top_srcdir)/lib \
+ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \
+ $(SHELL_CFLAGS) \
+ $(EVINCE_DISABLE_DEPRECATED) \
+ $(NULL)
+
+bin_PROGRAMS=evince
+
+evince_SOURCES= \
+ ev-application.c \
+ ev-application.h \
+ ev-window.c \
+ ev-window.h \
+ main.c \
+ $(NULL)
+
+evince_LDADD= \
+ $(SHELL_LIBS) \
+ $(top_builddir)/lib/libevprivate.a \
+ $(NULL)
diff --git a/shell/ev-application.c b/shell/ev-application.c
new file mode 100644
index 0000000..2a89eaa
--- /dev/null
+++ b/shell/ev-application.c
@@ -0,0 +1,196 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "ev-application.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtkfilechooserdialog.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtkwidget.h>
+#include <bonobo/bonobo-main.h>
+
+#include <ev-macros.h>
+#include <ev-window.h>
+
+struct _EvApplicationPrivate {
+ GList *windows;
+};
+
+G_DEFINE_TYPE (EvApplication, ev_application, G_TYPE_OBJECT);
+
+#define EV_APPLICATION_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_APPLICATION, EvApplicationPrivate))
+
+EvApplication *
+ev_application_get_instance (void)
+{
+ static EvApplication *instance;
+
+ if (!instance)
+ instance = EV_APPLICATION (
+ g_object_new (EV_TYPE_APPLICATION, NULL));
+
+ return instance;
+}
+
+static void
+window_destroy_cb (GtkObject *object, gpointer user_data)
+{
+ EvApplication *application;
+
+ g_return_if_fail (EV_IS_WINDOW (object));
+ g_return_if_fail (EV_IS_APPLICATION (user_data));
+
+ application = EV_APPLICATION (user_data);
+ application->priv->windows =
+ g_list_remove (application->priv->windows, object);
+
+ if (application->priv->windows == NULL)
+ bonobo_main_quit ();
+}
+
+EvWindow *
+ev_application_new_window (EvApplication *application)
+{
+ EvWindow *ev_window;
+
+ ev_window = EV_WINDOW (g_object_new (EV_TYPE_WINDOW,
+ "type", GTK_WINDOW_TOPLEVEL,
+ "default-height", 600,
+ "default-width", 600,
+ NULL));
+ application->priv->windows =
+ g_list_prepend (application->priv->windows, ev_window);
+ g_signal_connect (G_OBJECT (ev_window), "destroy",
+ G_CALLBACK (window_destroy_cb), application);
+
+ return ev_window;
+}
+
+static int
+is_window_empty (const EvWindow *ev_window, gconstpointer dummy)
+{
+ g_return_val_if_fail (EV_IS_WINDOW (ev_window), 0);
+
+ return ev_window_is_empty (ev_window)
+ ? 0
+ : -1;
+}
+
+static EvWindow *
+ev_application_get_empty_window (EvApplication *application)
+{
+ GList *node;
+
+ node = g_list_find_custom (application->priv->windows, NULL,
+ (GCompareFunc)is_window_empty);
+
+ return node && node->data
+ ? EV_WINDOW (node->data)
+ : ev_application_new_window (application);
+}
+
+void
+ev_application_open (EvApplication *application, GError *err)
+{
+ EvWindow *ev_window;
+ GtkWidget *chooser;
+ GtkFileFilter *both_filter, *pdf_filter, *ps_filter, *all_filter;
+
+
+ ev_window = ev_application_get_empty_window (application);
+
+ chooser = gtk_file_chooser_dialog_new (_("Open document"),
+ GTK_WINDOW (ev_window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL);
+
+ both_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (both_filter,
+ _("PostScript and PDF Documents"));
+ gtk_file_filter_add_mime_type (both_filter, "application/postscript");
+ gtk_file_filter_add_mime_type (both_filter, "application/pdf");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), both_filter);
+
+ ps_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (ps_filter, _("PostScript Documents"));
+ gtk_file_filter_add_mime_type (ps_filter, "application/postscript");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), ps_filter);
+
+ pdf_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (pdf_filter, _("PDF Documents"));
+ gtk_file_filter_add_mime_type (pdf_filter, "application/pdf");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), pdf_filter);
+
+ all_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (all_filter, _("All Files"));
+ gtk_file_filter_add_pattern (all_filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), all_filter);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), both_filter);
+
+ if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_OK) {
+ char *uri;
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
+ ev_window_open (ev_window, uri);
+ gtk_widget_show (GTK_WIDGET (ev_window));
+ g_free (uri);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (chooser));
+}
+
+static void
+ev_application_finalize (GObject *object)
+{
+ g_return_if_fail (object != NULL && EV_IS_APPLICATION (object));
+
+ EV_APPLICATION (object)->priv = NULL;
+
+ EV_CALL_VIRTUAL (
+ G_OBJECT_CLASS (ev_application_parent_class), finalize, (object));
+}
+
+static void
+ev_application_class_init (EvApplicationClass *ev_application_class)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_application_class);
+ g_object_class->finalize = ev_application_finalize;
+
+ g_type_class_add_private (g_object_class,
+ sizeof (EvApplicationPrivate));
+}
+
+static void
+ev_application_init (EvApplication *ev_application)
+{
+ ev_application->priv = EV_APPLICATION_GET_PRIVATE (ev_application);
+}
+
diff --git a/shell/ev-application.h b/shell/ev-application.h
new file mode 100644
index 0000000..b9f64c1
--- /dev/null
+++ b/shell/ev-application.h
@@ -0,0 +1,63 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef EV_APPLICATION_H
+#define EV_APPLICATION_H
+
+#include <glib/gerror.h>
+#include <glib-object.h>
+
+#include "ev-window.h"
+
+G_BEGIN_DECLS
+
+typedef struct _EvApplication EvApplication;
+typedef struct _EvApplicationClass EvApplicationClass;
+typedef struct _EvApplicationPrivate EvApplicationPrivate;
+
+#define EV_TYPE_APPLICATION (ev_application_get_type ())
+#define EV_APPLICATION(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_APPLICATION, EvApplication))
+#define EV_APPLICATION_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_APPLICATION, EvApplicationClass))
+#define EV_IS_APPLICATION(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_APPLICATION))
+#define EV_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_APPLICATION))
+#define EV_APPLICATION_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_APPLICATION, EvApplicationClass))
+
+#define EV_APP (ev_application_get_instance ())
+
+struct _EvApplication {
+ GObject base_instance;
+ EvApplicationPrivate *priv;
+};
+
+struct _EvApplicationClass {
+ GObjectClass base_class;
+};
+
+GType ev_application_get_type (void);
+EvApplication *ev_application_get_instance (void);
+void ev_application_open (EvApplication *application, GError *err);
+EvWindow *ev_application_new_window (EvApplication *application);
+
+G_END_DECLS
+
+#endif /* !EV_APPLICATION_H */
+
diff --git a/shell/ev-window.c b/shell/ev-window.c
new file mode 100644
index 0000000..cde0518
--- /dev/null
+++ b/shell/ev-window.c
@@ -0,0 +1,509 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ev-window.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gtk/gtkaboutdialog.h>
+#include <gtk/gtkaccelgroup.h>
+#include <gtk/gtkactiongroup.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkstatusbar.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtktoggleaction.h>
+#include <gtk/gtkuimanager.h>
+#include <gtk/gtkvbox.h>
+#include <libbonoboui.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
+
+#include <string.h>
+
+#include <ev-macros.h>
+#include <ev-stock-icons.h>
+
+#include "ev-application.h"
+
+enum {
+ PROP_0,
+ PROP_ATTRIBUTE
+};
+
+enum {
+ SIGNAL,
+ N_SIGNALS
+};
+
+struct _EvWindowPrivate {
+ GtkWidget *main_box;
+ GtkWidget *bonobo_widget;
+ GtkUIManager *ui_manager;
+ GtkWidget *statusbar;
+ guint help_message_cid;
+};
+
+#if 0
+/* enable these to add support for signals */
+static guint ev_window_signals [N_SIGNALS] = { 0 };
+#endif
+
+G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
+
+#define EV_WINDOW_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
+
+#if 0
+const char *
+ev_window_get_attribute (EvWindow *self)
+{
+ g_return_val_if_fail (self != NULL && EV_IS_WINDOW (self), NULL);
+
+ return self->priv->attribute;
+}
+
+void
+ev_window_set_attribute (EvWindow* self, const char *attribute)
+{
+ g_assert (self != NULL && EV_IS_WINDOW (self));
+ g_assert (attribute != NULL);
+
+ if (self->priv->attribute != NULL) {
+ g_free (self->priv->attribute);
+ }
+
+ self->priv->attribute = g_strdup (attribute);
+
+ g_object_notify (G_OBJECT (self), "attribute");
+}
+
+static void
+ev_window_get_property (GObject *object, guint prop_id, GValue *value,
+ GParamSpec *param_spec)
+{
+ EvWindow *self;
+
+ self = EV_WINDOW (object);
+
+ switch (prop_id) {
+ case PROP_ATTRIBUTE:
+ g_value_set_string (value, self->priv->attribute);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+
+static void
+ev_window_set_property (GObject *object, guint prop_id, const GValue *value,
+ GParamSpec *param_spec)
+{
+ EvWindow *self;
+
+ self = EV_WINDOW (object);
+
+ switch (prop_id) {
+ case PROP_ATTRIBUTE:
+ ev_window_set_attribute (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+ prop_id,
+ param_spec);
+ break;
+ }
+}
+#endif
+
+gboolean
+ev_window_is_empty (const EvWindow *ev_window)
+{
+ g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
+
+ return ev_window->priv->bonobo_widget == NULL;
+}
+
+void
+ev_window_open (EvWindow *ev_window, const char *uri)
+{
+#if 0
+ char *mime_type;
+ BonoboObject *bonobo_control;
+ CORBA_Environment ev;
+ Bonobo_PersistFile pf;
+
+ mime_type = gnome_vfs_get_mime_type (uri);
+
+ g_return_if_fail (mime_type != NULL); /* FIXME set error */
+
+ if (!strcmp (mime_type, "application/pdf")) {
+ bonobo_control = create_gpdf_control ();
+ } else if (!strcmp (mime_type, "application/postscript")) {
+ bonobo_control = create_ggv_control ();
+ } else if (!strcmp (mime_type, "application/x-gzip")) {
+ g_message ("Cannot open gzip-compressed file %s.", uri);
+ goto finally;
+ } else if (!strcmp (mime_type, "application/x-bzip")) {
+ g_message ("Cannot open bzip2-compressed file %s.", uri);
+ goto finally;
+ } else {
+ g_warning ("Don't know how to open %s file %s.",
+ mime_type, uri); /* FIXME set error */
+ goto finally;
+ }
+
+ ev_window->priv->bonobo_widget = bonobo_widget_new_control_from_objref (
+ bonobo_object_corba_objref (bonobo_control), CORBA_OBJECT_NIL);
+ gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
+ ev_window->priv->bonobo_widget,
+ TRUE, TRUE, 0);
+ CORBA_exception_init (&ev);
+ pf = bonobo_object_query_interface (
+ bonobo_control, "IDL:Bonobo/PersistFile:1.0", &ev);
+ Bonobo_PersistFile_load (pf, uri, &ev);
+ gtk_widget_show (ev_window->priv->bonobo_widget);
+ bonobo_object_release_unref (pf, &ev);
+ bonobo_object_unref (bonobo_control);
+ CORBA_exception_free (&ev);
+
+finally:
+ g_free (mime_type);
+#endif
+}
+
+static void
+ev_window_cmd_file_open (GtkAction *action, EvWindow *ev_window)
+{
+ ev_application_open (EV_APP, NULL);
+}
+
+static void
+ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
+{
+ g_return_if_fail (EV_IS_WINDOW (ev_window));
+
+ gtk_widget_destroy (GTK_WIDGET (ev_window));
+}
+
+static void
+ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)
+{
+ const char *authors[] = {
+ N_("Many..."),
+ NULL
+ };
+
+ const char *documenters[] = {
+ N_("Not so many..."),
+ NULL
+ };
+
+ const char *license[] = {
+ N_("Evince is free software; you can redistribute it and/or modify\n"
+ "it under the terms of the GNU General Public License as published by\n"
+ "the Free Software Foundation; either version 2 of the License, or\n"
+ "(at your option) any later version.\n"),
+ N_("Evince is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU General Public License for more details.\n"),
+ N_("You should have received a copy of the GNU General Public License\n"
+ "along with Evince; if not, write to the Free Software Foundation, Inc.,\n"
+ "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n")
+ };
+
+ char *license_trans;
+
+#ifdef ENABLE_NLS
+ const char **p;
+
+ for (p = authors; *p; ++p)
+ *p = _(*p);
+
+ for (p = documenters; *p; ++p)
+ *p = _(*p);
+#endif
+
+ license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
+ _(license[2]), "\n", NULL);
+
+ gtk_show_about_dialog (
+ GTK_WINDOW (ev_window),
+ "name", _("Evince"),
+ "version", VERSION,
+ "copyright",
+ _("\xc2\xa9 1996-2004 The Evince authors"),
+ "license", license_trans,
+ "website", "http://www.gnome.org/projects/evince",
+ "comments", _("PostScript and PDF File Viewer."),
+ "authors", authors,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ NULL);
+
+ g_free (license_trans);
+}
+
+static void
+ev_window_view_toolbar_cb (GtkAction *action, EvWindow *ev_window)
+{
+ g_object_set (
+ G_OBJECT (gtk_ui_manager_get_widget (
+ ev_window->priv->ui_manager,
+ "/ToolBar")),
+ "visible",
+ gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
+ NULL);
+}
+
+static void
+ev_window_view_statusbar_cb (GtkAction *action, EvWindow *ev_window)
+{
+ g_object_set (
+ ev_window->priv->statusbar,
+ "visible",
+ gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)),
+ NULL);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy, EvWindow *ev_window)
+{
+ GtkAction *action;
+ char *message;
+
+ action = g_object_get_data (G_OBJECT (proxy), "gtk-action");
+ g_return_if_fail (action != NULL);
+
+ g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+ if (message) {
+ gtk_statusbar_push (GTK_STATUSBAR (ev_window->priv->statusbar),
+ ev_window->priv->help_message_cid, message);
+ g_free (message);
+ }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy, EvWindow *ev_window)
+{
+ gtk_statusbar_pop (GTK_STATUSBAR (ev_window->priv->statusbar),
+ ev_window->priv->help_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
+ GtkWidget *proxy, EvWindow *ev_window)
+{
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ g_signal_connect (proxy, "select",
+ G_CALLBACK (menu_item_select_cb), ev_window);
+ g_signal_connect (proxy, "deselect",
+ G_CALLBACK (menu_item_deselect_cb),
+ ev_window);
+ }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *ui_manager, GtkAction *action,
+ GtkWidget *proxy, EvWindow *ev_window)
+{
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_select_cb), ev_window);
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_deselect_cb), ev_window);
+ }
+}
+
+static void
+ev_window_dispose (GObject *object)
+{
+ EvWindowPrivate *priv;
+
+ g_return_if_fail (object != NULL && EV_IS_WINDOW (object));
+
+ priv = EV_WINDOW (object)->priv;
+
+ EV_UNREF (priv->ui_manager);
+
+ EV_CALL_VIRTUAL (
+ G_OBJECT_CLASS (ev_window_parent_class), dispose, (object));
+}
+
+static void
+ev_window_finalize (GObject *object)
+{
+ g_return_if_fail (object != NULL && EV_IS_WINDOW (object));
+
+ EV_WINDOW (object)->priv = NULL;
+
+ EV_CALL_VIRTUAL (
+ G_OBJECT_CLASS (ev_window_parent_class), finalize, (object));
+}
+
+static void
+ev_window_class_init (EvWindowClass *ev_window_class)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_window_class);
+ g_object_class->dispose = ev_window_dispose;
+ g_object_class->finalize = ev_window_finalize;
+
+ g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
+
+#if 0
+ /* setting up signal system */
+ ev_window_class->signal = ev_window_signal;
+
+ ev_window_signals [SIGNAL] = g_signal_new (
+ "signal",
+ EV_TYPE_WINDOW,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EvWindowClass,
+ signal),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 0);
+ /* setting up property system */
+ g_object_class->set_property = ev_window_set_property;
+ g_object_class->get_property = ev_window_get_property;
+
+ g_object_class_install_property (
+ g_object_class,
+ PROP_ATTRIBUTE,
+ g_param_spec_string ("attribute",
+ "Attribute",
+ "A simple unneccessary attribute that "
+ "does nothing special except being a "
+ "demonstration for the correct implem"
+ "entation of a GObject property",
+ "default_value",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+#endif
+}
+
+/* Normal items */
+static GtkActionEntry entries[] = {
+ { "File", NULL, N_("_File") },
+ { "View", NULL, N_("_View") },
+ { "Help", NULL, N_("_Help") },
+
+ /* File menu */
+ { "FileOpen", GTK_STOCK_OPEN, N_("_Open"), "<control>O",
+ N_("Open a file"),
+ G_CALLBACK (ev_window_cmd_file_open) },
+ { "FileCloseWindow", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
+ N_("Close this window"),
+ G_CALLBACK (ev_window_cmd_file_close_window) },
+
+ /* Help menu */
+ { "HelpAbout", STOCK_ABOUT, N_("_About"), NULL,
+ N_("Display credits for the document viewer creators"),
+ G_CALLBACK (ev_window_cmd_help_about) },
+};
+
+/* Toggle items */
+static GtkToggleActionEntry toggle_entries[] = {
+ /* View Menu */
+ { "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
+ N_("Show or hide toolbar"),
+ G_CALLBACK (ev_window_view_toolbar_cb), TRUE },
+ { "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
+ N_("Show or hide statusbar"),
+ G_CALLBACK (ev_window_view_statusbar_cb), TRUE },
+};
+
+static void
+ev_window_init (EvWindow *ev_window)
+{
+ GtkActionGroup *action_group;
+ GtkAccelGroup *accel_group;
+ GError *error = NULL;
+ GtkWidget *menubar;
+ GtkWidget *toolbar;
+
+ ev_window->priv = EV_WINDOW_GET_PRIVATE (ev_window);
+
+ gtk_window_set_title (GTK_WINDOW (ev_window), _("Evince"));
+
+ ev_window->priv->main_box = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (ev_window), ev_window->priv->main_box);
+ gtk_widget_show (ev_window->priv->main_box);
+
+ action_group = gtk_action_group_new ("MenuActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group, entries,
+ G_N_ELEMENTS (entries), ev_window);
+ gtk_action_group_add_toggle_actions (action_group, toggle_entries,
+ G_N_ELEMENTS (toggle_entries),
+ ev_window);
+
+ ev_window->priv->ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+ action_group, 0);
+
+ accel_group =
+ gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
+
+ g_signal_connect (ev_window->priv->ui_manager, "connect_proxy",
+ G_CALLBACK (connect_proxy_cb), ev_window);
+ g_signal_connect (ev_window->priv->ui_manager, "disconnect_proxy",
+ G_CALLBACK (disconnect_proxy_cb), ev_window);
+
+ if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
+ DATADIR"/evince-ui.xml",
+ &error)) {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+
+ menubar = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/MainMenu");
+ gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), menubar,
+ FALSE, FALSE, 0);
+
+ toolbar = gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
+ "/ToolBar");
+ gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), toolbar,
+ FALSE, FALSE, 0);
+
+ ev_window->priv->statusbar = gtk_statusbar_new ();
+ gtk_widget_show (ev_window->priv->statusbar);
+ gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
+ ev_window->priv->statusbar,
+ FALSE, TRUE, 0);
+ ev_window->priv->help_message_cid = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (ev_window->priv->statusbar), "help_message");
+
+}
diff --git a/shell/ev-window.h b/shell/ev-window.h
new file mode 100644
index 0000000..0d2e242
--- /dev/null
+++ b/shell/ev-window.h
@@ -0,0 +1,62 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef EV_WINDOW_H
+#define EV_WINDOW_H
+
+#include <glib-object.h>
+#include <gtk/gtkwindow.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvWindow EvWindow;
+typedef struct _EvWindowClass EvWindowClass;
+typedef struct _EvWindowPrivate EvWindowPrivate;
+
+#define EV_TYPE_WINDOW (ev_window_get_type())
+#define EV_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_WINDOW, EvWindow))
+#define EV_WINDOW_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_WINDOW, EvWindowClass))
+#define EV_IS_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_WINDOW))
+#define EV_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_WINDOW))
+#define EV_WINDOW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_WINDOW, EvWindowClass))
+
+struct _EvWindow {
+ GtkWindow base_instance;
+ EvWindowPrivate *priv;
+};
+
+struct _EvWindowClass {
+ GtkWindowClass base_class;
+
+ /* signals */
+ void (*signal) (EvWindow *self,
+ const char *string);
+};
+
+GType ev_window_get_type (void);
+void ev_window_open (EvWindow *ev_window, const char *uri);
+gboolean ev_window_is_empty (const EvWindow *ev_window);
+
+G_END_DECLS
+
+#endif /* !EV_WINDOW_H */
+
diff --git a/shell/global-params.cc b/shell/global-params.cc
new file mode 100644
index 0000000..a8ab177
--- /dev/null
+++ b/shell/global-params.cc
@@ -0,0 +1,36 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "global-params.h"
+#include <GlobalParams.h>
+
+void
+global_params_init (const char *cfg_filename)
+{
+ globalParams = new GlobalParams (const_cast<char *> (cfg_filename));
+}
+
+void
+global_params_destroy (void)
+{
+ delete globalParams;
+}
diff --git a/shell/global-params.h b/shell/global-params.h
new file mode 100644
index 0000000..0b243de
--- /dev/null
+++ b/shell/global-params.h
@@ -0,0 +1,36 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GLOBAL_PARAMS_H
+#define GLOBAL_PARAMS_H
+
+#include <glib/gmacros.h>
+
+G_BEGIN_DECLS
+
+void global_params_init (const char *cfg_filename);
+void global_params_destroy (void);
+
+G_END_DECLS
+
+
+#endif /* GLOBAL_PARAMS_H */
diff --git a/shell/main.c b/shell/main.c
new file mode 100644
index 0000000..8ad8f28
--- /dev/null
+++ b/shell/main.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004 Marco Pesenti Gritti
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtkmain.h>
+#include <libgnome/gnome-program.h>
+#include <libgnomeui/gnome-ui-init.h>
+
+static struct poptOption popt_options[] =
+{
+ { NULL, 0, 0, NULL, 0, NULL, NULL }
+};
+
+int
+main (int argc, char *argv[])
+{
+ poptContext context;
+ GValue context_as_value = { 0 };
+ GnomeProgram *program;
+
+#ifdef ENABLE_NLS
+ /* Initialize the i18n stuff */
+ bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+#endif
+
+ program = gnome_program_init (PACKAGE, VERSION,
+ LIBGNOMEUI_MODULE, argc, argv,
+ GNOME_PARAM_POPT_TABLE, popt_options,
+ GNOME_PARAM_HUMAN_READABLE_NAME, _("Evince"),
+ GNOME_PARAM_APP_DATADIR, DATADIR,
+ NULL);
+
+ g_set_application_name (_("Epiphany Web Browser"));
+
+ 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);
+
+ gtk_main ();
+
+ poptFreeContext (context);
+
+ return 0;
+}