Bugzilla – Attachment 206381 Details for
Bug 230478
main-menu: pointless thumbnailing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Forgot Password
[patch]
gnome-main-menu-bnc230478-bnc364186-bnc350662-performance.diff
gnome-main-menu-bnc230478-bnc364186-bnc350662-performance.diff (text/plain), 30.22 KB, created by
Federico Mena Quintero
on 2008-04-05 05:00:54 UTC
(
hide
)
Description:
gnome-main-menu-bnc230478-bnc364186-bnc350662-performance.diff
Filename:
MIME Type:
Creator:
Federico Mena Quintero
Created:
2008-04-05 05:00:54 UTC
Size:
30.22 KB
patch
obsolete
>2008-04-04 Federico Mena Quintero <federico@novell.com> > > https://bugzilla.novell.com/show_bug.cgi?id=230478 - Pointless thumbnailing > https://bugzilla.novell.com/show_bug.cgi?id=364186 - Main menu leaks > > * main-menu/src/main-menu-ui.c: Monitor the recent-files store on > our own, and update the BookmarkAgents for recent-docs and > recent-apps from a single GBookmarkFile. This prevents each agent > from loading the recent-files on its own. > > * main-menu/src/main-menu-ui.c: Don't load the recent-files store > at startup, but do it in an idle. This makes the applet start up > more quickly, and then we can effectively use the idle time > between the applet hitting the main loop initially and the user > activating the Computer menu. > > * main-menu/src/main-menu-ui.c: Throttle updates to the > recent-files store if it changes frequently, to avoid CPU churn > when an app updates ~/.recently-used.xbel many times in rapid > succession. > > * main-menu/src/main-menu.c (main_menu_applet_init): Preinit the > global thumbnail factory here; it will get loaded in an idle > handler after the applet hits the main loop. > >2008-04-04 Magnus Boman <captain.magnus@gmail.com> > > https://bugzilla.novell.com/show_bug.cgi?id=350662 - Improve > startup time by loading tile tables only once. > > * main-menu/src/main-menu-ui.c (apply_lockdown_settings): Reload > the recent-documents table here. > (main_menu_ui_new): Don't call update_limits() here; it gets > called already in apply_lockdown_settings(). > > * main-menu/src/tile-table.c (tile_table_new): Don't reload the > tile table immediately here. > >diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c >index 291212b..db97134 100644 >--- a/libslab/bookmark-agent.c >+++ b/libslab/bookmark-agent.c >@@ -121,9 +121,7 @@ static void set_rank (BookmarkAgent *, const gchar *, gint); > > static void load_xbel_store (BookmarkAgent *); > static void load_places_store (BookmarkAgent *); >-static void load_recent_store (BookmarkAgent *); > static void update_user_spec_path (BookmarkAgent *); >-static void update_recent_store_path (BookmarkAgent *); > static void save_xbel_store (BookmarkAgent *); > static void create_app_item (BookmarkAgent *, const gchar *); > static void create_doc_item (BookmarkAgent *, const gchar *); >@@ -321,6 +319,85 @@ bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris) > save_store (this); > } > >+static GList * >+make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store) >+{ >+ BookmarkAgentPrivate *priv = PRIVATE (this); >+ gchar **uris; >+ gint i; >+ GList *items_ordered; >+ >+ if (!store) >+ return NULL; >+ >+ uris = g_bookmark_file_get_uris (store, NULL); >+ items_ordered = NULL; >+ >+ for (i = 0; uris && uris [i]; ++i) { >+ gboolean include; >+ >+ if (priv->type == BOOKMARK_STORE_RECENT_APPS) >+ include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL); >+ else >+ include = ! g_bookmark_file_get_is_private (store, uris [i], NULL); >+ >+ if (include) { >+ BookmarkItem *item; >+ >+ item = g_new0 (BookmarkItem, 1); >+ >+ item->uri = g_strdup (uris [i]); >+ item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL); >+ item->mtime = g_bookmark_file_get_modified (store, uris [i], NULL); >+ >+ items_ordered = g_list_prepend (items_ordered, item); >+ } >+ } >+ >+ items_ordered = g_list_sort (items_ordered, recent_item_mru_comp_func); >+ >+ g_strfreev (uris); >+ >+ return items_ordered; >+} >+ >+void >+bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store) >+{ >+ BookmarkAgentPrivate *priv; >+ GList *items_ordered; >+ GList *node; >+ >+ g_return_if_fail (IS_BOOKMARK_AGENT (this)); >+ >+ priv = PRIVATE (this); >+ >+ libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): start updating"); >+ >+ items_ordered = make_items_from_bookmark_file (this, store); >+ >+ g_bookmark_file_free (priv->store); >+ priv->store = g_bookmark_file_new (); >+ >+ for (node = items_ordered; node; node = node->next) { >+ BookmarkItem *item; >+ >+ item = (BookmarkItem *) node->data; >+ >+ g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type); >+ g_bookmark_file_set_modified (priv->store, item->uri, item->mtime); >+ >+ bookmark_item_free (item); >+ } >+ >+ g_list_free (items_ordered); >+ >+ libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): updating internal items"); >+ update_items (this); >+ >+ libslab_checkpoint ("bookmark_agent_update_from_bookmark_file(): end updating"); >+} >+ > void > bookmark_item_free (BookmarkItem *item) > { >@@ -465,13 +542,6 @@ bookmark_agent_new (BookmarkStoreType type) > priv->store_path = g_build_filename (g_get_home_dir (), ".recently-used", NULL); > #endif > >- gnome_vfs_monitor_add ( >- & priv->store_monitor, priv->store_path, >- GNOME_VFS_MONITOR_FILE, store_monitor_cb, this); >- >- priv->update_path = update_recent_store_path; >- priv->load_store = load_recent_store; >- > break; > > case BOOKMARK_STORE_SYSTEM: >@@ -572,8 +642,11 @@ update_agent (BookmarkAgent *this) > { > BookmarkAgentPrivate *priv = PRIVATE (this); > >- priv->update_path (this); >- priv->load_store (this); >+ if (priv->update_path) >+ priv->update_path (this); >+ >+ if (priv->load_store) >+ priv->load_store (this); > > update_items (this); > } >@@ -665,7 +738,11 @@ update_items (BookmarkAgent *this) > g_bookmark_file_get_icon (priv->store, uris_ordered [i], & priv->items [i]->icon, NULL, NULL); > } > >- g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_ITEMS_PROP); >+ /* Since the bookmark store for recently-used items is updated by the caller of BookmarkAgent, >+ * we don't emit notifications in that case. The caller will know when to update itself. >+ */ >+ if (!TYPE_IS_RECENT (priv->type)) >+ g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_ITEMS_PROP); > } > > if (store_corrupted) >@@ -766,9 +843,17 @@ load_xbel_store (BookmarkAgent *this) > GError *error = NULL; > > gint i; >+ gboolean success; > >+ if (!priv->store_path) >+ success = FALSE; >+ else { >+ libslab_checkpoint ("load_xbel_store(): start loading %s", priv->store_path); >+ success = g_bookmark_file_load_from_file (priv->store, priv->store_path, & error); >+ libslab_checkpoint ("load_xbel_store(): end loading %s", priv->store_path); >+ } > >- if (! (priv->store_path && g_bookmark_file_load_from_file (priv->store, priv->store_path, & error))) { >+ if (!success) { > g_bookmark_file_free (priv->store); > priv->store = g_bookmark_file_new (); > >@@ -779,10 +864,14 @@ load_xbel_store (BookmarkAgent *this) > return; > } > >+ libslab_checkpoint ("load_xbel_store(): start creating items from %s", priv->store_path); >+ > uris = g_bookmark_file_get_uris (priv->store, NULL); > > for (i = 0; uris && uris [i]; ++i) > priv->create_item (this, uris [i]); >+ >+ libslab_checkpoint ("load_xbel_store(): end creating items from %s", priv->store_path); > } > > static void >@@ -847,62 +936,6 @@ load_places_store (BookmarkAgent *this) > g_strfreev (bookmarks); > } > >-static void >-load_recent_store (BookmarkAgent *this) >-{ >- BookmarkAgentPrivate *priv = PRIVATE (this); >- >- GBookmarkFile *store; >- >- gchar **uris = NULL; >- GList *items_ordered = NULL; >- >- BookmarkItem *item; >- >- gboolean include; >- >- gint i; >- GList *node; >- >- >- store = g_bookmark_file_new (); >- g_bookmark_file_load_from_file (store, priv->store_path, NULL); >- >- uris = g_bookmark_file_get_uris (store, NULL); >- >- for (i = 0; uris && uris [i]; ++i) { >- if (priv->type == BOOKMARK_STORE_RECENT_APPS) >- include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL); >- else >- include = ! g_bookmark_file_get_is_private (store, uris [i], NULL); >- >- if (include) { >- item = g_new0 (BookmarkItem, 1); >- >- item->uri = g_strdup (uris [i]); >- item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL); >- item->mtime = g_bookmark_file_get_modified (store, uris [i], NULL); >- >- items_ordered = g_list_insert_sorted (items_ordered, item, recent_item_mru_comp_func); >- } >- } >- >- g_strfreev (uris); >- g_bookmark_file_free (store); >- >- g_bookmark_file_free (priv->store); >- priv->store = g_bookmark_file_new (); >- >- for (node = items_ordered; node; node = node->next) { >- item = (BookmarkItem *) node->data; >- >- g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type); >- g_bookmark_file_set_modified (priv->store, item->uri, item->mtime); >- >- bookmark_item_free (item); >- } >-} >- > static gchar * > find_package_data_file (const gchar *filename) > { >@@ -984,25 +1017,6 @@ update_user_spec_path (BookmarkAgent *this) > } > > static void >-update_recent_store_path (BookmarkAgent *this) >-{ >- BookmarkAgentPrivate *priv = PRIVATE (this); >- >- BookmarkStoreStatus status; >- >- >- if (g_file_test (priv->store_path, G_FILE_TEST_EXISTS)) >- status = BOOKMARK_STORE_USER; >- else >- status = BOOKMARK_STORE_USER; >- >- if (priv->status != status) { >- priv->status = status; >- g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_STORE_STATUS_PROP); >- } >-} >- >-static void > save_xbel_store (BookmarkAgent *this) > { > BookmarkAgentPrivate *priv = PRIVATE (this); >diff --git a/libslab/bookmark-agent.h b/libslab/bookmark-agent.h >index 1f90882..391389e 100644 >--- a/libslab/bookmark-agent.h >+++ b/libslab/bookmark-agent.h >@@ -80,6 +80,8 @@ void bookmark_agent_move_item (BookmarkAgent *this, const gchar *u > void bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri); > void bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris); > >+void bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store); >+ > void bookmark_item_free (BookmarkItem *item); > > G_END_DECLS >diff --git a/libslab/document-tile.c b/libslab/document-tile.c >index a90624a..ab2cd71 100644 >--- a/libslab/document-tile.c >+++ b/libslab/document-tile.c >@@ -94,8 +94,6 @@ typedef struct > gulong notify_signal_id; > } DocumentTilePrivate; > >-static GnomeThumbnailFactory *thumbnail_factory = NULL; >- > #define DOCUMENT_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DOCUMENT_TILE_TYPE, DocumentTilePrivate)) > > static void document_tile_class_init (DocumentTileClass *this_class) >@@ -137,6 +135,8 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified) > > gchar *filename; > gchar *tooltip_text; >+ >+ libslab_checkpoint ("document_tile_new(): start"); > > uri = g_strdup (in_uri); > >@@ -293,8 +293,6 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified) > > gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu)); > >- load_image (this); >- > accessible = gtk_widget_get_accessible (GTK_WIDGET (this)); > if (basename) > atk_object_set_name (accessible, basename); >@@ -304,6 +302,8 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified) > g_free (basename); > g_free (time_str); > >+ libslab_checkpoint ("document_tile_new(): end"); >+ > return GTK_WIDGET (this); > } > >@@ -417,6 +417,9 @@ load_image (DocumentTile *tile) > > gchar *icon_id = NULL; > gboolean free_icon_id = TRUE; >+ GnomeThumbnailFactory *thumbnail_factory; >+ >+ libslab_checkpoint ("document-tile.c: load_image(): start for %s", TILE (tile)->uri); > > if (! priv->mime_type || ! strstr (TILE (tile)->uri, "file://")) { > icon_id = "gnome-fs-regular"; >@@ -425,8 +428,7 @@ load_image (DocumentTile *tile) > goto exit; > } > >- if (! thumbnail_factory) >- thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL); >+ thumbnail_factory = libslab_thumbnail_factory_get (); > > thumb_path = gnome_thumbnail_factory_lookup (thumbnail_factory, TILE (tile)->uri, priv->modified); > >@@ -467,6 +469,8 @@ exit: > > if (free_icon_id && icon_id) > g_free (icon_id); >+ >+ libslab_checkpoint ("document-tile.c: load_image(): end"); > } > > /* Next function taken from e-data-server-util.c in evolution-data-server */ >diff --git a/libslab/libslab-utils.c b/libslab/libslab-utils.c >index c664a88..c43ac92 100644 >--- a/libslab/libslab-utils.c >+++ b/libslab/libslab-utils.c >@@ -5,12 +5,20 @@ > #endif > > #include <string.h> >+#include <stdio.h> >+#include <unistd.h> >+#include <time.h> >+#include <sys/stat.h> >+#include <sys/resource.h> >+#include <sys/time.h> > #include <gconf/gconf-value.h> > #include <libgnome/gnome-url.h> > > #define DESKTOP_ITEM_TERMINAL_EMULATOR_FLAG "TerminalEmulator" > #define ALTERNATE_DOCPATH_KEY "DocPath" > >+static FILE *checkpoint_file; >+ > gboolean > libslab_gtk_image_set_by_id (GtkImage *image, const gchar *id) > { >@@ -562,3 +570,121 @@ libslab_spawn_command (const gchar *cmd) > > g_strfreev (argv); > } >+ >+static guint thumbnail_factory_idle_id; >+static GnomeThumbnailFactory *thumbnail_factory; >+ >+static void >+create_thumbnail_factory (void) >+{ >+ libslab_checkpoint ("create_thumbnail_factory(): start"); >+ >+ g_assert (thumbnail_factory == NULL); >+ thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL); >+ >+ libslab_checkpoint ("create_thumbnail_factory(): end"); >+} >+ >+static gboolean >+init_thumbnail_factory_idle_cb (gpointer data) >+{ >+ create_thumbnail_factory (); >+ thumbnail_factory_idle_id = 0; >+ return FALSE; >+} >+ >+void >+libslab_thumbnail_factory_preinit (void) >+{ >+ thumbnail_factory_idle_id = g_idle_add (init_thumbnail_factory_idle_cb, NULL); >+} >+ >+GnomeThumbnailFactory * >+libslab_thumbnail_factory_get (void) >+{ >+ if (thumbnail_factory_idle_id != 0) { >+ g_source_remove (thumbnail_factory_idle_id); >+ thumbnail_factory_idle_id = 0; >+ >+ create_thumbnail_factory (); >+ } >+ >+ g_assert (thumbnail_factory != NULL); >+ return thumbnail_factory; >+} >+ >+void >+libslab_checkpoint_init (const char *checkpoint_config_file_basename, >+ const char *checkpoint_file_basename) >+{ >+ char *filename; >+ struct stat st; >+ int result; >+ time_t t; >+ struct tm tm; >+ char *checkpoint_full_basename; >+ >+ g_return_if_fail (checkpoint_config_file_basename != NULL); >+ g_return_if_fail (checkpoint_file_basename != NULL); >+ >+ filename = g_build_filename (g_get_home_dir (), checkpoint_config_file_basename, NULL); >+ >+ result = stat (filename, &st); >+ g_free (filename); >+ >+ if (result != 0) >+ return; >+ >+ t = time (NULL); >+ tm = *localtime (&t); >+ >+ checkpoint_full_basename = g_strdup_printf ("%s-%04d-%02d-%02d-%02d-%02d-%02d.checkpoint", >+ checkpoint_file_basename, >+ tm.tm_year + 1900, >+ tm.tm_mon + 1, >+ tm.tm_mday, >+ tm.tm_hour, >+ tm.tm_min, >+ tm.tm_sec); >+ >+ filename = g_build_filename (g_get_home_dir (), checkpoint_full_basename, NULL); >+ g_free (checkpoint_full_basename); >+ >+ checkpoint_file = fopen (filename, "w"); >+ g_free (filename); >+} >+ >+void >+libslab_checkpoint (const char *format, ...) >+{ >+ va_list args; >+ struct timeval tv; >+ struct tm tm; >+ struct rusage rusage; >+ >+ if (!checkpoint_file) >+ return; >+ >+ gettimeofday (&tv, NULL); >+ tm = *localtime (&tv.tv_sec); >+ >+ getrusage (RUSAGE_SELF, &rusage); >+ >+ fprintf (checkpoint_file, >+ "%02d:%02d:%02d.%04d (user:%d.%04d, sys:%d.%04d) - ", >+ (int) tm.tm_hour, >+ (int) tm.tm_min, >+ (int) tm.tm_sec, >+ (int) (tv.tv_usec / 100), >+ (int) rusage.ru_utime.tv_sec, >+ (int) (rusage.ru_utime.tv_usec / 100), >+ (int) rusage.ru_stime.tv_sec, >+ (int) (rusage.ru_stime.tv_usec / 100)); >+ >+ va_start (args, format); >+ vfprintf (checkpoint_file, format, args); >+ va_end (args); >+ >+ fputs ("\n", checkpoint_file); >+ fflush (checkpoint_file); >+} >diff --git a/libslab/libslab-utils.h b/libslab/libslab-utils.h >index b20e29f..ee0cdc8 100644 >--- a/libslab/libslab-utils.h >+++ b/libslab/libslab-utils.h >@@ -5,6 +5,7 @@ > #include <gtk/gtk.h> > #include <gconf/gconf-client.h> > #include <libgnome/gnome-desktop-item.h> >+#include <libgnomeui/gnome-thumbnail.h> > > G_BEGIN_DECLS > >@@ -27,6 +28,12 @@ gboolean libslab_desktop_item_is_lockscreen (const gchar *uri); > gchar *libslab_string_replace_once (const gchar *string, const gchar *key, const gchar *value); > void libslab_spawn_command (const gchar *cmd); > >+void libslab_thumbnail_factory_preinit (void); >+GnomeThumbnailFactory *libslab_thumbnail_factory_get (void); >+ >+void libslab_checkpoint_init (const char *checkpoint_config_file_basename, const char *checkpoint_file_basename); >+void libslab_checkpoint (const char *format, ...); >+ > G_END_DECLS > > #endif >diff --git a/main-menu/src/main-menu-ui.c b/main-menu/src/main-menu-ui.c >index 71cf99d..50643a3 100644 >--- a/main-menu/src/main-menu-ui.c >+++ b/main-menu/src/main-menu-ui.c >@@ -36,6 +36,11 @@ > #include <libgnomevfs/gnome-vfs.h> > #include <libgnomevfs/gnome-vfs-mime-handlers.h> > >+#include <gtk/gtkversion.h> >+#if GTK_CHECK_VERSION (2, 10, 0) >+# define USE_GTK_RECENT_MANAGER >+#endif >+ > #include "tile.h" > #include "application-tile.h" > #include "document-tile.h" >@@ -119,6 +124,9 @@ typedef struct { > GnomeVFSVolumeMonitor *volume_mon; > GList *mounts; > >+ guint recently_used_throttle_timeout_id; >+ GnomeVFSMonitorHandle *recently_used_store_monitor; >+ > guint search_cmd_gconf_mntr_id; > guint current_page_gconf_mntr_id; > guint more_link_vis_gconf_mntr_id; >@@ -136,6 +144,8 @@ typedef struct { > > gboolean ptr_is_grabbed; > gboolean kbd_is_grabbed; >+ >+ guint recently_used_store_has_changed : 1; > } MainMenuUIPrivate; > > #define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MAIN_MENU_UI_TYPE, MainMenuUIPrivate)) >@@ -157,6 +167,8 @@ static void create_more_buttons (MainMenuUI *); > static void setup_file_tables (MainMenuUI *); > static void setup_bookmark_agents (MainMenuUI *); > static void setup_lock_down (MainMenuUI *); >+static void setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup); >+static void update_recently_used_sections (MainMenuUI *this); > > static void select_page (MainMenuUI *); > static void update_limits (MainMenuUI *); >@@ -277,25 +289,44 @@ main_menu_ui_new (PanelApplet *applet) > priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL); > g_free (glade_xml_path); > >+ libslab_checkpoint ("main_menu_ui_new(): setup_recently_used_store_monitor"); >+ setup_recently_used_store_monitor (this, TRUE); >+ libslab_checkpoint ("main_menu_ui_new(): setup_bookmark_agents"); > setup_bookmark_agents (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_panel_button"); > create_panel_button (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_slab_window"); > create_slab_window (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_search_section"); > create_search_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_file_section"); > create_file_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_user_apps_section"); > create_user_apps_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_rct_apps_section"); > create_rct_apps_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_user_docs_section"); > create_user_docs_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_rct_docs_section"); > create_rct_docs_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_user_dirs_section"); > create_user_dirs_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_system_section"); > create_system_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_status_section"); > create_status_section (this); >+ libslab_checkpoint ("main_menu_ui_new(): create_more_buttons"); > create_more_buttons (this); >+ libslab_checkpoint ("main_menu_ui_new(): setup_file_tables"); > setup_file_tables (this); >+ libslab_checkpoint ("main_menu_ui_new(): setup_lock_down"); > setup_lock_down (this); > >+ libslab_checkpoint ("main_menu_ui_new(): bind_beagle_search_key"); > bind_beagle_search_key (this); >- update_limits (this); >+ libslab_checkpoint ("main_menu_ui_new(): select_page"); > select_page (this); >+ libslab_checkpoint ("main_menu_ui_new(): apply_lockdown_settings"); > apply_lockdown_settings (this); > > return this; >@@ -404,6 +435,11 @@ main_menu_ui_finalize (GObject *g_obj) > > gint i; > >+ if (priv->recently_used_store_monitor) >+ gnome_vfs_monitor_cancel (priv->recently_used_store_monitor); >+ >+ if (priv->recently_used_throttle_timeout_id) >+ g_source_remove (priv->recently_used_throttle_timeout_id); > > for (i = 0; i < 4; ++i) { > g_object_unref (G_OBJECT (g_object_get_data ( >@@ -921,6 +957,104 @@ setup_lock_down (MainMenuUI *this) > DISABLE_LOCKSCREEN_GCONF_KEY, lockdown_notify_cb, this); > } > >+static char * >+get_recently_used_store_filename (void) >+{ >+ const char *basename; >+ >+#ifdef USE_GTK_RECENT_MANAGER >+ basename = ".recently-used.xbel"; >+#else >+ basename = ".recently-used"; >+#endif >+ >+ return g_build_filename (g_get_home_dir (), basename, NULL); >+} >+ >+static gboolean >+recently_used_throttle_timeout_cb (gpointer data) >+{ >+ MainMenuUI *this = MAIN_MENU_UI (data); >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ >+ update_recently_used_sections (this); >+ >+ priv->recently_used_throttle_timeout_id = 0; >+ >+ return FALSE; >+} >+ >+#define RECENTLY_USED_STORE_THROTTLE_SECONDS 2 >+ >+static void >+setup_recently_used_throttle_timeout (MainMenuUI *this, gboolean is_startup) >+{ >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ >+ if (priv->recently_used_throttle_timeout_id != 0) >+ g_source_remove (priv->recently_used_throttle_timeout_id); >+ >+ /* Some apps do many updates to the recently-used store quickly, like >+ * when Nautilus or EOG are asked to open a bunch of files at the same >+ * time. So, we throttle our updates to the recently-used store to >+ * avoid re-reading the store more times than needed. >+ * >+ * Additionally, we do this in an idle during startup, not a timeout, >+ * so that the Computer menu will be up to date as soon as possible. >+ */ >+ if (is_startup) >+ priv->recently_used_throttle_timeout_id = g_idle_add (recently_used_throttle_timeout_cb, this); >+ else >+ priv->recently_used_throttle_timeout_id = g_timeout_add_seconds (RECENTLY_USED_STORE_THROTTLE_SECONDS, >+ recently_used_throttle_timeout_cb, >+ this); >+} >+ >+/* Called from GnomeVFSMonitor when the recently-used store changes. We'll note >+ * this in a flag, and we'll check that flag later, when it is necessary to have >+ * an up-to-date view of the recently-used store. >+ */ >+static void recently_used_store_monitor_changed_cb (GnomeVFSMonitorHandle *handle, >+ const gchar *monitor_uri, >+ const gchar *info_uri, >+ GnomeVFSMonitorEventType event_type, >+ gpointer data) >+{ >+ MainMenuUI *this = MAIN_MENU_UI (data); >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ >+ priv->recently_used_store_has_changed = TRUE; >+ setup_recently_used_throttle_timeout (this, FALSE); >+} >+ >+/* Creates a GnomeVFSMonitor for the recently-used store, so we can be informed >+ * when the store changes. >+ */ >+static void >+setup_recently_used_store_monitor (MainMenuUI *this, gboolean is_startup) >+{ >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ char *filename; >+ char *uri; >+ >+ priv->recently_used_store_has_changed = TRUE; /* ensure the store gets read the first time we need it */ >+ >+ filename = get_recently_used_store_filename (); >+ uri = g_strconcat ("file://", filename, NULL); >+ g_free (filename); >+ >+ if (gnome_vfs_monitor_add (&priv->recently_used_store_monitor, >+ uri, >+ GNOME_VFS_MONITOR_FILE, >+ recently_used_store_monitor_changed_cb, >+ this) != GNOME_VFS_OK) >+ priv->recently_used_store_monitor = NULL; >+ >+ g_free (uri); >+ >+ setup_recently_used_throttle_timeout (this, is_startup); >+} >+ > static Tile * > item_to_user_app_tile (BookmarkItem *item, gpointer data) > { >@@ -1492,6 +1626,7 @@ apply_lockdown_settings (MainMenuUI *this) > GList *node; > gint i; > >+ libslab_checkpoint ("apply_lockdown_settings(): start"); > > more_link_visible = GPOINTER_TO_INT (libslab_get_gconf_value (MORE_LINK_VIS_GCONF_KEY)); > status_area_visible = GPOINTER_TO_INT (libslab_get_gconf_value (STATUS_VIS_GCONF_KEY)); >@@ -1531,13 +1666,22 @@ apply_lockdown_settings (MainMenuUI *this) > for (i = 0; i < 5; ++i) > set_table_section_visible (this, priv->file_tables [i]); > >+ libslab_checkpoint ("apply_lockdown_settings(): loading sys_table"); > tile_table_reload (priv->sys_table); >+ >+ libslab_checkpoint ("apply_lockdown_settings(): loading user_apps_table"); > tile_table_reload (priv->file_tables [USER_APPS_TABLE]); >- tile_table_reload (priv->file_tables [RCNT_APPS_TABLE]); >+ >+ libslab_checkpoint ("apply_lockdown_settings(): loading user_docs_table"); > tile_table_reload (priv->file_tables [USER_DOCS_TABLE]); >+ >+ libslab_checkpoint ("apply_lockdown_settings(): loading user_dirs_table"); > tile_table_reload (priv->file_tables [USER_DIRS_TABLE]); > >+ libslab_checkpoint ("apply_lockdown_settings(): update_limits"); > update_limits (this); >+ >+ libslab_checkpoint ("apply_lockdown_settings(): end"); > } > > static void >@@ -1616,6 +1760,92 @@ exit: > xmlFreeDoc (doc); > } > >+static GBookmarkFile * >+load_recently_used_store (void) >+{ >+ GBookmarkFile *store; >+ char *filename; >+ >+ store = g_bookmark_file_new (); >+ >+ filename = get_recently_used_store_filename (); >+ >+ /* FIXME: if we can't load the store, do we need to hide the >+ * recently-used sections in the GUI? If so, do that in the caller(s) >+ * of this function, not here. >+ */ >+ >+ libslab_checkpoint ("main-menu-ui.c: load_recently_used_store(): start loading %s", filename); >+ g_bookmark_file_load_from_file (store, filename, NULL); /* NULL-GError */ >+ libslab_checkpoint ("main-menu-ui.c: load_recently_used_store(): end loading %s", filename); >+ >+ g_free (filename); >+ >+ return store; >+} >+ >+/* Updates the bookmark agents for the recently-used apps and documents, by reading the >+ * recently-used store. >+ */ >+static void >+update_recently_used_bookmark_agents (MainMenuUI *this) >+{ >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ GBookmarkFile *store; >+ >+ store = load_recently_used_store (); >+ >+ bookmark_agent_update_from_bookmark_file (priv->bm_agents[BOOKMARK_STORE_RECENT_APPS], store); >+ bookmark_agent_update_from_bookmark_file (priv->bm_agents[BOOKMARK_STORE_RECENT_DOCS], store); >+ >+ g_bookmark_file_free (store); >+} >+ >+/* Updates the recently-used tile tables from their corresponding bookmark agents */ >+static void >+update_recently_used_tables (MainMenuUI *this) >+{ >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ >+ tile_table_reload (priv->file_tables[RCNT_APPS_TABLE]); >+ tile_table_reload (priv->file_tables[RCNT_DOCS_TABLE]); >+} >+ >+/* If the recently-used store has changed since the last time we updated from >+ * it, this updates our view of the store and the corresponding sections in the >+ * slab_window. >+ */ >+static void >+update_recently_used_sections (MainMenuUI *this) >+{ >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ >+ libslab_checkpoint ("main-menu-ui.c: update_recently_used_sections() start"); >+ >+ if (priv->recently_used_store_has_changed) { >+ update_recently_used_bookmark_agents (this); >+ update_recently_used_tables (this); >+ >+ priv->recently_used_store_has_changed = FALSE; >+ } >+ >+ if (!priv->recently_used_store_monitor) >+ setup_recently_used_store_monitor (this, FALSE); /* for if we couldn't create the monitor the first time */ >+ >+ libslab_checkpoint ("main-menu-ui.c: update_recently_used_sections() end"); >+} >+ >+/* Updates the slab_window's sections that need updating and presents the window */ >+static void >+present_slab_window (MainMenuUI *this) >+{ >+ MainMenuUIPrivate *priv = PRIVATE (this); >+ >+ update_recently_used_sections (this); >+ >+ gtk_window_present_with_time (GTK_WINDOW (priv->slab_window), gtk_get_current_event_time ()); >+} >+ > static void > panel_button_clicked_cb (GtkButton *button, gpointer user_data) > { >@@ -1636,7 +1866,7 @@ panel_button_clicked_cb (GtkButton *button, gpointer user_data) > > if (! double_click_detector_is_double_click (detector, gtk_get_current_event_time (), TRUE)) { > if (! visible) >- gtk_window_present_with_time (GTK_WINDOW (priv->slab_window), gtk_get_current_event_time ()); >+ present_slab_window (this); > else > gtk_widget_hide (priv->slab_window); > >diff --git a/main-menu/src/main-menu.c b/main-menu/src/main-menu.c >index 0a569b4..0959d8a 100644 >--- a/main-menu/src/main-menu.c >+++ b/main-menu/src/main-menu.c >@@ -26,6 +26,7 @@ > #include <panel-applet.h> > #include <string.h> > >+#include "libslab-utils.h" > #include "main-menu-ui.h" > > #include "main-menu-migration.h" >@@ -35,11 +36,18 @@ static gboolean main_menu_applet_init (PanelApplet *, const gchar *, gpointer); > PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MainMenu_Factory", PANEL_TYPE_APPLET, "Main Menu", "0", > main_menu_applet_init, NULL); > >+#define CHECKPOINT_CONFIG_BASENAME "main-menu-checkpoint.conf" >+#define CHECKPOINT_FILE_BASENAME "main-menu" >+ > static gboolean > main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data) > { > gchar *argv [1] = { "slab" }; > >+ libslab_checkpoint_init (CHECKPOINT_CONFIG_BASENAME, CHECKPOINT_FILE_BASENAME); >+ >+ libslab_checkpoint ("Main-menu starts up"); >+ > if (strcmp (iid, "OAFIID:GNOME_MainMenu") != 0) > return FALSE; > >@@ -58,13 +66,19 @@ main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data > > gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, 1, argv, NULL, NULL); > >+ libslab_checkpoint ("Migrating old configurations"); > migrate_system_gconf_to_bookmark_file (); > migrate_user_apps_gconf_to_bookmark_file (); > migrate_showable_file_types (); > >+ libslab_checkpoint ("Creating user interface for whole applet"); > main_menu_ui_new (applet); > >+ libslab_checkpoint ("Showing all widgets in applet"); > gtk_widget_show_all (GTK_WIDGET (applet)); > >+ libslab_thumbnail_factory_preinit (); >+ >+ libslab_checkpoint ("Finished initializing applet"); > return TRUE; > } >diff --git a/main-menu/src/tile-table.c b/main-menu/src/tile-table.c >index 6cbc858..5b368e6 100644 >--- a/main-menu/src/tile-table.c >+++ b/main-menu/src/tile-table.c >@@ -22,6 +22,7 @@ > > #include "tile.h" > #include "nameplate-tile.h" >+#include "libslab-utils.h" > > G_DEFINE_TYPE (TileTable, tile_table, GTK_TYPE_TABLE) > >@@ -101,8 +102,6 @@ tile_table_new (BookmarkAgent *agent, gint limit, gint n_cols, > priv->create_item_func = uti_func; > priv->item_func_data = data_uti; > >- tile_table_reload (TILE_TABLE (this)); >- > g_signal_connect ( > G_OBJECT (priv->agent), "notify::" BOOKMARK_AGENT_ITEMS_PROP, > G_CALLBACK (agent_notify_cb), this); >@@ -125,6 +124,7 @@ tile_table_reload (TileTable *this) > GList *node; > gint i; > >+ libslab_checkpoint ("tile_table_reload(): start reloading"); > > g_object_get (G_OBJECT (priv->agent), BOOKMARK_AGENT_ITEMS_PROP, & items, NULL); > >@@ -169,6 +169,8 @@ tile_table_reload (TileTable *this) > update_bins (this, priv->tiles); > > g_object_notify (G_OBJECT (this), TILE_TABLE_TILES_PROP); >+ >+ libslab_checkpoint ("tile_table_reload(): end reloading"); > } > > void
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 230478
:
203582
|
203583
|
203584
|
203585
|
203586
| 206381