Commit 05191e1c authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

* gladeui/glade-command.[ch]: Removed glade_command_set_naming_policy().

	* gladeui/glade-project.[ch]: Removed naming policy, object ids are always unique.

	* gladeui/glade-editor-property.c, glade-property-class.[ch], gladeui/glade-property.c,
	gladeui/glade-signal-editor.c, gladeui/glade-utils.[ch], gladeui/glade-widget.c,
	gladeui/glade-xml-utils.h, plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-icon-sources.c,
	plugins/gtk+/glade-model-data.c: Removed 'widget' argument from
	glade_property_class_make_gvalue_from_string() and from glade_utils_value_from_string() since
	you never need a common ancestor to search a widget by name anymore.
parent eb93a392
2011-01-22 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-command.[ch]: Removed glade_command_set_naming_policy().
* gladeui/glade-project.[ch]: Removed naming policy, object ids are always unique.
* gladeui/glade-editor-property.c, glade-property-class.[ch], gladeui/glade-property.c,
gladeui/glade-signal-editor.c, gladeui/glade-utils.[ch], gladeui/glade-widget.c,
gladeui/glade-xml-utils.h, plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-icon-sources.c,
plugins/gtk+/glade-model-data.c: Removed 'widget' argument from
glade_property_class_make_gvalue_from_string() and from glade_utils_value_from_string() since
you never need a common ancestor to search a widget by name anymore.
2011-01-21 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-palette.c: Dont strdup the adaptor names in the local hash table (those
......
......@@ -2131,140 +2131,6 @@ glade_command_set_i18n (GladeProperty * property,
g_object_unref (G_OBJECT (me));
}
/******************************************************************************
*
* set project naming policy
*
* This command sets the naming policy on the project.
*
*****************************************************************************/
typedef struct
{
GladeCommand parent;
GladeNamingPolicy policy;
GladeNamingPolicy old_policy;
} GladeCommandSetPolicy;
GLADE_MAKE_COMMAND (GladeCommandSetPolicy, glade_command_set_policy);
#define GLADE_COMMAND_SET_POLICY_TYPE (glade_command_set_policy_get_type ())
#define GLADE_COMMAND_SET_POLICY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GLADE_COMMAND_SET_POLICY_TYPE, GladeCommandSetPolicy))
#define GLADE_COMMAND_SET_POLICY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GLADE_COMMAND_SET_POLICY_TYPE, GladeCommandSetPolicyClass))
#define GLADE_IS_COMMAND_SET_POLICY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GLADE_COMMAND_SET_POLICY_TYPE))
#define GLADE_IS_COMMAND_SET_POLICY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_SET_POLICY_TYPE))
static gboolean
glade_command_set_policy_execute (GladeCommand * cmd)
{
GladeCommandSetPolicy *me = (GladeCommandSetPolicy *) cmd;
GladeNamingPolicy policy;
/* set the new policy */
glade_project_set_naming_policy (cmd->priv->project, me->policy);
/* swap the current values with the old values to prepare for undo */
policy = me->policy;
me->policy = me->old_policy;
me->old_policy = policy;
return TRUE;
}
static gboolean
glade_command_set_policy_undo (GladeCommand * cmd)
{
return glade_command_set_policy_execute (cmd);
}
static void
glade_command_set_policy_finalize (GObject * obj)
{
/* GladeCommandSetPolicy *me; */
g_return_if_fail (GLADE_IS_COMMAND_SET_POLICY (obj));
glade_command_finalize (obj);
}
static gboolean
glade_command_set_policy_unifies (GladeCommand * this_cmd,
GladeCommand * other_cmd)
{
/* GladeCommandSetPolicy *cmd1; */
/* GladeCommandSetPolicy *cmd2; */
return FALSE;
}
static void
glade_command_set_policy_collapse (GladeCommand * this_cmd,
GladeCommand * other_cmd)
{
/* this command is the one that will be used for an undo of the sequence of like commands */
//GladeCommandSetPolicy *this = GLADE_COMMAND_SET_POLICY (this_cmd);
/* the other command contains the values that will be used for a redo */
//GladeCommandSetPolicy *other = GLADE_COMMAND_SET_POLICY (other_cmd);
g_return_if_fail (GLADE_IS_COMMAND_SET_POLICY (this_cmd) &&
GLADE_IS_COMMAND_SET_POLICY (other_cmd));
/* no unify/collapse */
}
/**
* glade_command_set_project_naming_policy:
* @project: a #GladeProject
* @policy: the #GladeNamingPolicy
*
* Sets the naming policy of a project
*/
void
glade_command_set_project_naming_policy (GladeProject * project,
GladeNamingPolicy policy)
{
GladeCommandSetPolicy *me;
g_return_if_fail (GLADE_IS_PROJECT (project));
if (glade_project_get_naming_policy (project) != policy)
{
gchar *prj_name = glade_project_get_name (project);
glade_command_push_group (_("Setting %s to use a %s naming policy"),
prj_name,
policy == GLADE_POLICY_PROJECT_WIDE ?
"project wide" : "toplevel contextual");
g_free (prj_name);
/* load up the command */
me = g_object_new (GLADE_COMMAND_SET_POLICY_TYPE, NULL);
me->policy = policy;
me->old_policy = glade_project_get_naming_policy (project);
GLADE_COMMAND (me)->priv->project = project;
GLADE_COMMAND (me)->priv->description = g_strdup_printf ("dummy string");
glade_command_check_group (GLADE_COMMAND (me));
/* execute the command and push it on the stack if successful
* this sets the actual policy
*/
if (glade_command_set_policy_execute (GLADE_COMMAND (me)))
{
glade_project_push_undo (project, GLADE_COMMAND (me));
}
else
{
g_object_unref (G_OBJECT (me));
}
glade_command_pop_group ();
}
}
/******************************************************************************
*
* This command sets protection warnings on widgets
......
......@@ -79,11 +79,6 @@ gboolean glade_command_unifies (GladeCommand *com
void glade_command_collapse (GladeCommand *command,
GladeCommand *other);
/************************** project *********************************/
void glade_command_set_project_naming_policy (GladeProject *project,
GladeNamingPolicy policy);
/************************** properties *********************************/
void glade_command_set_property (GladeProperty *property,
......
......@@ -1636,10 +1636,11 @@ glade_eprop_text_changed_common (GladeEditorProperty * eprop,
pspec->value_type == G_TYPE_VALUE_ARRAY ||
pspec->value_type == GDK_TYPE_PIXBUF)
{
val = glade_property_class_make_gvalue_from_string
(eprop->priv->klass, text,
glade_widget_get_project (glade_property_get_widget (eprop->priv->property)),
glade_property_get_widget (eprop->priv->property));
GladeWidget *gwidget = glade_property_get_widget (eprop->priv->property);
val = glade_property_class_make_gvalue_from_string (eprop->priv->klass,
text,
glade_widget_get_project (gwidget));
}
else
{
......@@ -2981,7 +2982,7 @@ glade_eprop_object_show_dialog (GtkWidget * dialog_button,
TRUE);
value = glade_property_class_make_gvalue_from_string
(eprop->priv->klass, glade_widget_get_name (selected), project, widget);
(eprop->priv->klass, glade_widget_get_name (selected), project);
/* Unparent the widget so we can reuse it for this property */
if (glade_property_class_parentless_widget (eprop->priv->klass))
......@@ -3044,7 +3045,7 @@ glade_eprop_object_show_dialog (GtkWidget * dialog_button,
glade_project_selection_set (project, glade_widget_get_object (widget), TRUE);
value = glade_property_class_make_gvalue_from_string
(eprop->priv->klass, glade_widget_get_name (new_widget), project, NULL);
(eprop->priv->klass, glade_widget_get_name (new_widget), project);
glade_editor_property_commit (eprop, value);
......@@ -3056,8 +3057,8 @@ glade_eprop_object_show_dialog (GtkWidget * dialog_button,
}
else if (res == GLADE_RESPONSE_CLEAR)
{
GValue *value = glade_property_class_make_gvalue_from_string
(eprop->priv->klass, NULL, project, glade_property_get_widget (eprop->priv->property));
GValue *value =
glade_property_class_make_gvalue_from_string (eprop->priv->klass, NULL, project);
glade_editor_property_commit (eprop, value);
......
This diff is collapsed.
......@@ -154,7 +154,6 @@ void glade_project_widget_changed (GladeProject *proj
/* Widget names */
GladeWidget *glade_project_get_widget_by_name (GladeProject *project,
GladeWidget *ancestor,
const gchar *name);
void glade_project_set_widget_name (GladeProject *project,
GladeWidget *widget,
......@@ -199,9 +198,6 @@ GladePointerMode glade_project_get_pointer_mode (GladeProject *proj
void glade_project_set_add_item (GladeProject *project,
GladeWidgetAdaptor *adaptor);
GladeWidgetAdaptor *glade_project_get_add_item (GladeProject *project);
void glade_project_set_naming_policy (GladeProject *project,
GladeNamingPolicy policy);
GladeNamingPolicy glade_project_get_naming_policy (GladeProject *project);
void glade_project_get_target_version (GladeProject *project,
const gchar *catalog,
gint *major,
......
......@@ -683,8 +683,7 @@ static GObject *
glade_property_class_make_object_from_string (GladePropertyClass *
property_class,
const gchar * string,
GladeProject * project,
GladeWidget * widget)
GladeProject * project)
{
GObject *object = NULL;
gchar *fullpath;
......@@ -729,8 +728,7 @@ glade_property_class_make_object_from_string (GladePropertyClass *
else if (project)
{
GladeWidget *gwidget;
if ((gwidget = glade_project_get_widget_by_name
(project, widget, string)) != NULL)
if ((gwidget = glade_project_get_widget_by_name (project, string)) != NULL)
object = glade_widget_get_object (gwidget);
}
......@@ -741,8 +739,7 @@ static GList *
glade_property_class_make_objects_from_string (GladePropertyClass *
property_class,
const gchar * string,
GladeProject * project,
GladeWidget * widget)
GladeProject * project)
{
GList *objects = NULL;
GObject *object;
......@@ -753,8 +750,10 @@ glade_property_class_make_objects_from_string (GladePropertyClass *
{
for (i = 0; split[i]; i++)
{
if ((object = glade_property_class_make_object_from_string
(property_class, split[i], project, widget)) != NULL)
if ((object =
glade_property_class_make_object_from_string (property_class,
split[i],
project)) != NULL)
objects = g_list_prepend (objects, object);
}
g_strfreev (split);
......@@ -766,17 +765,15 @@ glade_property_class_make_objects_from_string (GladePropertyClass *
* glade_property_class_make_gvalue_from_string:
* @property_class: A #GladePropertyClass
* @string: a string representation of this property
* @widget: the #GladeWidget that the associated property belongs to.
* @project: the #GladeProject that the property should be resolved for
*
* Returns: A #GValue created based on the @property_class
* and @string criteria.
*/
GValue *
glade_property_class_make_gvalue_from_string (GladePropertyClass *
property_class,
const gchar * string,
GladeProject * project,
GladeWidget * widget)
glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class,
const gchar *string,
GladeProject *project)
{
GValue *value = g_new0 (GValue, 1);
gchar **strv;
......@@ -861,14 +858,14 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *
}
else if (G_IS_PARAM_SPEC_OBJECT (property_class->pspec))
{
GObject *object = glade_property_class_make_object_from_string
(property_class, string, project, widget);
GObject *object =
glade_property_class_make_object_from_string (property_class, string, project);
g_value_set_object (value, object);
}
else if (GLADE_IS_PARAM_SPEC_OBJECTS (property_class->pspec))
{
GList *objects = glade_property_class_make_objects_from_string
(property_class, string, project, widget);
GList *objects =
glade_property_class_make_objects_from_string (property_class, string, project);
g_value_take_boxed (value, objects);
}
else
......@@ -1967,15 +1964,14 @@ glade_property_class_update_from_node (GladeXmlNode * node,
g_free (klass->def);
}
klass->def =
glade_property_class_make_gvalue_from_string (klass, buf, NULL, NULL);
glade_property_class_make_gvalue_from_string (klass, buf, NULL);
if (klass->virt)
{
g_value_unset (klass->orig_def);
g_free (klass->orig_def);
klass->orig_def =
glade_property_class_make_gvalue_from_string (klass, buf, NULL,
NULL);
glade_property_class_make_gvalue_from_string (klass, buf, NULL);
}
g_free (buf);
......
......@@ -121,8 +121,7 @@ guint16 glade_property_class_since_minor (GladePropert
GValue *glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class,
const gchar *string,
GladeProject *project,
GladeWidget *widget);
GladeProject *project);
gchar *glade_property_class_make_string_from_gvalue (GladePropertyClass *property_class,
const GValue *value);
......
......@@ -1099,8 +1099,8 @@ glade_property_read (GladeProperty * property,
}
else
{
gvalue = glade_property_class_make_gvalue_from_string
(property->priv->klass, value, project, property->priv->widget);
gvalue =
glade_property_class_make_gvalue_from_string (property->priv->klass, value, project);
GLADE_PROPERTY_GET_KLASS (property)->set_value (property, gvalue);
......
......@@ -233,8 +233,7 @@ glade_signal_editor_user_data_activate (GtkCellRenderer * icon_renderer,
if (glade_signal_get_userdata (signal))
{
project_object =
glade_project_get_widget_by_name (project, NULL,
glade_signal_get_userdata (signal));
glade_project_get_widget_by_name (project, glade_signal_get_userdata (signal));
selected = g_list_prepend (selected, project_object);
}
......
......@@ -1357,10 +1357,9 @@ glade_utils_enum_value_from_string (GType enum_type, const gchar * strval)
if (((displayable =
glade_get_value_from_displayable (enum_type, strval)) != NULL &&
(gvalue =
glade_utils_value_from_string (enum_type, displayable, NULL,
NULL)) != NULL) ||
glade_utils_value_from_string (enum_type, displayable, NULL)) != NULL) ||
(gvalue =
glade_utils_value_from_string (enum_type, strval, NULL, NULL)) != NULL)
glade_utils_value_from_string (enum_type, strval, NULL)) != NULL)
{
value = g_value_get_enum (gvalue);
g_value_unset (gvalue);
......@@ -1420,10 +1419,9 @@ glade_utils_flags_value_from_string (GType flags_type, const gchar * strval)
if (((displayable =
glade_get_value_from_displayable (flags_type, strval)) != NULL &&
(gvalue =
glade_utils_value_from_string (flags_type, displayable, NULL,
NULL)) != NULL) ||
glade_utils_value_from_string (flags_type, displayable, NULL)) != NULL) ||
(gvalue =
glade_utils_value_from_string (flags_type, strval, NULL, NULL)) != NULL)
glade_utils_value_from_string (flags_type, strval, NULL)) != NULL)
{
value = g_value_get_flags (gvalue);
g_value_unset (gvalue);
......@@ -1612,7 +1610,7 @@ pclass_from_gtype (GType type)
GValue *
glade_utils_value_from_string (GType type,
const gchar * string,
GladeProject * project, GladeWidget * widget)
GladeProject * project)
{
GladePropertyClass *pclass;
......@@ -1620,8 +1618,7 @@ glade_utils_value_from_string (GType type,
g_return_val_if_fail (string != NULL, NULL);
if ((pclass = pclass_from_gtype (type)) != NULL)
return glade_property_class_make_gvalue_from_string (pclass, string,
project, widget);
return glade_property_class_make_gvalue_from_string (pclass, string, project);
return NULL;
}
......
......@@ -62,8 +62,7 @@ gchar *glade_utils_flags_string_from_value_displayable (GType flags_t
gchar *glade_utils_enum_string_from_value_displayable (GType flags_type, gint value);
GValue *glade_utils_value_from_string (GType type,
const gchar *string,
GladeProject *project,
GladeWidget *widget);
GladeProject *project);
gchar *glade_utils_string_from_value (const GValue *value);
/* Devhelp */
......
......@@ -1463,9 +1463,7 @@ glade_widget_set_default_packing_properties (GladeWidget * container,
continue;
value = glade_property_class_make_gvalue_from_string (property_class,
def,
child->priv->project,
child);
def, child->priv->project);
glade_widget_child_set_property (container, child,
glade_property_class_id (property_class), value);
......
......@@ -25,11 +25,6 @@ typedef struct _GladeWidgetAdaptor GladeWidgetAdaptor;
typedef struct _GladeProperty GladeProperty;
typedef struct _GladeProject GladeProject;
typedef enum {
GLADE_POLICY_PROJECT_WIDE = 0, /* widget names are unique throughout the project */
GLADE_POLICY_TOPLEVEL_CONTEXTUAL /* toplevel names are unique, and widgets inside a toplevel */
} GladeNamingPolicy;
#define GLADE_GTKBUILDER_VERSIONING_BASE_MAJOR 2
#define GLADE_GTKBUILDER_VERSIONING_BASE_MINOR 14
......
......@@ -244,7 +244,7 @@ glade_gtk_parse_atk_props (GladeWidget * widget, GladeXmlNode * node)
/* Set the parsed value on the property ... */
gvalue = glade_property_class_make_gvalue_from_string
(glade_property_get_class (property), value, glade_widget_get_project (widget), widget);
(glade_property_get_class (property), value, glade_widget_get_project (widget));
glade_property_set_value (property, gvalue);
g_value_unset (gvalue);
g_free (gvalue);
......@@ -5209,7 +5209,7 @@ glade_gtk_dialog_read_responses (GladeWidget * widget,
if ((action_widget =
glade_project_get_widget_by_name (glade_widget_get_project (widget),
widget, widget_name)) != NULL)
widget_name)) != NULL)
{
glade_widget_property_set (action_widget, "response-id",
g_ascii_strtoll (response, NULL, 10));
......@@ -9344,8 +9344,7 @@ glade_gtk_icon_factory_read_sources (GladeWidget * widget, GladeXmlNode * node)
source = gtk_icon_source_new ();
/* Deal with the filename... */
value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, str,
glade_widget_get_project (widget), widget);
value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, str, glade_widget_get_project (widget));
pixbuf = g_value_dup_object (value);
g_value_unset (value);
g_free (value);
......@@ -10380,7 +10379,7 @@ glade_gtk_store_read_data (GladeWidget * widget, GladeXmlNode * node)
*/
value_str = glade_xml_get_content (col_node);
value = glade_utils_value_from_string (g_type_from_name (column_type->type_name), value_str,
glade_widget_get_project (widget), widget);
glade_widget_get_project (widget));
g_free (value_str);
data = glade_model_data_new (g_type_from_name (column_type->type_name),
......
......@@ -484,8 +484,7 @@ value_filename_edited (GtkCellRendererText * cell,
/* get new pixbuf value... */
value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, new_text,
glade_widget_get_project (glade_property_get_widget (property)),
glade_property_get_widget (property));
glade_widget_get_project (glade_property_get_widget (property)));
pixbuf = g_value_get_object (value);
......
......@@ -715,14 +715,11 @@ value_text_edited (GtkCellRendererText * cell,
glade_get_value_from_displayable
(G_VALUE_TYPE (&data->value),
new_text),
glade_widget_get_project
(glade_property_get_widget (property)),
glade_property_get_widget (property));
glade_widget_get_project (glade_property_get_widget (property)));
else
value =
glade_utils_value_from_string (G_VALUE_TYPE (&data->value), new_text,
glade_widget_get_project (glade_property_get_widget (property)),
glade_property_get_widget (property));
glade_widget_get_project (glade_property_get_widget (property)));
g_value_copy (value, &data->value);
......
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