gtk-builder-tool: Start an exception list

We have a number of cases where properties should have their
default value overridden in a subclass, but haven't because thats
annoying to do. We also have properties where the absence of
an explicit value has context-dependent meaning.
Add a list of exceptions for these cases.
This commit is contained in:
Matthias Clasen 2015-05-02 07:35:35 -04:00
parent 354146143e
commit b8548d27a1

View File

@ -95,6 +95,53 @@ value_is_default (MyParserData *data,
return ret;
}
/* A number of properties unfortunately can't be omitted even
* if they are nominally set to their default value. In many
* cases, this is due to subclasses not overriding the default
* value from the superclass.
*/
static gboolean
needs_explicit_setting (MyParserData *data,
gint i)
{
struct _Prop {
const char *class;
const char *property;
gboolean packing;
} props[] = {
{ "GtkRadioButton", "draw-indicator", 0 },
{ "GtkGrid", "left-attach", 1 },
{ "GtkGrid", "top-attach", 1 },
{ NULL, NULL, 0 }
};
const gchar *class_name;
const gchar *property_name;
gchar *canonical_name;
gboolean found;
gint k;
class_name = (const gchar *)data->classes->data;
property_name = (const gchar *)data->attribute_values[i];
canonical_name = g_strdup (property_name);
g_strdelimit (canonical_name, "_", '-');
found = FALSE;
for (k = 0; props[k].class; k++)
{
if (strcmp (class_name, props[k].class) == 0 &&
strcmp (canonical_name, props[k].property) == 0 &&
data->packing == props[k].packing)
{
found = TRUE;
break;
}
}
g_free (canonical_name);
return found;
}
static void
maybe_emit_property (MyParserData *data)
{
@ -109,6 +156,9 @@ maybe_emit_property (MyParserData *data)
if (data->classes == NULL)
break;
if (needs_explicit_setting (data, i))
break;
if (value_is_default (data, i))
return;
}