diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-08-05 23:06:23 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-08-05 23:06:23 +0800 |
commit | a7d77f6d5eb0e0d73c1029dd751014efc21d95df (patch) | |
tree | 64314563f2a7321b6e11721605b07096accf3397 /lib/ephy-string.c | |
parent | 3fd222083b1d51093e6d736c8d657cfa9a43689f (diff) | |
download | gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.tar gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.tar.gz gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.tar.bz2 gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.tar.lz gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.tar.xz gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.tar.zst gsoc2013-epiphany-a7d77f6d5eb0e0d73c1029dd751014efc21d95df.zip |
A lib/ephy-print-utils.c: A lib/ephy-print-utils.h:
2006-08-05 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-shell.c: (ephy_embed_shell_set_page_setup),
(ephy_embed_shell_get_page_setup),
(ephy_embed_shell_set_print_settings),
(ephy_embed_shell_get_print_settings):
A lib/ephy-print-utils.c:
A lib/ephy-print-utils.h:
* lib/ephy-string.c: (ephy_string_flags_from_string),
(ephy_string_flags_to_string), (ephy_string_enum_from_string),
(ephy_string_enum_to_string):
* lib/ephy-string.h:
Persist print settings and page setup.
Diffstat (limited to 'lib/ephy-string.c')
-rw-r--r-- | lib/ephy-string.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/lib/ephy-string.c b/lib/ephy-string.c index 3eb991573..baec076b1 100644 --- a/lib/ephy-string.c +++ b/lib/ephy-string.c @@ -182,3 +182,107 @@ ephy_string_collate_key_for_domain (const char *str, return g_string_free (result, FALSE); } + +guint +ephy_string_flags_from_string (GType type, + const char *flags_string) +{ + GFlagsClass *flags_class; + const GFlagsValue *value; + gchar **flags; + guint retval = 0, i; + + g_return_val_if_fail (flags_string != NULL, 0); + + flags = g_strsplit (flags_string, "|", -1); + if (!flags) return 0; + + flags_class = g_type_class_ref (type); + + for (i = 0; flags[i] != NULL; ++i) + { + value = g_flags_get_value_by_nick (flags_class, flags[i]); + if (value != NULL) + { + retval |= value->value; + } + } + + g_type_class_unref (flags_class); + + return retval; +} + +char * +ephy_string_flags_to_string (GType type, + guint flags_value) +{ + GFlagsClass *flags_class; + GString *string; + gboolean first = TRUE; + guint i; + + string = g_string_sized_new (128); + + flags_class = g_type_class_ref (type); + + for (i = 0; i < flags_class->n_values; ++i) + { + if (flags_value & flags_class->values[i].value) + { + if (!first) + { + g_string_append_c (string, '|'); + } + first = FALSE; + g_string_append (string, flags_class->values[i].value_nick); + } + } + + g_type_class_unref (flags_class); + + return g_string_free (string, FALSE); +} + +guint +ephy_string_enum_from_string (GType type, + const char *enum_string) +{ + GEnumClass *enum_class; + const GEnumValue *value; + guint retval = 0; + + g_return_val_if_fail (enum_string != NULL, 0); + + enum_class = g_type_class_ref (type); + value = g_enum_get_value_by_nick (enum_class, enum_string); + if (value != NULL) + { + retval = value->value; + } + + g_type_class_unref (enum_class); + + return retval; +} + +char * +ephy_string_enum_to_string (GType type, + guint enum_value) +{ + GEnumClass *enum_class; + GEnumValue *value; + char *retval = NULL; + + enum_class = g_type_class_ref (type); + + value = g_enum_get_value (enum_class, enum_value); + if (value) + { + retval = g_strdup (value->value_nick); + } + + g_type_class_unref (enum_class); + + return retval; +} |