Re: [gedit-list] Is there a signal for text selection?



Il giorno ven, 01/05/2009 alle 13.57 -0600, steve love ha scritto:
> Thanks again, Paolo and Jesse. I've now got a first attempt at a
> plugin up and working.
> 
> I spent a lot of time programming with Notepad++ and one of the
> features I liked about it is that if you select a word, all
> occurrences of that word will be instantly highlighted within the
> document. It's similar to the way the Ctrl+K functionality works in
> Gedit, but it's triggered by text selection instead.
> 
> There's still an issue that I'd like to work out if anyone has any
> input. The plugin only works on double-click. If you try to select a
> word using the mouse or Shift+Arrows, it will only highlight the first
> letter or two.

Right, because has-selection will be "true" as soon as the first letter
is selected and you will not get the signal anymore.

>  I'm using "notify::has-selection" as suggested. Is there something
> that signals that the selection is changing? For instance, if you're
> dragging the mouse to select a word? I couldn't seem to find anything
> like this in the documentation.
> 

For your use case it's probably better to use the the mark-set signal:
be careful to only do stuff when the signal is for the "insert" and
"selection-mark" marks and instead return asap in the other cases,
otherwise you could incur in performance issues.

Also make sure to put your plugin on live.gnome.org/Gedit/Plugins :-)

Ciao

	Paolo


> http://github.com/stevelove/Highlight-Selected/tree/master
> 
> Steve
> 
> 
> On Sun, Apr 26, 2009 at 3:56 AM, Paolo Borelli <pborelli katamail com>
> wrote:
>         Il giorno dom, 26/04/2009 alle 11.42 +0200, Jesse van den
>         Kieboom ha
>         scritto:
>         > steve love schreef:
>         > > Thanks for the response, Paolo. You'll have to forgive me;
>         I'm pretty
>         > > new at this. I'm having trouble figuring out which object
>         has the
>         > > "has_selection" property. Can you point me in the right
>         direction? Or
>         > > perhaps tell me where to find some helpful documentation?
>         > It is the GtkTextView which has this property (in gedit this
>         is
>         > GeditView which descends from GtkSourceView which descends
>         from
>         > GtkTextView). The easiest way to browse and search gtk+
>         documentation is
>         > to install the application 'devhelp'.
>         >
>         
>         
>         Actually it is GtkTextBuffer. In this case the inheritance
>         goes like
>         this:
>         
>         GeditDocument inherits from GtkSourceBuffer which inherits
>         from
>         GtkTextBuffer.
>         
>         
>         Ciao
>         
>                Paolo
>         
>         
>         
>         >
>         > Jesse
>         > >
>         > > Thanks again,
>         > > Steve
>         > >
>         > > On Sat, Apr 25, 2009 at 4:00 AM, Paolo Borelli
>         <pborelli katamail com
>         > > <mailto:pborelli katamail com>> wrote:
>         > >
>         > >     Il giorno ven, 24/04/2009 alle 22.54 -0600, steve love
>         ha scritto:
>         > >     > Hello everyone,
>         > >     >
>         > >     > I've been RTFM'ing all evening. Is there a signal
>         that would allow a
>         > >     > plugin to listen for text selection? I'd like to
>         listen for
>         > >     selecting
>         > >     > text by any method: double-clicking, dragging the
>         cursor,
>         > >     Shift+Arrow
>         > >     > Keys, etc.
>         > >     >
>         > >     > Or, failing that, is there a way to listen for
>         cursor movement
>         > >     (after
>         > >     > which I can test "get_has_selection")?
>         > >     >
>         > >
>         > >     Since "has_selection" is a property, you can use the
>         "notify"
>         > >     signal to
>         > >     see when the property changes. At that point you can
>         grab the
>         > >     selection
>         > >     with get_selected()
>         > >
>         > >     ciao
>         > >            Paolo
>         > >
>         > >     > Thanks in advance for any help.
>         > >     >
>         > >     > Steve
>         > >     > _______________________________________________
>         > >     > gedit-list mailing list
>         > >     > gedit-list gnome org <mailto:gedit-list gnome org>
>         > >     > http://mail.gnome.org/mailman/listinfo/gedit-list
>         > >
>         > >
>         > >
>         ------------------------------------------------------------------------
>         > >
>         > > _______________________________________________
>         > > gedit-list mailing list
>         > > gedit-list gnome org
>         > > http://mail.gnome.org/mailman/listinfo/gedit-list
>         > >
>         >
>         >
>         
>         
> 



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