]> www.fi.muni.cz Git - evince.git/commitdiff
Use common toolbar and recent models for all windows. Patch by Nickolay V.
authorMarco Pesenti Gritti <mpg@redhat.com>
Fri, 8 Jul 2005 09:07:04 +0000 (09:07 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 8 Jul 2005 09:07:04 +0000 (09:07 +0000)
2005-07-08  Marco Pesenti Gritti  <mpg@redhat.com>

        * data/evince-ui.xml:
        * shell/ev-application.c: (ev_application_shutdown),
        (ev_application_init), (ev_application_get_toolbars_model),
        (ev_application_get_recent_model),
        (ev_application_save_toolbars_model):
        * shell/ev-application.h:
        * shell/ev-window.c: (ev_window_add_recent),
        (ev_window_setup_recent), (ev_window_cmd_edit_toolbar_cb),
        (ev_window_cmd_edit_toolbar), (ev_window_dispose),
        (ev_window_init):

        Use common toolbar and recent models for all windows.
        Patch by Nickolay V. Shmyrev  <nshmyrev@yandex.ru>

ChangeLog
data/evince-ui.xml
shell/ev-application.c
shell/ev-application.h
shell/ev-window.c

index 130437da9b491e721d7895f9d07c3f5f2ef6e4cd..79752920d30d82e4bbc892039500b43ab019582d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-07-08  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * data/evince-ui.xml:
+       * shell/ev-application.c: (ev_application_shutdown),
+       (ev_application_init), (ev_application_get_toolbars_model),
+       (ev_application_get_recent_model),
+       (ev_application_save_toolbars_model):
+       * shell/ev-application.h:
+       * shell/ev-window.c: (ev_window_add_recent),
+       (ev_window_setup_recent), (ev_window_cmd_edit_toolbar_cb),
+       (ev_window_cmd_edit_toolbar), (ev_window_dispose),
+       (ev_window_init):
+
+       Use common toolbar and recent models for all windows.
+       Patch by Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
 Thu Jul  7 23:10:01 2005  Jonathan Blandford  <jrb@redhat.com>
 
        * configure.ac: add FRONTEND_CORE_LIBS to evince_save_LIBS so we
index 1cb27cf426ed203a4879439f2112104f4744c797..90c66997129f6e6d6cb47c2d7450f5d05171078b 100644 (file)
     </menu>
   </menubar>
 
-  <toolbar name="LeaveFullscreenToolbar">
-    <toolitem action="GoPreviousPage"/>
-    <toolitem action="GoNextPage"/>
-    <separator/>
-    <toolitem action="PageSelector"/>
-    <separator/>
-    <toolitem action="ViewZoom"/>
-  </toolbar>
-
   <accelerator name="PageDownAccel" action="PageDown"/>
   <accelerator name="PageUpAccel" action="PageUp"/>
   <accelerator name="EscapeAccel" action="Escape"/>
index aa5ea56e95599de7d92314a89af462f253646529..9048653f3fd4325a69303c1128c4c7d060ea44ed 100644 (file)
@@ -27,6 +27,7 @@
 #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>
@@ -215,6 +216,18 @@ ev_application_open_uri_list (EvApplication *application, GSList *uri_list)
 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 ();
 }
@@ -227,5 +240,42 @@ ev_application_class_init (EvApplicationClass *ev_application_class)
 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");
+}
+
+
index 8c317c7e47f6f61af026b032e293b84bf622700a..1ed5b77b6c9d3a2a84b7eaad542cda66c713a96d 100644 (file)
@@ -28,6 +28,9 @@
 
 #include "ev-window.h"
 
+#include "egg-toolbars-model.h"
+#include "egg-recent-model.h"
+
 G_BEGIN_DECLS
 
 typedef struct _EvApplication EvApplication;
@@ -45,24 +48,36 @@ typedef struct _EvApplicationPrivate EvApplicationPrivate;
 
 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
 
index b18f98502f3940d472aba6a466ce04c523505b48..c98fdc93c68b23dc7cae289aaa2805b51a800779 100644 (file)
 #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>
@@ -114,13 +113,10 @@ struct _EvWindowPrivate {
        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;
@@ -139,8 +135,6 @@ struct _EvWindowPrivate {
        EvJob *xfer_job;
        EvJob *load_job;
 
-       /* recent file stuff */
-       EggRecentModel *recent_model;
        EggRecentViewUIManager *recent_view;
 };
 
@@ -1107,33 +1101,22 @@ ev_window_add_recent (EvWindow *window, const char *filename)
 
        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);
        
@@ -1947,8 +1930,7 @@ ev_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
        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));
 }
 
@@ -1984,7 +1966,7 @@ ev_window_cmd_edit_toolbar (GtkAction *action, EvWindow *ev_window)
        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);
              
@@ -2639,18 +2621,6 @@ ev_window_dispose (GObject *object)
        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;
@@ -3263,23 +3233,6 @@ ev_window_init (EvWindow *ev_window)
                            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.
@@ -3290,17 +3243,17 @@ ev_window_init (EvWindow *ev_window)
        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 ();