[Xfce4-commits] <xfce4-dict:master> When pasting text, always first query the PRIMARY clipboard and in case we didn't find anything, query the main clipboard.
Enrico Tröger
noreply at xfce.org
Sun May 30 19:18:01 CEST 2010
Updating branch refs/heads/master
to 6640412a4fd7cad4c029ccb33774d6bc674bb897 (commit)
from c94ceb68f638ab8e734fd4b8accfcedd02a5f535 (commit)
commit 6640412a4fd7cad4c029ccb33774d6bc674bb897
Author: Enrico Tröger <enrico.troeger at uvena.de>
Date: Sun May 30 19:17:01 2010 +0200
When pasting text, always first query the PRIMARY clipboard and in case we didn't find anything, query the main clipboard.
ChangeLog | 3 +++
lib/common.c | 9 +++++++++
lib/common.h | 1 +
lib/speedreader.c | 9 +++++++--
src/xfce4-dict.c | 6 +-----
5 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8fbf52a..eed937e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
Quit/Close main window if Escape is pressed.
* lib/speedreader.c:
Add a paste button to the Speed Reader.
+ * lib/common.c, lib/common.h, lib/speedreader.c, src/xfce4-dict.c:
+ When pasting text, always first query the PRIMARY clipboard
+ and in case we didn't find anything, query the main clipboard.
2010-01-01 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
diff --git a/lib/common.c b/lib/common.c
index 9f9bd7b..556d3d1 100644
--- a/lib/common.c
+++ b/lib/common.c
@@ -626,3 +626,12 @@ void dict_show_msgbox(DictData *dd, gint type, const gchar *text, ...)
}
+gchar *dict_get_clipboard_contents(void)
+{
+ gchar *text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
+
+ if (! text)
+ text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
+
+ return text;
+}
diff --git a/lib/common.h b/lib/common.h
index 115e857..7123540 100644
--- a/lib/common.h
+++ b/lib/common.h
@@ -136,6 +136,7 @@ void dict_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, gi
DictData *dict_create_dictdata();
gboolean dict_start_web_query(DictData *dd, const gchar *word);
gchar *dict_get_web_query_uri(DictData *dd, const gchar *word);
+gchar *dict_get_clipboard_contents(void);
void dict_show_msgbox(DictData *dd, gint type, const gchar *text, ...) G_GNUC_PRINTF (3, 4);
diff --git a/lib/speedreader.c b/lib/speedreader.c
index b875ac1..069ca72 100644
--- a/lib/speedreader.c
+++ b/lib/speedreader.c
@@ -548,9 +548,14 @@ static void sr_clear_clicked_cb(GtkButton *button, GtkTextBuffer *buffer)
static void sr_paste_clicked_cb(GtkButton *button, GtkTextBuffer *buffer)
{
- GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+ gchar *text;
gtk_text_buffer_set_text(buffer, "", 0);
- gtk_text_buffer_paste_clipboard(buffer, clipboard, NULL, TRUE);
+ text = dict_get_clipboard_contents();
+ if (text != NULL)
+ {
+ gtk_text_buffer_set_text(buffer, text, -1);
+ g_free(text);
+ }
}
diff --git a/src/xfce4-dict.c b/src/xfce4-dict.c
index 38ce6d9..b7cb2cc 100644
--- a/src/xfce4-dict.c
+++ b/src/xfce4-dict.c
@@ -154,11 +154,7 @@ gint main(gint argc, gchar *argv[])
if (use_clipboard)
{
- search_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(
- gdk_atom_intern("PRIMARY", FALSE)));
- if (! search_text)
- search_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(
- gdk_atom_intern("CLIPBOARD", FALSE)));
+ search_text = dict_get_clipboard_contents();
}
else
{
More information about the Xfce4-commits
mailing list