diff options
author | Richard Sharpe <sharpe@ns.aus.com> | 2004-09-02 16:58:43 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@ns.aus.com> | 2004-09-02 16:58:43 +0000 |
commit | 55691363515466d1c6d216cbab90fbb6cf7a0f88 (patch) | |
tree | bd16dcdfa41dfdcad49356195289d12f846a2d4a /gtk/ui_util.c | |
parent | f4f2b80b21b6c3174912c9d68f55b0a3e08861aa (diff) |
Add support for copying hex data to the clipboard. Submitted by Thomas
Palmer.
What we really should do is add this to the Edit menu as well.
svn path=/trunk/; revision=11883
Diffstat (limited to 'gtk/ui_util.c')
-rw-r--r-- | gtk/ui_util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gtk/ui_util.c b/gtk/ui_util.c index 8401f7042c..2e50b767ac 100644 --- a/gtk/ui_util.c +++ b/gtk/ui_util.c @@ -988,3 +988,24 @@ simple_list_new(gint cols, gchar **titles) { return plugins_list; } +extern void +copy_to_clipboard(GString *str) +{ +#if (GTK_MAJOR_VERSION >= 2) + GtkClipboard *cb; + + cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */ + gtk_clipboard_set_text(cb, str->str, -1); /* Copy the byte data into the clipboard */ +#else + GtkWidget *window; + GtkWidget *text; + + window = window_new (GTK_WINDOW_TOPLEVEL,""); + text = gtk_text_new (NULL, NULL); /* Create the GtkText widget */ + gtk_container_add (GTK_CONTAINER (window), text); /* Avoid a GTK assertion */ + gtk_widget_realize (text); /* Realizing a widget creates a window for it, ready for us to insert some text */ + gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, str->str, -1); + gtk_editable_select_region((GtkEditable *)text, 0, -1); /* Select ALL text */ + gtk_editable_copy_clipboard((GtkEditable *)text); /* Copy the byte data into the clipboard */ +#endif +} |