First of all, sorry about the bad email formatting. I made the mistake of
using my hotmail account (which I don't use too often) for the list and...
no big surprise...it's a raging piece of you-know-what. It took me forever
just to get it to reply in plain text. I assumed it would wrap the outgoing
stuff like gmail, and it didn't.
> Date: Tue, 6 Jan 2009 22:11:34 +0100
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> Subject: Re: Pasting selections supplied by GTK
>
> On Tue, Jan 06, 2009 at 02:58:35PM -0500, Tom Dexter wrote:
>>> I've found that selections supplied by GTK apps using code such as the
>>> following example on their devel site:
>
> any easily accessible gtk app that displays any issues? I just tried with
> firefox, gimp and gedit, and all just work. I assume the selection dcode is
> quite similar in them.
>
>>> The reason I ran into this is because I've used wmcliphist (a GTK clipboard
>>> history program that uses similar GTK selection code) for quite some time
>>> and would like to switch from aterm to urxvt because of the unicode support.
>
> I tried installing wmcliphist, but since I don't have easy access to
> libglib-1 anymore, I couldn't install it.
>
Apparenty Gentoo (which I'm running), as well as some other distributions, have
patched the
original wmcliphist to use gtk 2 and glib 2...you may not have access to that.
The sample code
on that GTK page, which I've attached (supply.c) compiles on my system with:
gcc supply.c -o supply `pkg-config --cflags --libs gtk+-2.0`
When the resulting 'sample' executable it run, clicking the button labeled
'Claim Selection'
puts text containing the current time in the primary selection.
The thing is that I don't know of any other GTK based program that's expressly
trying
to supply the selection programatically.
>>> Any ideas as why that doesn't work? Thanks in advance.
>
> No, but you really should format your e-mails so other people can read them.
> pasting everything together into a few long lines makes your e-mails hard to
> read, and it doesn't make me want to reply to them.
>
>> One question regarding the middle mouse click functionality in urxvt. Am I
>> correct that it pastes the primary selection? That's what appears to be the
>> case from testing using xsel etc.
>
> Yes.
>
>> The above issue I posted originally really perplexes me if that is in fact
>> that case. The primary selection supplied by the sample GTK code I linked to
>> can be pasted with the middle mouse in every terminal program I've tried (in
>> fact every application of any sort that I've tried) except urxvt.
>
> How did you come by with the specific urxvt binary? Did you compile it
> yourself?
>
As I mentioned, I'm running Gentoo, so actually like everything, it was
actually compiled on
my system. I'm running the latest stable version in Gentoo:
x11-terms/rxvt-unicode-9.05.
My current version of gcc is 4.1.2.
>> Any clues as to why that would be? If I had some idea I might be able to
>> find something on the GTK end that would correct it. Thanks.
>
> No, the selection works just fine between gtk+ apps and urxvt in
> general. I have not found any instance where it wouldn't work.
>
As I mentioned earlier, a lot of GTK apps will let you select text and paste
it, but that's not using
the GTK api that programatically populates the primary selection as that sample
program
and wmcliphist do.
Thanks a million for the reply, and sorry for the prior crappy hotmail posts.
Tom
> --
> The choice of a Deliantra, the free code+content MORPG
> -----==- _GNU_ http://www.deliantra.net
> ----==-- _ generation
> ---==---(_)__ __ ____ __ Marc Lehmann
> --==---/ / _ \/ // /\ \/ / [email protected]
> -=====/_/_//_/\_,_/ /_/\_\
_________________________________________________________________
Life on your PC is safer, easier, and more enjoyable with Windows Vista®.
http://clk.atdmt.com/MRT/go/127032870/direct/01/
#include <stdlib.h>
#include <gtk/gtk.h>
#include <time.h>
#include <string.h>
GtkWidget *selection_button;
GtkWidget *selection_widget;
/* Callback when the user toggles the selection */
static void selection_toggled( GtkWidget *widget,
gint *have_selection )
{
if (GTK_TOGGLE_BUTTON (widget)->active)
{
*have_selection = gtk_selection_owner_set (selection_widget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
/* if claiming the selection failed, we return the button to
the out state */
if (!*have_selection)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
}
else
{
if (*have_selection)
{
/* Before clearing the selection by setting the owner to NULL,
we check if we are the actual owner */
if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == widget->window)
gtk_selection_owner_set (NULL, GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
*have_selection = FALSE;
}
}
}
/* Called when another application claims the selection */
static gboolean selection_clear( GtkWidget *widget,
GdkEventSelection *event,
gint *have_selection )
{
g_print("In selection_clear\n");
*have_selection = FALSE;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (selection_button), FALSE);
return TRUE;
}
/* Supplies the current time as the selection. */
static void selection_handle( GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time_stamp,
gpointer data )
{
g_print("In selection_handle\n");
gchar *timestr;
time_t current_time;
current_time = time (NULL);
timestr = asctime (localtime (¤t_time));
/* When we return a single string, it should not be null terminated.
That will be done for us */
gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
8, timestr, strlen (timestr));
}
int main( int argc,
char *argv[] )
{
GtkWidget *window;
static int have_selection = FALSE;
gtk_init (&argc, &argv);
/* Create the toplevel window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Event Box");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (exit), NULL);
/* Create a toggle button to act as the selection */
selection_widget = gtk_invisible_new ();
selection_button = gtk_toggle_button_new_with_label ("Claim Selection");
gtk_container_add (GTK_CONTAINER (window), selection_button);
gtk_widget_show (selection_button);
g_signal_connect (G_OBJECT (selection_button), "toggled",
G_CALLBACK (selection_toggled), (gpointer) &have_selection);
g_signal_connect (G_OBJECT (selection_widget), "selection_clear_event",
G_CALLBACK (selection_clear), (gpointer) &have_selection);
gtk_selection_add_target (selection_widget,
GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING,
1);
g_signal_connect (G_OBJECT (selection_widget), "selection_get",
G_CALLBACK (selection_handle), (gpointer) &have_selection);
gtk_widget_show (selection_button);
gtk_widget_show (window);
gtk_main ();
return 0;
}
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode