Commit e19eaa02 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

added glade_widget_property_original_default()

* gladeui/glade-widget.[ch]: added glade_widget_property_original_default()

* gladeui/glade-property.[ch]: added glade_property_original_default()
  and glade_property_original_reset()

* plugins/gtk+/glade-gtk.c: fixed bug 397043
  "Not able to set label and stock separately in GtkImageMenuItems"

* plugins/gtk+/gtk+.xml.in: added generic-name to GtkMenuShell.

svn path=/trunk/; revision=1106
parent cdcad135
2007-02-15 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* gladeui/glade-widget.[ch]: added glade_widget_property_original_default()
* gladeui/glade-property.[ch]: added glade_property_original_default()
and glade_property_original_reset()
* plugins/gtk+/glade-gtk.c: fixed bug 397043
"Not able to set label and stock separately in GtkImageMenuItems"
* plugins/gtk+/gtk+.xml.in: added generic-name to GtkMenuShell.
2006-02-15 Jens Granseuer <jensgr@gmx.net>
* Fixed sources to build with gcc 2.95 (bug 406504)
......
......@@ -93,20 +93,6 @@ glade_property_dup_impl (GladeProperty *template_prop, GladeWidget *widget)
return property;
}
void
glade_property_reset_impl (GladeProperty *property)
{
GLADE_PROPERTY_GET_KLASS (property)->set_value
(property, property->klass->def);
}
gboolean
glade_property_default_impl (GladeProperty *property)
{
return GLADE_PROPERTY_GET_KLASS (property)->equals_value
(property, property->klass->def);
}
gboolean
glade_property_equals_value_impl (GladeProperty *property,
const GValue *value)
......@@ -567,8 +553,6 @@ glade_property_klass_init (GladePropertyKlass *prop_class)
/* Class methods */
prop_class->dup = glade_property_dup_impl;
prop_class->reset = glade_property_reset_impl;
prop_class->def = glade_property_default_impl;
prop_class->equals_value = glade_property_equals_value_impl;
prop_class->set_value = glade_property_set_value_impl;
prop_class->get_value = glade_property_get_value_impl;
......@@ -1039,6 +1023,15 @@ glade_property_dup (GladeProperty *template_prop, GladeWidget *widget)
return GLADE_PROPERTY_GET_KLASS (template_prop)->dup (template_prop, widget);
}
static void
glade_property_reset_common (GladeProperty *property, gboolean original)
{
g_return_if_fail (GLADE_IS_PROPERTY (property));
GLADE_PROPERTY_GET_KLASS (property)->set_value
(property, (original) ? property->klass->orig_def : property->klass->def);
}
/**
* glade_property_reset:
* @property: A #GladeProperty
......@@ -1048,8 +1041,27 @@ glade_property_dup (GladeProperty *template_prop, GladeWidget *widget)
void
glade_property_reset (GladeProperty *property)
{
g_return_if_fail (GLADE_IS_PROPERTY (property));
GLADE_PROPERTY_GET_KLASS (property)->reset (property);
glade_property_reset_common (property, FALSE);
}
/**
* glade_property_original_reset:
* @property: A #GladeProperty
*
* Resets this property to its original default value
*/
void
glade_property_original_reset (GladeProperty *property)
{
glade_property_reset_common (property, TRUE);
}
static gboolean
glade_property_default_common (GladeProperty *property, gboolean orig)
{
g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
return GLADE_PROPERTY_GET_KLASS (property)->equals_value
(property, (orig) ? property->klass->orig_def : property->klass->def);
}
/**
......@@ -1061,8 +1073,19 @@ glade_property_reset (GladeProperty *property)
gboolean
glade_property_default (GladeProperty *property)
{
g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
return GLADE_PROPERTY_GET_KLASS (property)->def (property);
return glade_property_default_common (property, FALSE);
}
/**
* glade_property_original_default:
* @property: A #GladeProperty
*
* Returns: Whether this property is at its original default value
*/
gboolean
glade_property_original_default (GladeProperty *property)
{
return glade_property_default_common (property, TRUE);
}
/**
......
......@@ -63,8 +63,6 @@ struct _GladePropertyKlass
/* Class methods */
GladeProperty * (* dup) (GladeProperty *, GladeWidget *);
void (* reset) (GladeProperty *);
gboolean (* def) (GladeProperty *);
gboolean (* equals_value) (GladeProperty *, const GValue *);
void (* set_value) (GladeProperty *, const GValue *);
void (* get_value) (GladeProperty *, GValue *);
......@@ -92,8 +90,12 @@ GladeProperty *glade_property_dup (GladeProperty
LIBGLADEUI_API
void glade_property_reset (GladeProperty *property);
LIBGLADEUI_API
void glade_property_original_reset (GladeProperty *property);
LIBGLADEUI_API
gboolean glade_property_default (GladeProperty *property);
LIBGLADEUI_API
gboolean glade_property_original_default (GladeProperty *property);
LIBGLADEUI_API
gboolean glade_property_equals_value (GladeProperty *property,
const GValue *value);
LIBGLADEUI_API
......
......@@ -1891,7 +1891,9 @@ glade_widget_properties_from_widget_info (GladeWidgetAdaptor *klass,
* otherwise initialize property to default.
*/
property = glade_property_new (pclass, NULL, NULL, FALSE);
glade_property_original_reset (property);
glade_property_read (property, property->klass,
loading_project, info, TRUE);
......@@ -2912,6 +2914,21 @@ glade_widget_pack_property_reset (GladeWidget *widget,
return FALSE;
}
static gboolean
glade_widget_property_default_common (GladeWidget *widget,
const gchar *id_property, gboolean original)
{
GladeProperty *property;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
if ((property = glade_widget_get_property (widget, id_property)) != NULL)
return (original) ? glade_property_original_default (property) :
glade_property_default (property);
return FALSE;
}
/**
* glade_widget_property_default:
* @widget: a #GladeWidget
......@@ -2924,14 +2941,22 @@ gboolean
glade_widget_property_default (GladeWidget *widget,
const gchar *id_property)
{
GladeProperty *property;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
if ((property = glade_widget_get_property (widget, id_property)) != NULL)
return glade_property_default (property);
return glade_widget_property_default_common (widget, id_property, FALSE);
}
return FALSE;
/**
* glade_widget_property_original_default:
* @widget: a #GladeWidget
* @id_property: a string naming a #GladeProperty
*
* Returns: whether whether @id_property was found and is
* currently set to it's original default value.
*/
gboolean
glade_widget_property_original_default (GladeWidget *widget,
const gchar *id_property)
{
return glade_widget_property_default_common (widget, id_property, TRUE);
}
/**
......
......@@ -256,6 +256,9 @@ LIBGLADEUI_API
gboolean glade_widget_property_default (GladeWidget *widget,
const gchar *id_property);
LIBGLADEUI_API
gboolean glade_widget_property_original_default (GladeWidget *widget,
const gchar *id_property);
LIBGLADEUI_API
gboolean glade_widget_pack_property_default (GladeWidget *widget,
const gchar *id_property);
LIBGLADEUI_API
......
......@@ -3622,12 +3622,12 @@ glade_gtk_image_parse_finished (GladeProject *project, GladeWidget *gimage)
{
GladeProperty *property;
gint size;
if (glade_widget_property_default (gimage, "icon-name") == FALSE)
if (glade_widget_property_original_default (gimage, "icon-name") == FALSE)
glade_widget_property_set (gimage, "glade-type", GLADEGTK_IMAGE_ICONTHEME);
else if (glade_widget_property_default (gimage, "stock") == FALSE)
else if (glade_widget_property_original_default (gimage, "stock") == FALSE)
glade_widget_property_set (gimage, "glade-type", GLADEGTK_IMAGE_STOCK);
else if (glade_widget_property_default (gimage, "pixbuf") == FALSE)
else if (glade_widget_property_original_default (gimage, "pixbuf") == FALSE)
glade_widget_property_set (gimage, "glade-type", GLADEGTK_IMAGE_FILENAME);
else
glade_widget_property_reset (gimage, "glade-type");
......@@ -3764,7 +3764,7 @@ glade_gtk_image_set_stock (GObject *object, const GValue *value)
g_free (str);
}
static void
void
glade_gtk_image_set_glade_stock (GObject *object, const GValue *value)
{
GladeWidget *gwidget;
......@@ -3775,7 +3775,11 @@ glade_gtk_image_set_glade_stock (GObject *object, const GValue *value)
g_return_if_fail (GTK_IS_IMAGE (object));
gwidget = glade_widget_get_from_gobject (object);
g_return_if_fail (GLADE_IS_WIDGET (gwidget));
/* This is triggered by glade_widget_sync_custom_props () from glade_widget_new_from_widget_info()
which makes "stock" property to reset */
if (glade_util_object_is_loading (object)) return;
val = g_value_get_enum (value);
eclass = g_type_class_ref (G_VALUE_TYPE (value));
if ((eval = g_enum_get_value (eclass, val)) != NULL)
......@@ -4339,7 +4343,7 @@ glade_gtk_menu_item_set_stock_item (GObject *object, const GValue *value)
is_image_item = GTK_IS_IMAGE_MENU_ITEM (object);
/* If tts a GtkImageMenuItem */
/* If its a GtkImageMenuItem */
if (is_image_item && eval->value_nick)
{
glade_widget_property_set (gitem, "use-stock", TRUE);
......
......@@ -196,7 +196,7 @@
</properties>
</glade-widget-class>
<glade-widget-class name="GtkMenuShell" _title="Menu Shell" use-placeholders="False">
<glade-widget-class name="GtkMenuShell" generic-name="menushell" _title="Menu Shell" use-placeholders="False">
<post-create-function>empty</post-create-function>
<add-child-function>glade_gtk_menu_shell_add_item</add-child-function>
<remove-child-function>glade_gtk_menu_shell_remove_item</remove-child-function>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment