[Xfce4-commits] r30148 - terminal/trunk/terminal
Nick Schermer
nick at xfce.org
Thu Jul 2 22:54:42 CEST 2009
Author: nick
Date: 2009-07-02 20:54:42 +0000 (Thu, 02 Jul 2009)
New Revision: 30148
Modified:
terminal/trunk/terminal/terminal-accel-map.c
terminal/trunk/terminal/terminal-accel-map.h
terminal/trunk/terminal/terminal-app.c
terminal/trunk/terminal/terminal-preferences-dialog.c
Log:
Idle the accel map load since it is quite slow and not needed directly.
Modified: terminal/trunk/terminal/terminal-accel-map.c
===================================================================
--- terminal/trunk/terminal/terminal-accel-map.c 2009-07-02 20:52:54 UTC (rev 30147)
+++ terminal/trunk/terminal/terminal-accel-map.c 2009-07-02 20:54:42 UTC (rev 30148)
@@ -29,10 +29,17 @@
-static void terminal_accel_map_finalize (GObject *object);
-static void terminal_accel_map_notify (TerminalPreferences *preferences,
- GParamSpec *pspec,
- TerminalAccelMap *map);
+static void terminal_accel_map_finalize (GObject *object);
+static gboolean terminal_accel_map_connect_idle (gpointer user_data);
+static void terminal_accel_map_connect_destroy (gpointer user_data);
+static void terminal_accel_map_notify (TerminalPreferences *preferences,
+ GParamSpec *pspec,
+ TerminalAccelMap *map);
+static void terminal_accel_map_changed (GtkAccelMap *object,
+ gchar *accel_path,
+ guint accel_key,
+ GdkModifierType accel_mods,
+ TerminalAccelMap *map);
@@ -40,6 +47,8 @@
{
GObject __parent__;
TerminalPreferences *preferences;
+
+ guint accels_connect_id;
};
@@ -62,13 +71,46 @@
static void
terminal_accel_map_init (TerminalAccelMap *map)
{
- GParamSpec **specs;
- GParamSpec *spec;
- gchar *signal_name;
- guint nspecs, n;
-
map->preferences = terminal_preferences_get ();
+ /* schedule a accel map load, this is quite slow so don't do this
+ * during startup since we don't need it right away */
+ map->accels_connect_id = g_idle_add_full (G_PRIORITY_LOW,
+ terminal_accel_map_connect_idle, map,
+ terminal_accel_map_connect_destroy);
+}
+
+
+
+static void
+terminal_accel_map_finalize (GObject *object)
+{
+ TerminalAccelMap *map = TERMINAL_ACCEL_MAP (object);
+
+ if (G_UNLIKELY (map->accels_connect_id != 0))
+ g_source_remove (map->accels_connect_id);
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT (map->preferences),
+ G_CALLBACK (terminal_accel_map_notify), map);
+ g_object_unref (G_OBJECT (map->preferences));
+
+ (*G_OBJECT_CLASS (terminal_accel_map_parent_class)->finalize) (object);
+}
+
+
+
+static gboolean
+terminal_accel_map_connect_idle (gpointer user_data)
+{
+ TerminalAccelMap *map = TERMINAL_ACCEL_MAP (user_data);
+ GtkAccelMap *gtkmap;
+ GParamSpec **specs;
+ GParamSpec *spec;
+ gchar *signal_name;
+ guint nspecs, n;
+
+ GDK_THREADS_ENTER ();
+
specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (map->preferences), &nspecs);
for (n = 0; n < nspecs; ++n)
{
@@ -84,19 +126,24 @@
terminal_accel_map_notify (map->preferences, spec, map);
}
g_free (specs);
+
+ /* monitor the accelmap for changes, so we can store
+ * changed accelerators in the preferences */
+ gtkmap = gtk_accel_map_get ();
+ g_signal_connect (G_OBJECT (gtkmap), "changed",
+ G_CALLBACK (terminal_accel_map_changed), map);
+
+ GDK_THREADS_LEAVE ();
+
+ return FALSE;
}
static void
-terminal_accel_map_finalize (GObject *object)
+terminal_accel_map_connect_destroy (gpointer user_data)
{
- TerminalAccelMap *map = TERMINAL_ACCEL_MAP (object);
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (map->preferences), G_CALLBACK (terminal_accel_map_notify), map);
- g_object_unref (G_OBJECT (map->preferences));
-
- (*G_OBJECT_CLASS (terminal_accel_map_parent_class)->finalize) (object);
+ TERMINAL_ACCEL_MAP (user_data)->accels_connect_id = 0;
}
@@ -174,17 +221,3 @@
{
return g_object_new (TERMINAL_TYPE_ACCEL_MAP, NULL);
}
-
-
-
-void
-terminal_accel_map_start_monitor (TerminalAccelMap *map)
-{
- GtkAccelMap *gtkmap;
-
- terminal_return_if_fail (TERMINAL_IS_ACCEL_MAP (map));
-
- /* monitor the accel map for changes */
- gtkmap = gtk_accel_map_get ();
- g_signal_connect (G_OBJECT (gtkmap), "changed", G_CALLBACK (terminal_accel_map_changed), map);
-}
Modified: terminal/trunk/terminal/terminal-accel-map.h
===================================================================
--- terminal/trunk/terminal/terminal-accel-map.h 2009-07-02 20:52:54 UTC (rev 30147)
+++ terminal/trunk/terminal/terminal-accel-map.h 2009-07-02 20:54:42 UTC (rev 30148)
@@ -45,8 +45,6 @@
TerminalAccelMap *terminal_accel_map_new (void);
-void terminal_accel_map_start_monitor (TerminalAccelMap *map);
-
G_END_DECLS
#endif /* !__TERMINAL_ACCEL_MAP_H__ */
Modified: terminal/trunk/terminal/terminal-app.c
===================================================================
--- terminal/trunk/terminal/terminal-app.c 2009-07-02 20:52:54 UTC (rev 30147)
+++ terminal/trunk/terminal/terminal-app.c 2009-07-02 20:54:42 UTC (rev 30148)
@@ -482,8 +482,6 @@
g_slist_foreach (attrs, (GFunc) terminal_window_attr_free, NULL);
g_slist_free (attrs);
- terminal_accel_map_start_monitor (app->accel_map);
-
return TRUE;
}
Modified: terminal/trunk/terminal/terminal-preferences-dialog.c
===================================================================
--- terminal/trunk/terminal/terminal-preferences-dialog.c 2009-07-02 20:52:54 UTC (rev 30147)
+++ terminal/trunk/terminal/terminal-preferences-dialog.c 2009-07-02 20:54:42 UTC (rev 30148)
@@ -89,7 +89,7 @@
"misc-borders-default", "color-selection-use-default",
"shortcuts-no-mnemonics", "shortcuts-no-menukey",
"binding-backspace", "binding-delete",
- "background-mode", "background-image-style"
+ "background-mode", "background-image-style"
#if TERMINAL_HAS_ANTI_ALIAS_SETTING
, "font-anti-alias"
#endif
More information about the Xfce4-commits
mailing list