[Xfce4-commits] <thunar:master> Idle updating the launcher.
Nick Schermer
noreply at xfce.org
Sun Nov 11 01:36:12 CET 2012
Updating branch refs/heads/master
to 415cacb8c9bed182dc18288db78be7d0167fe016 (commit)
from 34fdbb4a4b3ee4b3274389b58cd207d45f8349cc (commit)
commit 415cacb8c9bed182dc18288db78be7d0167fe016
Author: Nick Schermer <nick at xfce.org>
Date: Sun Nov 11 01:31:40 2012 +0100
Idle updating the launcher.
This should be smarter, but its a start. Especially
thunar_file_list_get_applications is very slow here
because of g_app_info_get_all_for_type.
thunar/thunar-launcher.c | 68 +++++++++++++++++++++++++++++++++-------------
1 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index 978c545..706515a 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -136,6 +136,8 @@ struct _ThunarLauncher
ThunarFile *current_directory;
GList *selected_files;
+ guint launcher_idle_id;
+
GtkIconFactory *icon_factory;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
@@ -322,6 +324,10 @@ thunar_launcher_finalize (GObject *object)
if (G_UNLIKELY (launcher->sendto_idle_id != 0))
g_source_remove (launcher->sendto_idle_id);
+ /* be sure to cancel the launcher idle source */
+ if (G_UNLIKELY (launcher->launcher_idle_id != 0))
+ g_source_remove (launcher->launcher_idle_id);
+
/* drop our custom icon factory for the application/action icons */
gtk_icon_factory_remove_default (launcher->icon_factory);
g_object_unref (launcher->icon_factory);
@@ -746,28 +752,29 @@ thunar_launcher_open_windows (ThunarLauncher *launcher,
-static void
-thunar_launcher_update (ThunarLauncher *launcher)
+static gboolean
+thunar_launcher_update_idle (gpointer data)
{
- const gchar *context_menu_path;
- const gchar *file_menu_path;
- GtkAction *action;
- gboolean default_is_open_with_other = FALSE;
- GList *applications;
- GList *actions;
- GList *lp;
- gchar *tooltip;
- gchar *label;
- gchar *name;
- gint n_directories = 0;
- gint n_executables = 0;
- gint n_regulars = 0;
- gint n_selected_files = 0;
- gint n;
+ ThunarLauncher *launcher = THUNAR_LAUNCHER (data);
+ const gchar *context_menu_path;
+ const gchar *file_menu_path;
+ GtkAction *action;
+ gboolean default_is_open_with_other = FALSE;
+ GList *applications;
+ GList *actions;
+ GList *lp;
+ gchar *tooltip;
+ gchar *label;
+ gchar *name;
+ gint n_directories = 0;
+ gint n_executables = 0;
+ gint n_regulars = 0;
+ gint n_selected_files = 0;
+ gint n;
/* verify that we're connected to an UI manager */
if (G_UNLIKELY (launcher->ui_manager == NULL))
- return;
+ return FALSE;
/* drop the previous addons ui controls from the UI manager */
if (G_LIKELY (launcher->ui_addons_merge_id != 0))
@@ -1043,10 +1050,33 @@ thunar_launcher_update (ThunarLauncher *launcher)
* GIO, so we'll have to roll our own thing here */
}
+ return FALSE;
+}
+
+
+
+static void
+thunar_launcher_update_idle_destroy (gpointer data)
+{
+ THUNAR_LAUNCHER (data)->launcher_idle_id = 0;
+}
+
+
+
+static void
+thunar_launcher_update (ThunarLauncher *launcher)
+{
+ /* schedule an update of the launcher items */
+ if (G_LIKELY (launcher->launcher_idle_id == 0))
+ {
+ launcher->launcher_idle_id = g_idle_add_full (G_PRIORITY_LOW, thunar_launcher_update_idle,
+ launcher, thunar_launcher_update_idle_destroy);
+ }
+
/* schedule an update of the "Send To" menu */
if (G_LIKELY (launcher->sendto_idle_id == 0))
{
- launcher->sendto_idle_id = g_idle_add_full (G_PRIORITY_LOW, thunar_launcher_sendto_idle,
+ launcher->sendto_idle_id = g_idle_add_full (G_PRIORITY_LOW + 50, thunar_launcher_sendto_idle,
launcher, thunar_launcher_sendto_idle_destroy);
}
}
More information about the Xfce4-commits
mailing list