Fwd: C & P event from x

thanks a lot
i'll read more about clipboard :)

On 6/14/05, Muthiah Annamalai <dearestchum yahoo co in> wrote:

--- Arx Henrique <arxcruz gmail com> wrote:
i'm newbie in gtk, and i'm making a simple program

Welcome to GTK!
Explore documents at

1. Www.gtk.org/ | tutorials | articles | code
2. $ gtk-demo & | A simple & powerful demo of GTK+
3. http://developer.gnome.org | GTK+ & GNOME
4. http://gnomefiles.org | free & non-free GTK+

how can i get copy and paste event from x in my gtk
app ?

Well I think youre using the 'entry' widget or
'TextView' for copy/pasting from/to your app.

Now you need to share data like this with other apps
using a clipboard.

So look at gtkclipboard.h in your
/usr/include/gtk-2.0/gtk/ folder.

Process is like this:

1: When you app starts, get access to a clipboard from
the X server using:

 GtkClipboard *gtk_clipboard_get_for_display
      (GdkDisplay   *display, GdkAtom

 display can be got like
GdkDisplay *gdk_display_get_default (void);

For atom choose one from gdkselection.h, its basically
the type of clipboard you want to save to.

2: If user selects some text in your app, and chooses
paste,  use this function to set clipboard contents.

void     gtk_clipboard_set_text
   (GtkClipboard *clipboard,
     const gchar   *text, gint   len);

3: If you want text from the user [paste], then
text from the clipboard using,

void gtk_clipboard_request_text
        (GtkClipboard  *clipboard,
GtkClipboardTextReceivedFunc callback,
         gpointer  user_data);

passing it a callback. Store the data, in some cache,
and only if user presses paste, copy the text to the
text buffer.

This is preliminary help, might not work all the time,
but if youre getting direction, then it helps.

For more help see  /gtk+/gtk/gtktextbuffer.c


Discover Yahoo!
Have fun online with music videos, cool games, IM and more. Check it out!

"A fé remove montanas, mas eu prefiro a dinamite"

"A fé remove montanas, mas eu prefiro a dinamite"

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]