changeset 17248:204cbfeae945

merge of '313e5f0e5697afe45ac3ac1160aa4de526089ba2' and 'ce9cdd5d43f18f094312c5c88c6b6406398f0f3b'
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 23 May 2007 01:22:20 +0000
parents d63075ed73c9 (current diff) 05fa005bdc59 (diff)
children 93fa59b2623e
files
diffstat 1 files changed, 21 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Wed May 23 01:20:42 2007 +0000
+++ b/pidgin/gtkimhtml.c	Wed May 23 01:22:20 2007 +0000
@@ -932,52 +932,41 @@
 static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused)
 {
 	GtkTextIter start, end;
-	GtkTextMark *sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
-	GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
-
-	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
-	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins);
-
-	gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
-				     selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
-				     (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
-				     (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
-
-	if (imhtml->clipboard_html_string) {
+	if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
+		gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
+						 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
+						 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
+						 (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
+
 		g_free(imhtml->clipboard_html_string);
 		g_free(imhtml->clipboard_text_string);
+
+		imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
+		imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
 	}
 
-	imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
-	imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
-
 	g_signal_stop_emission_by_name(imhtml, "copy-clipboard");
 }
 
 static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused)
 {
 	GtkTextIter start, end;
-	GtkTextMark *sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
-	GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
-
-	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel);
-	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins);
-
-	gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
-				     selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
-				     (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
-				     (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
-
-	if (imhtml->clipboard_html_string) {
+	if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
+		gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD),
+						 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry),
+						 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get,
+						 (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml));
+
 		g_free(imhtml->clipboard_html_string);
 		g_free(imhtml->clipboard_text_string);
+
+		imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
+		imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
+
+		if (imhtml->editable)
+			gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE);
 	}
 
-	imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end);
-	imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end);
-
-	if (imhtml->editable)
-		gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE);
 	g_signal_stop_emission_by_name(imhtml, "cut-clipboard");
 }