]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkrecentchooserdefault.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkrecentchooserdefault.c
index fcac5ca286b1c0a1f42c167b6994d9eff37d05bb..2d15efee8531729192d0c69815f465a4db15a963 100644 (file)
@@ -1,7 +1,7 @@
 /* GTK - The GIMP Toolkit
  * gtkrecentchooserdefault.c
  * Copyright (C) 2005-2006, Emmanuele Bassi
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
@@ -29,8 +27,6 @@
 #include <unistd.h>
 #endif
 
-#include <gdk/gdkscreen.h>
-
 #include "gtkstock.h"
 #include "gtkicontheme.h"
 #include "gtkiconfactory.h"
 #include "gtkcellrenderertext.h"
 #include "gtkcheckmenuitem.h"
 #include "gtkclipboard.h"
-#include "gtkcombobox.h"
+#include "gtkcomboboxtext.h"
 #include "gtkentry.h"
 #include "gtkeventbox.h"
 #include "gtkexpander.h"
 #include "gtkframe.h"
-#include "gtkhbox.h"
-#include "gtkhpaned.h"
+#include "gtkbox.h"
+#include "gtkpaned.h"
 #include "gtkimage.h"
 #include "gtkimagemenuitem.h"
 #include "gtkintl.h"
 #include "gtkscrolledwindow.h"
 #include "gtkseparatormenuitem.h"
 #include "gtksizegroup.h"
-#include "gtktable.h"
+#include "gtksizerequest.h"
 #include "gtktreemodelsort.h"
 #include "gtktreemodelfilter.h"
 #include "gtktreeselection.h"
 #include "gtktreestore.h"
-#include "gtktooltips.h"
+#include "gtktooltip.h"
 #include "gtktypebuiltins.h"
-#include "gtkvbox.h"
+#include "gtkorientable.h"
+#include "gtkactivatable.h"
 
 #include "gtkrecentmanager.h"
 #include "gtkrecentfilter.h"
 #include "gtkrecentchooserutils.h"
 #include "gtkrecentchooserdefault.h"
 
-#include "gtkalias.h"
 
-\f
+enum 
+{
+  PROP_0,
+
+  /* activatable properties */
+  PROP_ACTIVATABLE_RELATED_ACTION,
+  PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
+};
+
 
 struct _GtkRecentChooserDefault
 {
-  GtkVBox parent_instance;
-  
+  GtkBox parent_instance;
+
   GtkRecentManager *manager;
   gulong manager_changed_id;
   guint local_manager : 1;
-  
+
   gint icon_size;
 
   /* RecentChooser properties */
-  gint limit;  
+  gint limit;
   GtkRecentSortType sort_type;
   guint show_private : 1;
   guint show_not_found : 1;
@@ -98,6 +102,8 @@ struct _GtkRecentChooserDefault
   guint show_tips : 1;
   guint show_icons : 1;
   guint local_only : 1;
+
+  guint limit_set : 1;
   
   GSList *filters;
   GtkRecentFilter *current_filter;
@@ -108,13 +114,10 @@ struct _GtkRecentChooserDefault
   gpointer sort_data;
   GDestroyNotify sort_data_destroy;
 
-  GtkTooltips *tooltips;
-
   GtkIconTheme *icon_theme;
   
   GtkWidget *recent_view;
   GtkListStore *recent_store;
-  GtkTreeModel *recent_store_filter;
   GtkTreeViewColumn *icon_column;
   GtkTreeViewColumn *meta_column;
   GtkCellRenderer *meta_renderer;
@@ -135,14 +138,13 @@ struct _GtkRecentChooserDefault
 
 typedef struct _GtkRecentChooserDefaultClass
 {
-  GtkVBoxClass parent_class;
+  GtkBoxClass parent_class;
 } GtkRecentChooserDefaultClass;
 
 enum {
   RECENT_URI_COLUMN,
   RECENT_DISPLAY_NAME_COLUMN,
   RECENT_INFO_COLUMN,
-    
   N_RECENT_COLUMNS
 };
 
@@ -153,15 +155,6 @@ enum {
   LOAD_FINISHED  /* the model is fully loaded and inserted */
 };
 
-enum {
-  TEXT_URI_LIST
-};
-
-/* Target types for DnD from the file list */
-static const GtkTargetEntry recent_list_source_targets[] = {
-  { "text/uri-list", 0, TEXT_URI_LIST }
-};
-
 /* Icon size for if we can't get it from the theme */
 #define FALLBACK_ICON_SIZE  48
 #define FALLBACK_ITEM_LIMIT 20
@@ -178,6 +171,7 @@ static GObject *gtk_recent_chooser_default_constructor  (GType
                                                         guint                         n_construct_prop,
                                                         GObjectConstructParam        *construct_params);
 static void     gtk_recent_chooser_default_finalize     (GObject                      *object);
+static void     gtk_recent_chooser_default_dispose      (GObject                      *object);
 static void     gtk_recent_chooser_default_set_property (GObject                      *object,
                                                         guint                         prop_id,
                                                         const GValue                 *value,
@@ -222,6 +216,7 @@ static void set_current_filter        (GtkRecentChooserDefault *impl,
 static GtkIconTheme *get_icon_theme_for_widget (GtkWidget   *widget);
 static gint          get_icon_size_for_widget  (GtkWidget   *widget,
                                                GtkIconSize  icon_size);
+static gint          get_recent_files_limit    (GtkWidget   *widget);
 
 static void reload_recent_items (GtkRecentChooserDefault *impl);
 static void chooser_set_model   (GtkRecentChooserDefault *impl);
@@ -232,10 +227,6 @@ static void set_recent_manager (GtkRecentChooserDefault *impl,
 static void chooser_set_sort_type (GtkRecentChooserDefault *impl,
                                   GtkRecentSortType        sort_type);
 
-static gboolean recent_store_filter_func (GtkTreeModel *model,
-                                         GtkTreeIter  *iter,
-                                         gpointer      user_data);
-
 static void recent_manager_changed_cb (GtkRecentManager  *manager,
                                       gpointer           user_data);
 static void recent_icon_data_func     (GtkTreeViewColumn *tree_column,
@@ -280,12 +271,27 @@ static void     recent_view_drag_data_get_cb      (GtkWidget        *widget,
                                                   guint             info,
                                                   guint32           time_,
                                                   gpointer          data);
+static gboolean recent_view_query_tooltip_cb      (GtkWidget        *widget,
+                                                   gint              x,
+                                                   gint              y,
+                                                   gboolean          keyboard_tip,
+                                                   GtkTooltip       *tooltip,
+                                                   gpointer          user_data);
+
+static void gtk_recent_chooser_activatable_iface_init (GtkActivatableIface  *iface);
+static void gtk_recent_chooser_update                 (GtkActivatable       *activatable,
+                                                      GtkAction            *action,
+                                                      const gchar          *property_name);
+static void gtk_recent_chooser_sync_action_properties (GtkActivatable       *activatable,
+                                                      GtkAction            *action);
 
 G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDefault,
                         _gtk_recent_chooser_default,
-                        GTK_TYPE_VBOX,
+                        GTK_TYPE_BOX,
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
-                                               gtk_recent_chooser_iface_init))
+                                               gtk_recent_chooser_iface_init)
+                        G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
+                                               gtk_recent_chooser_activatable_iface_init))
 
 
 \f
@@ -307,21 +313,33 @@ gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface)
   iface->list_filters = gtk_recent_chooser_default_list_filters;
 }
 
+static void
+gtk_recent_chooser_activatable_iface_init (GtkActivatableIface *iface)
+
+{
+  iface->update = gtk_recent_chooser_update;
+  iface->sync_action_properties = gtk_recent_chooser_sync_action_properties;
+}
+
 static void
 _gtk_recent_chooser_default_class_init (GtkRecentChooserDefaultClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  gobject_class->constructor = gtk_recent_chooser_default_constructor;  
-  gobject_class->finalize = gtk_recent_chooser_default_finalize;
+  gobject_class->constructor = gtk_recent_chooser_default_constructor;
   gobject_class->set_property = gtk_recent_chooser_default_set_property;
   gobject_class->get_property = gtk_recent_chooser_default_get_property;
+  gobject_class->dispose = gtk_recent_chooser_default_dispose;
+  gobject_class->finalize = gtk_recent_chooser_default_finalize;
   
   widget_class->map = gtk_recent_chooser_default_map;
   widget_class->show_all = gtk_recent_chooser_default_show_all;
   
   _gtk_recent_chooser_install_properties (gobject_class);
+
+  g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
+  g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
 }
 
 static void
@@ -329,16 +347,19 @@ _gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl)
 {
   gtk_box_set_spacing (GTK_BOX (impl), 6);
 
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (impl),
+                                  GTK_ORIENTATION_VERTICAL);
+
   /* by default, we use the global manager */
   impl->local_manager = FALSE;
-  
+
   impl->limit = FALLBACK_ITEM_LIMIT;
   impl->sort_type = GTK_RECENT_SORT_NONE;
 
   impl->show_icons = TRUE;
   impl->show_private = FALSE;
   impl->show_not_found = TRUE;
-  impl->show_tips = TRUE;
+  impl->show_tips = FALSE;
   impl->select_multiple = FALSE;
   impl->local_only = TRUE;
   
@@ -347,9 +368,6 @@ _gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl)
   
   impl->current_filter = NULL;
 
-  impl->tooltips = gtk_tooltips_new ();
-  g_object_ref_sink (impl->tooltips);
-  
   impl->recent_items = NULL;
   impl->n_recent_items = 0;
   impl->loaded_items = 0;
@@ -359,22 +377,24 @@ _gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl)
 
 static GObject *
 gtk_recent_chooser_default_constructor (GType                  type,
-                                       guint                  n_construct_prop,
-                                       GObjectConstructParam *construct_params)
+                                       guint                  n_params,
+                                       GObjectConstructParam *params)
 {
+  GObjectClass *parent_class;
   GtkRecentChooserDefault *impl;
   GObject *object;
-  
   GtkWidget *scrollw;
   GtkCellRenderer *renderer;
-  
-  object = G_OBJECT_CLASS (_gtk_recent_chooser_default_parent_class)->constructor (type, n_construct_prop, construct_params);
 
+  parent_class = G_OBJECT_CLASS (_gtk_recent_chooser_default_parent_class);
+  object = parent_class->constructor (type, n_params, params);
   impl = GTK_RECENT_CHOOSER_DEFAULT (object);
   
   g_assert (impl->manager);
   
   gtk_widget_push_composite_child ();
+
+  impl->limit = get_recent_files_limit (GTK_WIDGET (impl));
   
   scrollw = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollw),
@@ -392,12 +412,17 @@ gtk_recent_chooser_default_constructor (GType                  type,
                    G_CALLBACK (recent_view_popup_menu_cb), impl);
   g_signal_connect (impl->recent_view, "button-press-event",
                    G_CALLBACK (recent_view_button_press_cb), impl);
-  g_signal_connect (impl->recent_view, "drag_begin",
+  g_signal_connect (impl->recent_view, "drag-begin",
                    G_CALLBACK (recent_view_drag_begin_cb), impl);
-  g_signal_connect (impl->recent_view, "drag_data_get",
+  g_signal_connect (impl->recent_view, "drag-data-get",
                    G_CALLBACK (recent_view_drag_data_get_cb), impl);
 
-  g_object_set_data (G_OBJECT (impl->recent_view), "GtkRecentChooserDefault", impl);
+  g_object_set (impl->recent_view, "has-tooltip", TRUE, NULL);
+  g_signal_connect (impl->recent_view, "query-tooltip",
+                    G_CALLBACK (recent_view_query_tooltip_cb), impl);
+
+  g_object_set_data (G_OBJECT (impl->recent_view),
+                     "GtkRecentChooserDefault", impl);
   
   gtk_container_add (GTK_CONTAINER (scrollw), impl->recent_view);
   gtk_widget_show (impl->recent_view);
@@ -407,6 +432,7 @@ gtk_recent_chooser_default_constructor (GType                  type,
   gtk_tree_view_column_set_resizable (impl->icon_column, FALSE);
   
   renderer = gtk_cell_renderer_pixbuf_new ();
+  g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
   gtk_tree_view_column_pack_start (impl->icon_column, renderer, FALSE);
   gtk_tree_view_column_set_cell_data_func (impl->icon_column,
                                           renderer,
@@ -440,20 +466,18 @@ gtk_recent_chooser_default_constructor (GType                  type,
   /* drag and drop */
   gtk_drag_source_set (impl->recent_view,
                       GDK_BUTTON1_MASK,
-                      recent_list_source_targets,
-                      G_N_ELEMENTS (recent_list_source_targets),
+                      NULL, 0,
                       GDK_ACTION_COPY);
+  gtk_drag_source_add_uri_targets (impl->recent_view);
 
-  impl->filter_combo_hbox = gtk_hbox_new (FALSE, 12);
-  
-  impl->filter_combo = gtk_combo_box_new_text ();
+  impl->filter_combo_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+
+  impl->filter_combo = gtk_combo_box_text_new ();
   gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (impl->filter_combo), FALSE);
   g_signal_connect (impl->filter_combo, "changed",
                     G_CALLBACK (filter_combo_changed_cb), impl);
-  gtk_tooltips_set_tip (impl->tooltips,
-                       impl->filter_combo,
-                       _("Select which type of documents are shown"),
-                       NULL);
+  gtk_widget_set_tooltip_text (impl->filter_combo,
+                              _("Select which type of documents are shown"));
   
   gtk_box_pack_end (GTK_BOX (impl->filter_combo_hbox),
                     impl->filter_combo,
@@ -487,10 +511,6 @@ gtk_recent_chooser_default_set_property (GObject      *object,
       break;
     case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE:
       impl->show_private = g_value_get_boolean (value);
-      
-      if (impl->recent_store && impl->recent_store_filter)
-        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->recent_store_filter));
-
       if (impl->recent_popup_menu_show_private_item)
        {
           GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (impl->recent_popup_menu_show_private_item);
@@ -498,20 +518,14 @@ gtk_recent_chooser_default_set_property (GObject      *object,
           gtk_check_menu_item_set_active (item, impl->show_private);
          g_signal_handlers_unblock_by_func (item, G_CALLBACK (show_private_toggled_cb), impl);
         }
+      reload_recent_items (impl);
       break;
     case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND:
       impl->show_not_found = g_value_get_boolean (value);
-      
-      if (impl->recent_store && impl->recent_store_filter)
-        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->recent_store_filter));
+      reload_recent_items (impl);
       break;
     case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS:
       impl->show_tips = g_value_get_boolean (value);
-
-      if (impl->show_tips)
-        gtk_tooltips_enable (impl->tooltips);
-      else
-        gtk_tooltips_disable (impl->tooltips);
       break;
     case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS:
       impl->show_icons = g_value_get_boolean (value);
@@ -527,9 +541,12 @@ gtk_recent_chooser_default_set_property (GObject      *object,
       break;
     case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY:
       impl->local_only = g_value_get_boolean (value);
+      reload_recent_items (impl);
       break;
     case GTK_RECENT_CHOOSER_PROP_LIMIT:
       impl->limit = g_value_get_int (value);
+      impl->limit_set = TRUE;
+      reload_recent_items (impl);
       break;
     case GTK_RECENT_CHOOSER_PROP_SORT_TYPE:
       chooser_set_sort_type (impl, g_value_get_enum (value));
@@ -537,6 +554,12 @@ gtk_recent_chooser_default_set_property (GObject      *object,
     case GTK_RECENT_CHOOSER_PROP_FILTER:
       set_current_filter (impl, g_value_get_object (value));
       break;
+    case PROP_ACTIVATABLE_RELATED_ACTION:
+      _gtk_recent_chooser_set_related_action (GTK_RECENT_CHOOSER (impl), g_value_get_object (value));
+      break;
+    case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE: 
+      _gtk_recent_chooser_set_use_action_appearance (GTK_RECENT_CHOOSER (impl), g_value_get_boolean (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -580,6 +603,12 @@ gtk_recent_chooser_default_get_property (GObject    *object,
     case GTK_RECENT_CHOOSER_PROP_FILTER:
       g_value_set_object (value, impl->current_filter);
       break;
+    case PROP_ACTIVATABLE_RELATED_ACTION:
+      g_value_set_object (value, _gtk_recent_chooser_get_related_action (GTK_RECENT_CHOOSER (impl)));
+      break;
+    case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE: 
+      g_value_set_boolean (value, _gtk_recent_chooser_get_use_action_appearance (GTK_RECENT_CHOOSER (impl)));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -587,55 +616,63 @@ gtk_recent_chooser_default_get_property (GObject    *object,
 }
 
 static void
-gtk_recent_chooser_default_finalize (GObject *object)
+gtk_recent_chooser_default_dispose (GObject *object)
 {
   GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (object);
 
-  if (impl->recent_items)
+  if (impl->load_id)
     {
-      g_list_foreach (impl->recent_items,
-                     (GFunc) gtk_recent_info_unref,
-                     NULL);
-      g_list_free (impl->recent_items);
-      impl->recent_items = NULL;
+      g_source_remove (impl->load_id);
+      impl->load_state = LOAD_EMPTY;
+      impl->load_id = 0;
     }
 
-  if (impl->manager_changed_id)
+  g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
+  impl->recent_items = NULL;
+
+  if (impl->manager && impl->manager_changed_id)
     {
       g_signal_handler_disconnect (impl->manager, impl->manager_changed_id);
       impl->manager_changed_id = 0;
     }
 
-  impl->manager = NULL; 
-  
-  if (impl->sort_data_destroy)
-    {
-      impl->sort_data_destroy (impl->sort_data);
-      
-      impl->sort_data_destroy = NULL;
-      impl->sort_data = NULL;
-      impl->sort_func = NULL;
-    }
-    
   if (impl->filters)
     {
-      g_slist_foreach (impl->filters,
-                      (GFunc) g_object_unref,
-                      NULL);
-      g_slist_free (impl->filters);    
+      g_slist_foreach (impl->filters, (GFunc) g_object_unref, NULL);
+      g_slist_free (impl->filters);
+      impl->filters = NULL;
     }
   
   if (impl->current_filter)
-    g_object_unref (impl->current_filter);
-
-  if (impl->recent_store_filter)
-    g_object_unref (impl->recent_store_filter);
+    {
+      g_object_unref (impl->current_filter);
+      impl->current_filter = NULL;
+    }
 
   if (impl->recent_store)
-    g_object_unref (impl->recent_store);
+    {
+      g_object_unref (impl->recent_store);
+      impl->recent_store = NULL;
+    }
 
-  if (impl->tooltips)
-    g_object_unref (impl->tooltips);
+  G_OBJECT_CLASS (_gtk_recent_chooser_default_parent_class)->dispose (object);
+}
+
+static void
+gtk_recent_chooser_default_finalize (GObject *object)
+{
+  GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (object);
+
+  impl->manager = NULL; 
+  
+  if (impl->sort_data_destroy)
+    {
+      impl->sort_data_destroy (impl->sort_data);
+      impl->sort_data_destroy = NULL;
+    }
+  
+  impl->sort_data = NULL;
+  impl->sort_func = NULL;
   
   G_OBJECT_CLASS (_gtk_recent_chooser_default_parent_class)->finalize (object);
 }
@@ -668,8 +705,9 @@ error_message_with_parent (GtkWindow   *parent,
   gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                            "%s", detail);
 
-  if (parent->group)
-    gtk_window_group_add_window (parent->group, GTK_WINDOW (dialog));
+  if (gtk_window_has_group (parent))
+    gtk_window_group_add_window (gtk_window_get_group (parent),
+                                 GTK_WINDOW (dialog));
 
   gtk_dialog_run (GTK_DIALOG (dialog));
   gtk_widget_destroy (dialog);
@@ -682,7 +720,7 @@ get_toplevel (GtkWidget *widget)
   GtkWidget *toplevel;
 
   toplevel = gtk_widget_get_toplevel (widget);
-  if (!GTK_WIDGET_TOPLEVEL (toplevel))
+  if (!gtk_widget_is_toplevel (toplevel))
     return NULL;
   else
     return GTK_WINDOW (toplevel);
@@ -706,7 +744,7 @@ set_busy_cursor (GtkRecentChooserDefault *impl,
   GdkCursor *cursor;
 
   toplevel = get_toplevel (GTK_WIDGET (impl));
-  if (!toplevel || !GTK_WIDGET_REALIZED (toplevel))
+  if (!toplevel || !gtk_widget_get_realized (GTK_WIDGET (toplevel)))
     return;
   
   display = gtk_widget_get_display (GTK_WIDGET (toplevel));
@@ -715,28 +753,22 @@ set_busy_cursor (GtkRecentChooserDefault *impl,
   if (show_busy_cursor)
     cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
 
-  gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor);
+  gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (toplevel)),
+                         cursor);
   gdk_display_flush (display);
 
   if (cursor)
-    gdk_cursor_unref (cursor);
+    g_object_unref (cursor);
 }
 
 static void
 chooser_set_model (GtkRecentChooserDefault *impl)
 {
   g_assert (impl->recent_store != NULL);
-  g_assert (impl->recent_store_filter == NULL);
   g_assert (impl->load_state == LOAD_LOADING);
-  
-  impl->recent_store_filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (impl->recent_store), NULL);
-  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (impl->recent_store_filter),
-                                         recent_store_filter_func,
-                                         impl,
-                                         NULL);
-  
+
   gtk_tree_view_set_model (GTK_TREE_VIEW (impl->recent_view),
-                          impl->recent_store_filter);
+                           GTK_TREE_MODEL (impl->recent_store));
   gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->recent_view));
   gtk_tree_view_set_enable_search (GTK_TREE_VIEW (impl->recent_view), TRUE);
   gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->recent_view),
@@ -801,21 +833,12 @@ load_recent_items (gpointer user_data)
       /* we have finished loading, so we remove the items cache */
       impl->load_state = LOAD_LOADING;
       
-      g_list_foreach (impl->recent_items,
-                     (GFunc) gtk_recent_info_unref,
-                     NULL);
-      g_list_free (impl->recent_items);
+      g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
       
       impl->recent_items = NULL;
       impl->n_recent_items = 0;
       impl->loaded_items = 0;
-      
-      if (impl->recent_store_filter)
-        {
-          g_object_unref (impl->recent_store_filter);
-         impl->recent_store_filter = NULL;
-       }
-      
+
       /* load the filled up model */
       chooser_set_model (impl);
 
@@ -839,7 +862,8 @@ cleanup_after_load (gpointer user_data)
 
   if (impl->load_id != 0)
     {
-      g_assert ((impl->load_state == LOAD_PRELOAD) ||
+      g_assert ((impl->load_state == LOAD_EMPTY) ||
+                (impl->load_state == LOAD_PRELOAD) ||
                (impl->load_state == LOAD_LOADING) ||
                (impl->load_state == LOAD_FINISHED));
       
@@ -862,74 +886,87 @@ cleanup_after_load (gpointer user_data)
 static void
 reload_recent_items (GtkRecentChooserDefault *impl)
 {
+  GtkWidget *widget;
+
   /* reload is already in progress - do not disturb */
   if (impl->load_id)
     return;
   
+  widget = GTK_WIDGET (impl);
+
   gtk_tree_view_set_model (GTK_TREE_VIEW (impl->recent_view), NULL);
   gtk_list_store_clear (impl->recent_store);
   
   if (!impl->icon_theme)
-    impl->icon_theme = get_icon_theme_for_widget (GTK_WIDGET (impl));
+    impl->icon_theme = get_icon_theme_for_widget (widget);
 
-  impl->icon_size = get_icon_size_for_widget (GTK_WIDGET (impl),
+  impl->icon_size = get_icon_size_for_widget (widget,
                                              GTK_ICON_SIZE_BUTTON);
 
+  if (!impl->limit_set)
+    impl->limit = get_recent_files_limit (widget);
+
   set_busy_cursor (impl, TRUE);
 
   impl->load_state = LOAD_EMPTY;
   impl->load_id = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 30,
-                                  load_recent_items,
-                                  impl,
-                                  cleanup_after_load);
+                                             load_recent_items,
+                                             impl,
+                                             cleanup_after_load);
 }
 
 /* taken form gtkfilechooserdialog.c */
 static void
 set_default_size (GtkRecentChooserDefault *impl)
 {
+  GtkScrolledWindow *scrollw;
   GtkWidget *widget;
   gint width, height;
-  gint font_size;
+  double font_size;
   GdkScreen *screen;
   gint monitor_num;
   GtkRequisition req;
   GdkRectangle monitor;
+  GtkStyleContext *context;
+  GtkStateFlags state;
 
   widget = GTK_WIDGET (impl);
+  context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
 
   /* Size based on characters and the icon size */
-  font_size = pango_font_description_get_size (widget->style->font_desc);
-  font_size = PANGO_PIXELS (font_size);
+  gtk_style_context_get (context, state, "font-size", &font_size, NULL);
 
-  width = impl->icon_size + font_size * NUM_CHARS;
-  height = (impl->icon_size + font_size) * NUM_LINES;
+  width = impl->icon_size + font_size * NUM_CHARS + 0.5;
+  height = (impl->icon_size + font_size) * NUM_LINES + 0.5;
 
   /* Use at least the requisition size... */
-  gtk_widget_size_request (widget, &req);
+  gtk_widget_get_preferred_size (widget, &req, NULL);
   width = MAX (width, req.width);
   height = MAX (height, req.height);
 
   /* ... but no larger than the monitor */
   screen = gtk_widget_get_screen (widget);
-  monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+  monitor_num = gdk_screen_get_monitor_at_window (screen,
+                                                  gtk_widget_get_window (widget));
 
-  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+  gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
 
   width = MIN (width, monitor.width * 3 / 4);
   height = MIN (height, monitor.height * 3 / 4);
 
   /* Set size */
-  gtk_widget_set_size_request (impl->recent_view, width, height);
+  scrollw = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (impl->recent_view));
+  gtk_scrolled_window_set_min_content_width (scrollw, width);
+  gtk_scrolled_window_set_min_content_height (scrollw, height);
 }
 
 static void
 gtk_recent_chooser_default_map (GtkWidget *widget)
 {
   GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (widget);
-  
-  if (GTK_WIDGET_CLASS (_gtk_recent_chooser_default_parent_class)->map)
-    GTK_WIDGET_CLASS (_gtk_recent_chooser_default_parent_class)->map (widget);
+
+  GTK_WIDGET_CLASS (_gtk_recent_chooser_default_parent_class)->map (widget);
 
   /* reloads everything */
   reload_recent_items (impl);
@@ -944,23 +981,19 @@ recent_icon_data_func (GtkTreeViewColumn *tree_column,
                       GtkTreeIter       *iter,
                       gpointer           user_data)
 {
-  GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data);
   GtkRecentInfo *info = NULL;
-  GdkPixbuf *pixbuf;
-  
-  gtk_tree_model_get (model, iter,
-                      RECENT_INFO_COLUMN, &info,
-                      -1);
+  GIcon *icon;
+
+  gtk_tree_model_get (model, iter, RECENT_INFO_COLUMN, &info, -1);
   g_assert (info != NULL);
-  
-  pixbuf = gtk_recent_info_get_icon (info, impl->icon_size);
-  
-  g_object_set (cell,
-                "pixbuf", pixbuf,
-                NULL);
-  
-  if (pixbuf)  
-    g_object_unref (pixbuf);
+
+  icon = gtk_recent_info_get_gicon (info);
+  g_object_set (cell, "gicon", icon, NULL);
+
+  if (icon != NULL)
+    g_object_unref (icon);
+
+  gtk_recent_info_unref (info);
 }
 
 static void
@@ -971,11 +1004,7 @@ recent_meta_data_func (GtkTreeViewColumn *tree_column,
                       gpointer           user_data)
 {
   GtkRecentInfo *info = NULL;
-  gchar *uri;
   gchar *name;
-  GString *data;
-  
-  data = g_string_new (NULL);
   
   gtk_tree_model_get (model, iter,
                       RECENT_DISPLAY_NAME_COLUMN, &name,
@@ -983,23 +1012,11 @@ recent_meta_data_func (GtkTreeViewColumn *tree_column,
                       -1);
   g_assert (info != NULL);
   
-  uri = gtk_recent_info_get_uri_display (info);
-  
   if (!name)
     name = gtk_recent_info_get_short_name (info);
-  g_string_append_printf (data,
-                         "<b>%s</b>\n"
-                         "<small>Location: %s</small>",
-                         name,
-                         uri);
-  
-  g_object_set (cell,
-                "markup", data->str,
-                NULL);
+
+  g_object_set (cell, "text", name, NULL);
   
-  g_string_free (data, TRUE);
-  g_free (uri);
   g_free (name);
   gtk_recent_info_unref (info);
 }
@@ -1209,11 +1226,11 @@ gtk_recent_chooser_default_set_sort_func (GtkRecentChooser  *chooser,
   if (impl->sort_data_destroy)
     {
       impl->sort_data_destroy (impl->sort_data);
-      
-      impl->sort_func = NULL;
-      impl->sort_data = NULL;
       impl->sort_data_destroy = NULL;
     }
+      
+  impl->sort_func = NULL;
+  impl->sort_data = NULL;
   
   if (sort_func)
     {
@@ -1223,129 +1240,23 @@ gtk_recent_chooser_default_set_sort_func (GtkRecentChooser  *chooser,
     }
 }
 
-static gint
-sort_recent_items_mru (GtkRecentInfo *a,
-                      GtkRecentInfo *b,
-                      gpointer       unused)
-{
-  g_assert (a != NULL && b != NULL);
-  
-  return (gtk_recent_info_get_modified (a) < gtk_recent_info_get_modified (b));
-}
-
-static gint
-sort_recent_items_lru (GtkRecentInfo *a,
-                      GtkRecentInfo *b,
-                      gpointer       unused)
-{
-  g_assert (a != NULL && b != NULL);
-  
-  return (gtk_recent_info_get_modified (a) > gtk_recent_info_get_modified (b));
-}
-
-/* our proxy sorting function */
-static gint
-sort_recent_items_proxy (gpointer *a,
-                        gpointer *b,
-                        gpointer  user_data)
-{
-  GtkRecentInfo *info_a = (GtkRecentInfo *) a;
-  GtkRecentInfo *info_b = (GtkRecentInfo *) b;
-  GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data);
-
-  if (impl->sort_func)
-    return (* impl->sort_func) (info_a,
-                               info_b,
-                               impl->sort_data);
-  
-  /* fallback */
-  return 0;
-}
-
-static void
-chooser_set_sort_type (GtkRecentChooserDefault *impl,
-                      GtkRecentSortType        sort_type)
-{
-  if (impl->sort_type == sort_type)
-    return;
-
-  impl->sort_type = sort_type;
-}
-
 static GList *
 gtk_recent_chooser_default_get_items (GtkRecentChooser *chooser)
 {
   GtkRecentChooserDefault *impl;
-  gint limit;
-  GtkRecentSortType sort_type;
-  GList *items;
-  GCompareDataFunc compare_func;
-  gint length;
-  
-  impl = GTK_RECENT_CHOOSER_DEFAULT (chooser);
-  
-  if (!impl->manager)
-    return NULL;
 
-  items = gtk_recent_manager_get_items (impl->manager);
-  if (!items)
-    return NULL;
-  limit = gtk_recent_chooser_get_limit (chooser);
-  if (limit == 0)
-    return NULL;
+  impl = GTK_RECENT_CHOOSER_DEFAULT (chooser);
 
-  sort_type = gtk_recent_chooser_get_sort_type (chooser);
-  switch (sort_type)
-    {
-    case GTK_RECENT_SORT_NONE:
-      compare_func = NULL;
-      break;
-    case GTK_RECENT_SORT_MRU:
-      compare_func = (GCompareDataFunc) sort_recent_items_mru;
-      break;
-    case GTK_RECENT_SORT_LRU:
-      compare_func = (GCompareDataFunc) sort_recent_items_lru;
-      break;
-    case GTK_RECENT_SORT_CUSTOM:
-      compare_func = (GCompareDataFunc) sort_recent_items_proxy;
-      break;
-    default:
-      g_assert_not_reached ();
-      break;
-    }
-  
-  /* sort the items; the filtering will be dealt with using
-   * the treeview's own filter object
-   */
-  if (compare_func)
-    items = g_list_sort_with_data (items, compare_func, impl);
-  
-  length = g_list_length (items);
-  if ((limit != -1) && (length > limit))
-    {
-      GList *clamp, *l;
-      
-      clamp = g_list_nth (items, limit - 1);
-      if (!clamp)
-        return items;
-      
-      l = clamp->next;
-      clamp->next = NULL;
-    
-      g_list_foreach (l, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (l);
-    }
-  
-  return items;
+  return _gtk_recent_chooser_get_items (chooser,
+                                        impl->current_filter,
+                                        impl->sort_func,
+                                        impl->sort_data);
 }
 
 static GtkRecentManager *
 gtk_recent_chooser_default_get_recent_manager (GtkRecentChooser *chooser)
 {
-  GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (chooser);
-  
-  return impl->manager;
+  return GTK_RECENT_CHOOSER_DEFAULT (chooser)->manager;
 }
 
 static void
@@ -1379,10 +1290,10 @@ gtk_recent_chooser_default_add_filter (GtkRecentChooser *chooser,
   /* display new filter */
   name = gtk_recent_filter_get_name (filter);
   if (!name)
-    name = "Untitled filter";
-    
-  gtk_combo_box_append_text (GTK_COMBO_BOX (impl->filter_combo), name);
-  
+    name = _("Untitled filter");
+
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (impl->filter_combo), name);
+
   if (!g_slist_find (impl->filters, impl->current_filter))
     set_current_filter (impl, filter);
   
@@ -1434,103 +1345,6 @@ gtk_recent_chooser_default_list_filters (GtkRecentChooser *chooser)
   return g_slist_copy (impl->filters);
 }
 
-static gboolean
-get_is_recent_filtered (GtkRecentChooserDefault *impl,
-                       GtkRecentInfo           *info)
-{
-  GtkRecentFilter *current_filter;
-  GtkRecentFilterInfo filter_info;
-  GtkRecentFilterFlags needed;
-  gboolean retval;
-
-  g_assert (info != NULL);
-  
-  if (!impl->current_filter)
-    return FALSE;
-  
-  current_filter = impl->current_filter;
-  needed = gtk_recent_filter_get_needed (current_filter);
-  
-  filter_info.contains = GTK_RECENT_FILTER_URI | GTK_RECENT_FILTER_MIME_TYPE;
-  
-  filter_info.uri = gtk_recent_info_get_uri (info);
-  filter_info.mime_type = gtk_recent_info_get_mime_type (info);
-  
-  if (needed & GTK_RECENT_FILTER_DISPLAY_NAME)
-    {
-      filter_info.display_name = gtk_recent_info_get_display_name (info);
-      filter_info.contains |= GTK_RECENT_FILTER_DISPLAY_NAME;
-    }
-  else
-    filter_info.uri = NULL;
-  
-  if (needed & GTK_RECENT_FILTER_APPLICATION)
-    {
-      filter_info.applications = (const gchar **) gtk_recent_info_get_applications (info, NULL);
-      filter_info.contains |= GTK_RECENT_FILTER_APPLICATION;
-    }
-  else
-    filter_info.applications = NULL;
-
-  if (needed & GTK_RECENT_FILTER_GROUP)
-    {
-      filter_info.groups = (const gchar **) gtk_recent_info_get_groups (info, NULL);
-      filter_info.contains |= GTK_RECENT_FILTER_GROUP;
-    }
-  else
-    filter_info.groups = NULL;
-
-  if (needed & GTK_RECENT_FILTER_AGE)
-    {
-      filter_info.age = gtk_recent_info_get_age (info);
-      filter_info.contains |= GTK_RECENT_FILTER_AGE;
-    }
-  else
-    filter_info.age = -1;
-  
-  retval = gtk_recent_filter_filter (current_filter, &filter_info);
-  
-  /* this we own */
-  if (filter_info.applications)
-    g_strfreev ((gchar **) filter_info.applications);
-  if (filter_info.groups)
-    g_strfreev ((gchar **) filter_info.groups);
-  
-  return !retval;
-}
-
-static gboolean
-recent_store_filter_func (GtkTreeModel *model,
-                          GtkTreeIter  *iter,
-                          gpointer      user_data)
-{
-  GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data);
-  GtkRecentInfo *info = NULL;
-
-  if (!impl->current_filter)
-    return TRUE;
-  
-  gtk_tree_model_get (model, iter,
-                      RECENT_INFO_COLUMN, &info,
-                      -1);
-  if (!info)
-    return TRUE;
-    
-  if (get_is_recent_filtered (impl, info))
-    return FALSE;
-  
-  if (impl->local_only && !gtk_recent_info_is_local (info))
-    return FALSE;
-  
-  if ((!impl->show_private) && gtk_recent_info_get_private_hint (info))
-    return FALSE;
-  
-  if ((!impl->show_not_found) && !gtk_recent_info_exists (info))
-    return FALSE;
-      
-  return TRUE;
-}
-
 static void
 set_current_filter (GtkRecentChooserDefault *impl,
                    GtkRecentFilter         *filter)
@@ -1557,15 +1371,27 @@ set_current_filter (GtkRecentChooserDefault *impl,
         gtk_combo_box_set_active (GTK_COMBO_BOX (impl->filter_combo),
                                   filter_idx);
       
-      if (impl->recent_store && impl->recent_store_filter)
-        {
-          gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->recent_store_filter));
-        }
-      
+      if (impl->recent_store)
+        reload_recent_items (impl);
+
       g_object_notify (G_OBJECT (impl), "filter");
     }
 }
 
+static void
+chooser_set_sort_type (GtkRecentChooserDefault *impl,
+                      GtkRecentSortType        sort_type)
+{
+  if (impl->sort_type != sort_type)
+    {
+      impl->sort_type = sort_type;
+      reload_recent_items (impl);
+
+      g_object_notify (G_OBJECT (impl), "sort-type");
+    }
+}
+
+
 static GtkIconTheme *
 get_icon_theme_for_widget (GtkWidget *widget)
 {
@@ -1594,6 +1420,21 @@ get_icon_size_for_widget (GtkWidget   *widget,
   return FALLBACK_ICON_SIZE;
 }
 
+static gint
+get_recent_files_limit (GtkWidget *widget)
+{
+  GtkSettings *settings;
+  gint limit;
+
+  if (gtk_widget_has_screen (widget))
+    settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
+  else
+    settings = gtk_settings_get_default ();
+  
+  g_object_get (G_OBJECT (settings), "gtk-recent-files-limit", &limit, NULL);
+
+  return limit;
+}
 
 static void
 recent_manager_changed_cb (GtkRecentManager *manager,
@@ -1716,28 +1557,73 @@ recent_view_drag_data_get_cb (GtkWidget        *widget,
                              gpointer          data)
 {
   GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (data);
-  DragData *drag_data;
+  DragData drag_data;
   gsize n_uris;
   
   n_uris = gtk_tree_selection_count_selected_rows (impl->selection);
   if (n_uris == 0)
-         return;
+    return;
 
-  drag_data = g_new (DragData, 1);
-  drag_data->uri_list = g_new0 (gchar *, n_uris + 1);
-  drag_data->next_pos = 0;
+  drag_data.uri_list = g_new0 (gchar *, n_uris + 1);
+  drag_data.next_pos = 0;
   
   gtk_tree_selection_selected_foreach (impl->selection,
                                       append_uri_to_urilist,
-                                      drag_data);
+                                      &drag_data);
   
-  gtk_selection_data_set_uris (selection_data, drag_data->uri_list);
+  gtk_selection_data_set_uris (selection_data, drag_data.uri_list);
 
-  g_strfreev (drag_data->uri_list);
-  g_free (drag_data);
+  g_strfreev (drag_data.uri_list);
 }
 
+static gboolean
+recent_view_query_tooltip_cb (GtkWidget  *widget,
+                              gint        x,
+                              gint        y,
+                              gboolean    keyboard_tip,
+                              GtkTooltip *tooltip,
+                              gpointer    user_data)
+{
+  GtkRecentChooserDefault *impl = user_data;
+  GtkTreeView *tree_view;
+  GtkTreeIter iter;
+  GtkTreePath *path = NULL;
+  GtkRecentInfo *info = NULL;
+  gchar *uri_display;
+
+  if (!impl->show_tips)
+    return FALSE;
 
+  tree_view = GTK_TREE_VIEW (impl->recent_view);
+
+  gtk_tree_view_get_tooltip_context (tree_view,
+                                     &x, &y,
+                                     keyboard_tip,
+                                     NULL, &path, NULL);
+  if (!path)
+    return FALSE;
+
+  if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->recent_store), &iter, path))
+    {
+      gtk_tree_path_free (path);
+      return FALSE;
+    }
+
+  gtk_tree_model_get (GTK_TREE_MODEL (impl->recent_store), &iter,
+                      RECENT_INFO_COLUMN, &info,
+                      -1);
+
+  uri_display = gtk_recent_info_get_uri_display (info);
+  
+  gtk_tooltip_set_text (tooltip, uri_display);
+  gtk_tree_view_set_tooltip_row (tree_view, tooltip, path);
+
+  g_free (uri_display);
+  gtk_tree_path_free (path);
+  gtk_recent_info_unref (info);
+
+  return TRUE;
+}
 
 static void
 remove_selected_from_list (GtkRecentChooserDefault *impl)
@@ -1757,7 +1643,7 @@ remove_selected_from_list (GtkRecentChooserDefault *impl)
     {
       gchar *msg;
    
-      msg = strdup (_("Could not remove item"));
+      msg = g_strdup (_("Could not remove item"));
       error_message (impl, msg, err->message);
       
       g_free (msg);
@@ -1785,6 +1671,7 @@ copy_activated_cb (GtkMenuItem *menu_item,
                                                    GDK_SELECTION_CLIPBOARD),
                           utf8_uri, -1);
 
+  gtk_recent_info_unref (info);
   g_free (utf8_uri);
 }
 
@@ -1939,25 +1826,29 @@ popup_position_func (GtkMenu   *menu,
                      gboolean  *push_in,
                      gpointer  user_data)
 {
+  GtkAllocation allocation;
   GtkWidget *widget = GTK_WIDGET (user_data);
   GdkScreen *screen = gtk_widget_get_screen (widget);
   GtkRequisition req;
   gint monitor_num;
   GdkRectangle monitor;
 
-  if (G_UNLIKELY (!GTK_WIDGET_REALIZED (widget)))
+  if (G_UNLIKELY (!gtk_widget_get_realized (widget)))
     return;
 
-  gdk_window_get_origin (widget->window, x, y);
+  gdk_window_get_origin (gtk_widget_get_window (widget),
+                         x, y);
 
-  gtk_widget_size_request (GTK_WIDGET (menu), &req);
+  gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+                                 &req, NULL);
 
-  *x += (widget->allocation.width - req.width) / 2;
-  *y += (widget->allocation.height - req.height) / 2;
+  gtk_widget_get_allocation (widget, &allocation);
+  *x += (allocation.width - req.width) / 2;
+  *y += (allocation.height - req.height) / 2;
 
   monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
   gtk_menu_set_monitor (menu, monitor_num);
-  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+  gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
 
   *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
   *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
@@ -2001,8 +1892,8 @@ recent_view_button_press_cb (GtkWidget      *widget,
                             gpointer        user_data)
 {
   GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data);
-  
-  if (event->button == 3)
+
+  if (gdk_event_triggers_context_menu ((GdkEvent *) event))
     {
       GtkTreePath *path;
       gboolean res;
@@ -2035,8 +1926,11 @@ set_recent_manager (GtkRecentChooserDefault *impl,
 {
   if (impl->manager)
     {
-      g_signal_handler_disconnect (impl, impl->manager_changed_id);
-      impl->manager_changed_id = 0;
+      if (impl->manager_changed_id)
+        {
+          g_signal_handler_disconnect (impl, impl->manager_changed_id);
+          impl->manager_changed_id = 0;
+        }
 
       impl->manager = NULL;
     }
@@ -2047,11 +1941,51 @@ set_recent_manager (GtkRecentChooserDefault *impl,
     impl->manager = gtk_recent_manager_get_default ();
   
   if (impl->manager)
-    impl->manager_changed_id = g_signal_connect (impl->manager, "changed",
-                                                G_CALLBACK (recent_manager_changed_cb),
-                                                impl);
+    {
+      impl->manager_changed_id = g_signal_connect (impl->manager, "changed",
+                                                   G_CALLBACK (recent_manager_changed_cb),
+                                                   impl);
+    }
 }
 
+static void
+gtk_recent_chooser_update (GtkActivatable *activatable,
+                          GtkAction      *action,
+                          const gchar    *property_name)
+{
+  if (strcmp (property_name, "visible") == 0)
+    {
+      if (gtk_action_is_visible (action))
+       gtk_widget_show (GTK_WIDGET (activatable));
+      else
+       gtk_widget_hide (GTK_WIDGET (activatable));
+    }
+
+  if (strcmp (property_name, "sensitive") == 0)
+    gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
+
+  _gtk_recent_chooser_update (activatable, action, property_name);
+}
+
+
+static void 
+gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
+                                          GtkAction      *action)
+{
+  if (action)
+    {
+      if (gtk_action_is_visible (action))
+       gtk_widget_show (GTK_WIDGET (activatable));
+      else
+       gtk_widget_hide (GTK_WIDGET (activatable));
+      
+      gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
+    }
+
+  _gtk_recent_chooser_sync_action_properties (activatable, action);
+}
+
+
 GtkWidget *
 _gtk_recent_chooser_default_new (GtkRecentManager *manager)
 {