示例#1
0
 def __init__ (self, default=None, label="Select Option", sublabel=None, options=[], parent=None, expander=None, cancel=True):
     """Options can be a simple option or can be a tuple or a list
     where the first item is the label and the second the value"""
     ModalDialog.__init__(self, okay=True, label=label, sublabel=sublabel, parent=parent, expander=expander, cancel=cancel)
     self.menucb = self.get_option        
     self.optdic={}
     self.menu = gtk.Menu()
     # set the default value to the first item
     first = options[0]
     if type(first)==type(""): self.ret=first
     else: self.ret=first[1]
     for o in options:
         if type(o)==type(""):
             l=o
             v=o
         else:
             l=o[0]
             v=o[1]
         i = gtk.MenuItem(l)
         i.connect('activate',self.menucb)
         i.show()
         self.optdic[i]=v
         self.menu.append(i)
     self.optionMenu=gtk.OptionMenu()
     self.vbox.pack_start(self.optionMenu,expand=False,fill=False)
     self.optionMenu.set_menu(self.menu)
     self.optionMenu.show()
     self.menu.show()
示例#2
0
    def __assemble_whole_or_substr_option_menu(self):

        table = (
            ("Substrings", MATCH_SUBSTRINGS),
            ("Whole Words", MATCH_WHOLE_WORDS),
        )

        menu = gtk.Menu()
        for name, code in table:
            mi = gtk.MenuItem(name)

            def set_cb(x, sbox, code):
                sbox.__match_whole_or_substr = code
                sbox.__changed()

            mi.connect("activate", set_cb, self, code)
            mi.show()
            menu.append(mi)

        opt = gtk.OptionMenu()
        opt.set_menu(menu)

        self.__match_whole_or_substr = MATCH_SUBSTRINGS

        return opt
    def createRaidLevelMenu(self, levels, reqlevel):
        leveloption = gtk.OptionMenu()
        leveloptionmenu = gtk.Menu()
        defindex = None
        i = 0
        for lev in levels:
            item = gtk.MenuItem(lev)
            item.set_data("level", lev)
            # XXX gtk bug, if you don't show then the menu will be larger
            # than the largest menu item
            item.show()
            leveloptionmenu.add(item)
            if reqlevel and lev == reqlevel:
                defindex = i
            if self.sparesb:
                item.connect("activate", self.raidlevelchangeCB, self.sparesb)
            i = i + 1

        leveloption.set_menu(leveloptionmenu)

        if defindex:
            leveloption.set_history(defindex)

        if reqlevel and reqlevel == "RAID0":
            self.sparesb.set_sensitive(0)

        return (leveloption, leveloptionmenu)
示例#4
0
    def __assemble_any_or_all_option_menu(self):

        table = (
            ("Any Word", MATCH_ANY_WORD),
            ("All Words", MATCH_ALL_WORDS),
        )

        menu = gtk.Menu()
        for name, code in table:
            mi = gtk.MenuItem(name)

            def set_cb(x, sbox, code):
                sbox.__match_any_or_all = code
                sbox.__changed()

            mi.connect("activate", set_cb, self, code)
            mi.show()
            menu.append(mi)

        opt = gtk.OptionMenu()
        opt.set_menu(menu)

        self.__match_any_or_all = MATCH_ANY_WORD

        return opt
示例#5
0
def make_option_menu(names, func=None):
    """
    Make an option menu with list of names in names.  Return value is
    a optMenu, itemDict tuple, where optMenu is the option menu and
    itemDict is a dictionary mapping menu items to labels.  Eg

    optmenu, menud = make_option_menu( ('Bill', 'Ted', 'Fred') )

    ...set up dialog ...
    if response==gtk.RESPONSE_OK:
       item = optmenu.get_menu().get_active()
       print menud[item]  # this is the selected name


    if func is not None, call func with label when selected
    """
    optmenu = gtk.OptionMenu()
    optmenu.show()
    menu = gtk.Menu()
    menu.show()
    d = {}
    for label in names:
        if not is_string_like(label): continue
        item = gtk.MenuItem(label)
        menu.append(item)
        item.show()
        d[item] = label
        if func is not None:
            item.connect("activate", func, label)
    optmenu.set_menu(menu)
    return optmenu, d
示例#6
0
    def __assemble_status_option(self):

        def uninstalled_cb():
            return ("installed", "is", "false")

        def installed_cb():
            return ("installed", "is", "true")

        def all_cb():
            return None

        status_types = (
            (_("All Bundles"),          all_cb),
            (_("Uninstalled Bundles"),  uninstalled_cb),
            (_("Installed Bundles"),    installed_cb),
            )


        menu = gtk.Menu()
        for name, filter_fn in status_types:
            mi = gtk.MenuItem(name)
            def set_cb(x, sbox, fn):
                sbox.__status_filter = fn
                sbox.__changed()
            mi.connect("activate", set_cb, self, filter_fn)
            mi.show()
            menu.append(mi)
        menu.show()

        opt = gtk.OptionMenu()
        opt.set_menu(menu)

        self.__status_filter = all_cb

        return opt
    def createDefaultLangMenu(self, supported):
        if self.deflang_optionmenu is None:
            self.deflang_optionmenu = gtk.OptionMenu()

        if self.deflang_menu is not None:
            self.deflang_optionmenu.remove_menu()

        self.deflang_menu = gtk.Menu()

        sel = None
        curidx = 0
        values = []
        for locale in self.languages:
            if locale == self.defaultLang or (locale in supported):
                item = gtk.MenuItem(locale)
                item.show()
                self.deflang_menu.add(item)

                if locale == self.defaultLang:
                    sel = curidx
                else:
                    curidx = curidx + 1

                values.append(locale)

        self.deflang_optionmenu.set_menu(self.deflang_menu)

        if sel is not None:
            self.deflang_optionmenu.set_history(sel)

        self.deflang_values = values
示例#8
0
    def createPEOptionMenu(self, default=4096):
        peOption = gtk.OptionMenu()
        peOptionMenu = gtk.Menu()

        idx = 0
        defindex = None
        actualPE = lvm.getPossiblePhysicalExtents(floor=1024)
        for curpe in actualPE:
            # dont show PE over 64M
            if curpe > 65536:
                continue

            val = self.prettyFormatPESize(curpe)

            item = gtk.MenuItem(val)
            item.set_data("value", curpe)
            item.show()
            peOptionMenu.add(item)
            item.connect("activate", self.peChangeCB, peOption)

            if default == curpe:
                defindex = idx

            idx = idx + 1

        peOption.set_menu(peOptionMenu)
        peOption.set_data("lastpe", default)

        if defindex:
            peOption.set_history(defindex)

        peOption.set_data("lastidx", peOption.get_history())

        return (peOption, peOptionMenu)
示例#9
0
def openFileDialog(fullscreen=True, filetype='png'):
    '''Save file to file.'''
    pixbuf = getScrotPixbuf(fullscreen)
    dialog = gtk.FileChooserDialog(
                                   "Save..",
                                   None,
                                   gtk.FILE_CHOOSER_ACTION_SAVE,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                    gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))


    dialog.set_default_response(gtk.RESPONSE_ACCEPT)
    dialog.set_position(gtk.WIN_POS_CENTER)
    dialog.set_local_only(True)


    dialog.set_current_folder(os.environ['HOME'])
    dialog.set_current_name("%s%s.%s" % (DEFAULT_FILENAME, getFormatTime(), saveFiletype))




    optionMenu = gtk.OptionMenu()
    optionMenu.set_size_request(155, -1)
    menu = gtk.Menu()
    menu.set_size_request(155, -1)

    pngItem = makeMenuItem('PNG (*.png)',
                 lambda item, data: setSaveFiletype(dialog, 'png'))

    jpgItem = makeMenuItem('JPEG (*.jpeg)',
                 lambda item, data: setSaveFiletype(dialog, 'jpeg'))

    bmpItem = makeMenuItem('BMP (*.bmp)',
                 lambda item, data: setSaveFiletype(dialog, 'bmp'))




    menu.append(pngItem)
    menu.append(jpgItem)
    menu.append(bmpItem)
    optionMenu.set_menu(menu)


    hbox = gtk.HBox()
    hbox.pack_end(optionMenu, False, False)
    dialog.vbox.pack_start(hbox, False, False)
    hbox.show_all()

    response = dialog.run()

    if response == gtk.RESPONSE_ACCEPT:
        filename = dialog.get_filename()
        pixbuf.save(filename, filetype)
        print "Save snapshot to %s" % (filename)
    elif response == gtk.RESPONSE_REJECT:
        print 'Closed, no files selected'
    dialog.destroy()
示例#10
0
    def createDropDownList(self, ListNames):
        opt = gtk.OptionMenu()
        menu = gtk.Menu()

        for name in ListNames:
            item = gtk.MenuItem(name)
            item.show()
            menu.append(item)
        opt.set_menu(menu)
        opt.show()
        return opt
示例#11
0
    def __assemble_section_option(self):

        section_table = (
            (_("All Sections"), None, -1),
            (_("Productivity"), "office", 0),
            (_("Imaging"), "imaging", 1),
            (_("Personal Info. Mgmt"), "pim", 2),
            (_("X Windows"), "xapp", 3),
            (_("Games"), "game", 4),
            (_("Multimedia"), "multimedia", 5),
            (_("Internet"), "internet", 6),
            (_("Utilities"), "util", 7),
            (_("System"), "system", 8),
            (_("Documentation"), "doc", 9),
            (_("Libraries"), "library", 10),
            (_("Development"), "devel", 11),
            (_("Development Tools"), "develutil", 12),
            (_("Miscellaneous"), "misc", 13),
        )

        menu = gtk.Menu()
        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        for name, icon, code in section_table:
            hbox = gtk.HBox(0, 0)

            if icon:
                icon = "section-" + icon
                img = red_pixbuf.get_widget(icon, width=width, height=height)
                hbox.pack_start(img, expand=0, fill=0, padding=0)

            label = gtk.Label(name)
            hbox.pack_start(label, expand=0, fill=0, padding=4)

            mi = gtk.MenuItem()

            def set_cb(x, sbox, code):
                sbox.__match_section = code
                self.__changed()

            mi.connect("activate", set_cb, self, code)
            mi.add(hbox)
            mi.show_all()

            menu.append(mi)

        opt = gtk.OptionMenu()
        opt.set_menu(menu)

        self.__match_section = -1

        return opt
示例#12
0
    def create_res_optionmenu(self):
        if self.res_optionmenu is None:
            self.res_optionmenu = gtk.OptionMenu()

        if self.res_menu is not None:
            self.res_optionmenu.remove_menu()

        self.res_menu = gtk.Menu()

        for r in self.avail_res:
            item = gtk.MenuItem(r)
            item.show()
            self.res_menu.add(item)

        self.res_optionmenu.set_menu(self.res_menu)
示例#13
0
def create_option_menu(items):
    try:
        _throwback()
        widget = gtk.combo_box_new_text()
        for item in items:
            widget.append_text(item)

    except Exception, exn:
        widget = gtk.OptionMenu()
        widget.item_list = items  # for get_selected_value
        menu = gtk.Menu()
        for item in items:
            mi = gtk.MenuItem(item)
            menu.append(mi)
        widget.set_menu(menu)
def createFSTypeMenu(fstype, fstypechangeCB, mountCombo,
                     availablefstypes = None, ignorefs = None):
    fstypeoption = gtk.OptionMenu()
    fstypeoptionMenu = gtk.Menu()
    types = fileSystemTypeGetTypes()
    if availablefstypes:
        names = availablefstypes
    else:
        names = types.keys()
    if fstype and fstype.isSupported() and fstype.isFormattable():
        default = fstype
    else:
        default = fileSystemTypeGetDefault()
        
    names.sort()
    defindex = None
    i = 0
    for name in names:
        if not fileSystemTypeGet(name).isSupported():
            continue

        if ignorefs and name in ignorefs:
            continue
        
        if fileSystemTypeGet(name).isFormattable():
            item = gtk.MenuItem(name)
            item.set_data("type", types[name])
            # XXX gtk bug, if you don't show then the menu will be larger
            # than the largest menu item
            item.show()
            fstypeoptionMenu.add(item)
            if default and default.getName() == name:
                defindex = i
                defismountable = types[name].isMountable()
            if fstypechangeCB and mountCombo:
                item.connect("activate", fstypechangeCB, mountCombo)
            i = i + 1

    fstypeoption.set_menu(fstypeoptionMenu)

    if defindex:
        fstypeoption.set_history(defindex)

    if mountCombo:
        mountCombo.set_data("prevmountable",
                            fstypeoptionMenu.get_active().get_data("type").isMountable())

    return (fstypeoption, fstypeoptionMenu)
示例#15
0
    def _create_toolitems_2_2(self):
        # use the GTK+ 2.2 (and lower) GtkToolbar API
        iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR

        for text, tooltip_text, image, callback, callback_arg, scroll \
                in self.toolitems:
            if text is None:
                self.append_space()
                continue
            item = self.append_item(text, tooltip_text, 'Private',
                                    gtk.image_new_from_stock(image, iconSize),
                                    getattr(self, callback), callback_arg)
            if scroll:
                item.connect("scroll_event", getattr(self, callback))

        self.omenu = gtk.OptionMenu()
        self.omenu.set_border_width(3)
        self.insert_widget(self.omenu, 'Select axes that controls affect',
                           'Private', 0)
示例#16
0
    def set_table(self, dict):
        l = len(dict)
        table = self.editTree.get_widget("argumentTable")
        for c in table.get_children():
            table.remove(c)
        table.resize(2, l)
        self.entryWidgets = []
        x = 0
        for name, value in dict.items():
            label = gtk.Label(name)
            label.set_alignment(1.0, 0.5)
            label.show()
            table.attach(label, 0, 1, x, x + 1, xoptions=FILL, yoptions=0)
            curval = value[0]
            value = value[1]

            if callable(value):
                value = value(dict)
            if type(value) == type([]):
                entry = gtk.OptionMenu()
                menu = gtk.Menu()
                menu.connect("selection-done", self.update_and_redraw, None)
                count = 0
                current = 0
                for v in value:
                    if v == curval:
                        current = count
                    i = gtk.MenuItem(v)
                    menu.append(i)
                    count = count + 1
                menu.show_all()
                entry.set_menu(menu)
                entry.set_history(current)
            if type(value) == type(''):
                entry = gtk.Entry()
                entry.set_text(curval)
            entry.show_all()
            align = gtk.Alignment(0.0, 0.5, 0.0, 0.0)
            align.add(entry)
            align.show()
            self.entryWidgets.append((name, entry))
            table.attach(align, 1, 2, x, x + 1, xoptions=FILL, yoptions=0)
            x = x + 1
示例#17
0
 def __getOptionMenu(widgets, key, val, entries):
     _widget = widgets.get(key)
     if _widget is None:
         _widget = gtk.OptionMenu()
         _menu = gtk.Menu()
     else:
         _menu = _widget.getMenu()
         for _child in _menu.get_children():
             _menu.remove(_child)
     _idx = 0
     for _i in range(len(entries)):
         _val = entries[_i]
         if _val == val:
             _idx = _i
         _item = gtk.MenuItem(_name)
         _menu.append(_item)
     _widget.set_menu(_menu)
     _widget.set_history(_idx)
     return _widget
示例#18
0
    def __assemble_status_option(self):
        def uninstalled_cb(p):
            return not p["installed"] and not p["name_installed"]

        def update_cb(p):
            return p["name_installed"] > 0 and not p["installed"]

        def installed_cb(p):
            return p["installed"] or p["name_installed"]

        def all_cb(p):
            return 1

        status_types = (
            (_("All Packages"), all_cb),
            (_("Updates"), update_cb),
            (_("Uninstalled Packages"), uninstalled_cb),
            (_("Installed Packages"), installed_cb),
        )

        menu = gtk.Menu()
        for name, filter_fn in status_types:
            mi = gtk.MenuItem(name)

            def set_cb(x, sbox, fn):
                sbox.__status_filter = fn
                sbox.__changed()

            mi.connect("activate", set_cb, self, filter_fn)
            mi.show()
            menu.append(mi)
        menu.show()

        opt = gtk.OptionMenu()
        opt.set_menu(menu)

        self.__status_filter = all_cb

        return opt
示例#19
0
    def createRaidMinorMenu(self, minors, reqminor):
        minoroption = gtk.OptionMenu()
        minoroptionmenu = gtk.Menu()
        defindex = None
        i = 0
        for minor in minors:
            item = gtk.MenuItem("md%d" % (minor, ))
            item.set_data("minor", minor)
            # XXX gtk bug, if you don't show then the menu will be larger
            # than the largest menu item
            item.show()
            minoroptionmenu.add(item)
            if reqminor and minor == reqminor:
                defindex = i
            i = i + 1

        minoroption.set_menu(minoroptionmenu)

        if defindex:
            minoroption.set_history(defindex)

        return (minoroption, minoroptionmenu)
示例#20
0
    def __init__(self, songs):
        self.songs = songs
        gtk.FileChooserDialog.__init__(self, _("Export playlist"), None,
                                       gtk.FILE_CHOOSER_ACTION_SAVE,
                                       (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_SAVE, gtk.RESPONSE_OK))

        self.set_modal(True)
        self.set_current_name("playlist.m3u")
        self.set_current_folder(os.path.expanduser("~/"))

        option_menu = gtk.OptionMenu()
        option_menu.set_size_request(155, -1)
        self.menu = gtk.Menu()
        self.menu.set_size_request(155, -1)
        self.make_menu_item("M3U (*.m3u)", "m3u")
        self.make_menu_item("pls (*.pls)", "pls")
        self.make_menu_item("xspf (*.xspf)", "xspf")
        option_menu.set_menu(self.menu)
        hbox = gtk.HBox()
        hbox.pack_end(option_menu, False, False)
        self.vbox.pack_start(hbox, False, False)
        hbox.show_all()
示例#21
0
    def __init__(self):
        # Standard window-creating stuff
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", lambda w: gtk.main_quit())
        self.window.set_title("range controls")

        box1 = gtk.VBox(False, 0)
        self.window.add(box1)
        box1.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        # value, lower, upper, step_increment, page_increment, page_size
        # Note that the page_size value only makes a difference for
        # scrollbar widgets, and the highest value you'll get is actually
        # (upper - page_size).
        adj1 = gtk.Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0)

        self.vscale = gtk.VScale(adj1)
        scale_set_default_values(self.vscale)
        box2.pack_start(self.vscale, True, True, 0)
        self.vscale.show()

        box3 = gtk.VBox(False, 10)
        box2.pack_start(box3, True, True, 0)
        box3.show()

        # Reuse the same adjustment
        self.hscale = gtk.HScale(adj1)
        self.hscale.set_size_request(200, 30)
        scale_set_default_values(self.hscale)
        box3.pack_start(self.hscale, True, True, 0)
        self.hscale.show()

        # Reuse the same adjustment again
        scrollbar = gtk.HScrollbar(adj1)
        # Notice how this causes the scales to always be updated
        # continuously when the scrollbar is moved
        scrollbar.set_update_policy(gtk.UPDATE_CONTINUOUS)
        box3.pack_start(scrollbar, True, True, 0)
        scrollbar.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        # A checkbutton to control whether the value is displayed or not
        button = gtk.CheckButton("Display value on scale widgets")
        button.set_active(True)
        button.connect("toggled", self.cb_draw_value)
        box2.pack_start(button, True, True, 0)
        button.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)

        # An option menu to change the position of the value
        label = gtk.Label("Scale Value Position:")
        box2.pack_start(label, False, False, 0)
        label.show()

        opt = gtk.OptionMenu()
        menu = gtk.Menu()

        item = make_menu_item("Top", self.cb_pos_menu_select, gtk.POS_TOP)
        menu.append(item)

        item = make_menu_item("Bottom", self.cb_pos_menu_select,
                              gtk.POS_BOTTOM)
        menu.append(item)

        item = make_menu_item("Left", self.cb_pos_menu_select, gtk.POS_LEFT)
        menu.append(item)

        item = make_menu_item("Right", self.cb_pos_menu_select, gtk.POS_RIGHT)
        menu.append(item)

        opt.set_menu(menu)
        box2.pack_start(opt, True, True, 0)
        opt.show()

        box1.pack_start(box2, True, True, 0)
        box2.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)

        # Yet another option menu, this time for the update policy of the
        # scale widgets
        label = gtk.Label("Scale Update Policy:")
        box2.pack_start(label, False, False, 0)
        label.show()

        opt = gtk.OptionMenu()
        menu = gtk.Menu()

        item = make_menu_item("Continuous", self.cb_update_menu_select,
                              gtk.UPDATE_CONTINUOUS)
        menu.append(item)

        item = make_menu_item("Discontinuous", self.cb_update_menu_select,
                              gtk.UPDATE_DISCONTINUOUS)
        menu.append(item)

        item = make_menu_item("Delayed", self.cb_update_menu_select,
                              gtk.UPDATE_DELAYED)
        menu.append(item)

        opt.set_menu(menu)
        box2.pack_start(opt, True, True, 0)
        opt.show()

        box1.pack_start(box2, True, True, 0)
        box2.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)

        # An HScale widget for adjusting the number of digits on the
        # sample scales.
        label = gtk.Label("Scale Digits:")
        box2.pack_start(label, False, False, 0)
        label.show()

        adj2 = gtk.Adjustment(1.0, 0.0, 5.0, 1.0, 1.0, 0.0)
        adj2.connect("value_changed", self.cb_digits_scale)
        scale = gtk.HScale(adj2)
        scale.set_digits(0)
        box2.pack_start(scale, True, True, 0)
        scale.show()

        box1.pack_start(box2, True, True, 0)
        box2.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)

        # And, one last HScale widget for adjusting the page size of the
        # scrollbar.
        label = gtk.Label("Scrollbar Page Size:")
        box2.pack_start(label, False, False, 0)
        label.show()

        adj2 = gtk.Adjustment(1.0, 1.0, 101.0, 1.0, 1.0, 0.0)
        adj2.connect("value_changed", self.cb_page_size, adj1)
        scale = gtk.HScale(adj2)
        scale.set_digits(0)
        box2.pack_start(scale, True, True, 0)
        scale.show()

        box1.pack_start(box2, True, True, 0)
        box2.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, False, True, 0)
        separator.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, False, True, 0)
        box2.show()

        button = gtk.Button("Quit")
        button.connect("clicked", lambda w: gtk.main_quit())
        box2.pack_start(button, True, True, 0)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()
        self.window.show()
示例#22
0
            radio_controller.set_size_request(widget.width,widget.height)
            self.fixed.put(radio_controller,widget.position_X[0], widget.position_Y[0])
            radio_controller.show()
            widget.controller.append(radio_controller)
            for i in range(1,len(widget.labels)):
                radio_controller = gtk.RadioButton(widget.controller[0], widget.labels[i])
                radio_controller.set_size_request(widget.width,widget.height)
                self.fixed.put(radio_controller,widget.position_X[i], widget.position_Y[i])
                radio_controller.show()
                widget.controller.append(radio_controller)
            
            if(widget.selected_pos != None):
                widget.controller[widget.selected_pos].set_active(True)
            
        elif(widget_type==ValueList):
            widget.controller = gtk.OptionMenu()
            widget.controller.set_size_request(widget.width,widget.height)
            menu = gtk.Menu()
            for name in widget.choices:
                item = gtk.MenuItem(name)
                item.show()
                menu.append(item)
                print "gis"
            widget.controller.set_menu(menu)
            widget.controller.show()
            self.fixed.put(widget.controller,widget.position_X, widget.position_Y)
            

class Button(gtk.Button):
    controller = None
    callbackMethod = None
示例#23
0
def print_dialog(gtkimage, plot):
    _window = gtkimage.getWindow()
    _dialog = gtk.Dialog(
        _('Printing Preferences'), _window,
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
    _vbox = _dialog.vbox
    #
    _psplot = PSPlot(plot)
    #
    # options for all plots
    #
    _frame = gtk.Frame(_('Plot Options'))
    _fvbox = gtk.VBox(False, 5)
    _fvbox.set_border_width(5)
    _frame.add(_fvbox)
    _ccb = gtk.CheckButton(_('Print in Color'))
    _fvbox.pack_start(_ccb, False, False, 5)
    _icb = gtk.CheckButton(_('Print White as Black'))
    _fvbox.pack_start(_icb, False, False, 5)
    _lcb = gtk.CheckButton(_('Print in Landscape Mode'))
    _fvbox.pack_start(_lcb, False, False, 5)
    _hbox = gtk.HBox(False, 5)
    _fvbox.pack_start(_hbox, True, True, 5)
    _label = gtk.Label(_('Paper Size:'))
    _hbox.pack_start(_label, False, False, 5)
    _papersizes = _psplot.getPaperSizes()
    _papersizes.sort()
    if hasattr(gtk, 'ComboBox'):  # PyGTK 2.4
        _size_widget = gtk.combo_box_new_text()
        for _size in _papersizes:
            _size_widget.append_text(_size)
        _size_widget.set_active(0)  # perhaps a global preferences value?
    else:
        _menu = gtk.Menu()
        for _size in _papersizes:
            _item = gtk.MenuItem(_size)
            _menu.append(_item)
        _size_widget = gtk.OptionMenu()
        _size_widget.set_menu(_menu)
        _size_widget.set_history(0)  # perhaps a global preference value?
    _hbox.pack_start(_size_widget, False, False, 5)
    _vbox.pack_start(_frame, False, False, 5)
    #
    #
    _label_size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
    _frame = gtk.Frame(_('Print Destination'))
    _fvbox = gtk.VBox(False, 5)
    _fvbox.set_border_width(5)
    _frame.add(_fvbox)
    #
    _phbox = gtk.HBox(False, 5)
    _label = gtk.Label(_('Printer:'))
    _label_size_group.add_widget(_label)
    _phbox.pack_start(_label, False, False, 5)
    _print_entry = gtk.Entry()
    _print_entry.set_text("lp")
    _phbox.pack_start(_print_entry, False, False, 5)
    _fvbox.pack_start(_phbox, False, False, 5)
    #
    _fhbox = gtk.HBox(False, 5)
    _label = gtk.Label(_('File:'))
    _label_size_group.add_widget(_label)
    _label.set_sensitive(False)
    _fhbox.pack_start(_label, False, False, 5)
    _file_entry = gtk.Entry()
    _file_entry.set_sensitive(False)
    _fhbox.pack_start(_file_entry, False, False, 5)
    _fvbox.pack_start(_fhbox, False, False, 5)
    #
    _hbox = gtk.HBox(False, 5)
    _label = gtk.Label(_('Send print to ...'))
    _label_size_group.add_widget(_label)
    _hbox.pack_start(_label, False, False, 5)
    _prb = gtk.RadioButton()
    _prb.set_label(_('Printer'))
    _prb.set_mode(True)
    _prb.connect("toggled", _print_rb_cb, _phbox)
    _hbox.pack_start(_prb, False, False, 5)
    _frb = gtk.RadioButton(_prb)
    _frb.set_label(_('File'))
    _frb.set_mode(True)
    _frb.connect("toggled", _print_rb_cb, _fhbox)
    _hbox.pack_start(_frb, False, False, 5)
    _fvbox.pack_start(_hbox, False, False, 5)
    #
    _vbox.pack_start(_frame, False, False, 5)
    _dialog.show_all()
    while True:
        _response = _dialog.run()
        if _response == gtk.RESPONSE_OK:
            plot.setColorMode(_ccb.get_active())
            plot.invertWhite(_icb.get_active())
            plot.setLandscapeMode(_lcb.get_active())
            plot.getPlotData()
            if hasattr(gtk, 'ComboBox') and isinstance(_size_widget,
                                                       gtk.ComboBox):
                _idx = _size_widget.get_active()
            elif isinstance(_size_widget, gtk.OptionMenu):
                _idx = _sizewidget.get_history()
            else:
                raise TypeError, "Unexpected size_widget: " + ` type(
                    _size_widget) `
            _psplot.setSize(_papersizes[_idx])
            if _prb.get_active():  # send job out
                try:
                    _f = tempfile.NamedTemporaryFile()
                    _fname = _f.name
                    try:
                        try:
                            _psplot.write(_f)
                            _cmd = "%s %s" % (_print_entry.get_text(), _fname)
                            try:
                                _res = os.system(_cmd)
                                if _res == 0:
                                    break
                                else:
                                    _msg = "Non-zero exit status from '%s': %d" % (
                                        _cmd, _res)
                                    _error_dialog(gtkimage, _msg)
                            except StandardError, _err:
                                _msg = "Error executing command '%s': %s" % (
                                    _cmd, _err)
                                _error_dialog(gtkimage, _msg)
                        except StandardError, _err:
                            _msg = "Error writing '%s': %s" % (_fname, _err)
                            _error_dialog(gtkimage, _msg)
                    finally:
                        _f.close()
                except StandardError, _err:
                    _msg = "Error creating temporary file %s" % _err
                    _error_dialog(gtkimage, _msg)
            else:
                _fname = _file_entry.get_text()
                try:
                    _f = file(_fname, "w")
                    try:
                        _psplot.write(_f)
                    finally:
                        _f.close()
                        break
                except StandardError, _err:
                    _msg = "Error writing to %s: %s" % (_fname, _err)
                    _error_dialog(gtkimage, _msg)
示例#24
0
    def addWidget(self, widget):
        widget_type = type(widget)
        if (widget_type == Button or isinstance(widget, Button)):
            widget.controller = gtk.Button(widget.text)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()
            if (widget.callbackMethod != None):
                widget.controller.connect('clicked', widget.callbackMethod)

        elif (widget_type == TextBuffer or isinstance(widget, TextBuffer)):
            widget.controller = gtk.TextView(widget.buffer)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()
            if (widget.callbackMethod != None):
                widget.controller.connect('clicked', widget.callbackMethod)

        elif (widget_type == CheckBox or isinstance(widget, CheckBox)):
            widget.controller = gtk.CheckButton(widget.title)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()
            widget.controller.set_active(widget.value)

        elif (widget_type == RadioButton or isinstance(widget, RadioButton)):
            widget.controller = []
            radio_controller = gtk.RadioButton(None, widget.labels[0])
            radio_controller.set_size_request(widget.width, widget.height)
            self.fixed.put(radio_controller, widget.position_X[0],
                           widget.position_Y[0])
            radio_controller.show()
            widget.controller.append(radio_controller)
            for i in range(1, len(widget.labels)):
                radio_controller = gtk.RadioButton(widget.controller[0],
                                                   widget.labels[i])
                radio_controller.set_size_request(widget.width, widget.height)
                self.fixed.put(radio_controller, widget.position_X[i],
                               widget.position_Y[i])
                radio_controller.show()
                widget.controller.append(radio_controller)

            if (widget.selected_pos != None):
                widget.controller[widget.selected_pos].set_active(True)

        elif (widget_type == List or isinstance(widget, List)):
            widget.controller = gtk.OptionMenu()
            widget.controller.set_size_request(widget.width, widget.height)
            menu = gtk.Menu()
            for name in widget.choices:
                item = gtk.MenuItem(name)
                item.show()
                menu.append(item)
            widget.controller.set_menu(menu)
            widget.controller.show()
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)

        elif (widget_type == TextArea or isinstance(widget, TextArea)):
            widget.controller = gtk.Entry()
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.set_text(widget.title)
            widget.controller.show()

        elif (widget_type == PasswordField
              or isinstance(widget, PasswordField)):
            widget.controller = gtk.Entry()
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.set_text(widget.title)
            widget.controller.set_visibility(gtk.FALSE)
            widget.controller.show()

        elif (widget_type == ShowText or isinstance(widget, ShowText)):
            widget.controller = gtk.Label(widget.text)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.controller, widget.position_X,
                           widget.position_Y)
            widget.controller.show()

        elif (widget_type == "Slider" or isinstance(widget, Slider)):
            adj1 = gtk.Adjustment(0.0, widget.start, widget.end, 0.1, 1.0, 1.0)
            widget.instance = gtk.HScale(adj1)
            widget.instance.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.instance, widget.position_X,
                           widget.position_Y)
            widget.instance.show()

        elif (widget_type == "SpinBox" or isinstance(widget, SpinBox)):
            adj = gtk.Adjustment(0.0, widget.start, widget.end, 0.1, 0.1, 0.0)
            widget.instance = gtk.SpinButton(adj, 0.1, 1)
            widget.instance.set_size_request(widget.width, widget.height)
            self.fixed.put(widget.instance, widget.position_X,
                           widget.position_Y)
            widget.instance.show()
示例#25
0
        global r

        print "selection -> ", r.getCurrent()

        gtk.mainquit()

    win = gtk.Window()
    win.connect('destroy', nowquit)

    if 0:
        opts = ['Red Hat 8.0 - /dev/hda1', 'Red Hat 7.1 - /dev/hda5']
    else:
        opts = ['Red Hat 8.0 - /dev/hda1']

    label = _("The following installed system will be upgraded:")
    upgradeoption = gtk.OptionMenu()
    upgradeoptionmenu = gtk.Menu()
    for lev in opts:
        item = gtk.MenuItem(lev)
        item.show()
        upgradeoptionmenu.add(item)

    upboxtmp = gtk.VBox(gtk.FALSE, 5)
    l = gtk.Label(label)
    l.set_alignment(0.0, 0.0)
    upboxtmp.pack_start(l)
    upboxtmp.pack_start(upgradeoption)
    upgradeoption.set_menu(upgradeoptionmenu)

    upgradeoption.set_sensitive(0)
示例#26
0
def textstyle_dialog(gtkimage, textstyles):
    _window = gtkimage.getWindow()
    _dialog = gtk.Dialog(
        _('TextStyle Settings'), _window,
        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
        (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
    _image = gtkimage.getImage()
    _ts = _image.getOption('TEXT_STYLE')
    _hbox = gtk.HBox(False, 5)
    _hbox.set_border_width(5)
    _label = gtk.Label(_('Active TextStyle:'))
    _hbox.pack_start(_label, False, False, 5)
    _idx = 0
    if hasattr(gtk, 'ComboBox'):
        _widget = gtk.combo_box_new_text()
        for _i in range(len(textstyles)):
            _textstyle = textstyles[_i]
            if (_ts is _textstyle or _ts == _textstyle):
                _idx = _i
            _widget.append_text(_textstyle.getName())
        _widget.set_active(_idx)
    else:
        _menu = gtk.Menu()
        for _i in range(len(textstyles)):
            _textstyle = textstyles[_i]
            if (_ts is _textstyle or _ts == _textstyle):
                _idx = _i
            _item = gtk.MenuItem(_textstyle.getName())
            _menu.append(_item)
        _widget = gtk.OptionMenu()
        _widget.set_menu(_menu)
        _widget.set_history(_idx)

    _hbox.pack_start(_widget, False, False, 0)
    _dialog.vbox.pack_start(_hbox, True, True)
    #
    _gts = GtkTextStyle(_window)
    for _textstyle in textstyles:
        _gts.addTextStyle(_textstyle)
    _gts.setTextStyle(_ts)
    _gts.setImageSettings(_image)
    _fill_dialog(_dialog.vbox, _gts)
    _widget.connect('changed', _widget_changed, _gts)
    _dialog.show_all()
    _response = _dialog.run()
    if _response == gtk.RESPONSE_OK:
        _nts = _gts.getTextStyle()
        if _nts != _ts:
            _image.setOption('TEXT_STYLE', _nts)
        for _opt, _val in _gts.getValues():
            if _opt == 'FONT_FAMILY':
                if _val != _image.getOption(_opt):
                    _image.setOption(_opt, _val)
            elif _opt == 'FONT_STYLE':
                if _val != _image.getOption(_opt):
                    _image.setOption(_opt, _val)
            elif _opt == 'FONT_WEIGHT':
                if _val != _image.getOption(_opt):
                    _image.setOption(_opt, _val)
            elif _opt == 'FONT_COLOR':
                if _val != _image.getOption(_opt).getColors():
                    _r, _g, _b = _val
                    _image.setOption(_opt, color.Color(_r, _g, _b))
            elif _opt == 'TEXT_SIZE':
                if abs(_val - _image.getOption(_opt)) > 1e-10:
                    _image.setOption(_opt, _val)
            elif _opt == 'TEXT_ANGLE':
                if abs(_val - _image.getOption(_opt)) > 1e-10:
                    _image.setOption(_opt, _val)
            elif _opt == 'TEXT_ALIGNMENT':
                if _val != _image.getOption(_opt):
                    _image.setOption(_opt, _val)
            else:
                raise RuntimeError, "Unexpected TextStyle option '%s'" % _opt
    _gts.clear()
    _dialog.destroy()
示例#27
0
    def getScreen(self, xsetup, monitor, videocard, desktop, grpset, instClass,
                  instPath):

        self.xsetup = xsetup
        self.monitor = monitor
        self.videocard = videocard
        self.desktop = desktop
        self.instClass = instClass

        # dont do anything on ppc - we want to use default fb setting
        if iutil.getArch() != "ppc":
            if not xsetup.imposed_sane_default:
                xsetup.xhwstate.choose_sane_default()
                xsetup.imposed_sane_default = 1

# save so we can restore if necessary going back
        self.origres = self.xsetup.xhwstate.get_resolution()
        self.origdepth = self.xsetup.xhwstate.get_colordepth()

        self.instPath = instPath

        # create toplevel packing structure
        self.box = gtk.VBox(gtk.FALSE)
        self.box.set_border_width(5)

        # hbox and alignment used for monitor preview area
        # list of pixmaps for monitor preview
        self.monitor_pixmaps = None
        self.hbox = gtk.HBox(gtk.FALSE, 5)
        self.monitor_align = None
        self.desktop_align = None
        self.load_monitor_preview_pixmap("monitor.png")
        self.box.pack_start(self.hbox)

        hbox1 = gtk.HBox(gtk.FALSE, 5)
        hbox3 = gtk.HBox(gtk.FALSE, 5)
        hbox4 = gtk.HBox(gtk.FALSE, 5)

        frame1 = gtk.Frame(_("_Color Depth:"))
        frame1.get_label_widget().set_property("use-underline", gtk.TRUE)
        frame1.set_shadow_type(gtk.SHADOW_NONE)
        frame1.set_border_width(10)
        hbox1.pack_start(frame1, gtk.TRUE, gtk.FALSE, 0)

        # determine video modes available for this card/monitor combo
        self.avail_depth = self.xsetup.xhwstate.available_color_depths()

        self.depth_list = [(_("256 Colors (8 Bit)")),
                           (_("High Color (16 Bit)")),
                           (_("True Color (24 Bit)"))]
        self.bit_depth = [8, 16, 24]

        # create option menu for bit depth
        self.depth_optionmenu = gtk.OptionMenu()
        self.depth_menu = gtk.Menu()

        for i in range(0, len(self.depth_list)):
            if self.bit_depth[i] in self.avail_depth:
                d = self.depth_list[i]
                item = gtk.MenuItem(d)
                item.show()
                self.depth_menu.add(item)

        self.depth_optionmenu.set_menu(self.depth_menu)

        frame1.add(self.depth_optionmenu)
        frame1.get_label_widget().set_mnemonic_widget(self.depth_optionmenu)

        # now we do screen resolution
        frame2 = gtk.Frame(_("_Screen Resolution:"))
        frame2.get_label_widget().set_property("use-underline", gtk.TRUE)
        frame2.set_shadow_type(gtk.SHADOW_NONE)
        frame2.set_border_width(10)
        hbox1.pack_start(frame2, gtk.TRUE, gtk.FALSE, 2)

        self.avail_res = self.xsetup.xhwstate.available_resolutions()

        self.res_optionmenu = None
        self.res_menu = None
        self.create_res_optionmenu()

        frame2.add(self.res_optionmenu)
        frame2.get_label_widget().set_mnemonic_widget(self.res_optionmenu)

        # apply current configuration to UI
        self.selectedDepth = self.xsetup.xhwstate.get_colordepth()
        self.selectedRes = self.xsetup.xhwstate.get_resolution()

        if self.selectedDepth not in self.avail_depth:
            self.selectedDepth = self.avail_depth[-1]

        idx = self.avail_depth.index(self.selectedDepth)
        self.depth_optionmenu.set_history(idx)

        if self.selectedRes not in self.avail_res:
            self.selectedRes = self.avail_res[-1]

        self.currentRes = self.avail_res.index(self.selectedRes)
        self.res_optionmenu.set_history(self.currentRes)
        self.swap_monitor(self.currentRes)

        self.depth_optionmenu.connect("changed", self.depth_cb)
        self.ignore_res_cb = 0
        self.res_optionmenu.connect("changed", self.res_cb)

        self.box.pack_start(hbox1, gtk.FALSE)

        #--If both KDE and GNOME are selected
        if grpset:
            gnomeSelected = (grpset.hdrlist.has_key('gnome-session')
                             and grpset.hdrlist['gnome-session'].isSelected())
            kdeSelected = (grpset.hdrlist.has_key('kdebase')
                           and grpset.hdrlist['kdebase'].isSelected())
        else:
            gnomeSelected = 0
            kdeSelected = 0

        self.newDesktop = ""
        self.origDesktop = self.desktop.getDefaultDesktop()

        if (ENABLE_DESKTOP_CHOICE) and (gnomeSelected or kdeSelected):
            hsep = gtk.HSeparator()
            self.box.pack_start(hsep)

            if gnomeSelected and kdeSelected:
                frame3 = gtk.Frame(
                    _("Please choose your default desktop environment:"))
            else:
                frame3 = gtk.Frame(_("Your desktop environment is:"))

            frame3.set_shadow_type(gtk.SHADOW_NONE)
            hbox3.pack_start(frame3, gtk.TRUE, gtk.FALSE, 2)

            self.hbox4 = gtk.HBox()
            frame3.add(self.hbox4)

            # need to have this around so self.display_desktop_pixmap()
            # will work later. (messy)
            self.vbox4 = gtk.VBox()

            if gnomeSelected and kdeSelected:
                vbox3 = gtk.VBox()

                gnome_radio = gtk.RadioButton(None, (_("GNO_ME")))
                vbox3.pack_start(gnome_radio, gtk.TRUE, gtk.FALSE, 2)
                kde_radio = gtk.RadioButton(gnome_radio, (_("_KDE")))
                vbox3.pack_start(kde_radio, gtk.TRUE, gtk.FALSE, 2)

                self.hbox4.pack_start(vbox3)

                self.hbox4.pack_start(self.vbox4)

                #--Set the desktop GUI widget to what the user has selected
                if self.origDesktop == "GNOME":
                    gnome_radio.set_active(gtk.TRUE)
                    self.display_desktop_pixmap("GNOME")
                elif self.origDesktop == "KDE":
                    kde_radio.set_active(gtk.TRUE)
                    self.display_desktop_pixmap("KDE")

                gnome_radio.connect("clicked", self.desktop_cb, "GNOME")
                kde_radio.connect("clicked", self.desktop_cb, "KDE")
            else:
                self.hbox4.pack_start(gtk.Label(self.origDesktop))
                self.display_desktop_pixmap(self.origDesktop)

            self.box.pack_start(hbox3, gtk.FALSE, gtk.TRUE, 2)
        else:
            gnome_radio = None
            kde_radio = None

        hsep = gtk.HSeparator()
        self.box.pack_start(hsep)

        # see if we should allow them to choose graphical or text login
        if self.instClass.showLoginChoice:
            frame4 = gtk.Frame(_("Please choose your login type:"))
            frame4.set_shadow_type(gtk.SHADOW_NONE)
            hbox4.pack_start(frame4, gtk.TRUE, gtk.FALSE, 2)

            self.hbox5 = gtk.HBox(gtk.TRUE, 2)
            frame4.add(self.hbox5)

            self.text = gtk.RadioButton(None, (_("_Text")))
            self.graphical = gtk.RadioButton(self.text, (_("_Graphical")))

            self.runLevel = self.desktop.getDefaultRunLevel()

            if self.runLevel == 3:
                self.text.set_active(gtk.TRUE)
            elif self.runLevel == 5:
                self.graphical.set_active(gtk.TRUE)

            self.hbox5.pack_start(self.graphical, gtk.FALSE, 2)
            self.hbox5.pack_start(self.text, gtk.FALSE, 2)

            self.box.pack_start(hbox4, gtk.FALSE, gtk.TRUE, 2)

        return self.box
示例#28
0
    def getScreen(self, dispatch, xsetup, videocard, intf):
        self.ics.setHelpEnabled(gtk.TRUE)

        self.dispatch = dispatch
        self.videocard = videocard
        self.xsetup = xsetup
        self.intf = intf

        self.lastvalidselection = None

        box = gtk.VBox(gtk.FALSE, 0)
        box.set_border_width(0)

        self.autoBox = gtk.VBox(gtk.FALSE, 5)

        self.force_ppc_fb = 0
        arch = iutil.getArch()
        # we can only probe video ram on i386
        # and we force frame buffer on ppc currently
        if arch == "ppc":
            label = makeFormattedLabel(
                _("Your system will be setup to "
                  "use the frame buffer driver for "
                  "the X Window System.  If you do "
                  "not want to setup the X Window "
                  "System, choose "
                  "'Skip X Configuration' below."))
            box.pack_start(label, gtk.FALSE, gtk.FALSE)
            self.force_ppc_fb = 1
        elif arch != "i386":
            label = makeFormattedLabel(
                _("Your video ram size can not be "
                  "autodetected.  Choose your video "
                  "ram size from the choices below:"))
            box.pack_start(label, gtk.FALSE)
        else:
            self.autoBox = gtk.VBox(gtk.FALSE, 5)

            label = makeFormattedLabel(
                _("In most cases, the video hardware "
                  "can be automatically detected. "
                  "If the detected settings are not "
                  "correct for the hardware, select "
                  "the right settings."))
            self.autoBox.pack_start(label, gtk.FALSE)

            box.pack_start(self.autoBox, gtk.FALSE)

# load in card database
        self.cards = self.videocard.cardsDB()
        cards = self.cards.keys()
        cards.sort()

        other_cards = copy.copy(cards)
        self.currentCard = None
        self.probedCard = None
        if self.videocard.primaryCard():
            carddata = self.videocard.primaryCard().getCardData(dontResolve=1)
            if carddata:
                self.currentCard = carddata["NAME"]
            else:
                self.currentCard = None

            carddata = self.videocard.primaryCard(useProbed=1).getCardData()
            if carddata:
                self.probedCard = carddata["NAME"]
            else:
                self.probedCard = None

# load images of videocard
        fn = self.ics.findPixmap("videocard.png")
        p = gtk.gdk.pixbuf_new_from_file(fn)
        if p:
            self.videocard_p, self.videocard_b = p.render_pixmap_and_mask()

        # Videocard selection tree - preset 'Generic' and 'Other' nodes
        self.cardstore = gtk.TreeStore(gobject.TYPE_STRING,
                                       gobject.TYPE_STRING)

        toplevels = {}

        # add "Generic" in before "Other" if supporting XFree86 3.x
        # Note other changes in videocard.py and elsewhere required to support
        # XFree86 3.x again
        manufacturers = ["Other"] + self.videocard.manufacturerDB()
        for man in manufacturers:
            toplevels[man] = self.cardstore.append(None)
            self.cardstore.set_value(toplevels[man], 0, man)

# now go through cards and matchup with manufacturers
        for card in cards:
            temp = string.lower(card)

            for man in manufacturers:
                if string.lower(man) == temp[:len(man)]:
                    parent = toplevels.get(man)
                    iter = self.cardstore.append(parent)
                    self.cardstore.set_value(iter, 0, card)
                    other_cards.remove(card)

        # now add cards not categorized into above manufacturers
        for card in other_cards:
            parent = toplevels.get("Other")
            iter = self.cardstore.append(parent)
            self.cardstore.set_value(iter, 0, card)

        self.cardview = gtk.TreeView(self.cardstore)
        self.cardview.set_property("headers-visible", gtk.FALSE)
        col = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=0)
        self.cardview.append_column(col)
        selection = self.cardview.get_selection()
        selection.connect("changed", self.selectCardType)
        selection.set_select_function(self.cardviewSelectCb)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(self.cardview)

        # only show this option on non-ppc
        if not self.force_ppc_fb:
            box.pack_start(sw, gtk.TRUE)

        #Memory configuration menu
        hbox = gtk.HBox()
        hbox.set_border_width(3)

        label = gui.MnemonicLabel(_("_Video card RAM: "))

        self.ramOption = gtk.OptionMenu()
        label.set_mnemonic_widget(self.ramOption)
        self.ramOption.set_size_request(40, 20)
        self.ramMenu = gtk.Menu()

        for mem in self.videocard.possible_ram_sizes():
            if mem < 1000:
                tag = "%d KB" % (mem)
            else:
                tag = "%d MB" % (mem / 1024)

            memitem = gtk.MenuItem(tag)
            self.ramMenu.add(memitem)

        hbox.pack_start(label, gtk.FALSE)
        hbox.pack_start(self.ramOption, gtk.TRUE, gtk.TRUE, 25)

        self.ramOption.set_menu(self.ramMenu)

        # only show this option on non-ppc
        if not self.force_ppc_fb:
            box.pack_start(hbox, gtk.FALSE)

        restore = gtk.Button(_("Restore _original values"))
        restore.connect("clicked", self.restorePressed)
        hbox.pack_start(restore, gtk.FALSE, 25)

        self.skip = gtk.CheckButton(_("_Skip X configuration"))
        self.skip.connect("toggled", self.skipToggled)

        hbox = gtk.HBox(gtk.TRUE, 5)

        self.topbox = gtk.VBox(gtk.FALSE, 5)
        self.topbox.set_border_width(5)
        if self.force_ppc_fb:
            # tweak packing
            self.topbox.pack_start(box, gtk.FALSE, gtk.FALSE)
            self.topbox.pack_start(self.skip, gtk.FALSE, gtk.FALSE)
        else:
            self.topbox.pack_start(box, gtk.TRUE, gtk.TRUE)
            self.topbox.pack_start(self.skip, gtk.FALSE)

        self.configbox = box

        self.skip.set_active(self.dispatch.stepInSkipList("monitor"))

        # set state
        self.ignoreEvents = 0
        self.currentMem = self.videocard.primaryCard(useProbed=0).getVideoRam()
        self.probedMem = self.videocard.primaryCard(useProbed=1).getVideoRam()
        self.setCurrent(self.currentCard, self.currentMem)

        setupTreeViewFixupIdleHandler(self.cardview, self.cardstore)

        return self.topbox
示例#29
0
    def __init__(self, diagram, data, props):
        import pygtk
        pygtk.require("2.0")
        import gtk

        self.diagram = diagram
        self.data = data
        self.props = props

        self.win = gtk.Window()
        self.win.connect("delete_event", self.on_delete)
        self.win.set_title("Group Properties")

        box1 = gtk.VBox()
        self.win.add(box1)
        box1.show()

        box2 = gtk.VBox(spacing=2)
        box2.set_border_width(10)
        box1.pack_start(box2)
        box2.show()

        self.checkboxes = []
        self.optionmenues = []
        table = gtk.Table(2, len(props), 0)
        table.set_row_spacings(2)
        table.set_col_spacings(5)
        table.set_border_width(5)
        y = 0
        for s in props.keys():
            w = gtk.CheckButton(s)
            self.checkboxes.append(w)
            table.attach(w, 0, 1, y, y + 1)
            w.show()
            menu = gtk.Menu()
            milist = None
            for opt in props[s].opts:
                #print opt
                menuitem = gtk.RadioMenuItem(milist, str(opt.value))
                milist = menuitem  # GSlist
                menu.append(menuitem)
                menuitem.show()
            menu.show()
            w = gtk.OptionMenu()
            w.set_menu(menu)
            self.optionmenues.append(w)
            table.attach(w, 1, 2, y, y + 1)
            w.show()
            y = y + 1
        else:
            w = gtk.Label(
                "The selected objects don't share any\n properties to change at once."
            )
            table.attach(w, 0, 1, y, y + 1)
            w.show()
        box2.pack_start(table)
        table.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, expand=0)
        separator.show()

        box2 = gtk.VBox(spacing=10)
        box2.set_border_width(10)
        box1.pack_start(box2, expand=0)
        box2.show()

        button = gtk.Button("Ok")
        button.connect("clicked", self.on_ok)
        box2.pack_start(button)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()
        self.win.show()
示例#30
0
    def Add(self, widget):
        widget_type = type(widget)
        if widget_type == gtk.Entry:
            self.fix.put(widget.entry, widget.posX, widget.posY)
            self.set_size_request(Length, Breadth)
            widget.entry.show()

        elif widget_type == Create_button:
            widget.controller = gtk.Button(widget.label)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fix.put(widget.controller, widget.posX, widget.posY)
            widget.controller.show()

        elif (widget_type == Check_box):
            self.fix.put(widget.button3, widget.posX, widget.posY)
            widget.button3.show()

        elif (widget_type == Drop_list):
            widget.controller = gtk.OptionMenu()
            widget.controller.set_size_request(widget.length, widget.width)
            menu = gtk.Menu()
            for name in widget.values:
                item = gtk.MenuItem(name)
                item.show()
                menu.append(item)
            widget.controller.set_menu(menu)
            self.fix.put(widget.controller, widget.posX, widget.posY)
            widget.controller.show()

        elif widget_type == Radio_button:
            widget.controller = []
            radio_controller = gtk.RadioButton(None, widget.names[0])
            self.fix.put(radio_controller, widget.postnX[0], widget.postnY[0])
            radio_controller.show()
            widget.controller.append(radio_controller)
            for i in range(1, len(widget.track)):
                radio_controller = gtk.RadioButton(widget.controller[0],
                                                   widget.names[i])
                self.fix.put(radio_controller, widget.postnX[i],
                             widget.postnY[i])
                radio_controller.show()
                widget.controller.append(radio_controller)

        elif widget_type == Static_text:
            self.fix.put(widget.mess, widget.posX, widget.posY)
            widget.mess.show()

        elif widget_type == Text_field:
            self.fix.put(widget.entry, widget.posX, widget.posY)
            widget.entry.show()

        elif (widget_type == Text_area):
            widget.controller = gtk.TextView(widget.buffer)
            widget.controller.set_size_request(widget.width, widget.height)
            self.fix.put(widget.controller, widget.postnX, widget.postnY)
            widget.controller.show()
            if (widget.callbackMethod != None):
                widget.controller.connect('clicked', widget.callbackMethod)

        elif widget_type == Spin_list:
            widget.controller = gtk.SpinButton()
            widget.controller.set_range(widget.minimum, widget.maximum)
            widget.controller.set_increments(1, 1)
            widget.controller.set_size_request(widget.length, widget.width)
            self.fix.put(widget.controller, widget.posX, widget.posY)
            widget.controller.show()

        elif widget_type == Password_field:
            self.fix.put(widget.entry, widget.posX, widget.posY)
            widget.entry.show()