mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-24 00:04:33 -04:00
Fixed bug in catalog_find_by_name (Luc Simard)
* src/glade-catalog.c: Fixed bug in catalog_find_by_name (Luc Simard) * src/glade-editor.c: Played around with how properties are dealt with. * src/glade-property-class.[ch], src/glade.h: Added "save" and "editable" tags to properties through xml catalog. * src/glade-property.[ch], src/glade-types.h: Major revamping of glade-property, now it is a full fledged GObject with class method access & the new "value-changed" signal. * src/glade-widget.c: Now g_object_unref the properties instead of glade_property_free, also adjusted arguments for glade_property_write.
This commit is contained in:
parent
df6a15ea78
commit
16a4bbf67b
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2005-07-28 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/glade-catalog.c: Fixed bug in catalog_find_by_name (Luc Simard)
|
||||
|
||||
* src/glade-editor.c: Played around with how properties are dealt with.
|
||||
|
||||
* src/glade-property-class.[ch], src/glade.h: Added "save" and "editable"
|
||||
tags to properties through xml catalog.
|
||||
|
||||
* src/glade-property.[ch], src/glade-types.h:
|
||||
Major revamping of glade-property, now it is a full fledged GObject with
|
||||
class method access & the new "value-changed" signal.
|
||||
|
||||
* src/glade-widget.c: Now g_object_unref the properties instead of
|
||||
glade_property_free, also adjusted arguments for glade_property_write.
|
||||
|
||||
2005-07-28 Tristan Van Berkom <tvb@gnome.org>
|
||||
|
||||
* src/glade-gtk.c:
|
||||
|
@ -167,7 +167,7 @@ catalog_load (GladeCatalog *catalog)
|
||||
static gint
|
||||
catalog_find_by_name (GladeCatalog *catalog, const gchar *name)
|
||||
{
|
||||
return !strcmp (catalog->name, name);
|
||||
return strcmp (catalog->name, name);
|
||||
}
|
||||
|
||||
static GList *
|
||||
@ -188,9 +188,7 @@ catalog_sort (GList *catalogs)
|
||||
(catalogs, catalog->dep_catalog,
|
||||
(GCompareFunc)catalog_find_by_name);
|
||||
|
||||
if (node)
|
||||
cat = node->data;
|
||||
else
|
||||
if ((cat = node->data) == NULL)
|
||||
{
|
||||
g_critical ("Catalog %s depends on catalog %s, not found",
|
||||
catalog->name, catalog->dep_catalog);
|
||||
@ -198,8 +196,8 @@ catalog_sort (GList *catalogs)
|
||||
}
|
||||
|
||||
/* Prepend to sort list */
|
||||
if (g_list_find (sort, node->data) == NULL &&
|
||||
g_list_find (sorted, node->data) == NULL)
|
||||
if (g_list_find (sort, cat) == NULL &&
|
||||
g_list_find (sorted, cat) == NULL)
|
||||
sort = g_list_prepend (sort, cat);
|
||||
|
||||
catalog = cat;
|
||||
|
@ -337,35 +337,35 @@ glade_editor_property_changed_numeric (GtkWidget *spin,
|
||||
if (property->property->loading)
|
||||
return;
|
||||
|
||||
g_value_init (&val, property->class->pspec->value_type);
|
||||
g_value_init (&val, property->property->class->pspec->value_type);
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT(property->class->pspec))
|
||||
if (G_IS_PARAM_SPEC_INT(property->property->class->pspec))
|
||||
g_value_set_int (&val, gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_UINT(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_UINT(property->property->class->pspec))
|
||||
g_value_set_uint (&val, gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_LONG(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_LONG(property->property->class->pspec))
|
||||
g_value_set_long (&val, (glong)gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_ULONG(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_ULONG(property->property->class->pspec))
|
||||
g_value_set_ulong (&val, (gulong)gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_INT64(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_INT64(property->property->class->pspec))
|
||||
g_value_set_int64 (&val, (gint64)gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_UINT64(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_UINT64(property->property->class->pspec))
|
||||
g_value_set_uint64 (&val, (guint64)gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_FLOAT(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_FLOAT(property->property->class->pspec))
|
||||
g_value_set_float (&val, (gfloat) gtk_spin_button_get_value
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE(property->property->class->pspec))
|
||||
g_value_set_double (&val, gtk_spin_button_get_value
|
||||
(GTK_SPIN_BUTTON (spin)));
|
||||
else
|
||||
g_warning ("Unsupported type %s\n",
|
||||
g_type_name(property->class->pspec->value_type));
|
||||
g_type_name(property->property->class->pspec->value_type));
|
||||
|
||||
if (property->from_query_dialog)
|
||||
glade_property_set (property->property, &val);
|
||||
@ -584,7 +584,7 @@ glade_editor_property_show_flags_dialog (GtkWidget *entry,
|
||||
mask = class->values[flag_num].value;
|
||||
setting = ((value & mask) == mask) ? TRUE : FALSE;
|
||||
|
||||
value_name = glade_property_class_get_displayable_value (property->class,
|
||||
value_name = glade_property_class_get_displayable_value (property->property->class,
|
||||
class->values[flag_num].value);
|
||||
|
||||
if (value_name == NULL) value_name = class->values[flag_num].value_name;
|
||||
@ -834,22 +834,28 @@ glade_editor_create_input_enum_item (GladeEditorProperty *property,
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_enum (GladeEditorProperty *property)
|
||||
{
|
||||
GladePropertyClass *class;
|
||||
GtkWidget *menu_item;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *option_menu;
|
||||
GEnumClass *eclass;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property->class), NULL);
|
||||
|
||||
class = property->class;
|
||||
g_return_val_if_fail ((eclass = g_type_class_ref
|
||||
(property->class->pspec->value_type)) != NULL, NULL);
|
||||
(class->pspec->value_type)) != NULL, NULL);
|
||||
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
for (i = 0; i < eclass->n_values; i++)
|
||||
{
|
||||
gchar *value_name = glade_property_class_get_displayable_value (property->class,
|
||||
eclass->values[i].value);
|
||||
gchar *value_name =
|
||||
glade_property_class_get_displayable_value
|
||||
(class, eclass->values[i].value);
|
||||
if (value_name == NULL) value_name = eclass->values[i].value_name;
|
||||
|
||||
menu_item = glade_editor_create_input_enum_item (property,
|
||||
@ -868,12 +874,14 @@ glade_editor_create_input_enum (GladeEditorProperty *property)
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_flags (GladeEditorProperty *property)
|
||||
glade_editor_create_input_flags (GladeEditorProperty *property)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *button;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
@ -895,10 +903,11 @@ glade_editor_create_input_flags (GladeEditorProperty *property)
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
{
|
||||
GladePropertyClass *class;
|
||||
gint lines = 1;
|
||||
gint lines;
|
||||
GladePropertyClass *class;
|
||||
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property->class), NULL);
|
||||
|
||||
class = property->class;
|
||||
|
||||
@ -922,7 +931,7 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
G_CALLBACK (glade_editor_entry_focus_out),
|
||||
property);
|
||||
|
||||
if (property->class->translatable) {
|
||||
if (class->translatable) {
|
||||
button = gtk_button_new_with_label ("...");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
@ -947,7 +956,7 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
G_CALLBACK (glade_editor_text_view_focus_out),
|
||||
property);
|
||||
|
||||
if (property->class->translatable) {
|
||||
if (class->translatable) {
|
||||
button = gtk_button_new_with_label ("...");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
@ -965,20 +974,20 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_numeric (GladeEditorProperty *property)
|
||||
{
|
||||
GladePropertyClass *property_class;
|
||||
GladePropertyClass *class;
|
||||
GtkAdjustment *adjustment;
|
||||
GtkWidget *spin;
|
||||
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property->class), NULL);
|
||||
|
||||
class = property->class;
|
||||
|
||||
property_class = property->class;
|
||||
|
||||
adjustment = glade_parameter_adjustment_new (property_class);
|
||||
|
||||
spin = gtk_spin_button_new (adjustment, 4,
|
||||
G_IS_PARAM_SPEC_FLOAT(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_DOUBLE(property->class->pspec)
|
||||
? 2 : 0);
|
||||
adjustment = glade_parameter_adjustment_new (class);
|
||||
spin = gtk_spin_button_new (adjustment, 4,
|
||||
G_IS_PARAM_SPEC_FLOAT (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_DOUBLE (class->pspec)
|
||||
? 2 : 0);
|
||||
|
||||
g_signal_connect (G_OBJECT (spin), "value_changed",
|
||||
G_CALLBACK (glade_editor_property_changed_numeric),
|
||||
@ -987,7 +996,7 @@ glade_editor_create_input_numeric (GladeEditorProperty *property)
|
||||
/* Some numeric types are optional, for example the default window size, so
|
||||
* they have a toggle button right next to the spin button.
|
||||
*/
|
||||
if (property_class->optional) {
|
||||
if (class->optional) {
|
||||
GtkWidget *check;
|
||||
GtkWidget *hbox;
|
||||
check = gtk_check_button_new ();
|
||||
@ -1009,7 +1018,7 @@ glade_editor_create_input_boolean (GladeEditorProperty *property)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
|
||||
button = gtk_toggle_button_new_with_label (_("No"));
|
||||
|
||||
@ -1025,7 +1034,7 @@ glade_editor_create_input_unichar (GladeEditorProperty *property)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
/* it's 2 to prevent spirious beeps... */
|
||||
@ -1084,44 +1093,48 @@ glade_editor_table_attach (GtkWidget *table, GtkWidget *child, gint pos, gint ro
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_append_item_real (GladeEditorTable *table,
|
||||
glade_editor_append_item_real (GladeEditorTable *table,
|
||||
GladeEditorProperty *property)
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *input = NULL;
|
||||
GladePropertyClass *class;
|
||||
GtkWidget *label;
|
||||
GtkWidget *input = NULL;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_TABLE (table), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (property), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property->class), NULL);
|
||||
|
||||
if (G_IS_PARAM_SPEC_ENUM(property->class->pspec))
|
||||
class = property->class;
|
||||
|
||||
if (G_IS_PARAM_SPEC_ENUM(class->pspec))
|
||||
input = glade_editor_create_input_enum (property);
|
||||
else if (G_IS_PARAM_SPEC_FLAGS(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_FLAGS(class->pspec))
|
||||
input = glade_editor_create_input_flags (property);
|
||||
else if (G_IS_PARAM_SPEC_BOOLEAN(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_BOOLEAN(class->pspec))
|
||||
input = glade_editor_create_input_boolean (property);
|
||||
else if (G_IS_PARAM_SPEC_INT(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_LONG(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_ULONG(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_INT64(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT64(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_FLOAT(property->class->pspec) ||
|
||||
G_IS_PARAM_SPEC_DOUBLE(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_INT(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_LONG(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_ULONG(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_INT64(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT64(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_FLOAT(class->pspec) ||
|
||||
G_IS_PARAM_SPEC_DOUBLE(class->pspec))
|
||||
input = glade_editor_create_input_numeric (property);
|
||||
else if (G_IS_PARAM_SPEC_STRING(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_STRING(class->pspec))
|
||||
input = glade_editor_create_input_text (property);
|
||||
else if (G_IS_PARAM_SPEC_STRING(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_STRING(class->pspec))
|
||||
input = glade_editor_create_input_text (property);
|
||||
else if (G_IS_PARAM_SPEC_UNICHAR(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_UNICHAR(class->pspec))
|
||||
input = glade_editor_create_input_unichar (property);
|
||||
|
||||
if (input == NULL) {
|
||||
g_warning ("Can't create an input widget for type %s\n",
|
||||
property->class->name);
|
||||
class->name);
|
||||
return gtk_label_new ("Implement me !");
|
||||
}
|
||||
|
||||
label = glade_editor_create_item_label (property->class);
|
||||
label = glade_editor_create_item_label (class);
|
||||
|
||||
glade_editor_table_attach (table->table_widget, label, 0, table->rows);
|
||||
glade_editor_table_attach (table->table_widget, input, 1, table->rows);
|
||||
@ -1137,15 +1150,16 @@ glade_editor_table_append_item (GladeEditorTable *table,
|
||||
{
|
||||
GladeEditorProperty *property;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (class), NULL);
|
||||
property = g_new0 (GladeEditorProperty, 1);
|
||||
|
||||
property->class = class;
|
||||
property->children = NULL;
|
||||
property->class = class;
|
||||
property->property = NULL;
|
||||
|
||||
/* Set this before creating the widget. */
|
||||
property->from_query_dialog = from_query_dialog;
|
||||
property->input = glade_editor_append_item_real (table, property);
|
||||
property->property = NULL;
|
||||
|
||||
|
||||
return property;
|
||||
@ -1440,10 +1454,10 @@ static void
|
||||
glade_editor_property_set_tooltips (GladeEditorProperty *property)
|
||||
{
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->class != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
glade_util_widget_set_tooltip (property->input, property->class->tooltip);
|
||||
glade_util_widget_set_tooltip (property->input, property->property->class->tooltip);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1451,15 +1465,18 @@ glade_editor_property_set_tooltips (GladeEditorProperty *property)
|
||||
static void
|
||||
glade_editor_property_load_integer (GladeEditorProperty *property)
|
||||
{
|
||||
GtkWidget *spin = NULL;
|
||||
gfloat val = 0.0F;
|
||||
GladePropertyClass *class;
|
||||
GtkWidget *spin = NULL;
|
||||
gfloat val = 0.0F;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
if (property->property->class->optional) {
|
||||
class = property->property->class;
|
||||
|
||||
if (class->optional) {
|
||||
GtkBoxChild *child;
|
||||
GtkWidget *widget1;
|
||||
GtkWidget *widget2;
|
||||
@ -1489,25 +1506,25 @@ glade_editor_property_load_integer (GladeEditorProperty *property)
|
||||
spin = property->input;
|
||||
}
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT(property->class->pspec))
|
||||
if (G_IS_PARAM_SPEC_INT(class->pspec))
|
||||
val = (gfloat) g_value_get_int (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_UINT(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_UINT(class->pspec))
|
||||
val = (gfloat) g_value_get_uint (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_LONG(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_LONG(class->pspec))
|
||||
val = (gfloat) g_value_get_long (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_ULONG(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_ULONG(class->pspec))
|
||||
val = (gfloat) g_value_get_ulong (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_INT64(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_INT64(class->pspec))
|
||||
val = (gfloat) g_value_get_int64 (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_UINT64(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_UINT64(class->pspec))
|
||||
val = (gfloat) g_value_get_uint64 (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE(class->pspec))
|
||||
val = (gfloat) g_value_get_double (property->property->value);
|
||||
else if (G_IS_PARAM_SPEC_FLOAT(property->class->pspec))
|
||||
else if (G_IS_PARAM_SPEC_FLOAT(class->pspec))
|
||||
val = g_value_get_float (property->property->value);
|
||||
else
|
||||
g_warning ("Unsupported type %s\n",
|
||||
g_type_name(property->class->pspec->value_type));
|
||||
g_type_name(class->pspec->value_type));
|
||||
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), val);
|
||||
|
||||
@ -1525,11 +1542,11 @@ glade_editor_property_load_enum (GladeEditorProperty *property)
|
||||
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
g_return_if_fail ((eclass = g_type_class_ref
|
||||
(property->class->pspec->value_type)) != NULL);
|
||||
(property->property->class->pspec->value_type)) != NULL);
|
||||
|
||||
pclass = property->property->class;
|
||||
|
||||
@ -1561,7 +1578,7 @@ glade_editor_property_load_flags (GladeEditorProperty *property)
|
||||
gchar *text;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
g_return_if_fail (GTK_IS_HBOX (property->input));
|
||||
@ -1571,7 +1588,7 @@ glade_editor_property_load_flags (GladeEditorProperty *property)
|
||||
entry = child->widget;
|
||||
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||
|
||||
text = glade_property_class_make_string_from_flags(property->class,
|
||||
text = glade_property_class_make_string_from_flags(property->property->class,
|
||||
g_value_get_flags(property->property->value),
|
||||
TRUE);
|
||||
|
||||
@ -1587,7 +1604,7 @@ glade_editor_property_load_boolean (GladeEditorProperty *property)
|
||||
gboolean state;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (property->input));
|
||||
@ -1609,7 +1626,7 @@ glade_editor_property_load_text (GladeEditorProperty *property)
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
@ -1652,7 +1669,7 @@ static void
|
||||
glade_editor_property_load_unichar (GladeEditorProperty *property)
|
||||
{
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property->property));
|
||||
g_return_if_fail (property->property->value != NULL);
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
@ -1675,19 +1692,23 @@ glade_editor_property_load_unichar (GladeEditorProperty *property)
|
||||
static void
|
||||
glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
{
|
||||
GladePropertyClass *class = property->class;
|
||||
GladePropertyClass *class;
|
||||
|
||||
g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (property));
|
||||
g_return_if_fail (GLADE_IS_PROPERTY_CLASS (property->class));
|
||||
|
||||
property->property = glade_widget_get_property (widget, class->id);
|
||||
class = property->class;
|
||||
|
||||
g_return_if_fail (property->property != NULL);
|
||||
g_return_if_fail (property->property->class == property->class);
|
||||
/* Load the property */
|
||||
if ((property->property = glade_widget_get_property (widget, class->id)) == NULL)
|
||||
{
|
||||
g_critical ("Couldnt find property of class %s on widget of class %s\n",
|
||||
class->id, widget->widget_class->name);
|
||||
return;
|
||||
}
|
||||
|
||||
property->property->loading = TRUE;
|
||||
|
||||
|
||||
if (G_IS_PARAM_SPEC_ENUM(class->pspec))
|
||||
glade_editor_property_load_enum (property);
|
||||
else if (G_IS_PARAM_SPEC_FLAGS(class->pspec))
|
||||
|
@ -62,7 +62,8 @@ glade_property_class_new (void)
|
||||
property_class->optional_default = TRUE;
|
||||
property_class->common = FALSE;
|
||||
property_class->packing = FALSE;
|
||||
property_class->is_modified = FALSE;
|
||||
property_class->save = TRUE;
|
||||
property_class->editable = TRUE;
|
||||
property_class->is_modified = FALSE;
|
||||
property_class->verify_function = NULL;
|
||||
property_class->set_function = NULL;
|
||||
@ -811,6 +812,8 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
class->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, FALSE);
|
||||
class->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, FALSE);
|
||||
class->query = glade_xml_get_property_boolean (node, GLADE_TAG_QUERY, FALSE);
|
||||
class->save = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, FALSE);
|
||||
class->editable = glade_xml_get_property_boolean (node, GLADE_TAG_EDITABLE, FALSE);
|
||||
|
||||
if (class->optional)
|
||||
class->optional_default =
|
||||
|
@ -143,7 +143,13 @@ struct _GladePropertyClass
|
||||
* means that it needs extra parameters in the
|
||||
* UI.
|
||||
*/
|
||||
|
||||
|
||||
gboolean save; /* Whether we should save to the glade file or not
|
||||
* (mostly just for custom glade properties)
|
||||
*/
|
||||
gboolean editable; /* Whether or not to show this property in the editor
|
||||
*/
|
||||
|
||||
gboolean is_modified; /* If true, this property_class has been "modified" from the
|
||||
* the standard property by a xml file. */
|
||||
|
||||
|
@ -32,59 +32,22 @@
|
||||
#include "glade-project.h"
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-debug.h"
|
||||
#include "glade-app.h"
|
||||
#include "glade-editor.h"
|
||||
#include "glade-marshallers.h"
|
||||
|
||||
/**
|
||||
* glade_property_new:
|
||||
* @class:
|
||||
* @widget:
|
||||
*
|
||||
* TODO: write me
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
GladeProperty *
|
||||
glade_property_new (GladePropertyClass *class, GladeWidget *widget, GValue *value)
|
||||
enum
|
||||
{
|
||||
GladeProperty *property;
|
||||
VALUE_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (class), NULL);
|
||||
|
||||
property = g_new0 (GladeProperty, 1);
|
||||
property->class = class;
|
||||
property->widget = widget;
|
||||
property->value = value;
|
||||
property->enabled = TRUE;
|
||||
|
||||
property->i18n_translatable = FALSE;
|
||||
property->i18n_has_context = FALSE;
|
||||
property->i18n_comment = NULL;
|
||||
|
||||
if (G_IS_PARAM_SPEC_DOUBLE (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_FLOAT (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_LONG (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_ULONG (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_INT64 (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT64 (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_INT (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT (class->pspec))
|
||||
property->enabled = class->optional_default;
|
||||
|
||||
/* Create an empty default if the class does not specify a default value */
|
||||
if (property->value == NULL)
|
||||
{
|
||||
if (!class->def)
|
||||
property->value =
|
||||
glade_property_class_make_gvalue_from_string (class, "");
|
||||
else
|
||||
{
|
||||
property->value = g_new0 (GValue, 1);
|
||||
g_value_init (property->value, class->def->g_type);
|
||||
g_value_copy (class->def, property->value);
|
||||
}
|
||||
}
|
||||
return property;
|
||||
}
|
||||
static guint glade_property_signals[LAST_SIGNAL] = { 0 };
|
||||
static GObjectClass* parent_class = NULL;
|
||||
|
||||
/*******************************************************************************
|
||||
GladeProperty class methods
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* glade_property_dup:
|
||||
* @template:
|
||||
@ -94,12 +57,12 @@ glade_property_new (GladePropertyClass *class, GladeWidget *widget, GValue *valu
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
GladeProperty *
|
||||
glade_property_dup (GladeProperty *template, GladeWidget *widget)
|
||||
static GladeProperty *
|
||||
glade_property_dup_impl (GladeProperty *template, GladeWidget *widget)
|
||||
{
|
||||
GladeProperty *property;
|
||||
|
||||
property = g_new0 (GladeProperty, 1);
|
||||
property = g_object_new (GLADE_TYPE_PROPERTY, NULL);
|
||||
property->class = template->class;
|
||||
property->widget = widget;
|
||||
property->value = g_new0 (GValue, 1);
|
||||
@ -109,35 +72,12 @@ glade_property_dup (GladeProperty *template, GladeWidget *widget)
|
||||
g_value_copy (template->value, property->value);
|
||||
|
||||
property->i18n_translatable = template->i18n_translatable;
|
||||
property->i18n_has_context = template->i18n_has_context;
|
||||
property->i18n_comment = g_strdup (template->i18n_comment);
|
||||
property->i18n_has_context = template->i18n_has_context;
|
||||
property->i18n_comment = g_strdup (template->i18n_comment);
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_free:
|
||||
* @property: a #GladeProperty
|
||||
*
|
||||
* Frees @property and its associated memory.
|
||||
*/
|
||||
void
|
||||
glade_property_free (GladeProperty *property)
|
||||
{
|
||||
property->class = NULL;
|
||||
property->widget = NULL;
|
||||
if (property->value)
|
||||
{
|
||||
g_value_unset (property->value);
|
||||
g_free (property->value);
|
||||
property->value = NULL;
|
||||
}
|
||||
|
||||
g_free (property->i18n_comment);
|
||||
|
||||
g_free (property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic set function for properties that do not have a
|
||||
* custom set_property method. This includes packing properties.
|
||||
@ -167,12 +107,9 @@ glade_property_set_property (GladeProperty *property, const GValue *value)
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
void
|
||||
glade_property_set (GladeProperty *property, const GValue *value)
|
||||
static void
|
||||
glade_property_set_impl (GladeProperty *property, const GValue *value)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
g_return_if_fail (value != NULL);
|
||||
|
||||
if (!g_value_type_compatible (G_VALUE_TYPE (property->value), G_VALUE_TYPE (value)))
|
||||
{
|
||||
g_warning ("Trying to assign an incompatible value to property %s\n",
|
||||
@ -193,7 +130,7 @@ glade_property_set (GladeProperty *property, const GValue *value)
|
||||
g_value_reset (property->value);
|
||||
g_value_copy (value, property->value);
|
||||
|
||||
glade_property_sync(property);
|
||||
GLADE_PROPERTY_GET_CINFO (property)->sync (property);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,15 +139,10 @@ glade_property_set (GladeProperty *property, const GValue *value)
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
void
|
||||
glade_property_sync (GladeProperty *property)
|
||||
static void
|
||||
glade_property_sync_impl (GladeProperty *property)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
|
||||
if (!property->enabled)
|
||||
return;
|
||||
|
||||
if (property->loading)
|
||||
if (!property->enabled || property->loading)
|
||||
return;
|
||||
|
||||
property->loading = TRUE;
|
||||
@ -278,15 +210,17 @@ glade_property_sync (GladeProperty *property)
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
gboolean
|
||||
glade_property_write (GArray *props, GladeProperty *property, GladeInterface *interface)
|
||||
static gboolean
|
||||
glade_property_write_impl (GladeProperty *property,
|
||||
GladeInterface *interface,
|
||||
GArray *props)
|
||||
{
|
||||
GladePropInfo info = { 0 };
|
||||
gchar *tmp;
|
||||
gchar *default_str = NULL;
|
||||
gboolean skip;
|
||||
|
||||
if (!property->enabled)
|
||||
if (!property->class->save || !property->enabled)
|
||||
return FALSE;
|
||||
|
||||
if (!glade_property_class_is_visible (property->class,
|
||||
@ -360,9 +294,9 @@ glade_property_write (GArray *props, GladeProperty *property, GladeInterface *in
|
||||
|
||||
/* Parameters for translatable properties. */
|
||||
|
||||
void
|
||||
glade_property_i18n_set_comment (GladeProperty *property,
|
||||
const gchar *str)
|
||||
static void
|
||||
glade_property_i18n_set_comment_impl (GladeProperty *property,
|
||||
const gchar *str)
|
||||
{
|
||||
if (property->i18n_comment)
|
||||
g_free (property->i18n_comment);
|
||||
@ -370,35 +304,319 @@ glade_property_i18n_set_comment (GladeProperty *property,
|
||||
property->i18n_comment = g_strdup (str);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
glade_property_i18n_get_comment_impl (GladeProperty *property)
|
||||
{
|
||||
return property->i18n_comment;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_i18n_set_translatable_impl (GladeProperty *property,
|
||||
gboolean translatable)
|
||||
{
|
||||
property->i18n_translatable = translatable;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_property_i18n_get_translatable_impl (GladeProperty *property)
|
||||
{
|
||||
return property->i18n_translatable;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_i18n_set_has_context_impl (GladeProperty *property,
|
||||
gboolean has_context)
|
||||
{
|
||||
property->i18n_has_context = has_context;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_property_i18n_get_has_context_impl (GladeProperty *property)
|
||||
{
|
||||
return property->i18n_has_context;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_set_sensitive_impl (GladeProperty *property,
|
||||
gboolean sensitive)
|
||||
{
|
||||
if (property->sensitive != sensitive)
|
||||
{
|
||||
GladeEditor *editor = glade_default_app_get_editor ();
|
||||
|
||||
property->sensitive = sensitive;
|
||||
|
||||
/* Reload editor if this widget is selected */
|
||||
if (editor->loaded_widget == property->widget)
|
||||
glade_editor_refresh (editor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
GObjectClass & Object Construction
|
||||
*******************************************************************************/
|
||||
static void
|
||||
glade_property_finalize (GObject *object)
|
||||
{
|
||||
GladeProperty *property = GLADE_PROPERTY (object);
|
||||
|
||||
if (property->value)
|
||||
{
|
||||
g_value_unset (property->value);
|
||||
g_free (property->value);
|
||||
property->value = NULL;
|
||||
}
|
||||
g_free (property->i18n_comment);
|
||||
g_free (property);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_init (GladeProperty *property)
|
||||
{
|
||||
property->enabled = TRUE;
|
||||
property->sensitive = TRUE;
|
||||
property->i18n_translatable = FALSE;
|
||||
property->i18n_has_context = FALSE;
|
||||
property->i18n_comment = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_property_cinfo_init (GladePropertyCinfo *prop_class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
g_return_if_fail (prop_class != NULL);
|
||||
|
||||
parent_class = g_type_class_peek_parent (prop_class);
|
||||
object_class = G_OBJECT_CLASS (prop_class);
|
||||
|
||||
object_class->finalize = glade_property_finalize;
|
||||
|
||||
/* Class methods */
|
||||
prop_class->set = glade_property_set_impl;
|
||||
prop_class->sync = glade_property_sync_impl;
|
||||
prop_class->write = glade_property_write_impl;
|
||||
prop_class->dup = glade_property_dup_impl;
|
||||
prop_class->set_sensitive = glade_property_set_sensitive_impl;
|
||||
prop_class->i18n_set_comment = glade_property_i18n_set_comment_impl;
|
||||
prop_class->i18n_get_comment = glade_property_i18n_get_comment_impl;
|
||||
prop_class->i18n_set_translatable = glade_property_i18n_set_translatable_impl;
|
||||
prop_class->i18n_get_translatable = glade_property_i18n_get_translatable_impl;
|
||||
prop_class->i18n_set_has_context = glade_property_i18n_set_has_context_impl;
|
||||
prop_class->i18n_get_has_context = glade_property_i18n_get_has_context_impl;
|
||||
|
||||
/* Signals */
|
||||
prop_class->value_changed = NULL;
|
||||
|
||||
glade_property_signals[VALUE_CHANGED] =
|
||||
g_signal_new ("value-changed",
|
||||
G_TYPE_FROM_CLASS (parent_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GladePropertyCinfo,
|
||||
value_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
glade_property_get_type (void)
|
||||
{
|
||||
static GType property_type = 0;
|
||||
|
||||
if (!property_type)
|
||||
{
|
||||
static const GTypeInfo property_info =
|
||||
{
|
||||
sizeof (GladePropertyCinfo), // Cinfo is our class
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) glade_property_cinfo_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GladeProperty),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) glade_property_init,
|
||||
NULL /* value_table */
|
||||
};
|
||||
property_type =
|
||||
g_type_register_static (G_TYPE_OBJECT,
|
||||
"GladeProperty",
|
||||
&property_info, 0);
|
||||
}
|
||||
return property_type;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
API
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* glade_property_new:
|
||||
* @class:
|
||||
* @widget:
|
||||
*
|
||||
* TODO: write me
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
GladeProperty *
|
||||
glade_property_new (GladePropertyClass *class,
|
||||
GladeWidget *widget,
|
||||
GValue *value)
|
||||
{
|
||||
GladeProperty *property;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (class), NULL);
|
||||
|
||||
property =
|
||||
(GladeProperty *)g_object_new (GLADE_TYPE_PROPERTY, NULL);
|
||||
property->class = class;
|
||||
property->widget = widget;
|
||||
property->value = value;
|
||||
|
||||
if (G_IS_PARAM_SPEC_DOUBLE (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_FLOAT (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_LONG (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_ULONG (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_INT64 (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT64 (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_INT (class->pspec) ||
|
||||
G_IS_PARAM_SPEC_UINT (class->pspec))
|
||||
property->enabled = class->optional_default;
|
||||
|
||||
/* Create an empty default if the class does not specify a default value */
|
||||
if (property->value == NULL)
|
||||
{
|
||||
if (!class->def)
|
||||
property->value =
|
||||
glade_property_class_make_gvalue_from_string (class, "");
|
||||
else
|
||||
{
|
||||
property->value = g_new0 (GValue, 1);
|
||||
g_value_init (property->value, class->def->g_type);
|
||||
g_value_copy (class->def, property->value);
|
||||
}
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_dup:
|
||||
* @template:
|
||||
* @widget:
|
||||
*
|
||||
* TODO: write me
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
GladeProperty *
|
||||
glade_property_dup (GladeProperty *template, GladeWidget *widget)
|
||||
{
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY (template), NULL);
|
||||
return GLADE_PROPERTY_GET_CINFO (template)->dup (template, widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_set:
|
||||
* @property: a #GladeProperty
|
||||
* @value: a #GValue
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
void
|
||||
glade_property_set (GladeProperty *property, const GValue *value)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
g_return_if_fail (value != NULL);
|
||||
GLADE_PROPERTY_GET_CINFO (property)->set (property, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_sync:
|
||||
* @property: a #GladeProperty
|
||||
*
|
||||
* TODO: write me
|
||||
*/
|
||||
void
|
||||
glade_property_sync (GladeProperty *property)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
GLADE_PROPERTY_GET_CINFO (property)->sync (property);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_property_write:
|
||||
* @property: a #GladeProperty
|
||||
* @interface: a #GladeInterface
|
||||
* @props: a GArray of #GladePropInfo
|
||||
*
|
||||
* TODO: write me
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
gboolean
|
||||
glade_property_write (GladeProperty *property, GladeInterface *interface, GArray *props)
|
||||
{
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
|
||||
g_return_val_if_fail (interface != NULL, FALSE);
|
||||
g_return_val_if_fail (props != NULL, FALSE);
|
||||
return GLADE_PROPERTY_GET_CINFO (property)->write (property, interface, props);
|
||||
}
|
||||
|
||||
/* Parameters for translatable properties. */
|
||||
void
|
||||
glade_property_i18n_set_comment (GladeProperty *property,
|
||||
const gchar *str)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
GLADE_PROPERTY_GET_CINFO (property)->i18n_set_comment (property, str);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
glade_property_i18n_get_comment (GladeProperty *property)
|
||||
{
|
||||
return property->i18n_comment;
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL);
|
||||
return GLADE_PROPERTY_GET_CINFO (property)->i18n_get_comment (property);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_i18n_set_translatable (GladeProperty *property,
|
||||
gboolean translatable)
|
||||
{
|
||||
property->i18n_translatable = translatable;
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
GLADE_PROPERTY_GET_CINFO (property)->i18n_set_translatable (property, translatable);
|
||||
}
|
||||
|
||||
gboolean
|
||||
glade_property_i18n_get_translatable (GladeProperty *property)
|
||||
{
|
||||
return property->i18n_translatable;
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
|
||||
return GLADE_PROPERTY_GET_CINFO (property)->i18n_get_translatable (property);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_i18n_set_has_context (GladeProperty *property,
|
||||
gboolean has_context)
|
||||
{
|
||||
property->i18n_has_context = has_context;
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
GLADE_PROPERTY_GET_CINFO (property)->i18n_set_has_context (property, has_context);
|
||||
}
|
||||
|
||||
gboolean
|
||||
glade_property_i18n_get_has_context (GladeProperty *property)
|
||||
{
|
||||
return property->i18n_has_context;
|
||||
g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
|
||||
return GLADE_PROPERTY_GET_CINFO (property)->i18n_get_has_context (property);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_set_sensitive (GladeProperty *property,
|
||||
gboolean sensitive)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROPERTY (property));
|
||||
GLADE_PROPERTY_GET_CINFO (property)->set_sensitive (property, sensitive);
|
||||
}
|
||||
|
@ -4,9 +4,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GLADE_PROPERTY(p) ((GladeProperty *)p)
|
||||
#define GLADE_IS_PROPERTY(p) (p != NULL)
|
||||
#define GLADE_TYPE_PROPERTY (glade_property_get_type())
|
||||
#define GLADE_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PROPERTY, GladeProperty))
|
||||
#define GLADE_PROPERTY_CINFO(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PROPERTY, GladePropertyCinfo))
|
||||
#define GLADE_IS_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PROPERTY))
|
||||
#define GLADE_IS_PROPERTY_CINFO(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PROPERTY))
|
||||
#define GLADE_PROPERTY_GET_CINFO(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_PROPERTY, GladePropertyCinfo))
|
||||
|
||||
|
||||
/* A GladeProperty is an instance of a GladePropertyClass.
|
||||
@ -15,63 +18,89 @@ G_BEGIN_DECLS
|
||||
*/
|
||||
struct _GladeProperty
|
||||
{
|
||||
GladePropertyClass *class; /* A pointer to the GladeProperty that this
|
||||
* setting specifies
|
||||
*/
|
||||
GladeWidget *widget; /* A pointer to the GladeWidget that this
|
||||
* GladeProperty is modifying
|
||||
*/
|
||||
GObject parent_instance;
|
||||
|
||||
GValue *value; /* The value of the property
|
||||
*/
|
||||
GladePropertyClass *class; /* A pointer to the GladeProperty that this
|
||||
* setting specifies
|
||||
*/
|
||||
GladeWidget *widget; /* A pointer to the GladeWidget that this
|
||||
* GladeProperty is modifying
|
||||
*/
|
||||
|
||||
GValue *value; /* The value of the property
|
||||
*/
|
||||
|
||||
gboolean enabled; /* Enabled is a flag that is used for GladeProperties
|
||||
* that have the optional flag set to let us know
|
||||
* if this widget has this GladeSetting enabled or
|
||||
* not. (Like default size, it can be specified or
|
||||
* unspecified). This flag also sets the state
|
||||
* of the property->input state for the loaded
|
||||
* widget.
|
||||
*/
|
||||
gboolean sensitive; /* Whether this property is sensitive (if the
|
||||
* property is "optional" this takes precedence).
|
||||
*/
|
||||
|
||||
gboolean enabled; /* Enabled is a flag that is used for GladeProperties
|
||||
* that have the optional flag set to let us know
|
||||
* if this widget has this GladeSetting enabled or
|
||||
* not. (Like default size, it can be specified or
|
||||
* unspecified). This flag also sets the state
|
||||
* of the property->input state for the loaded
|
||||
* widget.
|
||||
*/
|
||||
|
||||
/* Used only for translatable strings. */
|
||||
gboolean i18n_translatable;
|
||||
gboolean i18n_has_context;
|
||||
gchar *i18n_comment;
|
||||
|
||||
#if 0
|
||||
GladeWidget *child; /* A GladeProperty of type object has a child */
|
||||
/* A GladeProperty of type object has a child */
|
||||
GladeWidget *child;
|
||||
#endif
|
||||
gboolean loading;
|
||||
};
|
||||
|
||||
|
||||
LIBGLADEUI_API GladeProperty *glade_property_new (GladePropertyClass *class,
|
||||
GladeWidget *widget,
|
||||
GValue *value);
|
||||
struct _GladePropertyCinfo
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
LIBGLADEUI_API void glade_property_free (GladeProperty *property);
|
||||
/* Class methods */
|
||||
GladeProperty * (* dup) (GladeProperty *, GladeWidget *);
|
||||
void (* set) (GladeProperty *, const GValue *);
|
||||
void (* sync) (GladeProperty *);
|
||||
gboolean (* write) (GladeProperty *, GladeInterface *, GArray *);
|
||||
void (* set_sensitive) (GladeProperty *, gboolean);
|
||||
void (* i18n_set_comment) (GladeProperty *, const gchar *);
|
||||
G_CONST_RETURN gchar * (* i18n_get_comment) (GladeProperty *);
|
||||
void (* i18n_set_translatable) (GladeProperty *, gboolean);
|
||||
gboolean (* i18n_get_translatable) (GladeProperty *);
|
||||
void (* i18n_set_has_context) (GladeProperty *, gboolean);
|
||||
gboolean (* i18n_get_has_context) (GladeProperty *);
|
||||
|
||||
LIBGLADEUI_API void glade_property_set (GladeProperty *property, const GValue *value);
|
||||
/* Signals */
|
||||
void (* value_changed) (GladeProperty *, GValue *);
|
||||
};
|
||||
|
||||
LIBGLADEUI_API void glade_property_sync (GladeProperty *property);
|
||||
LIBGLADEUI_API GType glade_property_get_type (void);
|
||||
LIBGLADEUI_API GladeProperty *glade_property_new (GladePropertyClass *class,
|
||||
GladeWidget *widget,
|
||||
GValue *value);
|
||||
LIBGLADEUI_API GladeProperty *glade_property_dup (GladeProperty *template,
|
||||
GladeWidget *widget);
|
||||
LIBGLADEUI_API void glade_property_set (GladeProperty *property,
|
||||
const GValue *value);
|
||||
LIBGLADEUI_API void glade_property_sync (GladeProperty *property);
|
||||
LIBGLADEUI_API gboolean glade_property_write (GladeProperty *property,
|
||||
GladeInterface *interface,
|
||||
GArray *props);
|
||||
LIBGLADEUI_API void glade_property_set_sensitive (GladeProperty *property,
|
||||
gboolean sensitive);
|
||||
|
||||
LIBGLADEUI_API gboolean glade_property_write (GArray *props, GladeProperty *property,
|
||||
GladeInterface *interface);
|
||||
|
||||
LIBGLADEUI_API GladeProperty *glade_property_dup (GladeProperty *template, GladeWidget *widget);
|
||||
|
||||
LIBGLADEUI_API void glade_property_i18n_set_comment (GladeProperty *property, const gchar *str);
|
||||
|
||||
LIBGLADEUI_API const gchar *glade_property_i18n_get_comment (GladeProperty *property);
|
||||
|
||||
LIBGLADEUI_API void glade_property_i18n_set_translatable (GladeProperty *property, gboolean translatable);
|
||||
|
||||
LIBGLADEUI_API gboolean glade_property_i18n_get_translatable (GladeProperty *property);
|
||||
|
||||
LIBGLADEUI_API void glade_property_i18n_set_has_context (GladeProperty *property, gboolean has_context);
|
||||
|
||||
LIBGLADEUI_API gboolean glade_property_i18n_get_has_context (GladeProperty *property);
|
||||
LIBGLADEUI_API void glade_property_i18n_set_comment (GladeProperty *property,
|
||||
const gchar *str);
|
||||
LIBGLADEUI_API G_CONST_RETURN gchar *glade_property_i18n_get_comment (GladeProperty *property);
|
||||
LIBGLADEUI_API void glade_property_i18n_set_translatable (GladeProperty *property,
|
||||
gboolean translatable);
|
||||
LIBGLADEUI_API gboolean glade_property_i18n_get_translatable (GladeProperty *property);
|
||||
LIBGLADEUI_API void glade_property_i18n_set_has_context (GladeProperty *property,
|
||||
gboolean has_context);
|
||||
LIBGLADEUI_API gboolean glade_property_i18n_get_has_context (GladeProperty *property);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -15,6 +15,7 @@ typedef struct _GladeWidgetClassSignal GladeWidgetClassSignal;
|
||||
typedef struct _GladePackagingDefault GladePackingDefault;
|
||||
|
||||
typedef struct _GladeProperty GladeProperty;
|
||||
typedef struct _GladePropertyCinfo GladePropertyCinfo;
|
||||
typedef struct _GladePropertyClass GladePropertyClass;
|
||||
typedef struct _GladePropertyQuery GladePropertyQuery;
|
||||
|
||||
|
@ -787,13 +787,13 @@ glade_widget_finalize (GObject *object)
|
||||
|
||||
if (widget->properties)
|
||||
{
|
||||
g_list_foreach (widget->properties, (GFunc)glade_property_free, NULL);
|
||||
g_list_foreach (widget->properties, (GFunc)g_object_unref, NULL);
|
||||
g_list_free (widget->properties);
|
||||
}
|
||||
|
||||
if (widget->packing_properties)
|
||||
{
|
||||
g_list_foreach (widget->packing_properties, (GFunc)glade_property_free, NULL);
|
||||
g_list_foreach (widget->packing_properties, (GFunc)g_object_unref, NULL);
|
||||
g_list_free (widget->packing_properties);
|
||||
}
|
||||
|
||||
@ -1688,7 +1688,7 @@ glade_widget_set_packing_properties (GladeWidget *widget,
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
g_return_if_fail (GLADE_IS_WIDGET (container));
|
||||
|
||||
g_list_foreach (widget->packing_properties, (GFunc) glade_property_free, NULL);
|
||||
g_list_foreach (widget->packing_properties, (GFunc)g_object_unref, NULL);
|
||||
g_list_free (widget->packing_properties);
|
||||
|
||||
glade_widget_set_default_packing_properties (container, widget);
|
||||
@ -1809,7 +1809,7 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
|
||||
if (property->class->packing)
|
||||
continue;
|
||||
|
||||
glade_property_write (props, property, interface);
|
||||
glade_property_write (property, interface, props);
|
||||
}
|
||||
info->properties = (GladePropInfo *) props->data;
|
||||
info->n_properties = props->len;
|
||||
@ -1933,7 +1933,7 @@ glade_widget_write_child (GArray *children,
|
||||
|
||||
property = list->data;
|
||||
g_assert (property->class->packing == TRUE);
|
||||
glade_property_write (props, property, interface);
|
||||
glade_property_write (property, interface, props);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
#ifndef __GLADE_H__
|
||||
#define __GLADE_H__
|
||||
@ -105,6 +106,8 @@
|
||||
#define GLADE_TAG_DISPLAYABLE_VALUES "displayable-values"
|
||||
#define GLADE_TAG_NICK "nick"
|
||||
#define GLADE_TAG_SPECIAL_CHILD_TYPE "special-child-type"
|
||||
#define GLADE_TAG_SAVE "save"
|
||||
#define GLADE_TAG_EDITABLE "editable"
|
||||
|
||||
LIBGLADEUI_API gboolean glade_verbose;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user