diff options
author | Milan Crha <mcrha@redhat.com> | 2007-11-05 18:07:23 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-11-05 18:07:23 +0800 |
commit | a1a1f31ef8aa921e84f82d0e88b00ead5e92c738 (patch) | |
tree | 1ef2ab796f73424e443a8dd156963bfbd05284e6 /calendar/gui/comp-util.c | |
parent | abf34a4520db2714e688fcdc01f3e5cbb890bc73 (diff) | |
download | gsoc2013-evolution-a1a1f31ef8aa921e84f82d0e88b00ead5e92c738.tar.gz gsoc2013-evolution-a1a1f31ef8aa921e84f82d0e88b00ead5e92c738.tar.zst gsoc2013-evolution-a1a1f31ef8aa921e84f82d0e88b00ead5e92c738.zip |
** Fix for bug #315101
2007-11-05 Milan Crha <mcrha@redhat.com>
** Fix for bug #315101
* drag and drop to other source for multiselect
* gui/comp-util.h:
* gui/comp-util.c: (cal_comp_selection_set_string_list),
(cal_comp_selection_get_string_list): Two new helper functions
to set and get list of strings into GtkSelectionData.
* gui/e-tasks.c: (get_selected_components_cb),
(do_for_selected_components), (obtain_list_of_components),
(table_drag_data_get):
* gui/e-memos.c: (get_selected_components_cb),
(do_for_selected_components), (obtain_list_of_components),
(table_drag_data_get): Pass list of selected components as data
for drag and drop instead of focused component from the list.
* gui/e-tasks.c: (table_drag_data_delete):
* gui/e-memos.c: (table_drag_data_delete): Obsolete now.
* gui/tasks-component.c: (selector_tree_drag_data_received):
* gui/memos-component.c: (selector_tree_drag_data_received):
Receiving list of components, so made changes here to reflect it.
svn path=/trunk/; revision=34496
Diffstat (limited to 'calendar/gui/comp-util.c')
-rw-r--r-- | calendar/gui/comp-util.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 6919302b73..0be96dbefa 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -432,3 +432,72 @@ cal_comp_util_get_n_icons (ECalComponent *comp) return num_icons; } + +/** + * cal_comp_selection_set_string_list + * Stores list of strings into selection target data. + * Use @ref cal_comp_selection_get_string_list to get this list from target data. + * + * @param data Selection data, where to put list of strings. + * @param str_list List of strings. (Each element is of type const gchar *.) + **/ +void +cal_comp_selection_set_string_list (GtkSelectionData *data, GSList *str_list) +{ + /* format is "str1\0str2\0...strN\0" */ + GSList *p; + GByteArray *array; + + g_return_if_fail (data != NULL); + + if (!str_list) + return; + + array = g_byte_array_new (); + for (p = str_list; p; p = p->next) { + const guint8 *c = p->data; + + if (c) + g_byte_array_append (array, c, strlen ((const char *) c) + 1); + } + + gtk_selection_data_set (data, data->target, 8, array->data, array->len); + g_byte_array_free (array, TRUE); +} + +/** + * cal_comp_selection_get_string_list + * Converts data from selection to list of strings. Data should be assigned + * to selection data with @ref cal_comp_selection_set_string_list. + * Each string in newly created list should be freed by g_free. + * List itself should be freed by g_slist_free. + * + * @param data Selection data, where to put list of strings. + * @return Newly allocated GSList of strings. + **/ +GSList * +cal_comp_selection_get_string_list (GtkSelectionData *data) +{ + /* format is "str1\0str2\0...strN\0" */ + char *inptr, *inend; + GSList *list; + + g_return_val_if_fail (data != NULL, NULL); + + list = NULL; + inptr = (char *)data->data; + inend = (char *)(data->data + data->length); + + while (inptr < inend) { + char *start = inptr; + + while (inptr < inend && *inptr) + inptr++; + + list = g_slist_prepend (list, g_strndup (start, inptr - start)); + + inptr++; + } + + return list; +} |