Commit 751d222f authored by Tristan Van Berkom's avatar Tristan Van Berkom

glade_command_cut_copy_paste_common(); fixed "project" source in case of


	* src/glade-command.c: glade_command_cut_copy_paste_common(); fixed
	  "project" source in case of `type == GLADE_PASTE'

	* src/glade-editor-property.c: Clean up compiler warnings, removed useless
	  mnemonic label.

	* src/glade-project.[ch], src/glade-property.c, src/glade-widget.[ch]:
	  Implemented references on widgets from object properties, object properties
	  are automaticly set to NULL when the target object is removed from its
	  project, an undo will result in the object being re-added to the project;
	  and its reffered properties to be reset to thier previous value.
parent 1fc74d5f
2005-12-27 Tristan Van Berkom <tvb@gnome.org>
* src/glade-command.c: glade_command_cut_copy_paste_common(); fixed
"project" source in case of `type == GLADE_PASTE'
* src/glade-editor-property.c: Clean up compiler warnings, removed useless
mnemonic label.
* src/glade-project.[ch], src/glade-property.c, src/glade-widget.[ch]:
Implemented references on widgets from object properties, object properties
are automaticly set to NULL when the target object is removed from its
project, an undo will result in the object being re-added to the project;
and its reffered properties to be reset to thier previous value.
2005-12-27 Tristan Van Berkom <tvb@gnome.org>
* src/glade-editor-property.c: Added GLADE_TYPE_EPROP_OBJECT (object properties)
......
......@@ -1451,9 +1451,19 @@ glade_command_cut_copy_paste_common (GList *widgets,
widget = GLADE_WIDGET (widgets->data);
/* And now we feel safe enough to go on and create */
me = (GladeCommandCutCopyPaste *)
me = (GladeCommandCutCopyPaste *)
g_object_new (GLADE_COMMAND_CUT_COPY_PASTE_TYPE, NULL);
me->project = glade_widget_get_project (widget);
if (type == GLADE_PASTE && placeholder)
{
GladeWidget *some_widget = glade_placeholder_get_parent (placeholder);
me->project = some_widget->project;
}
else if (type == GLADE_PASTE)
me->project = glade_default_app_get_active_project();
else
me->project = glade_widget_get_project (widget);
me->type = type;
me->from_clipboard = (type == GLADE_PASTE);
GLADE_COMMAND (me)->description =
......
......@@ -2015,9 +2015,8 @@ static void
glade_eprop_object_show_dialog (GtkWidget *dialog_button,
GladeEditorProperty *eprop)
{
GtkTreeSelection *selection;
GtkWidget *dialog, *parent;
GtkWidget *vbox, *hbox, *label, *sw, *button;
GtkWidget *vbox, *label, *sw;
GtkWidget *tree_view;
gint res;
......@@ -2040,7 +2039,7 @@ glade_eprop_object_show_dialog (GtkWidget *dialog_button,
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
/* Checklist */
label = gtk_label_new_with_mnemonic (_("_Objects:"));
label = gtk_label_new (_("Objects:"));
gtk_widget_show (label);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
......@@ -2061,7 +2060,6 @@ glade_eprop_object_show_dialog (GtkWidget *dialog_button,
gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
gtk_widget_show (tree_view);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
gtk_container_add (GTK_CONTAINER (sw), tree_view);
/* Run the dialog */
......@@ -2070,8 +2068,9 @@ glade_eprop_object_show_dialog (GtkWidget *dialog_button,
{
GladeWidget *selected = NULL;
gtk_tree_model_foreach (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
glade_eprop_object_selected_widget, &selected);
gtk_tree_model_foreach
(gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
(GtkTreeModelForeachFunc) glade_eprop_object_selected_widget, &selected);
if (selected)
{
......
......@@ -333,6 +333,9 @@ glade_project_add_object (GladeProject *project, GObject *object)
if (GTK_IS_WINDOW (object) &&
(transient_parent = glade_default_app_get_transient_parent ()) != NULL)
gtk_window_set_transient_for (GTK_WINDOW (object), transient_parent);
/* Notify widget it was added to the project */
glade_widget_project_notify (gwidget, project);
}
/**
......@@ -428,6 +431,9 @@ glade_project_remove_object (GladeProject *project, GObject *object)
if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
return;
/* Notify widget is being removed from the project */
glade_widget_project_notify (gwidget, NULL);
if ((children = glade_widget_class_container_get_children (gwidget->widget_class,
gwidget->object)) != NULL)
......
......@@ -163,6 +163,27 @@ glade_property_set_value_impl (GladeProperty *property, const GValue *value)
changed = g_param_values_cmp (property->class->pspec,
property->value, value) != 0;
/* Add/Remove references from widget ref stacks here
*/
if (changed && glade_property_class_is_object (property->class))
{
GladeWidget *gold, *gnew;
GObject *old_object, *new_object;
if ((old_object = g_value_get_object (property->value)) != NULL)
{
gold = glade_widget_get_from_gobject (old_object);
glade_widget_remove_prop_ref (gold, property);
}
if ((new_object = g_value_get_object (value)) != NULL)
{
gnew = glade_widget_get_from_gobject (new_object);
glade_widget_add_prop_ref (gnew, property);
}
}
/* Assign property first so that; if the object need be
* rebuilt, it will reflect the new value
*/
......
......@@ -52,11 +52,6 @@ struct _GladeProperty
gboolean i18n_has_context;
gchar *i18n_comment;
#if 0
/* A GladeProperty of type object has a child */
GladeWidget *child;
#endif
gboolean syncing; /* Avoid recursion while synchronizing object with value.
*/
};
......
......@@ -258,6 +258,8 @@ glade_widget_init (GladeWidget *widget)
widget->object = NULL;
widget->properties = NULL;
widget->packing_properties = NULL;
widget->prop_refs = NULL;
widget->prop_refs_readonly = FALSE;
widget->signals = g_hash_table_new_full
(g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
......@@ -308,7 +310,6 @@ glade_widget_debug (GladeWidget *widget)
glade_widget_debug_real (widget, 0);
}
static void
glade_widget_save_coords (GladeWidget *widget)
{
......@@ -355,6 +356,48 @@ glade_widget_hide (GladeWidget *widget)
widget->visible = FALSE;
}
void
glade_widget_add_prop_ref (GladeWidget *widget, GladeProperty *property)
{
g_return_if_fail (GLADE_IS_WIDGET (widget));
g_return_if_fail (GLADE_IS_PROPERTY (property));
if (property && !widget->prop_refs_readonly &&
!g_list_find (widget->prop_refs, property))
widget->prop_refs = g_list_prepend (widget->prop_refs, property);
}
void
glade_widget_remove_prop_ref (GladeWidget *widget, GladeProperty *property)
{
g_return_if_fail (GLADE_IS_WIDGET (widget));
g_return_if_fail (GLADE_IS_PROPERTY (property));
if (!widget->prop_refs_readonly)
widget->prop_refs = g_list_remove (widget->prop_refs, property);
}
void
glade_widget_project_notify (GladeWidget *widget, GladeProject *project)
{
GList *l;
GladeProperty *property;
widget->prop_refs_readonly = TRUE;
for (l = widget->prop_refs; l && l->data; l = l->next)
{
property = GLADE_PROPERTY (l->data);
if (project != NULL &&
project == property->widget->project)
glade_property_set (property, widget->object);
else
glade_property_set (property, NULL);
}
widget->prop_refs_readonly = FALSE;
}
static void
glade_widget_copy_packing_props (GladeWidget *parent,
GladeWidget *child,
......
......@@ -26,7 +26,7 @@ struct _GladeWidget
GObject parent_instance;
GladeWidgetClass *widget_class;
GladeProject *project; /* A pointer to the project that this widget belongs to. */
GladeProject *project; /* A pointer to the project that this widget belongs to. */
GladeWidget *parent; /* A pointer to the parent widget in the heirarchy */
......@@ -79,6 +79,12 @@ struct _GladeWidget
*/
gboolean prop_refs_readonly; /* Whether this list is currently readonly */
GList *prop_refs; /* List of properties in the project who's value are `this object'
* (this is used to set/unset those properties when the object is
* added/removed from the project).
*/
/* Save toplevel positions */
gint save_x;
gint save_y;
......@@ -113,22 +119,28 @@ LIBGLADEUI_API void glade_widget_set_object (GladeWidget
GObject *new_object);
LIBGLADEUI_API void glade_widget_set_project (GladeWidget *widget,
GladeProject *project);
LIBGLADEUI_API const gchar *glade_widget_get_name (GladeWidget *widget);
LIBGLADEUI_API const gchar *glade_widget_get_internal (GladeWidget *widget);
LIBGLADEUI_API GladeWidgetClass *glade_widget_get_class (GladeWidget *widget);
LIBGLADEUI_API GladeProject *glade_widget_get_project (GladeWidget *widget);
LIBGLADEUI_API GObject *glade_widget_get_object (GladeWidget *widget);
LIBGLADEUI_API void glade_widget_project_notify (GladeWidget *widget,
GladeProject *project);
LIBGLADEUI_API void glade_widget_show (GladeWidget *widget);
LIBGLADEUI_API void glade_widget_hide (GladeWidget *widget);
LIBGLADEUI_API void glade_widget_add_prop_ref (GladeWidget *widget,
GladeProperty *property);
LIBGLADEUI_API void glade_widget_remove_prop_ref (GladeWidget *widget,
GladeProperty *property);
LIBGLADEUI_API GladeProperty *glade_widget_get_property (GladeWidget *widget,
const gchar *id_property);
LIBGLADEUI_API GladeProperty *glade_widget_get_pack_property (GladeWidget *widget,
const gchar *id_property);
/* Convenience functions for plugin & application use */
LIBGLADEUI_API gboolean glade_widget_property_get (GladeWidget *widget,
const gchar *id_property,
......
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