Re: [gtk-list] NEWBIE: Implementing Copy/Paste



Well it depends on what you're copying from and pasting to.  I'm going
to assume you're using a widget that derives off of GtkEditable (both
GtkEntry and GtkText fall into this category).  In this case all you need
to do is write wrapper functions for copy and paste and hook those
functions to accelerators and/or buttons.  Here's a sample.

....

void
copy_callback (GtkWidget *w, GtkWidget *text)
{
  gtk_editable_copy_clipboard (GTK_EDITABLE (text));
  
  /* unselects the newly copied region */
  gtk_editable_select_region (GTK_EDITABLE (text), 0, 0);
}

void
paste_callback (GtkWidget *w, GtkWidget *text)
{
  gtk_editable_paste_clipboard (GTK_EDITABLE (text));
}

...

gtk_signal_connect (GTK_OBJECT (copy_button), "clicked",
  GTK_SIGNAL_FUNC (copy_callback), text);
  
gtk_signal_connect (GTK_OBJECT (paste_button), "clicked",
  GTK_SIGNAL_FUNC (paste_callback), text);
...

For more information take a look at http://gtk.org/rdp/gtk/gtkeditable.html.

HTH

Eden Li
tile@primenet.com

Matt Long <matt.long@wcom.com> wrote:
> Is there any documentation on implementing Copy/Paste (usring a
> pushbutton)? And if not, can someone provide some source code examples.



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