[gucharmap] settings: Only save to dconf on exit
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] settings: Only save to dconf on exit
- Date: Sun, 7 Sep 2014 16:34:38 +0000 (UTC)
commit 901a8cdfabd59c676a2cbe41f2e53bff4f156802
Author: Peter Moulder <pjrm mail internode on net>
Date: Sun Sep 7 18:31:13 2014 +0200
settings: Only save to dconf on exit
https://bugzilla.gnome.org/show_bug.cgi?id=734191
gucharmap/gucharmap-window.c | 38 ++++++++++++++++++--------------------
gucharmap/gucharmap-window.h | 2 --
2 files changed, 18 insertions(+), 22 deletions(-)
---
diff --git a/gucharmap/gucharmap-window.c b/gucharmap/gucharmap-window.c
index 87be8b7..74d7969 100644
--- a/gucharmap/gucharmap-window.c
+++ b/gucharmap/gucharmap-window.c
@@ -649,17 +649,6 @@ status_realize (GtkWidget *status,
gtk_widget_set_size_request (guw->status, -1, allocation->height + 9);
}
-static gboolean
-save_last_char_idle_cb (GucharmapWindow *guw)
-{
- guw->save_last_char_idle_id = 0;
-
- g_settings_set_uint (guw->settings, "last-char",
- gucharmap_charmap_get_active_character (guw->charmap));
-
- return FALSE;
-}
-
static void
fontsel_sync_font_desc (GucharmapMiniFontSelection *fontsel,
GParamSpec *pspec,
@@ -700,15 +689,25 @@ charmap_sync_font_desc (GucharmapCharmap *charmap,
guw->in_notification = FALSE;
}
+static int last_char_dirty = 0;
+
static void
-charmap_sync_active_character (GtkWidget *widget,
- GParamSpec *pspec,
+charmap_dirty_active_character (GtkWidget *widget,
+ GParamSpec *pspec,
+ GucharmapWindow *guw)
+{
+ last_char_dirty = 1;
+}
+
+static gboolean
+charmap_save_active_character (GtkWidget *widget,
GucharmapWindow *guw)
{
- if (guw->save_last_char_idle_id != 0)
- return;
+ if (last_char_dirty)
+ g_settings_set_uint (guw->settings, "last-char",
+ gucharmap_charmap_get_active_character (guw->charmap));
- guw->save_last_char_idle_id = g_idle_add ((GSourceFunc) save_last_char_idle_cb, guw);
+ return FALSE;
}
static void
@@ -854,8 +853,10 @@ gucharmap_window_init (GucharmapWindow *guw)
/* connect these only after applying the initial settings in order to
* avoid unnecessary writes to GSettings.
*/
+ g_signal_connect (guw, "destroy",
+ G_CALLBACK (charmap_save_active_character), guw);
g_signal_connect (guw->charmap, "notify::active-character",
- G_CALLBACK (charmap_sync_active_character), guw);
+ G_CALLBACK (charmap_dirty_active_character), guw);
g_signal_connect (guw->fontsel, "notify::font-desc",
G_CALLBACK (fontsel_sync_font_desc), guw);
}
@@ -865,9 +866,6 @@ gucharmap_window_finalize (GObject *object)
{
GucharmapWindow *guw = GUCHARMAP_WINDOW (object);
- if (guw->save_last_char_idle_id != 0)
- g_source_remove (guw->save_last_char_idle_id);
-
if (guw->page_setup)
g_object_unref (guw->page_setup);
diff --git a/gucharmap/gucharmap-window.h b/gucharmap/gucharmap-window.h
index 662a085..f613b0c 100644
--- a/gucharmap/gucharmap-window.h
+++ b/gucharmap/gucharmap-window.h
@@ -49,8 +49,6 @@ struct _GucharmapWindow
GtkWidget *search_dialog; /* takes care of all aspects of searching */
- guint save_last_char_idle_id;
-
GtkPageSetup *page_setup;
GtkPrintSettings *print_settings;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]