Guest
December 21st, 2006, 09:24 PM
I'm having some trouble getting dbus support into compiz-settings, the problem is with a string restriction I don't know how many restrictions there are so the dbus method i'm using at the moment doesn't work.
Here's how i'm getting a float restriction
CompOptionFloatRestriction * backend_get_float_restriction(gchar * plugin, gchar * screen, gchar * key) {
DBusGProxy *proxy;
GError *error;
gchar * dbus_path;
double MinValue;
double MaxValue;
double Precision;
dbus_path = g_strdup_printf("/org/freedesktop/compiz/%s/%s/%s", plugin, screen, key);
/* Create a proxy object for the dbus */
proxy = dbus_g_proxy_new_for_name (DbusConnection,
DbusDomain,
dbus_path,
DbusDomain);
/* Call ListNames method, wait for reply */
error = NULL;
if (!dbus_g_proxy_call (proxy, "getMetadata", &error, G_TYPE_INVALID,
G_TYPE_STRING, NULL,
G_TYPE_STRING, NULL,
G_TYPE_STRING, NULL,
G_TYPE_DOUBLE, &MinValue,
G_TYPE_DOUBLE, &MaxValue,
G_TYPE_DOUBLE, &Precision,
G_TYPE_INVALID))
{
dbus_error(error);
return NULL;
}
CompOptionFloatRestriction * float_restriction = malloc(sizeof(CompOptionFloatRestriction));
float_restriction->min = MinValue;
float_restriction->max = MaxValue;
float_restriction->precision = Precision;
g_free(dbus_path);
g_object_unref (proxy);
return float_restriction;
}
This works fine because i know there is only going to be min, max and precision options. Is their a way to get the options without knowing how many there are? i.e. put them in an array or something?
Here's how i'm getting a float restriction
CompOptionFloatRestriction * backend_get_float_restriction(gchar * plugin, gchar * screen, gchar * key) {
DBusGProxy *proxy;
GError *error;
gchar * dbus_path;
double MinValue;
double MaxValue;
double Precision;
dbus_path = g_strdup_printf("/org/freedesktop/compiz/%s/%s/%s", plugin, screen, key);
/* Create a proxy object for the dbus */
proxy = dbus_g_proxy_new_for_name (DbusConnection,
DbusDomain,
dbus_path,
DbusDomain);
/* Call ListNames method, wait for reply */
error = NULL;
if (!dbus_g_proxy_call (proxy, "getMetadata", &error, G_TYPE_INVALID,
G_TYPE_STRING, NULL,
G_TYPE_STRING, NULL,
G_TYPE_STRING, NULL,
G_TYPE_DOUBLE, &MinValue,
G_TYPE_DOUBLE, &MaxValue,
G_TYPE_DOUBLE, &Precision,
G_TYPE_INVALID))
{
dbus_error(error);
return NULL;
}
CompOptionFloatRestriction * float_restriction = malloc(sizeof(CompOptionFloatRestriction));
float_restriction->min = MinValue;
float_restriction->max = MaxValue;
float_restriction->precision = Precision;
g_free(dbus_path);
g_object_unref (proxy);
return float_restriction;
}
This works fine because i know there is only going to be min, max and precision options. Is their a way to get the options without knowing how many there are? i.e. put them in an array or something?