Ejemplo n.º 1
0
def _OOFMenuItem_construct_gui(self, base, parent_menu, accelgroup):
    # "base" is this menu item's OOF menu parent, and "parent_menu" is
    # the to-be-constructed GtkMenuItem's gtk container.
    debug.mainthreadTest()
    if not (self.secret or self.getOption('cli_only')):

        new_gtkitem = gtk.MenuItem()  # Built with no label.
        gtklogger.setWidgetName(new_gtkitem, self.name)
        new_gtkitem.add(self.gtklabel(new_gtkitem))
        try:
            self.gtkitem.append(new_gtkitem)
        except AttributeError:
            self.gtkitem = [new_gtkitem]

        new_gtkitem.connect("destroy", self.gtkitem_destroyed)

        parent_menu.insert(new_gtkitem, self.gui_order())
        if self.help_menu:
            base.gtkhelpmenu = 1
            new_gtkitem.set_right_justified(True)

        if (self.callback is None) and (self.gui_callback is None) \
               and self.children_visible():

            new_gtkmenu = gtk.Menu()
            try:
                self.gtkmenu.append(new_gtkmenu)
            except AttributeError:
                self.gtkmenu = [new_gtkmenu]

            gtklogger.set_submenu(new_gtkitem, new_gtkmenu)
            for item in self.items:
                item.construct_gui(self, new_gtkmenu, accelgroup)  # recursive!
        else:  # no submenu, create command
            gtklogger.connect(new_gtkitem, 'activate',
                              MenuCallBackWrapper(self))
            if self.accel is not None and accelgroup is not None:
                new_gtkitem.add_accelerator('activate', accelgroup,
                                            ord(self.accel),
                                            gtk.gdk.CONTROL_MASK,
                                            gtk.ACCEL_VISIBLE)

        if not self.enabled():
            new_gtkitem.set_sensitive(0)
Ejemplo n.º 2
0
def _OOFMenuItem_construct_gui(self, base, parent_menu, accelgroup):
    # "base" is this menu item's OOF menu parent, and "parent_menu" is
    # the to-be-constructed GtkMenuItem's gtk container.
    debug.mainthreadTest()
    if not (self.secret or self.getOption('cli_only')):

        new_gtkitem = gtk.MenuItem() # Built with no label.
        gtklogger.setWidgetName(new_gtkitem, self.name)
        new_gtkitem.add(self.gtklabel(new_gtkitem))
        try:
            self.gtkitem.append(new_gtkitem)
        except AttributeError:
            self.gtkitem = [new_gtkitem]
            
        new_gtkitem.connect("destroy", self.gtkitem_destroyed)
        
        parent_menu.insert(new_gtkitem, self.gui_order())
        if self.help_menu:
            base.gtkhelpmenu = 1
            new_gtkitem.set_right_justified(True)

        if (self.callback is None) and (self.gui_callback is None) \
               and self.children_visible():

            new_gtkmenu = gtk.Menu()
            try:
                self.gtkmenu.append(new_gtkmenu)
            except AttributeError:
                self.gtkmenu=[new_gtkmenu]

            gtklogger.set_submenu(new_gtkitem, new_gtkmenu)
            for item in self.items:
                item.construct_gui(self, new_gtkmenu, accelgroup) # recursive!
        else:                               # no submenu, create command
            gtklogger.connect(new_gtkitem, 'activate', MenuCallBackWrapper(self))
            if self.accel is not None and accelgroup is not None:
                new_gtkitem.add_accelerator('activate', accelgroup,
                                            ord(self.accel),
                                            gtk.gdk.CONTROL_MASK,
                                            gtk.ACCEL_VISIBLE)

        if not self.enabled():
            new_gtkitem.set_sensitive(0)
Ejemplo n.º 3
0
def gtkOOFMenu(menu, accelgroup=None):
    """
    Function to turn an OOFMenu into GTK+.  The leading GtkMenuItem is
    returned.
    """
    debug.mainthreadTest()
    base = gtk.MenuItem(utils.underscore2space(menu.name))
    gtklogger.setWidgetName(base, menu.name)
    new_gtkmenu = gtk.Menu()
    try:
        menu.gtkmenu.append(new_gtkmenu)
    except AttributeError:
        menu.gtkmenu = [new_gtkmenu]

    new_gtkmenu.connect("destroy", menu.gtkmenu_destroyed)

    gtklogger.set_submenu(base, new_gtkmenu)
    menu.setOption('accelgroup', accelgroup)

    for item in menu:
        if not (item.secret or item.getOption('cli_only')):
            item.construct_gui(menu, new_gtkmenu, accelgroup)
    return base
Ejemplo n.º 4
0
def gtkOOFMenu(menu, accelgroup=None):
    """
    Function to turn an OOFMenu into GTK+.  The leading GtkMenuItem is
    returned.
    """
    debug.mainthreadTest()
    base = gtk.MenuItem(utils.underscore2space(menu.name))
    gtklogger.setWidgetName(base, menu.name)
    new_gtkmenu = gtk.Menu()
    try:
        menu.gtkmenu.append(new_gtkmenu)
    except AttributeError:
        menu.gtkmenu = [new_gtkmenu]

    new_gtkmenu.connect("destroy", menu.gtkmenu_destroyed)
                        
    gtklogger.set_submenu(base, new_gtkmenu)
    menu.setOption('accelgroup', accelgroup)

    for item in menu:
        if not (item.secret or item.getOption('cli_only')):
            item.construct_gui(menu, new_gtkmenu, accelgroup)
    return base
Ejemplo n.º 5
0
def _addItem_thread(self, item):
    debug.mainthreadTest()
    _oldAddItem(self, item)
    # Check to see if the gui has been constructed yet. The gui
    # objects for the root of the menu have gtkmenu attributes, but
    # not gtkitem attributes.  Other nodes of the tree have gtkitem,
    # but may not have gtkmenu, so it's necessary to check for both.
    if (hasattr(self, 'gtkitem') or hasattr(self, 'gtkmenu')) and \
       self.children_visible():
        # We've been guied, so gui the new children, if they're visible.
        if not hasattr(self, 'gtkmenu'):
            # Make a gtkmenu for each gtkitem.
            self.gtkmenu = [gtk.Menu() for i in range(len(self.gtkitem))]
            for (i, m) in zip(self.gtkitem, self.gtkmenu):
                gtklogger.set_submenu(i, m)
            for m in self.gtkmenu:
                m.connect("destroy", self.gtkmenu_destroyed)

        # At this point, we ourselves are guaranteed both gtkitem and gtkmenu.
        # Build a GUI object for each menu.
        for m in self.gtkmenu:
            item.construct_gui(self, m, item.getOption('accelgroup'))

    # If the parent menu had been desensitized because it had been
    # empty, it has to be sensitized now.
    self.enable_parent_gui()

    try:
        map(lambda x: x.show_all(), self.gtkmenu)
    except AttributeError:
        pass
    try:
        map(lambda x: x.show_all(), self.gtkitem)
    except AttributeError:
        pass
    return item
Ejemplo n.º 6
0
def _addItem_thread(self, item):
    debug.mainthreadTest()
    _oldAddItem(self, item)
    # Check to see if the gui has been constructed yet. The gui
    # objects for the root of the menu have gtkmenu attributes, but
    # not gtkitem attributes.  Other nodes of the tree have gtkitem,
    # but may not have gtkmenu, so it's necessary to check for both.
    if (hasattr(self, 'gtkitem') or hasattr(self, 'gtkmenu')) and \
       self.children_visible():
        # We've been guied, so gui the new children, if they're visible.
        if not hasattr(self, 'gtkmenu'):
            # Make a gtkmenu for each gtkitem.
            self.gtkmenu = [gtk.Menu() for i in range(len(self.gtkitem))]
            for (i,m) in zip(self.gtkitem, self.gtkmenu):
                gtklogger.set_submenu(i, m)
            for m in self.gtkmenu:
                m.connect("destroy", self.gtkmenu_destroyed)
            
        # At this point, we ourselves are guaranteed both gtkitem and gtkmenu.
        # Build a GUI object for each menu.
        for m in self.gtkmenu:
            item.construct_gui(self, m, item.getOption('accelgroup'))

    # If the parent menu had been desensitized because it had been
    # empty, it has to be sensitized now.
    self.enable_parent_gui()
    
    try:
        map(lambda x: x.show_all(), self.gtkmenu)
    except AttributeError:
        pass
    try:
        map(lambda x: x.show_all(), self.gtkitem)
    except AttributeError:
        pass
    return item