#include "ev-application.h"
#include "ev-utils.h"
#include "ev-document-types.h"
+#include "ev-file-helpers.h"
#include <glib.h>
#include <glib/gi18n.h>
void
ev_application_shutdown (EvApplication *application)
{
+ if (application->toolbars_model) {
+ g_object_unref (application->toolbars_model);
+ g_free (application->toolbars_file);
+ application->toolbars_model = NULL;
+ application->toolbars_file = NULL;
+ }
+
+ if (application->recent_model) {
+ g_object_unref (application->recent_model);
+ application->recent_model = NULL;
+ }
+
g_object_unref (application);
gtk_main_quit ();
}
static void
ev_application_init (EvApplication *ev_application)
{
+ ev_application->toolbars_model = egg_toolbars_model_new ();
+
+ ev_application->toolbars_file = g_build_filename
+ (ev_dot_dir (), "evince_toolbar.xml", NULL);
+
+ if (!g_file_test (ev_application->toolbars_file, G_FILE_TEST_EXISTS)) {
+ egg_toolbars_model_load (ev_application->toolbars_model,
+ DATADIR"/evince-toolbar.xml");
+ } else {
+ egg_toolbars_model_load (ev_application->toolbars_model,
+ ev_application->toolbars_file);
+ }
+
+ egg_toolbars_model_set_flags (ev_application->toolbars_model, 0,
+ EGG_TB_MODEL_NOT_REMOVABLE);
+
+ ev_application->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
+ egg_recent_model_set_limit (ev_application->recent_model, 5);
+ egg_recent_model_set_filter_groups (ev_application->recent_model,
+ "Evince", NULL);
+}
+
+EggToolbarsModel *ev_application_get_toolbars_model (EvApplication *application)
+{
+ return application->toolbars_model;
+}
+
+EggRecentModel *ev_application_get_recent_model (EvApplication *application)
+{
+ return application->recent_model;
}
+void ev_application_save_toolbars_model (EvApplication *application)
+{
+ egg_toolbars_model_save (application->toolbars_model,
+ application->toolbars_file, "1.0");
+}
+
+
#include "ev-window.h"
+#include "egg-toolbars-model.h"
+#include "egg-recent-model.h"
+
G_BEGIN_DECLS
typedef struct _EvApplication EvApplication;
struct _EvApplication {
GObject base_instance;
+
+ gchar *toolbars_file;
+
+ EggToolbarsModel *toolbars_model;
+ EggRecentModel *recent_model;
};
struct _EvApplicationClass {
GObjectClass base_class;
};
-GType ev_application_get_type (void);
-gboolean ev_application_register_service (EvApplication *application);
-EvApplication *ev_application_get_instance (void);
-gboolean ev_application_open_window (EvApplication *application,
- GError **error);
-gboolean ev_application_open_uri (EvApplication *application,
- const char *uri,
- const char *page_label,
- GError **error);
-void ev_application_open_uri_list (EvApplication *application,
- GSList *uri_list);
-void ev_application_shutdown (EvApplication *application);
+GType ev_application_get_type (void);
+EvApplication *ev_application_get_instance (void);
+gboolean ev_application_register_service (EvApplication *application);
+void ev_application_shutdown (EvApplication *application);
+
+
+gboolean ev_application_open_window (EvApplication *application,
+ GError **error);
+gboolean ev_application_open_uri (EvApplication *application,
+ const char *uri,
+ const char *page_label,
+ GError **error);
+void ev_application_open_uri_list (EvApplication *application,
+ GSList *uri_list);
+
+
+EggToolbarsModel *ev_application_get_toolbars_model (EvApplication *application);
+void ev_application_save_toolbars_model (EvApplication *application);
+EggRecentModel *ev_application_get_recent_model (EvApplication *application);
G_END_DECLS
#include "eggfindbar.h"
#include "egg-recent-view-uimanager.h"
#include "egg-recent-view.h"
-#include "egg-recent-model.h"
#include "egg-toolbar-editor.h"
-#include "egg-toolbars-model.h"
#include "egg-editable-toolbar.h"
+#include "egg-recent-model.h"
+#include "egg-toolbars-model.h"
#include "ephy-zoom.h"
#include "ephy-zoom-action.h"
#include "ev-application.h"
#include "ev-stock-icons.h"
-#include "ev-file-helpers.h"
#include "ev-metadata-manager.h"
#include <poppler.h>
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
- gchar *toolbar_file;
- EggToolbarsModel *toolbar_model;
-
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
GtkWidget *fullscreen_popup;
- GSource *fullscreen_timeout_source;
+ GSource *fullscreen_timeout_source;
/* Document */
char *uri;
EvJob *xfer_job;
EvJob *load_job;
- /* recent file stuff */
- EggRecentModel *recent_model;
EggRecentViewUIManager *recent_view;
};
item = egg_recent_item_new_from_uri (filename);
egg_recent_item_add_group (item, "Evince");
- egg_recent_model_add_full (window->priv->recent_model, item);
+ egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
}
static void
ev_window_setup_recent (EvWindow *ev_window)
{
-
-
- /* it would be better if we just filtered by mime-type, but there
- * doesn't seem to be an easy way to figure out which mime-types we
- * can handle */
- ev_window->priv->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
-
ev_window->priv->recent_view = egg_recent_view_uimanager_new (ev_window->priv->ui_manager,
"/MainMenu/FileMenu/RecentFilesMenu",
G_CALLBACK (ev_window_cmd_recent_file_activate),
ev_window);
egg_recent_view_uimanager_show_icons (EGG_RECENT_VIEW_UIMANAGER (ev_window->priv->recent_view), FALSE);
- egg_recent_model_set_limit (ev_window->priv->recent_model, 5);
egg_recent_view_set_model (EGG_RECENT_VIEW (ev_window->priv->recent_view),
- ev_window->priv->recent_model);
-
- egg_recent_model_set_filter_groups (ev_window->priv->recent_model,
- "Evince", NULL);
+ ev_application_get_recent_model (EV_APP));
egg_recent_view_uimanager_set_trailing_sep (ev_window->priv->recent_view, TRUE);
EvWindow *ev_window = EV_WINDOW (data);
egg_editable_toolbar_set_edit_mode
(EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar), FALSE);
- egg_toolbars_model_save (ev_window->priv->toolbar_model,
- ev_window->priv->toolbar_file, "1.0");
+ ev_application_save_toolbars_model (EV_APP);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 400);
editor = egg_toolbar_editor_new (ev_window->priv->ui_manager,
- ev_window->priv->toolbar_model);
+ ev_application_get_toolbars_model (EV_APP));
gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
EvWindow *window = EV_WINDOW (object);
EvWindowPrivate *priv = window->priv;
- if (priv->toolbar_model) {
- g_object_unref (priv->toolbar_model);
- g_free (priv->toolbar_file);
- priv->toolbar_model = NULL;
- priv->toolbar_file = NULL;
- }
-
- if (priv->recent_model) {
- g_object_unref (priv->recent_model);
- priv->recent_model = NULL;
- }
-
if (priv->recent_view) {
g_object_unref (priv->recent_view);
priv->recent_view = NULL;
ev_window->priv->menubar,
FALSE, FALSE, 0);
- /* Toolbar editor */
- ev_window->priv->toolbar_model = egg_toolbars_model_new ();
-
- ev_window->priv->toolbar_file = g_build_filename
- (ev_dot_dir (), "evince_toolbar.xml", NULL);
-
- if (!g_file_test (ev_window->priv->toolbar_file, G_FILE_TEST_EXISTS)) {
- egg_toolbars_model_load (ev_window->priv->toolbar_model,
- DATADIR"/evince-toolbar.xml");
- } else {
- egg_toolbars_model_load (ev_window->priv->toolbar_model,
- ev_window->priv->toolbar_file);
- }
-
- egg_toolbars_model_set_flags (ev_window->priv->toolbar_model, 0,
- EGG_TB_MODEL_NOT_REMOVABLE);
-
/* This sucks, but there is no way to have a draw=no, expand=true separator
* in a GtkUIManager-built toolbar. So, just add another toolbar.
* See gtk+ bug 166489.
gtk_widget_show (toolbar_dock);
ev_window->priv->toolbar = egg_editable_toolbar_new_with_model
- (ev_window->priv->ui_manager, ev_window->priv->toolbar_model);
+ (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
"DefaultToolBar");
gtk_box_pack_start (GTK_BOX (toolbar_dock), ev_window->priv->toolbar,
TRUE, TRUE, 0);
gtk_widget_show (ev_window->priv->toolbar);
- ev_window->priv->fullscreen_toolbar =
- gtk_ui_manager_get_widget (ev_window->priv->ui_manager, "/LeaveFullscreenToolbar");
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (ev_window->priv->fullscreen_toolbar), TRUE);
-
+ ev_window->priv->fullscreen_toolbar = egg_editable_toolbar_new_with_model
+ (ev_window->priv->ui_manager, ev_application_get_toolbars_model (EV_APP));
+ egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (ev_window->priv->toolbar),
+ "DefaultToolBar");
/* Add the main area */
ev_window->priv->hpaned = gtk_hpaned_new ();