Commit 6400dda3 authored by Christian Persch's avatar Christian Persch Committed by Christian Persch

Use gtk_target_table_new_from_list and gtk_target_table_free instead of

2007-01-14  Christian Persch  <chpe@svn.gnome.org>

	* gtk/gtkclipboard.c: (gtk_clipboard_set_text),
	(gtk_clipboard_set_image): Use gtk_target_table_new_from_list and
	gtk_target_table_free instead of duplicating the code. Bug #396493.

svn path=/trunk/; revision=17152
parent 653d2932
2007-01-14 Christian Persch <chpe@svn.gnome.org>
* gtk/gtkclipboard.c: (gtk_clipboard_set_text),
(gtk_clipboard_set_image): Use gtk_target_table_new_from_list and
gtk_target_table_free instead of duplicating the code. Bug #396493.
2007-01-13 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkuimanager.c: Don't crash if menu or toolbar
......
......@@ -728,9 +728,8 @@ gtk_clipboard_set_text (GtkClipboard *clipboard,
gint len)
{
GtkTargetList *list;
GList *l;
GtkTargetEntry *targets;
gint n_targets, i;
gint n_targets;
g_return_if_fail (clipboard != NULL);
g_return_if_fail (text != NULL);
......@@ -738,13 +737,7 @@ gtk_clipboard_set_text (GtkClipboard *clipboard,
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (list, 0);
n_targets = g_list_length (list->list);
targets = g_new0 (GtkTargetEntry, n_targets);
for (l = list->list, i = 0; l; l = l->next, i++)
{
GtkTargetPair *pair = (GtkTargetPair *)l->data;
targets[i].target = gdk_atom_name (pair->target);
}
targets = gtk_target_table_new_from_list (list, &n_targets);
if (len < 0)
len = strlen (text);
......@@ -755,9 +748,7 @@ gtk_clipboard_set_text (GtkClipboard *clipboard,
g_strndup (text, len));
gtk_clipboard_set_can_store (clipboard, NULL, 0);
for (i = 0; i < n_targets; i++)
g_free (targets[i].target);
g_free (targets);
gtk_target_table_free (targets, n_targets);
gtk_target_list_unref (list);
}
......@@ -794,9 +785,8 @@ gtk_clipboard_set_image (GtkClipboard *clipboard,
GdkPixbuf *pixbuf)
{
GtkTargetList *list;
GList *l;
GtkTargetEntry *targets;
gint n_targets, i;
gint n_targets;
g_return_if_fail (clipboard != NULL);
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
......@@ -804,13 +794,7 @@ gtk_clipboard_set_image (GtkClipboard *clipboard,
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (list, 0, TRUE);
n_targets = g_list_length (list->list);
targets = g_new0 (GtkTargetEntry, n_targets);
for (l = list->list, i = 0; l; l = l->next, i++)
{
GtkTargetPair *pair = (GtkTargetPair *)l->data;
targets[i].target = gdk_atom_name (pair->target);
}
targets = gtk_target_table_new_from_list (list, &n_targets);
gtk_clipboard_set_with_data (clipboard,
targets, n_targets,
......@@ -818,9 +802,7 @@ gtk_clipboard_set_image (GtkClipboard *clipboard,
g_object_ref (pixbuf));
gtk_clipboard_set_can_store (clipboard, NULL, 0);
for (i = 0; i < n_targets; i++)
g_free (targets[i].target);
g_free (targets);
gtk_target_table_free (targets, n_targets);
gtk_target_list_unref (list);
}
......
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