Binding signals to items in an inherited canvas class (was: Re: GooCanvas & Gtk3)



Am 14.05.2013 12:12, schrieb Damon Chaplin:
On Tue, 2013-05-14 at 11:00 +0200, Sven Anders wrote:

This leads me to another question:

I'm trying to implement a "GooCanvasEditor" class. I want to connect the mouse event signals
to each item I add to the Canvas, but I cannot figure out, what is the best method to do
this...

I tried to override and connect to the "add" signal of the Gtk.Container class, but this does
not work. The "item-created" signal is only available in the Model/View variant, but this may
be deprecated?!

Any ideas?

In the demo (demo/demo.c) it calls a function after adding each item
like this:

  item = goo_canvas_rect_new (root, 20, 30, 50, 30,
                            "stroke-color", "red",
                            "line-width", 8.0,
                            "tooltip", "Red stroked rectangle",
                            NULL);
  setup_item_signals (item);

static void
setup_item_signals (GooCanvasItem *item)
{
  g_signal_connect (item, "motion_notify_event",
                  G_CALLBACK (on_motion_notify), NULL);
  g_signal_connect (item, "button_press_event",
                  G_CALLBACK (on_button_press), NULL);
  g_signal_connect (item, "button_release_event",
                  G_CALLBACK (on_button_release), NULL);
}

That's probably the easiest thing to do.
 Damon

Thanks for the answer, but not the thing I had in mind...

As I said, I'm trying to implement a CanvasEditor class (inherited from the GooCanvas) and
I want an easy way to connect each item I'll add to the editor to the Editors event handlers.

I other words, I want to use the "goo_canvas_rect_new(root,...)" function with my CanvasEditor
root item and all signal handlers should be added automatically.


Regards
 Sven Anders

-- 
 Sven Anders <anders anduras de>                 () UTF-8 Ribbon Campaign
                                                 /\ Support plain text e-mail
 ANDURAS intranet security AG
 Messestrasse 3 - 94036 Passau - Germany
 Web: www.anduras.de - Tel: +49 (0)851-4 90 50-0 - Fax: +49 (0)851-4 90 50-55

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin

Attachment: anders.vcf
Description: Vcard



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