diff options
author | Tristan Van Berkom <tvb@src.gnome.org> | 2005-04-02 18:02:00 +0000 |
---|---|---|
committer | Tristan Van Berkom <tvb@src.gnome.org> | 2005-04-02 18:02:00 +0000 |
commit | f2cda8fc83f4da7fc7a7e3b1297edb66579b24c0 (patch) | |
tree | e5369845a9d84fff551260765725fb6cdb0ddeb3 /src/glade-utils.c | |
parent | e71e88cbaf269535983e185f4b23fb350cf3db9a (diff) | |
download | glade-f2cda8fc83f4da7fc7a7e3b1297edb66579b24c0.tar.gz |
glade_command_paste() now searches for placeholders for multi-paste
* src/glade-command.c:
glade_command_paste() now searches for placeholders for
multi-paste circumstances.
* src/glade-project-view.c:
Added code to adjust selection on project radio item
on project closure (radio list still doesn't work
properly).
* src/glade-utils.[ch]: glade_util_count_placeholders added
paste code now considers multiple paste on gtkwidget containers.
Diffstat (limited to 'src/glade-utils.c')
-rw-r--r-- | src/glade-utils.c | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/glade-utils.c b/src/glade-utils.c index 12dc5c13..f7b5b95c 100644 --- a/src/glade-utils.c +++ b/src/glade-utils.c @@ -988,6 +988,31 @@ glade_util_widget_pastable (GladeWidget *child, child->widget_class->type) != NULL) ? TRUE : FALSE; } +/** + * glade_util_widget_pastable: + * @parent: a #GladeWidget + * + * Returns the amount of #GladePlaceholders parented by @parent + */ +gint +glade_util_count_placeholders (GladeWidget *parent) +{ + gint placeholders = 0; + GList *list, *children; + + /* count placeholders */ + if ((children = glade_widget_class_container_get_children + (parent->widget_class, parent->object)) != NULL) + { + for (list = children; list && list->data; list = list->next) + { + if (GLADE_IS_PLACEHOLDER (list->data)) + placeholders++; + } + g_list_free (children); + } + return placeholders; +} /** * glade_util_paste_clipboard: @@ -1001,13 +1026,13 @@ void glade_util_paste_clipboard (GladePlaceholder *placeholder, GladeWidget *parent) { - GladeProject *project = glade_default_app_get_active_project (); GladeClipboard *clipboard = glade_default_app_get_clipboard (); GList *list; GladeWidget *widget; + gint gtkcontainer_relations = 0; - if ((list = glade_project_selection_get (project)) != NULL) + if ((list = glade_default_app_get_selection ()) != NULL) { if (placeholder == NULL && g_list_length (list) != 1) @@ -1018,19 +1043,21 @@ glade_util_paste_clipboard (GladePlaceholder *placeholder, return; } } - + if (g_list_length (clipboard->selection) == 0) { glade_util_ui_warn (glade_default_app_get_window (), _("No widget selected on the clipboard")); return; } - + for (list = clipboard->selection; list && list->data; list = list->next) { widget = list->data; + /* Ensure a paste is supported + */ if (parent && glade_util_widget_pastable (widget, parent) == FALSE) { @@ -1041,7 +1068,25 @@ glade_util_paste_clipboard (GladePlaceholder *placeholder, g_free (message); return; } + + /* Count gtk container relations + */ + if (parent && + glade_util_gtkcontainer_relation (parent, widget)) + gtkcontainer_relations++; } + + + /* Ensure enough placeholders are available */ + if (parent && + glade_util_count_placeholders (parent) < gtkcontainer_relations) + { + glade_util_ui_warn (glade_default_app_get_window (), + _("Insufficient amount of placeholders in " + "target container")); + return; + } + glade_command_paste (clipboard->selection, parent, placeholder); } |