mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-11-22 00:12:33 -05:00
* 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.
This commit is contained in:
parent
eb93a39278
commit
05191e1c37
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
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);
|
||||
|
||||
|
||||
@ -100,8 +100,7 @@ struct _GladeProjectPrivate
|
||||
*/
|
||||
guint selection_changed_id;
|
||||
|
||||
GladeNameContext *toplevel_names; /* Context for uniqueness of names at the toplevel */
|
||||
GList *toplevels; /* List of toplevels with thier own naming contexts */
|
||||
GladeNameContext *widget_names; /* Context for uniqueness of names */
|
||||
|
||||
|
||||
GList *undo_stack; /* A stack with the last executed commands */
|
||||
@ -123,8 +122,6 @@ struct _GladeProjectPrivate
|
||||
GHashTable *target_versions_major; /* target versions by catalog */
|
||||
GHashTable *target_versions_minor; /* target versions by catalog */
|
||||
|
||||
GladeNamingPolicy naming_policy; /* What rules apply to widget names */
|
||||
|
||||
gchar *resource_path; /* Indicates where to load resources from for this project
|
||||
* (full or relative path, null means project directory).
|
||||
*/
|
||||
@ -162,12 +159,6 @@ struct _GladeProjectPrivate
|
||||
guint pointer_mode : 2; /* The currently effective GladePointerMode */
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GladeWidget *toplevel;
|
||||
GladeNameContext *names;
|
||||
} TopLevelInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *stock;
|
||||
@ -224,15 +215,8 @@ static void glade_project_verify_adaptor (GladeProject * project,
|
||||
gboolean forwidget,
|
||||
GladeSupportMask * mask);
|
||||
|
||||
static GladeWidget *search_ancestry_by_name (GladeWidget * toplevel,
|
||||
const gchar * name);
|
||||
|
||||
static GtkWidget *glade_project_build_prefs_dialog (GladeProject * project);
|
||||
|
||||
static void policy_project_wide_button_clicked (GtkWidget * widget,
|
||||
GladeProject * project);
|
||||
static void policy_toplevel_contextual_button_clicked (GtkWidget * widget,
|
||||
GladeProject * project);
|
||||
static void target_button_clicked (GtkWidget * widget, GladeProject * project);
|
||||
static void update_prefs_for_resource_path (GladeProject * project);
|
||||
|
||||
@ -342,8 +326,6 @@ static void
|
||||
glade_project_finalize (GObject * object)
|
||||
{
|
||||
GladeProject *project = GLADE_PROJECT (object);
|
||||
GList *list;
|
||||
TopLevelInfo *tinfo;
|
||||
|
||||
gtk_widget_destroy (project->priv->prefs_dialog);
|
||||
|
||||
@ -358,15 +340,7 @@ glade_project_finalize (GObject * object)
|
||||
g_hash_table_destroy (project->priv->target_versions_minor);
|
||||
g_hash_table_destroy (project->priv->target_radios);
|
||||
|
||||
glade_name_context_destroy (project->priv->toplevel_names);
|
||||
|
||||
for (list = project->priv->toplevels; list; list = list->next)
|
||||
{
|
||||
tinfo = list->data;
|
||||
glade_name_context_destroy (tinfo->names);
|
||||
g_free (tinfo);
|
||||
}
|
||||
g_list_free (project->priv->toplevels);
|
||||
glade_name_context_destroy (project->priv->widget_names);
|
||||
|
||||
G_OBJECT_CLASS (glade_project_parent_class)->finalize (object);
|
||||
}
|
||||
@ -764,7 +738,6 @@ glade_project_init (GladeProject * project)
|
||||
priv->path = NULL;
|
||||
priv->readonly = FALSE;
|
||||
priv->tree = NULL;
|
||||
priv->toplevels = NULL;
|
||||
priv->selection = NULL;
|
||||
priv->has_selection = FALSE;
|
||||
priv->undo_stack = NULL;
|
||||
@ -774,8 +747,7 @@ glade_project_init (GladeProject * project)
|
||||
|
||||
priv->preview_channels =
|
||||
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
priv->toplevel_names = glade_name_context_new ();
|
||||
priv->naming_policy = GLADE_POLICY_PROJECT_WIDE;
|
||||
priv->widget_names = glade_name_context_new ();
|
||||
|
||||
priv->accel_group = NULL;
|
||||
|
||||
@ -1092,8 +1064,7 @@ glade_project_fix_object_props (GladeProject * project)
|
||||
/* Parse the object list and set the property to it
|
||||
* (this magicly works for both objects & object lists)
|
||||
*/
|
||||
value = glade_property_class_make_gvalue_from_string
|
||||
(klass, txt, glade_widget_get_project (gwidget), gwidget);
|
||||
value = glade_property_class_make_gvalue_from_string (klass, txt, project);
|
||||
|
||||
glade_property_set_value (property, value);
|
||||
|
||||
@ -1206,58 +1177,6 @@ glade_project_read_requires (GladeProject * project,
|
||||
return loadable;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
glade_project_read_policy_from_comment (GladeXmlNode * comment,
|
||||
GladeNamingPolicy * policy)
|
||||
{
|
||||
gchar *value, buffer[256];
|
||||
gboolean loaded = FALSE;
|
||||
|
||||
if (!glade_xml_node_is_comment (comment))
|
||||
return FALSE;
|
||||
|
||||
value = glade_xml_get_content (comment);
|
||||
if (value &&
|
||||
!strncmp (" interface-naming-policy", value,
|
||||
strlen (" interface-naming-policy")))
|
||||
{
|
||||
if (sscanf (value, " interface-naming-policy %s", buffer) == 1)
|
||||
{
|
||||
if (strcmp (buffer, "project-wide") == 0)
|
||||
*policy = GLADE_POLICY_PROJECT_WIDE;
|
||||
else
|
||||
*policy = GLADE_POLICY_TOPLEVEL_CONTEXTUAL;
|
||||
|
||||
loaded = TRUE;
|
||||
}
|
||||
}
|
||||
g_free (value);
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_read_naming_policy (GladeProject * project,
|
||||
GladeXmlNode * root_node)
|
||||
{
|
||||
/* A project file with no mention of a policy needs more lax rules
|
||||
* (a new project has a project wide policy by default)
|
||||
*/
|
||||
GladeNamingPolicy policy = GLADE_POLICY_TOPLEVEL_CONTEXTUAL;
|
||||
GladeXmlNode *node;
|
||||
|
||||
for (node = glade_xml_node_get_children_with_comments (root_node);
|
||||
node; node = glade_xml_node_next_with_comments (node))
|
||||
{
|
||||
if (glade_project_read_policy_from_comment (node, &policy))
|
||||
break;
|
||||
}
|
||||
|
||||
glade_project_set_naming_policy (project, policy);
|
||||
}
|
||||
|
||||
|
||||
static gchar *
|
||||
glade_project_read_resource_path_from_comment (GladeXmlNode * comment)
|
||||
{
|
||||
@ -1311,8 +1230,7 @@ update_project_for_resource_path (GladeProject * project)
|
||||
gchar *string;
|
||||
|
||||
string = glade_property_make_string (property);
|
||||
value = glade_property_class_make_gvalue_from_string
|
||||
(klass, string, project, widget);
|
||||
value = glade_property_class_make_gvalue_from_string (klass, string, project);
|
||||
|
||||
glade_property_set_value (property, value);
|
||||
|
||||
@ -1544,7 +1462,6 @@ glade_project_load_internal (GladeProject * project)
|
||||
gint count;
|
||||
|
||||
project->priv->selection = NULL;
|
||||
project->priv->toplevels = NULL;
|
||||
project->priv->objects = NULL;
|
||||
project->priv->loading = TRUE;
|
||||
|
||||
@ -1585,8 +1502,6 @@ glade_project_load_internal (GladeProject * project)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glade_project_read_naming_policy (project, root);
|
||||
|
||||
glade_project_read_resource_path (project, root);
|
||||
|
||||
/* Launch a dialog if it's going to take enough time to be
|
||||
@ -1816,22 +1731,6 @@ glade_project_write_required_libs (GladeProject * project,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_write_naming_policy (GladeProject * project,
|
||||
GladeXmlContext * context,
|
||||
GladeXmlNode * root)
|
||||
{
|
||||
GladeXmlNode *policy_node;
|
||||
gchar *comment = g_strdup_printf (" interface-naming-policy %s ",
|
||||
project->priv->naming_policy ==
|
||||
GLADE_POLICY_PROJECT_WIDE ? "project-wide" :
|
||||
"toplevel-contextual");
|
||||
|
||||
policy_node = glade_xml_node_new_comment (context, comment);
|
||||
glade_xml_node_append_child (root, policy_node);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_write_resource_path (GladeProject * project,
|
||||
GladeXmlContext * context,
|
||||
@ -1885,8 +1784,6 @@ glade_project_write (GladeProject * project)
|
||||
|
||||
glade_project_write_required_libs (project, context, root);
|
||||
|
||||
glade_project_write_naming_policy (project, context, root);
|
||||
|
||||
glade_project_write_resource_path (project, context, root);
|
||||
|
||||
/* Sort the whole thing */
|
||||
@ -2573,59 +2470,6 @@ glade_project_verify_project_for_ui (GladeProject * project)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Project object tracking code, name exclusivity etc...
|
||||
*******************************************************************/
|
||||
static GladeNameContext *
|
||||
name_context_by_widget (GladeProject * project, GladeWidget * gwidget)
|
||||
{
|
||||
TopLevelInfo *tinfo;
|
||||
GladeWidget *toplevel;
|
||||
GList *list;
|
||||
|
||||
if (!glade_widget_get_parent (gwidget))
|
||||
return NULL;
|
||||
|
||||
toplevel = glade_widget_get_toplevel (gwidget);
|
||||
|
||||
for (list = project->priv->toplevels; list; list = list->next)
|
||||
{
|
||||
tinfo = list->data;
|
||||
if (tinfo->toplevel == toplevel)
|
||||
return tinfo->names;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GladeWidget *
|
||||
search_ancestry_by_name (GladeWidget * toplevel, const gchar * name)
|
||||
{
|
||||
GladeWidget *widget = NULL, *iter;
|
||||
GList *list, *children;
|
||||
|
||||
if ((children = glade_widget_get_children (toplevel)) != NULL)
|
||||
{
|
||||
for (list = children; list; list = list->next)
|
||||
{
|
||||
const gchar *iter_name;
|
||||
|
||||
iter = glade_widget_get_from_gobject (list->data);
|
||||
iter_name = glade_widget_get_name (iter);
|
||||
|
||||
if (iter_name && strcmp (iter_name, name) == 0)
|
||||
{
|
||||
widget = iter;
|
||||
break;
|
||||
}
|
||||
else if ((widget = search_ancestry_by_name (iter, name)) != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_project_get_widget_by_name:
|
||||
* @project: a #GladeProject
|
||||
@ -2638,39 +2482,19 @@ search_ancestry_by_name (GladeWidget * toplevel, const gchar * name)
|
||||
*/
|
||||
GladeWidget *
|
||||
glade_project_get_widget_by_name (GladeProject * project,
|
||||
GladeWidget * ancestor, const gchar * name)
|
||||
const gchar * name)
|
||||
{
|
||||
GladeWidget *toplevel, *widget = NULL;
|
||||
GList *list;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if (ancestor)
|
||||
{
|
||||
toplevel = glade_widget_get_toplevel (ancestor);
|
||||
if ((widget = search_ancestry_by_name (toplevel, name)) != NULL)
|
||||
return widget;
|
||||
}
|
||||
|
||||
/* Now try searching in only toplevel objects... */
|
||||
for (list = project->priv->tree; list; list = list->next)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
|
||||
widget = glade_widget_get_from_gobject (list->data);
|
||||
g_assert (glade_widget_get_name (widget));
|
||||
if (strcmp (glade_widget_get_name (widget), name) == 0)
|
||||
return widget;
|
||||
}
|
||||
|
||||
/* Finally resort to a project wide search. */
|
||||
for (list = project->priv->objects; list; list = list->next)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
|
||||
widget = glade_widget_get_from_gobject (list->data);
|
||||
g_return_val_if_fail (glade_widget_get_name (widget) != NULL, NULL);
|
||||
|
||||
if (strcmp (glade_widget_get_name (widget), name) == 0)
|
||||
return widget;
|
||||
}
|
||||
@ -2683,38 +2507,7 @@ glade_project_release_widget_name (GladeProject * project,
|
||||
GladeWidget * gwidget,
|
||||
const char *widget_name)
|
||||
{
|
||||
GladeNameContext *context = NULL;
|
||||
TopLevelInfo *tinfo = NULL;
|
||||
GladeWidget *toplevel;
|
||||
GList *list;
|
||||
|
||||
/* Search by hand here since we need the tinfo to free... */
|
||||
toplevel = glade_widget_get_toplevel (gwidget);
|
||||
|
||||
for (list = project->priv->toplevels; list; list = list->next)
|
||||
{
|
||||
tinfo = list->data;
|
||||
if (tinfo->toplevel == toplevel)
|
||||
{
|
||||
context = tinfo->names;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (context)
|
||||
glade_name_context_release_name (context, widget_name);
|
||||
|
||||
if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE ||
|
||||
!glade_widget_get_parent (gwidget))
|
||||
glade_name_context_release_name (project->priv->toplevel_names, widget_name);
|
||||
|
||||
if (context && glade_name_context_n_names (context) == 0)
|
||||
{
|
||||
glade_name_context_destroy (context);
|
||||
project->priv->toplevels =
|
||||
g_list_remove (project->priv->toplevels, tinfo);
|
||||
g_free (tinfo);
|
||||
}
|
||||
glade_name_context_release_name (project->priv->widget_names, widget_name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2731,33 +2524,13 @@ gboolean
|
||||
glade_project_available_widget_name (GladeProject * project,
|
||||
GladeWidget * widget, const gchar * name)
|
||||
{
|
||||
GladeNameContext *context;
|
||||
gboolean sub_has_name = FALSE;
|
||||
gboolean available = FALSE;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
|
||||
|
||||
if (!name || !name[0])
|
||||
return FALSE;
|
||||
|
||||
if ((context = name_context_by_widget (project, widget)) != NULL)
|
||||
sub_has_name = glade_name_context_has_name (context, name);
|
||||
|
||||
if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
|
||||
{
|
||||
available = (!sub_has_name &&
|
||||
!glade_name_context_has_name (project->priv->toplevel_names,
|
||||
name));
|
||||
|
||||
}
|
||||
else if (context)
|
||||
available = !sub_has_name;
|
||||
else
|
||||
available =
|
||||
!glade_name_context_has_name (project->priv->toplevel_names, name);
|
||||
|
||||
return available;
|
||||
return !glade_name_context_has_name (project->priv->widget_names, name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2765,8 +2538,6 @@ glade_project_reserve_widget_name (GladeProject * project,
|
||||
GladeWidget * gwidget,
|
||||
const char *widget_name)
|
||||
{
|
||||
GladeNameContext *context;
|
||||
|
||||
if (!glade_project_available_widget_name (project, gwidget, widget_name))
|
||||
{
|
||||
g_warning ("BUG: widget '%s' attempting to reserve an unavailable widget name '%s' !",
|
||||
@ -2774,14 +2545,8 @@ glade_project_reserve_widget_name (GladeProject * project,
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add to name context(s) */
|
||||
if ((context = name_context_by_widget (project, gwidget)) != NULL)
|
||||
glade_name_context_add_name (context, widget_name);
|
||||
|
||||
if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE ||
|
||||
!glade_widget_get_parent (gwidget))
|
||||
glade_name_context_add_name (project->priv->toplevel_names, widget_name);
|
||||
|
||||
/* Add to name context */
|
||||
glade_name_context_add_name (project->priv->widget_names, widget_name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2800,32 +2565,13 @@ gchar *
|
||||
glade_project_new_widget_name (GladeProject * project,
|
||||
GladeWidget * widget, const gchar * base_name)
|
||||
{
|
||||
GladeNameContext *context;
|
||||
gchar *name;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
|
||||
g_return_val_if_fail (base_name && base_name[0], NULL);
|
||||
|
||||
context = name_context_by_widget (project, widget);
|
||||
|
||||
if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
|
||||
{
|
||||
if (context)
|
||||
name =
|
||||
glade_name_context_dual_new_name (context,
|
||||
project->priv->toplevel_names,
|
||||
base_name);
|
||||
else
|
||||
name =
|
||||
glade_name_context_new_name (project->priv->toplevel_names,
|
||||
base_name);
|
||||
}
|
||||
else if (context)
|
||||
name = glade_name_context_new_name (context, base_name);
|
||||
else
|
||||
name =
|
||||
glade_name_context_new_name (project->priv->toplevel_names, base_name);
|
||||
name = glade_name_context_new_name (project->priv->widget_names, base_name);
|
||||
|
||||
return name;
|
||||
}
|
||||
@ -2958,21 +2704,16 @@ glade_project_add_object (GladeProject * project, GObject * object)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create a name context for newly added toplevels... */
|
||||
if (!glade_widget_get_parent (gwidget))
|
||||
{
|
||||
TopLevelInfo *tinfo = g_new0 (TopLevelInfo, 1);
|
||||
tinfo->toplevel = gwidget;
|
||||
tinfo->names = glade_name_context_new ();
|
||||
project->priv->toplevels =
|
||||
g_list_prepend (project->priv->toplevels, tinfo);
|
||||
}
|
||||
|
||||
/* Make sure we have an exclusive name first... */
|
||||
if (!glade_project_available_widget_name (project, gwidget, glade_widget_get_name (gwidget)))
|
||||
{
|
||||
name = glade_project_new_widget_name (project, gwidget, glade_widget_get_name (gwidget));
|
||||
|
||||
/* XXX Collect these errors and make a report at startup time */
|
||||
if (project->priv->loading)
|
||||
g_warning ("Loading object '%s' with name conflict, renaming to '%s'",
|
||||
glade_widget_get_name (gwidget), name);
|
||||
|
||||
glade_widget_set_name (gwidget, name);
|
||||
|
||||
g_free (name);
|
||||
@ -3112,39 +2853,6 @@ glade_project_remove_object (GladeProject * project, GObject * object)
|
||||
g_object_unref (gwidget);
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_naming_policy (GladeProject * project, GladeNamingPolicy policy)
|
||||
{
|
||||
GList *list, *objects;
|
||||
GladeWidget *widget;
|
||||
|
||||
/* Ref *all* objects */
|
||||
for (list = project->priv->objects; list; list = list->next)
|
||||
{
|
||||
widget = glade_widget_get_from_gobject (list->data);
|
||||
g_object_ref (widget);
|
||||
}
|
||||
|
||||
/* Remove all toplevels (recursive operation) */
|
||||
objects = g_list_copy (project->priv->tree);
|
||||
for (list = objects; list; list = list->next)
|
||||
glade_project_remove_object (project, G_OBJECT (list->data));
|
||||
|
||||
project->priv->naming_policy = policy;
|
||||
|
||||
/* Put the toplevels back with the new policy (recursive operation) */
|
||||
for (list = objects; list; list = list->next)
|
||||
glade_project_add_object (project, G_OBJECT (list->data));
|
||||
g_list_free (objects);
|
||||
|
||||
/* Unref them now */
|
||||
for (list = project->priv->objects; list; list = list->next)
|
||||
{
|
||||
widget = glade_widget_get_from_gobject (list->data);
|
||||
g_object_ref (widget);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Remaining stubs and api
|
||||
*******************************************************************/
|
||||
@ -3857,123 +3565,6 @@ glade_project_get_objects (GladeProject * project)
|
||||
return project->priv->objects;
|
||||
}
|
||||
|
||||
void
|
||||
glade_project_set_naming_policy (GladeProject * project,
|
||||
GladeNamingPolicy policy)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||
|
||||
if (project->priv->naming_policy != policy)
|
||||
{
|
||||
adjust_naming_policy (project, policy);
|
||||
|
||||
/* Update the toggle button in the prefs dialog here: */
|
||||
g_signal_handlers_block_by_func (project->priv->project_wide_radio,
|
||||
G_CALLBACK
|
||||
(policy_project_wide_button_clicked),
|
||||
project);
|
||||
g_signal_handlers_block_by_func (project->priv->toplevel_contextual_radio,
|
||||
G_CALLBACK
|
||||
(policy_toplevel_contextual_button_clicked),
|
||||
project);
|
||||
|
||||
if (policy == GLADE_POLICY_PROJECT_WIDE)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(project->priv->project_wide_radio),
|
||||
TRUE);
|
||||
else
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(project->priv->
|
||||
toplevel_contextual_radio), TRUE);
|
||||
|
||||
g_signal_handlers_unblock_by_func (project->priv->project_wide_radio,
|
||||
G_CALLBACK
|
||||
(policy_project_wide_button_clicked),
|
||||
project);
|
||||
g_signal_handlers_unblock_by_func (project->priv->
|
||||
toplevel_contextual_radio,
|
||||
G_CALLBACK
|
||||
(policy_toplevel_contextual_button_clicked),
|
||||
project);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
GladeNamingPolicy
|
||||
glade_project_get_naming_policy (GladeProject * project)
|
||||
{
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), -1);
|
||||
|
||||
return project->priv->naming_policy;
|
||||
}
|
||||
|
||||
static gint
|
||||
count_objects_with_name (GladeProject * project, const gchar * name)
|
||||
{
|
||||
GList *l;
|
||||
GladeWidget *widget;
|
||||
gint count = 0;
|
||||
|
||||
for (l = project->priv->objects; l; l = l->next)
|
||||
{
|
||||
widget = glade_widget_get_from_gobject (l->data);
|
||||
if (!strcmp (glade_widget_get_name (widget), name))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
policy_project_wide_button_clicked (GtkWidget * widget, GladeProject * project)
|
||||
{
|
||||
GList *l, *objects;
|
||||
GladeWidget *gwidget;
|
||||
|
||||
/* The formatting here is only to avoid a string change in a stable series... */
|
||||
gchar *prj_name = glade_project_get_name (project);
|
||||
glade_command_push_group (_("Setting %s to use a %s naming policy"),
|
||||
prj_name, "project wide");
|
||||
g_free (prj_name);
|
||||
|
||||
/* Uniquify names here before switching policy (so names undo) */
|
||||
objects = g_list_copy (project->priv->objects);
|
||||
for (l = g_list_last (objects); l; l = l->prev)
|
||||
{
|
||||
gwidget = glade_widget_get_from_gobject (l->data);
|
||||
|
||||
if (count_objects_with_name (project, glade_widget_get_name (gwidget)) > 1)
|
||||
{
|
||||
GladeNameContext *context = name_context_by_widget (project, gwidget);
|
||||
gchar *new_name;
|
||||
|
||||
if (context)
|
||||
new_name = glade_name_context_dual_new_name
|
||||
(context, project->priv->toplevel_names, glade_widget_get_name (gwidget));
|
||||
else
|
||||
new_name =
|
||||
glade_name_context_new_name (project->priv->toplevel_names,
|
||||
glade_widget_get_name (gwidget));
|
||||
|
||||
glade_command_set_name (gwidget, new_name);
|
||||
}
|
||||
}
|
||||
g_list_free (objects);
|
||||
|
||||
glade_command_set_project_naming_policy (project, GLADE_POLICY_PROJECT_WIDE);
|
||||
|
||||
glade_command_pop_group ();
|
||||
}
|
||||
|
||||
static void
|
||||
policy_toplevel_contextual_button_clicked (GtkWidget * widget,
|
||||
GladeProject * project)
|
||||
{
|
||||
glade_command_set_project_naming_policy (project,
|
||||
GLADE_POLICY_TOPLEVEL_CONTEXTUAL);
|
||||
}
|
||||
|
||||
static void
|
||||
target_button_clicked (GtkWidget * widget, GladeProject * project)
|
||||
{
|
||||
@ -4117,9 +3708,7 @@ glade_project_build_prefs_box (GladeProject * project)
|
||||
GList *list, *targets;
|
||||
gchar *string;
|
||||
GtkWidget *main_frame, *main_alignment;
|
||||
GtkSizeGroup *sizegroup1 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL),
|
||||
*sizegroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL),
|
||||
*sizegroup3 = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
||||
GtkSizeGroup *sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
main_frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (main_frame), GTK_SHADOW_NONE);
|
||||
@ -4131,59 +3720,6 @@ glade_project_build_prefs_box (GladeProject * project)
|
||||
gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
|
||||
gtk_container_add (GTK_CONTAINER (main_frame), main_alignment);
|
||||
|
||||
/* Naming policy format */
|
||||
string = g_strdup_printf ("<b>%s</b>", _("Object names are unique:"));
|
||||
frame = gtk_frame_new (NULL);
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
|
||||
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
|
||||
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
|
||||
|
||||
label = gtk_label_new (string);
|
||||
g_free (string);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
|
||||
project->priv->project_wide_radio =
|
||||
gtk_radio_button_new_with_label (NULL, _("within the project"));
|
||||
project->priv->toplevel_contextual_radio =
|
||||
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
|
||||
(project->priv->project_wide_radio),
|
||||
_("inside toplevels"));
|
||||
|
||||
gtk_size_group_add_widget (sizegroup1, project->priv->project_wide_radio);
|
||||
gtk_size_group_add_widget (sizegroup2,
|
||||
project->priv->toplevel_contextual_radio);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), project->priv->project_wide_radio, TRUE,
|
||||
TRUE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), project->priv->toplevel_contextual_radio,
|
||||
TRUE, TRUE, 2);
|
||||
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame), label);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), hbox);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 6);
|
||||
|
||||
if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(project->priv->project_wide_radio), TRUE);
|
||||
else
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
||||
(project->priv->toplevel_contextual_radio),
|
||||
TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (project->priv->project_wide_radio), "clicked",
|
||||
G_CALLBACK (policy_project_wide_button_clicked), project);
|
||||
|
||||
g_signal_connect (G_OBJECT (project->priv->toplevel_contextual_radio),
|
||||
"clicked",
|
||||
G_CALLBACK (policy_toplevel_contextual_button_clicked),
|
||||
project);
|
||||
|
||||
|
||||
/* Resource path */
|
||||
string =
|
||||
g_strdup_printf ("<b>%s</b>", _("Image resources are loaded locally:"));
|
||||
@ -4206,7 +3742,7 @@ glade_project_build_prefs_box (GladeProject * project)
|
||||
gtk_radio_button_new_with_label (NULL, _("From the project directory"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), project->priv->resource_default_radio,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_size_group_add_widget (sizegroup3, project->priv->resource_default_radio);
|
||||
gtk_size_group_add_widget (sizegroup, project->priv->resource_default_radio);
|
||||
|
||||
/* Project relative directory... */
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
@ -4223,7 +3759,7 @@ glade_project_build_prefs_box (GladeProject * project)
|
||||
gtk_box_pack_start (GTK_BOX (hbox), project->priv->relative_path_entry, FALSE,
|
||||
TRUE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_size_group_add_widget (sizegroup3, hbox);
|
||||
gtk_size_group_add_widget (sizegroup, hbox);
|
||||
|
||||
|
||||
/* fullpath directory... */
|
||||
@ -4242,12 +3778,10 @@ glade_project_build_prefs_box (GladeProject * project)
|
||||
gtk_box_pack_start (GTK_BOX (hbox), project->priv->full_path_button, FALSE,
|
||||
TRUE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_size_group_add_widget (sizegroup3, hbox);
|
||||
gtk_size_group_add_widget (sizegroup, hbox);
|
||||
|
||||
/* Pass ownership to the widgets in the groups */
|
||||
g_object_unref (sizegroup1);
|
||||
g_object_unref (sizegroup2);
|
||||
g_object_unref (sizegroup3);
|
||||
/* Pass ownership to the widgets in the group */
|
||||
g_object_unref (sizegroup);
|
||||
|
||||
update_prefs_for_resource_path (project);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user