Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2006-08-05 10:40:56 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2006-08-05 10:40:56 (GMT)
commit63718064505c640af952c6e180b75235a1de5f14 (patch)
tree213f0d030710ece03ee26b98f878a56642382877
parente47828bd9933f9a44cdfb009fdfcddfcec2748dd (diff)
Use GtkRecent instead of EggRecent when it's available. Fixes bug #349273
2006-08-05 Carlos Garcia Campos <carlosgc@gnome.org> * configure.ac: * cut-n-paste/Makefile.am: * data/evince-ui.xml: * shell/Makefile.am: * shell/ev-application.[ch]: * shell/ev-window.c: Use GtkRecent instead of EggRecent when it's available. Fixes bug #349273
-rw-r--r--ChangeLog12
-rw-r--r--configure.ac8
-rw-r--r--cut-n-paste/Makefile.am10
-rw-r--r--data/evince-ui.xml1
-rw-r--r--shell/Makefile.am14
-rw-r--r--shell/ev-application.c8
-rw-r--r--shell/ev-application.h6
-rw-r--r--shell/ev-window.c179
8 files changed, 222 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 401114e..89b63c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-08-05 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * configure.ac:
+ * cut-n-paste/Makefile.am:
+ * data/evince-ui.xml:
+ * shell/Makefile.am:
+ * shell/ev-application.[ch]:
+ * shell/ev-window.c:
+
+ Use GtkRecent instead of EggRecent when it's available. Fixes bug
+ #349273
+
2006-08-04 Wouter Bolsterlee <uws+gnome@xs4all.nl>
* shell/eggfindbar.c: (egg_find_bar_init): Fixed typo in
diff --git a/configure.ac b/configure.ac
index d355ff2..462891a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -167,6 +167,14 @@ if test x$HAVE_NAUTILUS = "xyes"; then
fi
AM_CONDITIONAL(HAVE_NAUTILUS, test x$HAVE_NAUTILUS = "xyes")
+dnl Check for GtkRecent
+PKG_CHECK_MODULES(GTK_RECENT, gtk+-2.0 >= 2.10.0,
+ [HAVE_GTK_RECENT=yes], [HAVE_GTK_RECENT=no])
+if test x$HAVE_GTK_RECENT = xyes; then
+ AC_DEFINE(HAVE_GTK_RECENT, 1, [defined if GtkRecent is available])
+fi
+AM_CONDITIONAL(HAVE_GTK_RECENT, test x$HAVE_GTK_RECENT = "xyes")
+
dnl GConf configuration
AM_GCONF_SOURCE_2
diff --git a/cut-n-paste/Makefile.am b/cut-n-paste/Makefile.am
index ce69b61..33218c0 100644
--- a/cut-n-paste/Makefile.am
+++ b/cut-n-paste/Makefile.am
@@ -1 +1,9 @@
-SUBDIRS = recent-files zoom-control toolbar-editor
+SUBDIRS =
+
+if HAVE_GTK_RECENT
+SUBDIRS +=
+else
+SUBDIRS += recent-files
+endif
+
+SUBDIRS += zoom-control toolbar-editor
diff --git a/data/evince-ui.xml b/data/evince-ui.xml
index 1470f8b..5fd01d4 100644
--- a/data/evince-ui.xml
+++ b/data/evince-ui.xml
@@ -9,6 +9,7 @@
<menuitem name="FilePropertiesMenu" action="FileProperties"/>
<separator/>
<placeholder name="RecentFilesMenu"/>
+ <separator/>
<menuitem name="FileCloseWindowMenu" action="FileCloseWindow"/>
</menu>
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 4a6c5de..6c1cdcf 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -2,7 +2,6 @@ INCLUDES= \
-DDATADIR=\"$(pkgdatadir)\" \
-DGNOMEDATADIR=\"$(datadir)\" \
-I$(top_srcdir)/lib \
- -I$(top_srcdir)/cut-n-paste/recent-files/ \
-I$(top_srcdir)/cut-n-paste/zoom-control/ \
-I$(top_srcdir)/cut-n-paste/toolbar-editor/ \
-I$(top_srcdir)/backend \
@@ -15,6 +14,12 @@ INCLUDES= \
$(GNOME_PRINT_CFLAGS) \
$(GTK_PRINT_CFLAGS)
+if HAVE_GTK_RECENT
+INCLUDES +=
+else
+INCLUDES += -I$(top_srcdir)/cut-n-paste/recent-files/
+endif
+
bin_PROGRAMS=evince
evince_SOURCES= \
@@ -77,7 +82,6 @@ endif
evince_LDADD= \
- $(top_builddir)/cut-n-paste/recent-files/librecent.la \
$(top_builddir)/cut-n-paste/zoom-control/libephyzoom.la \
$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la \
$(top_builddir)/properties/libevproperties.la \
@@ -85,6 +89,12 @@ evince_LDADD= \
$(SHELL_LIBS) \
$(GNOME_PRINT_LIBS)
+if HAVE_GTK_RECENT
+evince_LDADD +=
+else
+evince_LDADD += $(top_builddir)/cut-n-paste/recent-files/librecent.la
+endif
+
if ENABLE_DJVU
evince_LDADD += $(DJVU_LIBS)
endif
diff --git a/shell/ev-application.c b/shell/ev-application.c
index b7002a7..88a2ee9 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -330,10 +330,12 @@ ev_application_shutdown (EvApplication *application)
application->toolbars_file = NULL;
}
+#ifndef HAVE_GTK_RECENT
if (application->recent_model) {
g_object_unref (application->recent_model);
application->recent_model = NULL;
}
+#endif
g_free (application->last_chooser_uri);
g_object_unref (application);
@@ -367,7 +369,8 @@ ev_application_init (EvApplication *ev_application)
egg_toolbars_model_set_flags (ev_application->toolbars_model, 0,
EGG_TB_MODEL_NOT_REMOVABLE);
-
+
+#ifndef HAVE_GTK_RECENT
ev_application->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
/* FIXME we should add a mime type filter but current eggrecent
has only a varargs style api which does not work well when
@@ -375,6 +378,7 @@ ev_application_init (EvApplication *ev_application)
egg_recent_model_set_limit (ev_application->recent_model, 5);
egg_recent_model_set_filter_groups (ev_application->recent_model,
"Evince", NULL);
+#endif /* HAVE_GTK_RECENT */
}
GList *
@@ -401,10 +405,12 @@ EggToolbarsModel *ev_application_get_toolbars_model (EvApplication *application)
return application->toolbars_model;
}
+#ifndef HAVE_GTK_RECENT
EggRecentModel *ev_application_get_recent_model (EvApplication *application)
{
return application->recent_model;
}
+#endif
void ev_application_save_toolbars_model (EvApplication *application)
{
diff --git a/shell/ev-application.h b/shell/ev-application.h
index 9388612..880f037 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -29,7 +29,9 @@
#include "ev-window.h"
#include "egg-toolbars-model.h"
+#ifndef HAVE_GTK_RECENT
#include "egg-recent-model.h"
+#endif
G_BEGIN_DECLS
@@ -51,7 +53,9 @@ struct _EvApplication {
gchar *toolbars_file;
EggToolbarsModel *toolbars_model;
+#ifndef HAVE_GTK_RECENT
EggRecentModel *recent_model;
+#endif
gchar *last_chooser_uri;
};
@@ -86,7 +90,9 @@ GList *ev_application_get_windows (EvApplication *application);
EggToolbarsModel *ev_application_get_toolbars_model (EvApplication *application);
void ev_application_save_toolbars_model (EvApplication *application);
+#ifndef HAVE_GTK_RECENT
EggRecentModel *ev_application_get_recent_model (EvApplication *application);
+#endif
void ev_application_set_chooser_uri (EvApplication *application,
const gchar *uri);
const gchar *ev_application_get_chooser_uri (EvApplication *application);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index ad80f75..1eafe51 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -50,11 +50,15 @@
#include "ev-jobs.h"
#include "ev-sidebar-page.h"
#include "eggfindbar.h"
+
+#ifndef HAVE_GTK_RECENT
#include "egg-recent-view-uimanager.h"
#include "egg-recent-view.h"
+#include "egg-recent-model.h"
+#endif
+
#include "egg-toolbar-editor.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"
@@ -125,10 +129,15 @@ struct _EvWindowPrivate {
GtkWidget *password_dialog;
/* UI Builders */
- GtkActionGroup *action_group;
- GtkActionGroup *view_popup_action_group;
- GtkActionGroup *attachment_popup_action_group;
- GtkUIManager *ui_manager;
+ GtkActionGroup *action_group;
+ GtkActionGroup *view_popup_action_group;
+ GtkActionGroup *attachment_popup_action_group;
+#ifdef HAVE_GTK_RECENT
+ GtkRecentManager *recent_manager;
+ GtkActionGroup *recent_action_group;
+ guint recent_ui_id;
+#endif
+ GtkUIManager *ui_manager;
/* Fullscreen mode */
GtkWidget *fullscreen_toolbar;
@@ -153,7 +162,9 @@ struct _EvWindowPrivate {
EvPageCache *page_cache;
EvWindowPageMode page_mode;
EvWindowTitle *title;
+#ifndef HAVE_GTK_RECENT
EggRecentViewUIManager *recent_view;
+#endif
EvJob *xfer_job;
#ifdef WITH_GNOME_PRINT
@@ -1043,7 +1054,7 @@ ev_window_open_uri (EvWindow *ev_window,
ev_window_clear_xfer_job (ev_window);
ev_window_clear_local_uri (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
-
+
ev_window->priv->xfer_job = ev_job_xfer_new (uri, dest, mode);
g_signal_connect (ev_window->priv->xfer_job,
"finished",
@@ -1106,6 +1117,18 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *window)
gtk_widget_show (chooser);
}
+#ifdef HAVE_GTK_RECENT
+static void
+ev_window_cmd_recent_file_activate (GtkAction *action,
+ GtkRecentInfo *info)
+{
+ const gchar *uri;
+
+ uri = gtk_recent_info_get_uri (info);
+
+ ev_application_open_uri (EV_APP, uri, NULL, GDK_CURRENT_TIME, NULL);
+}
+#else
static void
ev_window_cmd_recent_file_activate (GtkAction *action,
EvWindow *ev_window)
@@ -1122,21 +1145,126 @@ ev_window_cmd_recent_file_activate (GtkAction *action,
g_free (uri);
}
+#endif /* HAVE_GTK_RECENT */
static void
ev_window_add_recent (EvWindow *window, const char *filename)
{
+#ifdef HAVE_GTK_RECENT
+ gtk_recent_manager_add_item (window->priv->recent_manager, filename);
+#else
EggRecentItem *item;
item = egg_recent_item_new_from_uri (filename);
egg_recent_item_add_group (item, "Evince");
egg_recent_model_add_full (ev_application_get_recent_model (EV_APP), item);
+#endif /* HAVE_GTK_RECENT */
+}
+
+#ifdef HAVE_GTK_RECENT
+static gint
+compare_recent_items (GtkRecentInfo *a, GtkRecentInfo *b)
+{
+ gboolean has_ev_a, has_ev_b;
+ const gchar *evince = g_get_application_name ();
+
+ has_ev_a = gtk_recent_info_has_application (a, evince);
+ has_ev_b = gtk_recent_info_has_application (b, evince);
+
+ if (has_ev_a && has_ev_b) {
+ time_t time_a, time_b;
+
+ time_a = gtk_recent_info_get_modified (a);
+ time_b = gtk_recent_info_get_modified (b);
+
+ return (time_b - time_a);
+ } else if (has_ev_a) {
+ return -1;
+ } else if (has_ev_b) {
+ return 1;
+ }
+
+ return 0;
}
+#endif /* HAVE_GTK_RECENT */
static void
ev_window_setup_recent (EvWindow *ev_window)
{
+#ifdef HAVE_GTK_RECENT
+ GList *items, *l;
+ guint n_items = 0;
+ const gchar *evince = g_get_application_name ();
+ static guint i = 0;
+
+ if (ev_window->priv->recent_ui_id > 0) {
+ gtk_ui_manager_remove_ui (ev_window->priv->ui_manager,
+ ev_window->priv->recent_ui_id);
+ gtk_ui_manager_ensure_update (ev_window->priv->ui_manager);
+ }
+ ev_window->priv->recent_ui_id = gtk_ui_manager_new_merge_id (ev_window->priv->ui_manager);
+
+ if (ev_window->priv->recent_action_group) {
+ gtk_ui_manager_remove_action_group (ev_window->priv->ui_manager,
+ ev_window->priv->recent_action_group);
+ g_object_unref (ev_window->priv->recent_action_group);
+ }
+ ev_window->priv->recent_action_group = gtk_action_group_new ("RecentFilesActions");
+ gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
+ ev_window->priv->recent_action_group, 0);
+
+ items = gtk_recent_manager_get_items (ev_window->priv->recent_manager);
+ items = g_list_sort (items, (GCompareFunc) compare_recent_items);
+
+ for (l = items; l && l->data; l = g_list_next (l)) {
+ GtkRecentInfo *info;
+ GtkAction *action;
+ gchar *action_name;
+ gchar *label;
+ info = (GtkRecentInfo *) l->data;
+
+ if (!gtk_recent_info_has_application (info, evince))
+ continue;
+
+ action_name = g_strdup_printf ("RecentFile%u", i++);
+ label = g_strdup_printf ("_%d. %s",
+ n_items + 1,
+ gtk_recent_info_get_display_name (info));
+
+ action = g_object_new (GTK_TYPE_ACTION,
+ "name", action_name,
+ "label", label,
+ NULL);
+
+ g_object_weak_ref (G_OBJECT (action),
+ (GWeakNotify) gtk_recent_info_unref,
+ gtk_recent_info_ref (info));
+ g_signal_connect (G_OBJECT (action), "activate",
+ G_CALLBACK (ev_window_cmd_recent_file_activate),
+ (gpointer) info);
+
+ gtk_action_group_add_action (ev_window->priv->recent_action_group,
+ action);
+ g_object_unref (action);
+
+ gtk_ui_manager_add_ui (ev_window->priv->ui_manager,
+ ev_window->priv->recent_ui_id,
+ "/MainMenu/FileMenu/RecentFilesMenu",
+ label,
+ action_name,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+ g_free (action_name);
+ g_free (label);
+
+ if (++n_items == 5)
+ break;
+ }
+
+ g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
+ g_list_free (items);
+#else /* HAVE_GTK_RECENT */
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),
@@ -1151,6 +1279,7 @@ ev_window_setup_recent (EvWindow *ev_window)
g_signal_connect (ev_window->priv->recent_view, "activate",
G_CALLBACK (ev_window_cmd_recent_file_activate), ev_window);
+#endif /* HAVE_GTK_RECENT */
}
static void
@@ -3040,11 +3169,6 @@ ev_window_dispose (GObject *object)
priv->title = NULL;
}
- if (priv->recent_view) {
- g_object_unref (priv->recent_view);
- priv->recent_view = NULL;
- }
-
if (priv->ui_manager) {
g_object_unref (priv->ui_manager);
priv->ui_manager = NULL;
@@ -3065,6 +3189,27 @@ ev_window_dispose (GObject *object)
priv->attachment_popup_action_group = NULL;
}
+#ifdef HAVE_GTK_RECENT
+ if (priv->recent_action_group) {
+ g_object_unref (priv->recent_action_group);
+ priv->recent_action_group = NULL;
+ }
+
+ if (priv->recent_manager) {
+ g_signal_handlers_disconnect_by_func (priv->recent_manager,
+ ev_window_setup_recent,
+ window);
+ priv->recent_manager = NULL;
+ }
+
+ priv->recent_ui_id = 0;
+#else
+ if (priv->recent_view) {
+ g_object_unref (priv->recent_view);
+ priv->recent_view = NULL;
+ }
+#endif /* HAVE_GTK_RECENT */
+
if (priv->page_cache) {
g_signal_handlers_disconnect_by_func (priv->page_cache, page_changed_cb, window);
priv->page_cache = NULL;
@@ -3887,7 +4032,17 @@ ev_window_init (EvWindow *ev_window)
g_warning ("building menus failed: %s", error->message);
g_error_free (error);
}
-
+
+#ifdef HAVE_GTK_RECENT
+ ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
+ ev_window->priv->recent_action_group = NULL;
+ ev_window->priv->recent_ui_id = 0;
+ g_signal_connect_swapped (ev_window->priv->recent_manager,
+ "changed",
+ G_CALLBACK (ev_window_setup_recent),
+ ev_window);
+#endif /* HAVE_GTK_RECENT */
+
ev_window->priv->menubar =
gtk_ui_manager_get_widget (ev_window->priv->ui_manager,
"/MainMenu");