~registry/libsignon-glib/packaging

« back to all changes in this revision

Viewing changes to libsignon-glib/signon-utils.c

  • Committer: Alberto Mardegan
  • Date: 2012-01-20 10:35:45 UTC
  • Revision ID: git-v1:60eb31dd832fae00fb57891c2e2496ef0871ed94
Better handling of "as" type in Python bindings

Revert python hack in libsignon-glib; instead, use pygobject "hidden"
support for GStrv to convert Python lists to GStrv on the fly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 */
24
24
#include "signon-utils.h"
25
25
 
26
 
#ifdef ENABLE_PYGOBJECT_HACK
27
 
static gboolean
28
 
signon_demarshal_joined_values (const gchar *key,
29
 
                                const GValue *value,
30
 
                                GHashTable *dest)
31
 
{
32
 
    /* Hack to support marshalling of string arrays in python. See also the
33
 
     * "GI overrides" file in the pygobject directory */
34
 
    GValue *copy_value;
35
 
    const gchar *full_string, *joined_values;
36
 
    gchar separator[2];
37
 
    gchar **values;
38
 
    full_string = g_value_get_string (value);
39
 
    if (full_string == NULL || !g_str_has_prefix (full_string, "pySignon"))
40
 
        return FALSE;
41
 
 
42
 
    separator[0] = full_string[8];
43
 
    separator[1] = '\0';
44
 
    joined_values = full_string + 9;
45
 
    values = g_strsplit (joined_values, separator, 0);
46
 
 
47
 
    copy_value = g_slice_new0 (GValue);
48
 
    g_value_init (copy_value, G_TYPE_STRV);
49
 
    g_value_take_boxed (copy_value, values);
50
 
 
51
 
    g_hash_table_insert (dest, g_strdup(key), copy_value);
52
 
    return TRUE;
53
 
}
54
 
#endif
55
 
 
56
26
static void signon_copy_gvalue (gchar *key,
57
27
                                GValue *value,
58
28
                                GHashTable *dest)
59
29
{
60
 
#ifdef ENABLE_PYGOBJECT_HACK
61
 
    if (G_VALUE_HOLDS_STRING(value) &&
62
 
        signon_demarshal_joined_values (key, value, dest)) return;
63
 
#endif
64
 
 
65
30
    GValue *copy_value = g_slice_new0 (GValue);
66
31
    g_value_init (copy_value, value->g_type);
67
32
    g_value_copy (value, copy_value);