[gucharmap] charmap: Store last selected character as uint32
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] charmap: Store last selected character as uint32
- Date: Fri, 24 Aug 2012 20:25:54 +0000 (UTC)
commit 825e10f869d0802ff035347c7f85220e730a505b
Author: Christian Persch <chpe gnome org>
Date: Fri Aug 24 22:15:46 2012 +0200
charmap: Store last selected character as uint32
... instead of as string.
https://bugzilla.gnome.org/show_bug.cgi?id=678263
gucharmap/gucharmap-window.c | 28 +++-------------------------
gucharmap/org.gnome.Charmap.gschema.xml | 8 +++++---
2 files changed, 8 insertions(+), 28 deletions(-)
---
diff --git a/gucharmap/gucharmap-window.c b/gucharmap/gucharmap-window.c
index 7c8d811..e907922 100644
--- a/gucharmap/gucharmap-window.c
+++ b/gucharmap/gucharmap-window.c
@@ -663,17 +663,10 @@ status_realize (GtkWidget *status,
static gboolean
save_last_char_idle_cb (GucharmapWindow *guw)
{
- gchar outbuf[10];
- gunichar wc;
- gint len;
-
guw->save_last_char_idle_id = 0;
- wc = gucharmap_charmap_get_active_character (guw->charmap);
- len = g_unichar_to_utf8 (wc, outbuf);
- outbuf[len] = '\0';
-
- g_settings_set_string (guw->settings, "last-char", outbuf);
+ g_settings_set_uint (guw->settings, "last-char",
+ gucharmap_charmap_get_active_character (guw->charmap));
return FALSE;
}
@@ -729,21 +722,6 @@ charmap_sync_active_character (GtkWidget *widget,
guw->save_last_char_idle_id = g_idle_add ((GSourceFunc) save_last_char_idle_cb, guw);
}
-static gboolean
-string_to_unichar_mapping (GVariant *value,
- gpointer *result,
- gpointer user_data)
-{
- const gchar *str;
-
- str = g_variant_get_string (value, NULL);
- if (g_utf8_strlen (str, -1) != 1)
- return FALSE;
-
- *result = GINT_TO_POINTER (g_utf8_get_char (str));
- return TRUE;
-}
-
static void
gucharmap_window_init (GucharmapWindow *guw)
{
@@ -878,7 +856,7 @@ gucharmap_window_init (GucharmapWindow *guw)
gucharmap_window_set_chapters_model (guw, g_settings_get_enum (guw->settings, "group-by"));
/* active character */
- active = (gsize) g_settings_get_mapped (guw->settings, "last-char", string_to_unichar_mapping, NULL);
+ active = g_settings_get_uint (guw->settings, "last-char");
gucharmap_charmap_set_active_character (guw->charmap, active);
/* window geometry */
diff --git a/gucharmap/org.gnome.Charmap.gschema.xml b/gucharmap/org.gnome.Charmap.gschema.xml
index 69fb9d6..4683345 100644
--- a/gucharmap/org.gnome.Charmap.gschema.xml
+++ b/gucharmap/org.gnome.Charmap.gschema.xml
@@ -52,17 +52,19 @@
<default>false</default>
</key>
- <key name='last-char' type='s'>
+ <key name='last-char' type='u'>
+ <range min="0" max="0x10ffff" />
<summary>Last selected character</summary>
<description>
This is the last character that was selected in the character
map (and will be selected again when the character map is next
- started). If set, it should be a string with a single character.
+ started).
By default, it is the first letter of the alphabet in the current
locale.
</description>
- <default l10n='messages' context='First letter of alphabet'>'A'</default>
+ <!-- The unicode code point of the first letter of the alphabet -->
+ <default l10n='messages' context='First letter'>0x41</default>
</key>
</schema>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]