Create right click menu



Hi all !

I work on DIa 0.97 for win xp.

I have created this small plugin starting from the example
shwon here; http://projects.gnome.org/dia/python.html

I'm totally new to Python but my question is how to implement
right click contex menu instead of going up on the horizontal menu bar.

Is this possible ? Even compiling again dia ?
Where I have to look inside dia code ?

Thanks a lot for your help



import sys, dia

def get_progname():
    return "Center"

def center_objects (objs) :
        r = objs[0].bounding_box
        cx = (r.right + r.left) / 2
        cy = (r.bottom + r.top) / 2
        for o in objs[1:] :
                r = o.bounding_box
                (x, y) = o.properties["obj_pos"].value
                dx = (r.right + r.left) / 2 - cx
                dy = (r.bottom + r.top) / 2 - cy
                o.move (x - dx, y - dy)

def dia_objects_center_cb (data, flags) :
        grp = data.get_sorted_selected()
        if (len(grp) > 1) :
                center_objects (grp)
                data.update_extents ()
        dia.active_display().diagram.add_update_all()
                                                
dia.register_action ("DialogsGroupproperties", "Center",
                      "/DisplayMenu/Dialogs/Center",
                       dia_objects_center_cb)



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