# Gtk::Drag.source\_set produces \[BUG\] Segmentation fault

**URL:** <https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245>\
**Category:** Ruby-Gnome 2\
**Created:** [January 24, 2007, 4:44pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245 "2007-01-24T16:44:25Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 24, 2007, 4:44pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/1 "2007-01-24T16:44:25Z")

</div>

hi,

i want to have some texts on screen, in a way that user can position  
them by dragging them with the mouse.  
i decided to use Gtk::Label-s on a Gtk::Layout.  
when i try to add drag-and-drop to it, it segfaults.

require ‘gtk2’

Gtk.init

@w = Gtk::Window.new  
@w.signal\_connect(‘destroy’){Gtk.main\_quit}  
@w.set\_default\_size(500, 500)

lay=Gtk::Layout.new()

l1=Gtk::Label.new(“test”)  
l1.signal\_connect(‘drag-begin’){|me,context|  
print “drag-begin: “,context.inspect,”\n”  
}

lay.put(l1,10,10)

@w.add(lay)

#Gtk::Drag.dest\_set(lay,Gtk::Drag::DEST\_DEFAULT\_ALL,nil,Gdk::DragContext::ACTION\_MOVE)  
Gtk::Drag.source\_set(l1,Gdk::Window::SHIFT\_MASK,nil,Gdk::DragContext::ACTION\_MOVE)

#@w.show\_all

#Gtk.main

the #d lines probably don’t didn’t play part in the issue.

i tried setting the window parameter of l1, didn’t help.

thanks,

balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 25, 2007, 12:53pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/2 "2007-01-25T12:53:35Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] Gtk::Drag.source\_set produces [BUG]  
Segmentation fault” on Tue, 23 Jan 2007 15:31:56 +0200,  
Dobai-Pataky Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i want to have some texts on screen, in a way that user can position  
> them by dragging them with the mouse.  
> i decided to use Gtk::Label-s on a Gtk::Layout.  
> when i try to add drag-and-drop to it, it segfaults.

> #Gtk::Drag.dest\_set(lay,Gtk::Drag::DEST\_DEFAULT\_ALL,nil,Gdk::DragContext::ACTION\_MOVE)  
> Gtk::Drag.source\_set(l1,Gdk:🪟:SHIFT\_MASK,nil,Gdk::DragContext::ACTION\_MOVE)

You don’t need to use Gtk::Drag for this. See  
sample/misc/drag-move.rb in Ruby/GTK2.

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 25, 2007, 3:37pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/3 "2007-01-25T15:37:21Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 27, 2007, 8:02am UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/4 "2007-01-27T08:02:57Z")

</div>

Hi,

I suggest you that you show a sample script that describes  
what you want if you’ll save our time to understand what you  
want.

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Gtk::Drag.source\_set produces [BUG]  
Segmentation fault” on Thu, 25 Jan 2007 16:36:29 +0200,  
Dobai-Pataky\_Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> You don't need to use Gtk::Drag for this. See
> sample/misc/drag-move.rb in Ruby/GTK2.
> 
> ```
> 
> yeah, after i sent this mail, i have found the examples, and understood them.  
> but they are not the right solution for me, what i want to do is to have a  
> fixed or a layout and some labels on it, and allow the user to move the labels  
> with the mouse.

I think the example shows a hint for what you want to do…  
Anyway, what about sample/misc/dnd.rb?

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 27, 2007, 11:18am UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/5 "2007-01-27T11:18:16Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Gtk::Drag.source\_set produces [BUG]  
Segmentation fault” on Sat, 27 Jan 2007 11:42:39 +0200,  
Dobai-Pataky\_Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> Dobai-Pataky_Bálint <removed_email_address@domain.invalid> wrote:
> Anyway, what about sample/misc/dnd.rb?
> 
> ```
> 
> the current state of my Layout class is:

You should show us the Layout class if you want to get more  
help.

> white path on the theme’d gray background - i thought i should fill the  
> Drawable with white, but haven’t found the filling method yet.
> 
> - i’ll have to snap the rectangle in movement to a 10x10 pixel grid, so Labels  
> may be easily positioned on a line
> 
> if you have any ideas regarding, please don’t hold them back 🙂

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 27, 2007, 11:48am UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/6 "2007-01-27T11:48:22Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 27, 2007, 10:43am UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/7 "2007-01-27T10:43:13Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 27, 2007, 12:57pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/8 "2007-01-27T12:57:29Z")

</div>

Hi,

> ```
> the current state of my Layout class is:
> 
> You should show us the Layout class if you want to get more
> help.
> 
> ```
> 
> thought so 🙂  
> attaching

> signal\_connect(‘event’){|me,event|  
> case event.event\_type

It’s better that you connect each signal  
(button-press-event, motion-notify-event and  
button-release-event) instead of signal\_connect('event") and  
case - when style.

> ```
> when Gdk::Event::BUTTON_PRESS
> 
> ```
> 
> # print “press\tx=#{event.x}\ty=#{event.y}\n”
> 
> ```
> @xshift=event.x
> @yshift=event.y
> @dragging=true
> @myobject.hide
> @w,@h=@myobject.child_requisition
> parent.bin_window.draw_rectangle(parent.gc,false,@x-1,@y-1,@w+1,@h+1)
> @lastx=@xshift
> @lasty=@yshift
> 
> ```

> ```
> when Gdk::Event::MOTION_NOTIFY
> 
> ```

…

> ```
> when Gdk::Event::BUTTON_RELEASE
> 
> ```

…

It’s better that you draw on “expose” signal not on  
“button-press-event”, “motion-notify-event” and  
“button-release-event” signals. So, you just call  
parent.queue\_draw\_area on those signals and wait “expose”  
signal is emitted.

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 27, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/9 "2007-01-27T16:30:53Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 1:58am UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/10 "2007-01-28T01:58:01Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Gtk::Drag.source\_set produces [BUG]  
Segmentation fault” on Sat, 27 Jan 2007 17:30:36 +0200,  
Dobai-Pataky\_Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> It's better that you draw on "expose" signal not on
> "button-press-event", "motion-notify-event" and
> "button-release-event" signals. So, you just call
> parent.queue_draw_area on those signals and wait "expose"
> signal is emitted.
> 
> ```
> 
> and why is that?

“expose” signal is for redrawing but other signal is not.

> anyways, any ideas on the color issue?

parent.queue\_draw\_area will solve the issue if you specify  
correct area.

Please try!

## Thank,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 1:51pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/11 "2007-01-28T13:51:11Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Gtk::Drag.source\_set produces [BUG]  
Segmentation fault” on Sun, 28 Jan 2007 12:28:22 +0200,  
Dobai-Pataky\_Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> okay, this one works, got another problem, my queue works only in a rectangle,  
> dunno why.  
> can you please take a look at it?

You need to move your EventBox to a queued area to receive  
an expose event.

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 11:28am UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/12 "2007-01-28T11:28:45Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/13 "2007-01-28T14:56:33Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 3:19pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/14 "2007-01-28T15:19:39Z")

</div>

Am Sonntag, den 28.01.2007, 15:55 +0200 schrieb Dobai-Pataky BÃ¡lint:

Hi,

cause it seems to be a bigger problem 😉 i changed your code a little  
bit.

I don’t want to sound harsh but i think, that you don’t understand the  
Gdk concepts very well. I suggest to read the Xlib manuals from  
O’Reilly. Gdk is very close to the Xlib and so these are the best docs  
you can get.

Cheers  
detlef

#!/usr/bin/ruby

require ‘gtk2’

class Lay \< Gtk::Layout  
class LayLabel \< Gtk::EventBox  
def initialize(text)  
@x=0  
@y=0  
@text=text  
@dragging=false  
@myobject=Gtk::Label.new(@text)  
super()  
add(@myobject)

signal\_connect(‘event’){|me,event|  
if @xorgc.nil? and self.realized?  
@xorgc = Gdk::GC.new parent.bin\_window  
@xorgc.function = Gdk::GC::INVERT  
end

```
case event.event_type

when Gdk::Event::BUTTON_PRESS
  @xshift=event.x
  @yshift=event.y
  @dragging=true
  @w,@h=@myobject.child_requisition
  parent.bin_window.draw_rectangle(@xorgc,false,@x-1,@y-1,@w+1,@h+1)
  @lastx=@xshift
  @lasty=@yshift

when Gdk::Event::MOTION_NOTIFY
  parent.bin_window.draw_rectangle(@xorgc,false,@x+@lastx-@xshift-1,@y

```

+@lasty-@yshift-1,@w+1,@h+1)  
parent.bin\_window.draw\_rectangle(@xorgc,false,@x  
+event.x-@xshift-1,@y+event.y-@yshift-1,@w+1,@h+1)  
@lastx=event.x  
@lasty=event.y

```
when Gdk::Event::BUTTON_RELEASE
  @dragging=false
  parent.bin_window.draw_rectangle(@xorgc,false,@x+@lastx-@xshift-1,@y

```

+@lasty-@yshift-1,@w+1,@h+1)  
@x=event.x+@x-@xshift  
@y=event.y+@y-@yshift  
parent.move(self)  
end  
}  
end  
attr\_accessor :x  
attr\_accessor :y  
attr\_accessor :text  
end

def initialize  
super  
@mygc=nil  
@clearmygc=nil  
w,h=size  
end

def put(gtk\_type,x,y)  
case gtk\_type  
when “text”  
l=LayLabel.new(“test text”)  
l.x=x  
l.y=y  
end  
super(l,x,y)  
end  
def move(ch,x=ch.x,y=ch.y)  
ch.x=x  
ch.y=y  
super  
end  
end

lay=Lay.new  
lay.put(“text”,100,100)  
lay.put(“text”,200,200)  
lay.put(“text”,300,300)

@w = Gtk::Window.new  
@w.signal\_connect(‘destroy’){Gtk.main\_quit}  
@w.set\_default\_size(500, 500)  
@w.add(lay)  
@w.show\_all

Gtk.main

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 5:12pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/15 "2007-01-28T17:12:58Z")

</div>

Detlef R. wrote:

> Am Sonntag, den 28.01.2007, 15:55 +0200 schrieb Dobai-Pataky BÃ¡lint:
> 
> Hi,
> 
> cause it seems to be a bigger problem 😉 i changed your code a little  
> bit.

no problem

> I don’t want to sound harsh but i think, that you don’t understand the  
> Gdk concepts very well. I suggest to read the Xlib manuals from  
> O’Reilly. Gdk is very close to the Xlib and so these are the best docs  
> you can get.

that has to be true, all i used was the ruby-gtk2 hiki, and i’m learning  
this gtk-gdk stuff.  
but please enlighten me, what was your invention besides inverting the  
color of the rectangle and not drawing one with a defined color? would  
you provide an example where the border is red please?  
and please consider my previous script, not the one using the expose  
event. i just tried that way, as Kou suggested.

> class Lay \< Gtk::Layout  
> signal\_connect(‘event’){|me,event|  
> @yshift=event.y  
> +event.x-@xshift-1,@y+event.y-@yshift-1,@w+1,@h+1)  
> end  
> @clearmygc=nil  
> end  
> lay.put(“text”,100,100)  
> Gtk.main

this one works.  
in the mean time i got a version working when Label follows the mouse,  
not a rectangle.  
thanks  
balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/16 "2007-01-28T17:36:03Z")

</div>

Am Sonntag, den 28.01.2007, 18:12 +0200 schrieb Dobai-Pataky BÃ¡lint:

> but please enlighten me, what was your invention besides inverting the  
> color of the rectangle and not drawing one with a defined color? would  
> you provide an example where the border is red please?

If you want to use a special colour for drawing, you also have to  
specify the background colour of your drawable. Else if the user has a  
theme in use, where the background is red you wouldn’t see your  
rectangle at all.

> and please consider my previous script, not the one using the expose  
> event. i just tried that way, as Kou suggested.

> From my point of view using queue\_draw\_area is unnecessary complicated  
> for this case. You have to invalidate all the areas where your rectangle  
> moves over while dragging. If you use a very complex layout with many  
> widgets on them it may make sense.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [January 28, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/gtk-drag-source-set-produces-bug-segmentation-fault/83245/17 "2007-01-28T19:38:23Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
