Re: Some cut,copy and paste thoughts



Damian Ivereigh <damian cisco com> writes:

> Hi all,
> 
> I hope this is the right forum for this. I have been working on Galeon
> and have just completed all the stuff around doing the cut,copy & paste
> from the Edit pulldown menu. Pretty standard stuff I thought.
> 
> The first place I got stuck was wanting to make each selection sensitive
> according to what was going on - for example only offering Paste if
> there was something actually in the CLIPBOARD.
> 
> However I could not find a way to detect this. In the end I did it via a
> native X call - XGetSelectionOwner(). I found another gdk routine that
> *almost* did what I needed: gdk_selection_owner_get(), however it
> returns NULL not only when there is no owner (nothing in the clipboard),
> but also when it is owned by a non gdk process, so was no use to me.
> 
> Since all I care about is if there is anything there, not trying to
> actually work out what is on the other end. I am wondering if there
> would be any point in creating a new gdk function called, say,
> gdk_selection_is_owned(). 

Well, I'd be a little hestitant about offering such a function 
because there are two snags in the usage:

 - X does not provide any notification on changes for this, so you have 
   to check every time the menu is popped up. Which for a menu from 
   a menubar is decidedly painful.

 - Just because there is an owner for the selection, doesn't mean
   the owner is offering anything you can paste.

   It would be more reliable to actually request the TARGETS selection
   and check to see if any of them are acceptable.

   But then you get into the problem that by the time you've gotten
   that information from the owner, either you've displayed the
   menu in a possibly incorrect way, or you've paused long enough
   to be noticeable to the user.

But that doesn't mean that something along these lines couldn't
be useful.

> What is the procedure for creating a new library function such as
> this? 

The best way to request something is to file a bug in bugzilla.gnome.org.
Including a patch may help get it done, though not always.

> Who do I need to persuade? 

Me.

> Can anyone suggest a better way.
>
> On a related, but different, subject. Having now finished all the
> Cut/Copy/Paste stuff, I am wondering if there really should be a widget
> or at least some easy way to perform it (and handle all the
> sensitivities). I felt like I was reinventing the wheel. I notice few
> other gnome apps bother with fixing the sensitivity. Again is the right
> place to talk about it? I have a few ideas about how to do it, however I
> am a gtk/gnome newbie (though I long-time 'C' hack) and I am unsure of
> the "right" way to do it.

 http://developer.gnome.org/doc/API/2.0/gtk/gtk-clipboards.html

Regards,
                                        Owen




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