Having problems with gtk_editable_copy_clipboard



Hello,

I am having problems with the function, gtk_editable_copy_clipboard, on the
Solaris 2.6 platform.  I created a very simple program, which creates a
GtkEntry (for text input), as shown below:

   entry = gtk_entry_new ();
   gtk_entry_set_max_length (GTK_ENTRY (entry), 50);

I then attached a signal handler, copy_clipboard(), to the event, 
"copy-clipboard," as shown below:

   g_signal_connect (G_OBJECT (entry), "copy-clipboard",
                     G_CALLBACK (copy_clipboard),
                     entry);

My signal handler, copy_clipboard(), follows:

   void copy_clipboard( GtkWidget *widget,
                        GtkWidget *entry)
   {
      static int   count        = 0;
      const  gchar *entry_text;
   
      entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
      printf("copy_clipboard:  Entry contents: %s\n", entry_text);
   
      g_print( "Copy Clipboard executing for the %d time.\n", count++ );
      gtk_editable_copy_clipboard( GTK_EDITABLE( widget ) );
   }

When I highlight text in the text entry, right click and select "Copy", the
following is displayed on standard out before the program dumps core:

   copy_clipboard:  Entry contents: hello world
   Copy Clipboard executing for the 0 time.
   copy_clipboard:  Entry contents: hello world
   Copy Clipboard executing for the 1 time.

    . . .

   copy_clipboard:  Entry contents: hello world
   Copy Clipboard executing for the 5395 time.
   Segmentation Fault (core dumped)


Note that it seems as though the "copy-clipboard" event is generated
5395 times (because the function is called 5395 times for one "Copy."
Am I doing something wrong or is there a bug in GTK?


Thanks in advance for your assistance,

Brad



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