Commit 9a0ff231 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Add support for deprecated properties and signals.

Parse the "deprecated" parts of gtk+.xml.in on properties and signals,
and update GladeProject to format the deprecation messages when verifying
the project.
parent 8a5cba1a
......@@ -2088,6 +2088,11 @@ glade_project_preview (GladeProject *project, GladeWidget *gwidget)
Verify code here (versioning, incompatability checks)
*******************************************************************/
/* Defined here for pretty translator comments (bug in intl tools, for some reason
* you can only comment about the line directly following, forcing you to write
* ugly messy code with comments in line breaks inside function calls).
*/
/* translators: refers to a widget in toolkit version '%s %d.%d' and a project targeting toolkit version '%s %d.%d' */
#define WIDGET_VERSION_CONFLICT_MSGFMT _("This widget was introduced in %s %d.%d " \
"while project targets %s %d.%d")
......@@ -2101,11 +2106,6 @@ glade_project_preview (GladeProject *project, GladeWidget *gwidget)
#define WIDGET_DEPRECATED_FMT _("[%s] Object class '%s' from %s %d.%d is deprecated\n")
/* Defined here for pretty translator comments (bug in intl tools, for some reason
* you can only comment about the line directly following, forcing you to write
* ugly messy code with comments in line breaks inside function calls).
*/
/* translators: refers to a property in toolkit version '%s %d.%d'
* and a project targeting toolkit version '%s %d.%d' */
#define PROP_VERSION_CONFLICT_MSGFMT _("This property was introduced in %s %d.%d " \
......@@ -2119,22 +2119,33 @@ glade_project_preview (GladeProject *project, GladeWidget *gwidget)
#define PACK_PROP_VERSION_CONFLICT_FMT _("[%s] Packing property '%s' of object class '%s' " \
"was introduced in %s %d.%d\n")
/* translators: refers to a signal '%s' of widget '[%s]' in toolkit version '%s %d.%d' */
#define SIGNAL_VERSION_CONFLICT_FMT _("[%s] Signal '%s' of object class '%s' " \
"was introduced in %s %d.%d\n")
#define PROP_DEPRECATED_MSG _("This property is deprecated")
/* translators: refers to a property '%s' of widget '[%s]' */
#define PROP_DEPRECATED_FMT _("[%s] Property '%s' of object class '%s' is deprecated")
/* translators: refers to a signal in toolkit version '%s %d.%d'
* and a project targeting toolkit version '%s %d.%d' */
#define SIGNAL_VERSION_CONFLICT_MSGFMT _("This signal was introduced in %s %d.%d " \
"while project targets %s %d.%d")
/* translators: refers to a signal '%s' of widget '[%s]' in toolkit version '%s %d.%d' */
#define SIGNAL_VERSION_CONFLICT_FMT _("[%s] Signal '%s' of object class '%s' " \
"was introduced in %s %d.%d\n")
#define SIGNAL_DEPRECATED_MSG _("This signal is deprecated")
/* translators: refers to a signal '%s' of widget '[%s]' */
#define SIGNAL_DEPRECATED_FMT _("[%s] Signal '%s' of object class '%s' is deprecated")
static void
glade_project_verify_property_internal (GladeProject *project,
GladeProperty *property,
const gchar *path_name,
GString *string,
gboolean forwidget)
gboolean forwidget,
gboolean saving)
{
GladeWidgetAdaptor *adaptor, *prop_adaptor;
GladePropertyClass *pclass;
......@@ -2179,6 +2190,17 @@ glade_project_verify_property_internal (GladeProject *project,
glade_property_class_since_major (pclass),
glade_property_class_since_minor (pclass));
}
else if (!saving && glade_property_class_deprecated (pclass))
{
if (forwidget)
glade_property_set_support_warning (property, FALSE, PROP_DEPRECATED_MSG);
else
g_string_append_printf (string,
PROP_DEPRECATED_FMT,
path_name,
glade_property_class_get_name (pclass),
glade_widget_adaptor_get_title (adaptor));
}
else if (forwidget)
glade_property_set_support_warning (property, FALSE, NULL);
......@@ -2189,7 +2211,8 @@ static void
glade_project_verify_properties_internal (GladeWidget *widget,
const gchar *path_name,
GString *string,
gboolean forwidget)
gboolean forwidget,
gboolean saving)
{
GList *list;
GladeProperty *property;
......@@ -2199,7 +2222,7 @@ glade_project_verify_properties_internal (GladeWidget *widget,
property = list->data;
glade_project_verify_property_internal (glade_widget_get_project (widget),
property, path_name,
string, forwidget);
string, forwidget, saving);
}
/* Sometimes widgets on the clipboard have packing props with no parent */
......@@ -2209,7 +2232,7 @@ glade_project_verify_properties_internal (GladeWidget *widget,
{
property = list->data;
glade_project_verify_property_internal (glade_widget_get_project (widget),
property, path_name, string, forwidget);
property, path_name, string, forwidget, saving);
}
}
}
......@@ -2219,7 +2242,8 @@ glade_project_verify_signal_internal (GladeWidget *widget,
GladeSignal *signal,
const gchar *path_name,
GString *string,
gboolean forwidget)
gboolean forwidget,
gboolean saving)
{
GladeSignalClass *signal_class;
GladeWidgetAdaptor *adaptor;
......@@ -2264,6 +2288,17 @@ glade_project_verify_signal_internal (GladeWidget *widget,
glade_signal_class_since_major (signal_class),
glade_signal_class_since_minor (signal_class));
}
else if (!saving && glade_signal_class_deprecated (signal_class))
{
if (forwidget)
glade_signal_set_support_warning (signal, SIGNAL_DEPRECATED_MSG);
else
g_string_append_printf (string,
SIGNAL_DEPRECATED_FMT,
path_name,
glade_signal_get_name (signal),
glade_widget_adaptor_get_title (adaptor));
}
else if (forwidget)
glade_signal_set_support_warning (signal, NULL);
......@@ -2282,20 +2317,21 @@ glade_project_verify_property (GladeProperty *property)
project = glade_widget_get_project (widget);
if (project)
glade_project_verify_property_internal (project, property, NULL, NULL, TRUE);
glade_project_verify_property_internal (project, property, NULL, NULL, TRUE, FALSE);
}
void
glade_project_verify_signal (GladeWidget *widget, GladeSignal *signal)
{
glade_project_verify_signal_internal (widget, signal, NULL, NULL, TRUE);
glade_project_verify_signal_internal (widget, signal, NULL, NULL, TRUE, FALSE);
}
static void
glade_project_verify_signals (GladeWidget *widget,
const gchar *path_name,
GString *string,
gboolean forwidget)
gboolean forwidget,
gboolean saving)
{
GladeSignal *signal;
GList *signals, *list;
......@@ -2306,7 +2342,7 @@ glade_project_verify_signals (GladeWidget *widget,
{
signal = list->data;
glade_project_verify_signal_internal (widget, signal, path_name,
string, forwidget);
string, forwidget, saving);
}
g_list_free (signals);
}
......@@ -2332,8 +2368,8 @@ glade_project_verify_properties (GladeWidget *widget)
if (!project || project->priv->loading)
return;
glade_project_verify_properties_internal (widget, NULL, NULL, TRUE);
glade_project_verify_signals (widget, NULL, NULL, TRUE);
glade_project_verify_properties_internal (widget, NULL, NULL, TRUE, FALSE);
glade_project_verify_signals (widget, NULL, NULL, TRUE, FALSE);
glade_widget_support_changed (widget);
}
......@@ -2405,9 +2441,8 @@ glade_project_verify (GladeProject *project, gboolean saving)
glade_project_verify_adaptor (project, glade_widget_get_adaptor (widget),
path_name, string, saving, FALSE, NULL);
glade_project_verify_properties_internal (widget, path_name, string,
FALSE);
glade_project_verify_signals (widget, path_name, string, FALSE);
glade_project_verify_properties_internal (widget, path_name, string, FALSE, saving);
glade_project_verify_signals (widget, path_name, string, FALSE, saving);
g_free (path_name);
}
......
......@@ -176,6 +176,8 @@ struct _GladePropertyClass
* in the project
*/
guint deprecated : 1; /* True if this property is deprecated */
gdouble weight; /* This will determine the position of this property in
* the editor.
*/
......@@ -229,9 +231,10 @@ glade_property_class_new (GladeWidgetAdaptor *adaptor,
property_class->weight = -1.0;
property_class->parentless_widget = FALSE;
/* Initialize them to the base version */
/* Initialize property versions & deprecated to adaptor */
property_class->version_since_major = GWA_VERSION_SINCE_MAJOR (adaptor);
property_class->version_since_minor = GWA_VERSION_SINCE_MINOR (adaptor);
property_class->deprecated = GWA_DEPRECATED (adaptor);
return property_class;
}
......@@ -1478,6 +1481,13 @@ glade_property_class_since_minor (GladePropertyClass *property_class)
return property_class->version_since_minor;
}
gboolean
glade_property_class_deprecated (GladePropertyClass *property_class)
{
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property_class), FALSE);
return property_class->deprecated;
}
G_CONST_RETURN gchar *
glade_property_class_id (GladePropertyClass *property_class)
......@@ -2089,6 +2099,16 @@ glade_property_class_update_from_node (GladeXmlNode * node,
klass->parentless_widget);
glade_xml_get_property_version (node, GLADE_TAG_VERSION_SINCE,
&klass->version_since_major,
&klass->version_since_minor);
klass->deprecated =
glade_xml_get_property_boolean (node,
GLADE_TAG_DEPRECATED,
klass->deprecated);
if ((buf = glade_xml_get_property_string
(node, GLADE_TAG_CREATE_TYPE)) != NULL)
{
......
......@@ -118,6 +118,7 @@ G_CONST_RETURN gchar *glade_property_class_create_type (GladePropert
guint16 glade_property_class_since_major (GladePropertyClass *property_class);
guint16 glade_property_class_since_minor (GladePropertyClass *property_class);
gboolean glade_property_class_deprecated (GladePropertyClass *property_class);
GValue *glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class,
const gchar *string,
......
......@@ -38,6 +38,8 @@ struct _GladeSignalClass
const gchar *name; /* Name of the signal, eg clicked */
const gchar *type; /* Name of the object class that this signal
* belongs to eg GtkButton */
guint deprecated : 1; /* True if this signal is deprecated */
};
GladeSignalClass *
......@@ -66,9 +68,10 @@ glade_signal_class_new (GladeWidgetAdaptor *adaptor,
class->name = (class->query.signal_name);
class->type = g_type_name (for_type);
/* Initialize signal versions to adaptor version */
/* Initialize signal versions & deprecated to adaptor version */
class->version_since_major = GWA_VERSION_SINCE_MAJOR (adaptor);
class->version_since_minor = GWA_VERSION_SINCE_MINOR (adaptor);
class->deprecated = GWA_DEPRECATED (adaptor);
return class;
}
......@@ -90,6 +93,11 @@ glade_signal_class_update_from_node (GladeSignalClass *signal_class,
glade_xml_get_property_version (node, GLADE_TAG_VERSION_SINCE,
&signal_class->version_since_major,
&signal_class->version_since_minor);
signal_class->deprecated =
glade_xml_get_property_boolean (node,
GLADE_TAG_DEPRECATED,
signal_class->deprecated);
}
GladeWidgetAdaptor *
......@@ -151,3 +159,19 @@ glade_signal_class_since_minor (GladeSignalClass *signal_class)
return signal_class->version_since_minor;
}
void
glade_signal_class_set_deprecated (GladeSignalClass *signal_class,
gboolean deprecated)
{
g_return_if_fail (signal_class != NULL);
signal_class->deprecated = deprecated;
}
gboolean
glade_signal_class_deprecated (GladeSignalClass *signal_class)
{
g_return_val_if_fail (signal_class != NULL, FALSE);
return signal_class->deprecated;
}
......@@ -66,6 +66,9 @@ void glade_signal_class_set_since (GladeSignalCl
guint16 glade_signal_class_since_major (GladeSignalClass *signal_class);
guint16 glade_signal_class_since_minor (GladeSignalClass *signal_class);
void glade_signal_class_set_deprecated (GladeSignalClass *signal_class,
gboolean deprecated);
gboolean glade_signal_class_deprecated (GladeSignalClass *signal_class);
G_END_DECLS
......
......@@ -532,7 +532,11 @@ gwa_inherit_signals (GladeWidgetAdaptor *adaptor)
{
parent_signal = node->data;
/* Reset versioning in derived catalogs just once */
/* XXX FIXME: This is questionable, why should derived catalogs
* reset the derived signal versions ???
*
* Reset versioning in derived catalogs just once
*/
if (strcmp (adaptor->priv->catalog,
parent_adaptor->priv->catalog))
glade_signal_class_set_since (signal, 0, 0);
......@@ -540,6 +544,8 @@ gwa_inherit_signals (GladeWidgetAdaptor *adaptor)
glade_signal_class_set_since (signal,
glade_signal_class_since_major (parent_signal),
glade_signal_class_since_minor (parent_signal));
glade_signal_class_set_deprecated (signal, glade_signal_class_deprecated (parent_signal));
}
}
}
......
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