X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=gtk%2Fsrc%2Fvalues.c;h=5800a008e44a96f73c04c476224a0025937f71b2;hb=5fd4d5461a874e0cf0202616bb88eb591a59ff3f;hp=94b417f6d39165d47cf5d6846c7447b0f5eb08ec;hpb=7f9e1e2552c13a16423d2668c734740e020e95ff;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/gtk/src/values.c b/gtk/src/values.c index 94b417f6..5800a008 100644 --- a/gtk/src/values.c +++ b/gtk/src/values.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "values.h" static void dict_delete_key(gpointer data); @@ -77,7 +78,43 @@ debug_show_type(GType tp) { str ="dict"; } - g_debug("%s", str); + g_debug("Type %s", str); +} + +void +debug_show_value(GValue *gval) +{ + GType tp; + + tp = G_VALUE_TYPE(gval); + if (tp == G_TYPE_STRING) + { + g_message("Type %s value %s", "string", g_value_get_string(gval)); + } + else if (tp == G_TYPE_INT) + { + g_message("Type %s value %d", "int", g_value_get_int(gval)); + } + else if (tp == G_TYPE_INT64) + { + g_message("Type %s value %" PRId64, "int64", g_value_get_int64(gval)); + } + else if (tp == G_TYPE_DOUBLE) + { + g_message("Type %s value %f", "double", g_value_get_double(gval)); + } + else if (tp == G_TYPE_BOOLEAN) + { + g_message("Type %s value %d", "boolean", g_value_get_boolean(gval)); + } + else if (tp == ghb_array_get_type()) + { + g_message("Type %s", "boolean"); + } + else if (tp == ghb_dict_get_type()) + { + g_message("Type %s", "dict"); + } } gint @@ -216,6 +253,10 @@ ghb_value_cmp(const GValue *vala, const GValue *valb) GType typa; GType typb; + if ((vala == NULL && valb != NULL) || (vala != NULL && valb == NULL)) + { + return 1; + } typa = G_VALUE_TYPE(vala); typb = G_VALUE_TYPE(valb); if (typa != typb) @@ -533,7 +574,7 @@ ghb_dict_iter_init(GHashTableIter *iter, GValue *gval) } GValue* -ghb_dict_lookup(GValue *gval, const gchar *key) +ghb_dict_lookup(const GValue *gval, const gchar *key) { GHashTable *dict = g_value_get_boxed(gval); return g_hash_table_lookup(dict, key); @@ -712,6 +753,15 @@ xform_string_double(const GValue *sval, GValue *dval) } static void +xform_double_string(const GValue *dval, GValue *sval) +{ + gchar *str; + double val = g_value_get_double(dval); + str = g_strdup_printf("%g", val); + g_value_take_string(sval, str); +} + +static void xform_boolean_double(const GValue *bval, GValue *dval) { gboolean b = g_value_get_boolean(bval); @@ -730,4 +780,6 @@ ghb_register_transforms() xform_string_double); g_value_register_transform_func(G_TYPE_BOOLEAN, G_TYPE_DOUBLE, xform_boolean_double); + g_value_register_transform_func(G_TYPE_DOUBLE, G_TYPE_STRING, + xform_double_string); }