Exemplo n.º 1
0
    def init_menu(self):
        ag = gtk.GtkAccelGroup()
        self.itemf = gtk.GtkItemFactory(gtk.GtkMenuBar, "<main>", ag)
        self.add_accel_group(ag)

        self.itemf.create_items([
            ('/File', None, None, 0, '<Branch>'),
            ('/File/Exit', None, self.quit, 0, ''),
            ('/Tools', None, None, 0, '<Branch>'),
            ('/Tools/Chat', None, self.jabberObj.addChatTabViaRoster, 1, ''),
            ('/Tools/sep1', None, None, 0, '<Separator>'),
            ('/Tools/Add', None, self.addCB, 1, ''),
            ('/Tools/Remove', None, self.removeCB, 0, ''),
            ('/Tools/Status/Available', None, self.statusCB, 1, '<CheckItem>'),
            ('/Tools/Status/Unavailable', None, self.statusCB, 0,
             '<CheckItem>'),
            ('/Tools/Status/Custom', None, self.custstatusCB, 0, ''),
            ('/Tools/sep2', None, None, 0, '<Separator>'),
            ('/Tools/Transports', None, self.transCB, 0, ''),
            ('/Tools/Tabs/Rotate', None, self.rotateTabCB, 0, ''),
            ('/Tools/Tabs/Url Grabber', None, self.urlTabCB, 0, ''),
            ('/Tools/Tabs/Debug', None, self.debugTabCB, 0, ''),
            ('/Help', None, None, 0, '<Branch>'),
            ('/Help/About', None, self.infoCB, 0, '')
        ])

        self.menubar = self.itemf.get_widget('<main>')
        self.itemf.get_widget('/Tools/Status/Available').set_active(gtk.TRUE)
        self.tbox.pack_start(self.menubar, fill=gtk.TRUE, expand=gtk.TRUE)
        self.menubar.show()
 def buildMenuBar(self):
     menu_items = (
         ("/File", None, None, 0, "<Branch>"),
         ("/File/New", None, self.newMap, 0, None),
         ("/File/Open", None, self.openMap, 0, None),
         ("/File/Save", None, self.saveMap, 0, None),
     )
     accel_group = gtk.GtkAccelGroup()
     item_factory = gtk.GtkItemFactory(gtk.GtkMenuBar.get_type(), "<main>",
                                       accel_group)
     item_factory.create_items(menu_items)
     menubar = item_factory.get_widget("<main>")
     menubar.show()
     return menubar
Exemplo n.º 3
0
    def init_status_select(self):
        ag = gtk.GtkAccelGroup()
        self.itemsel = gtk.GtkItemFactory(gtk.GtkOptionMenu, "<select>", ag)
        self.add_accel_group(ag)

        self.itemsel.create_items([
            ('/Available', None, self.statusCB, 1, ''),
            ('/Unavailable', None, self.statusCB, 0, ''),
            ('/Custom', None, self.custstatusCB, 0, ''),
        ])

        self.status_select = self.itemsel.get_widget('<select>')
        self.tbox.pack_start(self.status_select,
                             fill=gtk.TRUE,
                             expand=gtk.TRUE)
        self.status_select.show()
    def __init__(self, object, event, canvas):
        items = (("/Bring to front", None, self.toFront, 0,
                  None), ("/Send to back", None, self.toBack, 0,
                          None), ("/Remove", None, self.remove, 0, None),
                 ("/Properties", None, self.properties, 0, None))

        # Would be nicer to create the menu only once and then show/hide the
        # same one for each object
        self.object = object
        self.canvas = canvas
        accel_group = gtk.GtkAccelGroup()
        item_factory = gtk.GtkItemFactory(gtk.GtkMenu.get_type(), "<main>",
                                          accel_group)
        item_factory.create_items(items)
        menu = item_factory.get_widget("<main>")
        menu.popup(None, None, None, event.button, event.time)
Exemplo n.º 5
0
 def __init__(self, type=MENU_FACTORY_MENU_BAR):
     """
     Initialize the menu factory
     """
     self.accelerator = gtk.GtkAccelGroup()
     if type == MENU_FACTORY_MENU_BAR:
         self.__w = gtk.GtkMenuBar()
         self.__ret = self.__w
     elif type == MENU_FACTORY_MENU:
         self.__w =gtk. GtkMenu()
         self.__w.set_accel_group(self.accelerator)
         self.__ret = self.__w
     elif type == MENU_FACTORY_OPTION_MENU:
         self.__w = gtk.GtkMenu()
         self.__w.set_accel_group(self.accelerator)
         self.__ret = gtk.GtkOptionMenu()
         self.__ret.set_menu(self.__w)
     self.__menus = {}
     self.__items = {}
Exemplo n.º 6
0
def create_main_window(*args):
    win = gtk.GtkWindow()
    gui["main_window"] = win

    win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE)
    win.set_title("Clarence " + version)
    win.set_usize(hive.get_integer("/window/width", default_win_width),
                  hive.get_integer("/window/height", default_win_height))

    win.connect("delete_event", gtk.mainquit)

    window_pos_mode(win)

    vbox1 = gtk.GtkVBox(spacing=5)
    win.add(vbox1)
    vbox1.show()

    ag = gtk.GtkAccelGroup()
    itemf = gtk.GtkItemFactory(gtk.GtkMenuBar, "<main>", ag)
    gui["main_window"].add_accel_group(ag)
    itemf.create_items([
        ('/_Misc', None, None, 0, '<Branch>'),
        ('/_Misc/_Clear', 'Escape', main_menu, 1, ''),
        ('/_Misc/sep1', None, None, 0, '<Separator>'),
        ('/_Misc/Pre_ferences', '<control>P', main_menu, 3, ''),
        ('/_Misc/sep1', None, None, 0, '<Separator>'),
        ('/_Misc/E_xit', '<alt>X', main_menu, 2, ''),
        ('/_Insert', None, None, 0, '<Branch>'),
        ('/_Insert/_Bin value', '<control>comma', insert_menu, 1, ''),
        ('/_Insert/_ASCII chars', '<control>period', insert_menu, 2, ''),
        ('/_Insert/_Last result', '<control>slash', insert_menu, 3, ''),
        ('/_Select', None, None, 0, '<Branch>'),
        ('/_Select/_Decimal field', '<control>1', select_menu, 1, ''),
        ('/_Select/_Hexadecimal field', '<control>2', select_menu, 2, ''),
        ('/_Select/_Octal field', '<control>3', select_menu, 3, ''),
        ('/_Select/_ASCII field', '<control>4', select_menu, 4, ''),
        ('/_Select/_Binary field', '<control>5', select_menu, 5, ''),
        ('/_Select/sep1', None, None, 0, '<Separator>'),
        ('/_Select/_Clear fields', '<control>0', select_menu, 6, ''),
        ('/_Help', None, None, 0, '<LastBranch>'),
        ('/_Help/Functions list', 'F1', functions_help_window, 1, ''),
        ('/_Help/sep1', None, None, 0, '<Separator>'),
        ('/_Help/_About', '<control>I', help_menu, 1, '')
    ])
    menubar = itemf.get_widget('<main>')
    if (gui["disable_menu"] == 0):
        vbox1.pack_start(menubar, expand=gtk.FALSE)
        menubar.show()

    vbox2 = gtk.GtkVBox(spacing=5)
    vbox1.pack_start(vbox2, expand=gtk.TRUE)
    vbox2.show()

    entry = gtk.GtkEntry()
    gui["main_entry"] = entry
    vbox2.pack_start(entry, expand=gtk.FALSE)
    vbox2.set_border_width(4)
    set_font(entry)
    if hive.get_bool("/remember_expression", default_remember_expression):
        entry.set_text(
            hive.get_string("/last_expression", default_last_expression))

    entry.connect("key_press_event", key_function)
    entry.grab_focus()
    gui["main_entry"].show()

    frame = gtk.GtkFrame()
    vbox2.pack_start(frame)
    frame.show()

    vbox3 = gtk.GtkVBox()
    frame.add(vbox3)
    vbox3.show()

    table = gtk.GtkTable(2, 5, gtk.FALSE)
    table.set_row_spacings(5)
    table.set_col_spacings(5)
    table.set_border_width(10)
    vbox3.pack_start(table)
    table.show()

    for y in range(5):
        label = gtk.GtkLabel(labels[y])
        set_font(label)
        label.show()
        table.attach(label, 0, 1, y, y + 1)
        entry = gtk.GtkEntry()
        gui[entries[y]] = entry
        entry.set_editable(gtk.FALSE)
        entry.set_usize(260, -2)
        set_font(entry)
        entry.show()
        table.attach(entry, 1, 2, y, y + 1)

    gui["main_window"].show()

    if hive.get_string("/remember_expression", default_remember_expression):
        result(hive.get_string("/last_expression", default_last_expression))
    else:
        result(0)