Commit e07fc567 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Fixed a few compile warnings and fixed signal emmission to use


	* src/glade-app.c: Fixed a few compile warnings and fixed signal emmission to
	  use g_signal_emit().

	* src/glade-property.[ch]: glade_property_set to use a va_list for convenience,
	  added glade_property_set_value for setting properties with GValues.
	  Also added emission of value-changed signal.

	* src/glade-command.c, src/glade-editor.c, src/glade-gtk.c, src/glade-widget.c:
	  Changed callers.
parent 16a4bbf6
2005-07-28 Tristan Van Berkom <tvb@gnome.org>
* src/glade-app.c: Fixed a few compile warnings and fixed signal emmission to
use g_signal_emit().
* src/glade-property.[ch]: glade_property_set to use a va_list for convenience,
added glade_property_set_value for setting properties with GValues.
Also added emission of value-changed signal.
* src/glade-command.c, src/glade-editor.c, src/glade-gtk.c, src/glade-widget.c:
Changed callers.
2005-07-28 Tristan Van Berkom <tvb@gnome.org>
* src/glade-catalog.c: Fixed bug in catalog_find_by_name (Luc Simard)
......
......@@ -388,7 +388,8 @@ glade_app_new (void)
void
glade_app_update_ui (GladeApp* app)
{
g_signal_emit_by_name (app, "update-ui");
g_signal_emit (G_OBJECT (app),
glade_app_signals[UPDATE_UI_SIGNAL], 0);
}
void
......@@ -774,14 +775,14 @@ glade_default_app_get_projects (void)
void
glade_default_app_show_properties (gboolean raise)
{
g_return_val_if_fail (glade_default_app != NULL, NULL);
g_return_if_fail (glade_default_app != NULL);
return glade_app_show_properties (glade_default_app, raise);
}
void
glade_default_app_hide_properties (void)
{
g_return_val_if_fail (glade_default_app != NULL, NULL);
g_return_if_fail (glade_default_app != NULL);
return glade_app_hide_properties (glade_default_app);
}
......
......@@ -322,7 +322,7 @@ glade_command_set_property_execute (GladeCommand *cmd)
/* store the current value for undo */
g_value_copy (me->property->value, me->arg_value);
glade_property_set (me->property, &new_value);
glade_property_set_value (me->property, &new_value);
g_value_unset (&new_value);
......
......@@ -188,7 +188,7 @@ glade_editor_property_changed_text_common (GladeProperty *property,
g_value_set_string (&val, text);
if (from_query_dialog == TRUE)
glade_property_set (property, &val);
glade_property_set_value (property, &val);
else
glade_command_set_property (property, &val);
......@@ -278,7 +278,7 @@ glade_editor_property_changed_enum (GtkWidget *menu_item,
g_value_set_enum (&val, ival);
if (property->from_query_dialog)
glade_property_set (gproperty, &val);
glade_property_set_value (gproperty, &val);
else
glade_command_set_property (gproperty, &val);
......@@ -368,7 +368,7 @@ glade_editor_property_changed_numeric (GtkWidget *spin,
g_type_name(property->property->class->pspec->value_type));
if (property->from_query_dialog)
glade_property_set (property->property, &val);
glade_property_set_value (property->property, &val);
else
glade_command_set_property (property->property, &val);
......@@ -399,7 +399,7 @@ glade_editor_property_changed_boolean (GtkWidget *button,
g_value_set_boolean (&val, state);
if (property->from_query_dialog)
glade_property_set (property->property, &val);
glade_property_set_value (property->property, &val);
else
glade_command_set_property (property->property, &val);
......@@ -433,7 +433,7 @@ glade_editor_property_changed_unichar (GtkWidget *entry,
g_value_set_uint (&val, unich);
if (property->from_query_dialog)
glade_property_set (property->property, &val);
glade_property_set_value (property->property, &val);
else
glade_command_set_property (property->property, &val);
......@@ -635,7 +635,7 @@ glade_editor_property_show_flags_dialog (GtkWidget *entry,
g_value_set_flags (&val, new_value);
if (property->from_query_dialog)
glade_property_set (property->property, &val);
glade_property_set_value (property->property, &val);
else
glade_command_set_property (property->property, &val);
......
......@@ -1015,7 +1015,6 @@ glade_gtk_fixed_button_press (GtkWidget *widget,
GladeWidget *gwidget;
GladeWidget *fixed_gwidget;
GladeProperty *property;
GValue value = { 0, };
if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
{
......@@ -1035,30 +1034,24 @@ glade_gtk_fixed_button_press (GtkWidget *widget,
{
/* reset the palette */
glade_palette_unselect_widget (glade_default_app_get_palette());
g_value_init (&value, G_TYPE_INT);
property = glade_widget_get_property (gwidget, "x");
property->enabled = TRUE;
g_value_set_int (&value, (gint) event->x);
glade_property_set (property, &value);
glade_property_set (property, event->x);
property = glade_widget_get_property (gwidget, "y");
property->enabled = TRUE;
g_value_set_int (&value, (gint) event->y);
glade_property_set (property, &value);
glade_property_set (property, event->y);
property = glade_widget_get_property
(gwidget, "width-request");
property->enabled = TRUE;
g_value_set_int (&value, FIXED_DEFAULT_CHILD_WIDTH);
glade_property_set (property, &value);
glade_property_set (property, FIXED_DEFAULT_CHILD_WIDTH);
property = glade_widget_get_property
(gwidget, "height-request");
property->enabled = TRUE;
g_value_set_int (&value, FIXED_DEFAULT_CHILD_HEIGHT);
glade_property_set (property, &value);
glade_property_set (property, FIXED_DEFAULT_CHILD_HEIGHT);
/* We need to resync the editor so that width-request/height-request
* are actualy enabled in the editor
......@@ -1274,7 +1267,6 @@ glade_gtk_frame_create_idle (gpointer data)
GtkWidget *label, *frame;
GladeWidgetClass *wclass;
GladeProperty *property;
GValue value = { 0, };
g_return_val_if_fail (GLADE_IS_WIDGET (data), FALSE);
g_return_val_if_fail (GTK_IS_FRAME (GLADE_WIDGET (data)->object), FALSE);
......@@ -1291,13 +1283,9 @@ glade_gtk_frame_create_idle (gpointer data)
if ((property =
glade_widget_get_property (glabel, "label")) != NULL)
{
g_value_init (&value, G_TYPE_STRING);
g_value_set_static_string (&value, "Frame");
glade_property_set (property, &value);
g_value_unset (&value);
}
else g_critical ("Unable to get \"label\" property\n");
glade_property_set (property, "Frame");
else
g_critical ("Unable to get \"label\" property\n");
g_object_set_data (glabel->object, "special-child-type", "label_item");
gtk_frame_set_label_widget (GTK_FRAME (frame), GTK_WIDGET (glabel->object));
......@@ -1332,7 +1320,6 @@ glade_gtk_button_create_idle (gpointer data)
GtkWidget *widget, *button;
GladeWidgetClass *wclass;
GladeProperty *property;
GValue value = { 0, };
g_return_val_if_fail (GLADE_IS_WIDGET (data), FALSE);
g_return_val_if_fail (GTK_IS_BUTTON (GLADE_WIDGET (data)->object), FALSE);
......@@ -1349,13 +1336,9 @@ glade_gtk_button_create_idle (gpointer data)
if ((property =
glade_widget_get_property (glabel, "label")) != NULL)
{
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, gbutton->widget_class->generic_name);
glade_property_set (property, &value);
g_value_unset (&value);
}
else g_critical ("Unable to get \"label\" property\n");
glade_property_set (property, gbutton->widget_class->generic_name);
else
g_critical ("Unable to get \"label\" property\n");
if (widget)
gtk_container_remove (GTK_CONTAINER (button), widget);
......@@ -1594,7 +1577,7 @@ glade_gtk_dialog_get_internal_child (GtkWidget *dialog,
GtkWidget *child_widget;
g_return_if_fail (GTK_IS_DIALOG (dialog));
if (strcmp ("vbox", name) == 0)
child_widget = GTK_DIALOG (dialog)->vbox;
else if (strcmp ("action_area", name) == 0)
......
......@@ -48,15 +48,6 @@ static GObjectClass* parent_class = NULL;
/*******************************************************************************
GladeProperty class methods
*******************************************************************************/
/**
* glade_property_dup:
* @template:
* @widget:
*
* TODO: write me
*
* Returns:
*/
static GladeProperty *
glade_property_dup_impl (GladeProperty *template, GladeWidget *widget)
{
......@@ -100,16 +91,11 @@ glade_property_set_property (GladeProperty *property, const GValue *value)
}
}
/**
* glade_property_set:
* @property: a #GladeProperty
* @value: a #GValue
*
* TODO: write me
*/
static void
glade_property_set_impl (GladeProperty *property, const GValue *value)
glade_property_set_value_impl (GladeProperty *property, const GValue *value)
{
gboolean changed = FALSE;
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",
......@@ -124,6 +110,11 @@ glade_property_set_impl (GladeProperty *property, const GValue *value)
return;
}
/* save "changed" state.
*/
changed = g_param_values_cmp (property->class->pspec,
property->value, value) != 0;
/* Assign property first so that; if the object need be
* rebuilt, it will reflect the new value
*/
......@@ -131,14 +122,14 @@ glade_property_set_impl (GladeProperty *property, const GValue *value)
g_value_copy (value, property->value);
GLADE_PROPERTY_GET_CINFO (property)->sync (property);
if (changed)
g_signal_emit (G_OBJECT (property),
glade_property_signals[VALUE_CHANGED],
0, property->value);
}
/**
* glade_property_sync:
* @property: a #GladeProperty
*
* TODO: write me
*/
static void
glade_property_sync_impl (GladeProperty *property)
{
......@@ -200,16 +191,6 @@ glade_property_sync_impl (GladeProperty *property)
property->loading = FALSE;
}
/**
* glade_property_write:
* @props: a GArray of #GladePropInfo
* @property: a #GladeProperty
* @interface: a #GladeInterface
*
* TODO: write me
*
* Returns:
*/
static gboolean
glade_property_write_impl (GladeProperty *property,
GladeInterface *interface,
......@@ -293,7 +274,6 @@ glade_property_write_impl (GladeProperty *property,
}
/* Parameters for translatable properties. */
static void
glade_property_i18n_set_comment_impl (GladeProperty *property,
const gchar *str)
......@@ -396,7 +376,7 @@ glade_property_cinfo_init (GladePropertyCinfo *prop_class)
object_class->finalize = glade_property_finalize;
/* Class methods */
prop_class->set = glade_property_set_impl;
prop_class->set_value = glade_property_set_value_impl;
prop_class->sync = glade_property_sync_impl;
prop_class->write = glade_property_write_impl;
prop_class->dup = glade_property_dup_impl;
......@@ -520,6 +500,23 @@ glade_property_dup (GladeProperty *template, GladeWidget *widget)
return GLADE_PROPERTY_GET_CINFO (template)->dup (template, widget);
}
/**
* glade_property_set_value:
* @property: a #GladeProperty
* @value: a #GValue
*
* TODO: write me
*/
void
glade_property_set_value (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_value (property, value);
}
/**
* glade_property_set:
* @property: a #GladeProperty
......@@ -528,11 +525,58 @@ glade_property_dup (GladeProperty *template, GladeWidget *widget)
* TODO: write me
*/
void
glade_property_set (GladeProperty *property, const GValue *value)
glade_property_set (GladeProperty *property, ...)
{
va_list vl;
GValue *value;
g_return_if_fail (GLADE_IS_PROPERTY (property));
g_return_if_fail (value != NULL);
GLADE_PROPERTY_GET_CINFO (property)->set (property, value);
value = g_new0 (GValue, 1);
g_value_init (value, property->class->pspec->value_type);
va_start (vl, property);
if (G_IS_PARAM_SPEC_ENUM(property->class->pspec))
g_value_set_enum (value, va_arg (vl, gint));
else if (G_IS_PARAM_SPEC_FLAGS(property->class->pspec))
g_value_set_flags (value, va_arg (vl, gint));
else if (G_IS_PARAM_SPEC_INT(property->class->pspec))
g_value_set_int (value, va_arg (vl, gint));
else if (G_IS_PARAM_SPEC_UINT(property->class->pspec))
g_value_set_uint (value, va_arg (vl, guint));
else if (G_IS_PARAM_SPEC_LONG(property->class->pspec))
g_value_set_long (value, va_arg (vl, glong));
else if (G_IS_PARAM_SPEC_ULONG(property->class->pspec))
g_value_set_ulong (value, va_arg (vl, gulong));
else if (G_IS_PARAM_SPEC_INT64(property->class->pspec))
g_value_set_int64 (value, va_arg (vl, gint64));
else if (G_IS_PARAM_SPEC_UINT64(property->class->pspec))
g_value_set_uint64 (value, va_arg (vl, guint64));
else if (G_IS_PARAM_SPEC_FLOAT(property->class->pspec))
g_value_set_float (value, (gfloat)va_arg (vl, gdouble));
else if (G_IS_PARAM_SPEC_DOUBLE(property->class->pspec))
g_value_set_double (value, va_arg (vl, gdouble));
else if (G_IS_PARAM_SPEC_STRING(property->class->pspec))
g_value_set_string (value, va_arg (vl, gchar *));
else if (G_IS_PARAM_SPEC_CHAR(property->class->pspec))
g_value_set_char (value, (gchar)va_arg (vl, gint));
else if (G_IS_PARAM_SPEC_UCHAR(property->class->pspec))
g_value_set_uchar (value, (guchar)va_arg (vl, guint));
else if (G_IS_PARAM_SPEC_UNICHAR(property->class->pspec))
g_value_set_uint (value, va_arg (vl, gunichar));
else if (G_IS_PARAM_SPEC_BOOLEAN(property->class->pspec))
g_value_set_boolean (value, va_arg (vl, gboolean));
else
g_critical ("Unsupported pspec type %s",
g_type_name(property->class->pspec->value_type));
va_end (vl);
GLADE_PROPERTY_GET_CINFO (property)->set_value (property, value);
g_value_unset (value);
g_free (value);
}
/**
......
......@@ -62,7 +62,7 @@ struct _GladePropertyCinfo
/* Class methods */
GladeProperty * (* dup) (GladeProperty *, GladeWidget *);
void (* set) (GladeProperty *, const GValue *);
void (* set_value) (GladeProperty *, const GValue *);
void (* sync) (GladeProperty *);
gboolean (* write) (GladeProperty *, GladeInterface *, GArray *);
void (* set_sensitive) (GladeProperty *, gboolean);
......@@ -83,8 +83,10 @@ LIBGLADEUI_API GladeProperty *glade_property_new (GladePr
GValue *value);
LIBGLADEUI_API GladeProperty *glade_property_dup (GladeProperty *template,
GladeWidget *widget);
LIBGLADEUI_API void glade_property_set (GladeProperty *property,
LIBGLADEUI_API void glade_property_set_value (GladeProperty *property,
const GValue *value);
LIBGLADEUI_API void glade_property_set (GladeProperty *property,
...);
LIBGLADEUI_API void glade_property_sync (GladeProperty *property);
LIBGLADEUI_API gboolean glade_property_write (GladeProperty *property,
GladeInterface *interface,
......
......@@ -322,7 +322,7 @@ glade_widget_copy_packing_props (GladeWidget *parent,
GladeProperty *dup_prop = GLADE_PROPERTY(l->data);
GladeProperty *orig_prop =
glade_widget_get_property (template, dup_prop->class->id);
glade_property_set (dup_prop, orig_prop->value);
glade_property_set_value (dup_prop, orig_prop->value);
}
}
......@@ -358,7 +358,7 @@ glade_widget_copy_props (GladeWidget *widget,
GladeProperty *dup_prop = GLADE_PROPERTY(l->data);
GladeProperty *orig_prop =
glade_widget_get_property (template, dup_prop->class->id);
glade_property_set (dup_prop, orig_prop->value);
glade_property_set_value (dup_prop, orig_prop->value);
}
}
......@@ -2000,7 +2000,7 @@ glade_widget_apply_property_from_prop_info (GladePropInfo *info,
if ((gvalue = glade_widget_value_from_prop_info (info, wclass)) != NULL)
{
glade_property_set (property, gvalue);
glade_property_set_value (property, gvalue);
g_value_unset (gvalue);
g_free (gvalue);
......
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