[empathy: 1/2] chat: add a timer before saving the hpane position
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 1/2] chat: add a timer before saving the hpane position
- Date: Mon, 22 Nov 2010 08:00:23 +0000 (UTC)
commit 3acbe74046df8d57fdf498acceacb2737be92d80
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Nov 18 13:32:39 2010 +0100
chat: add a timer before saving the hpane position
This avoid to flood with D-Bus message when resizing the window (#635022).
libempathy-gtk/empathy-chat.c | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 04e7862..a55d53e 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -100,6 +100,8 @@ struct _EmpathyChatPriv {
/* Source func ID for update_misspelled_words () */
guint update_misspelled_words_id;
+ /* Source func ID for save_paned_pos_timeout () */
+ guint save_paned_pos_id;
GtkWidget *widget;
GtkWidget *hpaned;
@@ -2491,17 +2493,32 @@ conf_spell_checking_cb (GSettings *gsettings_chat,
}
static gboolean
+save_paned_pos_timeout (gpointer data)
+{
+ EmpathyChat *self = data;
+ gint hpaned_pos;
+
+ hpaned_pos = gtk_paned_get_position (GTK_PANED (self->priv->hpaned));
+
+ g_settings_set_int (self->priv->gsettings_ui,
+ EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS,
+ hpaned_pos);
+
+ return FALSE;
+}
+
+static gboolean
chat_hpaned_pos_changed_cb (GtkWidget* hpaned,
GParamSpec *spec,
gpointer user_data)
{
EmpathyChat *chat = EMPATHY_CHAT (user_data);
- gint hpaned_pos;
- hpaned_pos = gtk_paned_get_position (GTK_PANED(hpaned));
- g_settings_set_int (chat->priv->gsettings_ui,
- EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS,
- hpaned_pos);
+ if (chat->priv->save_paned_pos_id != 0)
+ g_source_remove (chat->priv->save_paned_pos_id);
+
+ chat->priv->save_paned_pos_id = g_timeout_add_seconds (1,
+ save_paned_pos_timeout, chat);
return TRUE;
}
@@ -2656,6 +2673,9 @@ chat_finalize (GObject *object)
if (priv->update_misspelled_words_id != 0)
g_source_remove (priv->update_misspelled_words_id);
+ if (priv->save_paned_pos_id != 0)
+ g_source_remove (priv->save_paned_pos_id);
+
g_object_unref (priv->gsettings_chat);
g_object_unref (priv->gsettings_ui);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]