示例#1
0
def register_stock_icons():
    try:
        import pygtk
#        pygtk.require('2.0')
        import gtk
    except: return
    items = [
        ('jdh-hide', '_Hide', 0, 0, None),
        ('jdh-auto', '_Auto', 0, 0, None),
             ]

    # We're too lazy to make our own icons, so we use regular stock icons.
    aliases = [
        ('jdh-hide', gtk.STOCK_CANCEL),
        ('jdh-auto', gtk.STOCK_EXECUTE),
               ]

    gtk.stock_add(items)

    factory = gtk.IconFactory()
    factory.add_default()

    for new_stock, alias in aliases:
        icon_set = gtk.icon_factory_lookup_default(alias)
        factory.add(new_stock, icon_set)
示例#2
0
def load_icons():
	items = [STOCK_ROTATE_LEFT, STOCK_ROTATE_RIGHT, STOCK_MOVE_TO_ORIGIN,
			STOCK_HOR_MIRROR, STOCK_VERT_MIRROR, STOCK_MULTIPLY]

	path = '' + os.path.join(config.resource_dir, 'icons')
	iconfactory = gtk.IconFactory()

	for item in items:
		gtk.stock_add([(item, '', 0, 0, ''), ])
		pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(path, item + '.png'))
		source = gtk.IconSource()
		source.set_pixbuf(pixbuf)
		source.set_size_wildcarded(True)
		iconset = gtk.IconSet()
		iconset.add_source(source)
		iconfactory.add(item, iconset)

	#Creating aliased icons
	items = [(STOCK_CUTTING, _('_Cutting'), 0, 0, None),
			(STOCK_DONT_SAVE, _("_Don't save"), 0, 0, None), ]

	aliases = [(STOCK_CUTTING, gtk.STOCK_PRINT),
			(STOCK_DONT_SAVE, gtk.STOCK_NO), ]

	gtk.stock_add(items)

	for item, alias in aliases:
		iconset = gtk.icon_factory_lookup_default(alias)
		iconfactory.add(item, iconset)

	iconfactory.add_default()
示例#3
0
def register_stock_icons():
    try:
        import pygtk
        #        pygtk.require('2.0')
        import gtk
    except:
        return
    items = [
        ('jdh-hide', '_Hide', 0, 0, None),
        ('jdh-auto', '_Auto', 0, 0, None),
    ]

    # We're too lazy to make our own icons, so we use regular stock icons.
    aliases = [
        ('jdh-hide', gtk.STOCK_CANCEL),
        ('jdh-auto', gtk.STOCK_EXECUTE),
    ]

    gtk.stock_add(items)

    factory = gtk.IconFactory()
    factory.add_default()

    for new_stock, alias in aliases:
        icon_set = gtk.icon_factory_lookup_default(alias)
        factory.add(new_stock, icon_set)
示例#4
0
    def get_pixbuf_from_stock_icon(self,
                                   widget,
                                   stock_id="",
                                   size=gtk.ICON_SIZE_DIALOG):
        if widget and stock_id and gtk.icon_factory_lookup_default(stock_id):
            return widget.render_icon(stock_id, size)

        return None
示例#5
0
 def update_folders(self):
     self.folders_model.clear()
     for folder in self.server.getConfig("folders"):
         print str(folder)
         icon = gtk.icon_factory_lookup_default(gtk.STOCK_DIRECTORY)
         pixbuf = icon.render_icon(gtk.Style(), gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_MENU, None, None)
         
         self.folders_model.append((str(folder),pixbuf))
示例#6
0
    def __create_model(self):
        store = gtk.ListStore(
            gobject.TYPE_PYOBJECT,
            gobject.TYPE_STRING)

        ids = gtk.stock_list_ids()
        ids.sort()

        for data in ids:
            info = StockItemInfo(stock_id=data)
            stock_item = gtk.stock_lookup(data)

            if stock_item:
                info.stock_item = stock_item
            else:
                # stock_id, label, modifier, keyval, translation_domain
                info.stock_item =('', '', 0, 0, '')

            # only show icons for stock IDs that have default icons
            icon_set = gtk.icon_factory_lookup_default(info.stock_id)
            if icon_set is None:
                info.small_icon = None
            else:
                # See what sizes this stock icon really exists at
                sizes = icon_set.get_sizes()
                n_sizes = len(sizes)

                # Use menu size if it exists, otherwise first size found
                size = sizes[0];
                i = 0;
                while(i < n_sizes):
                    if(sizes[i] == gtk.ICON_SIZE_MENU):
                        size = gtk.ICON_SIZE_MENU
                        break
                    i += 1

                info.small_icon = self.render_icon(info.stock_id, size)

                if(size != gtk.ICON_SIZE_MENU):
                    # Make the result the proper size for our thumbnail
                    w, h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)

                    scaled = info.small_icon.scale_simple(w, h, 'bilinear')
                    info.small_icon = scaled

            if info.stock_item[3] == 0:
                info.accel_str = ""
            else:
                info.accel_str = \
                    gtk.accelerator_name(info.stock_item[3], info.stock_item[2])

            iter = store.append()
            store.set(iter, 0, info, 1, info.stock_id)

        return store
示例#7
0
    def __create_model(self):
        store = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING)

        ids = gtk.stock_list_ids()
        ids.sort()

        for data in ids:
            info = StockItemInfo(stock_id=data)
            stock_item = gtk.stock_lookup(data)

            if stock_item:
                info.stock_item = stock_item
            else:
                # stock_id, label, modifier, keyval, translation_domain
                info.stock_item = ('', '', 0, 0, '')

            # only show icons for stock IDs that have default icons
            icon_set = gtk.icon_factory_lookup_default(info.stock_id)
            if icon_set is None:
                info.small_icon = None
            else:
                # See what sizes this stock icon really exists at
                sizes = icon_set.get_sizes()
                n_sizes = len(sizes)

                # Use menu size if it exists, otherwise first size found
                size = sizes[0]
                i = 0
                while (i < n_sizes):
                    if (sizes[i] == gtk.ICON_SIZE_MENU):
                        size = gtk.ICON_SIZE_MENU
                        break
                    i += 1

                info.small_icon = self.render_icon(info.stock_id, size)

                if (size != gtk.ICON_SIZE_MENU):
                    # Make the result the proper size for our thumbnail
                    w, h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)

                    scaled = info.small_icon.scale_simple(w, h, 'bilinear')
                    info.small_icon = scaled

            if info.stock_item[3] == 0:
                info.accel_str = ""
            else:
                info.accel_str = \
                    gtk.accelerator_name(info.stock_item[3], info.stock_item[2])

            iter = store.append()
            store.set(iter, 0, info, 1, info.stock_id)

        return store
示例#8
0
def setup_scheduler_icon(ipath=None):
    """Setup a 'stock' icon for the scheduler"""
    new_icon_factory = gtk.IconFactory()
    locator = rose.resource.ResourceLocator(paths=sys.path)
    iname = "rose-gtk-scheduler"
    if ipath is None:
        new_icon_factory.add(
            iname, gtk.icon_factory_lookup_default(gtk.STOCK_MISSING_IMAGE))
    else:
        path = locator.locate(ipath)
        pixbuf = gtk.gdk.pixbuf_new_from_file(path)
        new_icon_factory.add(iname, gtk.IconSet(pixbuf))
    new_icon_factory.add_default()
示例#9
0
文件: util.py 项目: lexual/rose
def setup_scheduler_icon(ipath=None):
    """Setup a 'stock' icon for the scheduler"""
    new_icon_factory = gtk.IconFactory()
    locator = rose.resource.ResourceLocator(paths=sys.path)
    iname = "rose-gtk-scheduler"
    if ipath is None:
        new_icon_factory.add(
            iname, gtk.icon_factory_lookup_default(gtk.STOCK_MISSING_IMAGE))
    else:
        path = locator.locate(ipath)
        pixbuf = gtk.gdk.pixbuf_new_from_file(path)
        new_icon_factory.add(iname, gtk.IconSet(pixbuf))
    new_icon_factory.add_default()
示例#10
0
class HobIconChecker(hic):
    def set_hob_icon_to_stock_icon(self, file_path, stock_id=""):
        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
        except Exception, e:
            return None

        if stock_id and (gtk.icon_factory_lookup_default(stock_id) == None):
            icon_factory = gtk.IconFactory()
            icon_factory.add_default()
            icon_factory.add(stock_id, gtk.IconSet(pixbuf))
            gtk.stock_add([(stock_id, '_label', 0, 0, '')])

            return icon_factory.lookup(stock_id)

        return None
示例#11
0
    def check_stock_icon(self, stock_name=""):
        HOB_CHECK_STOCK_NAME = {
            ('hic-dialog-info', 'gtk-dialog-info', 'dialog-info')           : self.ICON_INDI_INFO_FILE,
            ('hic-ok',          'gtk-ok',           'ok')                   : self.ICON_INDI_TICK_FILE,
            ('hic-dialog-error', 'gtk-dialog-error', 'dialog-error')        : self.ICON_INDI_ERROR_FILE,
            ('hic-dialog-warning', 'gtk-dialog-warning', 'dialog-warning')  : self.ICON_INDI_ALERT_FILE,
            ('hic-task-refresh', 'gtk-execute', 'execute')                  : self.ICON_INDI_REFRESH_FILE,
        }
        valid_stock_id = stock_name
        if stock_name:
            for names, path in HOB_CHECK_STOCK_NAME.iteritems():
                if stock_name in names:
                    valid_stock_id = names[0]
                    if not gtk.icon_factory_lookup_default(valid_stock_id):
                        self.set_hob_icon_to_stock_icon(path, valid_stock_id)

        return valid_stock_id
示例#12
0
def get_largest_size(stockid):
    ''' Finds the largest size at which the given image stock id is
        available. This would not be useful for a normal application.
    '''
    set = gtk.icon_factory_lookup_default(stockid)
    best_size = gtk.ICON_SIZE_INVALID
    best_pixels = 0

    sizes = set.get_sizes()
    n_sizes = len(sizes)

    i = 0
    while (i < n_sizes):
        width, height = gtk.icon_size_lookup(sizes[i])

        if (width * height > best_pixels):
            best_size = sizes[i]
            best_pixels = width * height

        i += 1
    return best_size
示例#13
0
def get_largest_size(stockid):
    ''' Finds the largest size at which the given image stock id is
        available. This would not be useful for a normal application.
    '''
    set = gtk.icon_factory_lookup_default(stockid)
    best_size = gtk.ICON_SIZE_INVALID
    best_pixels = 0

    sizes = set.get_sizes()
    n_sizes = len(sizes)

    i = 0
    while(i < n_sizes):
        width, height = gtk.icon_size_lookup(sizes[i])

        if(width * height > best_pixels):
            best_size = sizes[i]
            best_pixels = width * height

        i += 1

    return best_size
示例#14
0
文件: rc.py 项目: sk1project/sk1-gtk2
def registry_aliases(txt, overlay_icons=True):

	iconfactory = gtk.IconFactory()

	#--- Overlay for zoom icons
	if overlay_icons:
		gtk.stock_add([(STOCK_ZOOM_PAGE, '', 0, 0, ''), ])

		items = [gtk.STOCK_ZOOM_100, gtk.STOCK_ZOOM_FIT, gtk.STOCK_ZOOM_IN,
				gtk.STOCK_ZOOM_OUT, STOCK_ZOOM_PAGE]

		for item in items:
			iconset = gtk.IconSet()
			source = gtk.IconSource()
			filepath = os.path.join(ICONS24_PATH, item + '.png')
			pixbuf = gtk.gdk.pixbuf_new_from_file(filepath)
			source.set_pixbuf(pixbuf)
			source.set_size_wildcarded(True)
			iconset.add_source(source)
			iconfactory.add(item, iconset)

	#---Registry DON'T SAVE item
	aliases = [((STOCK_DONT_SAVE, txt, 0, 0, None),
			(STOCK_DONT_SAVE, gtk.STOCK_NO)), ]
	items = []
	alias_items = []
	for item in aliases:
		items.append(item[0])
		alias_items.append(item[1])

	gtk.stock_add(items)

	for item, alias in alias_items:
		iconset = gtk.icon_factory_lookup_default(alias)
		iconfactory.add(item, iconset)

	iconfactory.add_default()
示例#15
0
    def get_pixbuf_from_stock_icon(self, widget, stock_id="", size=gtk.ICON_SIZE_DIALOG):
        if widget and stock_id and gtk.icon_factory_lookup_default(stock_id):
            return widget.render_icon(stock_id, size)

        return None
示例#16
0
文件: timer.py 项目: Johennes/Timer
    def __init__(self, root):
        """
        Constructor.
        """

        # Register stock items
        items = (('timer-start', 'Start', 0, 0,
                  None), ('timer-stop', 'Stop', 0, 0,
                          None), ('timer-pause', 'Pause', 0, 0, None),
                 ('timer-continue', 'Continue', 0, 0,
                  None), ('timer-restart', 'Restart', 0, 0,
                          None), ('timer-back', 'Back', 0, 0, None))
        gtk.stock_add(items)

        # Set stock icons
        icons = (('timer-start', gtk.STOCK_MEDIA_PLAY),
                 ('timer-stop', gtk.STOCK_MEDIA_STOP), ('timer-pause',
                                                        gtk.STOCK_MEDIA_PAUSE),
                 ('timer-continue', gtk.STOCK_MEDIA_PLAY),
                 ('timer-restart', gtk.STOCK_REDO), ('timer-back',
                                                     gtk.STOCK_OK))
        factory = gtk.IconFactory()
        factory.add_default()
        for id, stock in icons:
            icon_set = gtk.icon_factory_lookup_default(stock)
            factory.add(id, icon_set)

        # Parse configuration
        defaults = {'UI': {'advanced_mode': str(False)}, 'Presets': {}}
        self.config = os.path.join(root, 'timer.conf')
        self.parser = self.initialize_config(defaults, self.config)
        self.presets_model = self.parse_presets(self.parser)

        # Create and connect timer object
        self.timer = Timer()
        self.timer.connect('timer-updated', self.update_display)
        self.timer.connect('timer-finished', self.finished)

        # Construct window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_size_request(300, -1)
        self.window.set_border_width(10)
        self.window.set_title('Timer')
        self.window.set_icon_list(
            gtk.gdk.pixbuf_new_from_file(
                os.path.join(os.path.join(root, 'icon'), 'timer-24.png')),
            gtk.gdk.pixbuf_new_from_file(
                os.path.join(os.path.join(root, 'icon'), 'timer-48.png')))
        self.window.connect('destroy', gtk.main_quit)

        vbox = gtk.VBox()
        self.window.add(vbox)

        # We use containers to be able to quickly switch the display
        self.countdown_container = gtk.VBox(spacing=10)
        vbox.pack_start(self.countdown_container)
        self.control_container = gtk.VBox()
        vbox.pack_start(self.control_container)

        self.simple_control_container = gtk.VBox()
        vbox.pack_start(self.simple_control_container)
        self.advanced_control_container = gtk.VBox()
        vbox.pack_start(self.advanced_control_container)
        self.button_box = gtk.HBox()
        vbox.pack_start(self.button_box, False)

        # Create the name label
        self.name_label = gtk.Label()
        self.countdown_container.pack_start(self.name_label, False)

        # Create the pie-meter
        self.pie_meter = PieWidget()
        self.countdown_container.pack_start(self.pie_meter)

        # Create the time label. The outer hbox is needed for horizontal
        # centering, the inner hbox to add padding between the label and
        # the frame.
        outer_hbox = gtk.HBox()
        self.countdown_container.pack_start(outer_hbox, False)

        frame = gtk.Frame()
        outer_hbox.pack_start(frame, True, False)

        inner_hbox = gtk.HBox()
        frame.add(inner_hbox)

        self.time_label = gtk.Label()
        inner_hbox.pack_start(self.time_label, padding=5)

        # Create countdown control buttons
        button_box = gtk.HBox()
        self.countdown_container.pack_start(button_box, False)

        controls = (('back', 'timer-back', self.stop_timer),
                    ('restart', 'timer-restart', self.restart_timer),
                    ('stop', 'timer-stop', self.stop_timer),
                    ('pause', 'timer-pause', self.toggle_timer),
                    ('continue', 'timer-continue', self.toggle_timer))

        self.countdown_buttons = {}
        for name, stock, callback in controls:
            button = gtk.Button(stock=stock)
            button_box.pack_end(button, False, False)
            button.connect('clicked', callback)
            self.countdown_buttons[name] = button

        # Create timer-controll ui
        table = gtk.Table(8, 2)
        table.set_col_spacings(20)
        table.set_row_spacings(10)
        self.control_container.pack_start(table, False)

        bg_check = gtk.CheckButton()
        bg_check.set_active(self.parser.getboolean('Colors', 'background'))
        bg_button = gtk.ColorButton()
        bg_button.set_sensitive(self.parser.getboolean('Colors', 'background'))
        bg_check.connect('toggled', lambda b: b.get_active() \
            and [bg_button.set_sensitive(True)] or bg_button.set_sensitive(False))
        bg_box = gtk.HBox()
        bg_box.pack_start(bg_check, False)
        bg_box.pack_end(bg_button)

        img_check = gtk.CheckButton()
        img_check.set_active(self.parser.getboolean('Colors', 'background'))
        img_button = gtk.FileChooserButton(gtk.FileChooserDialog())
        img_button.set_sensitive(self.parser.getboolean(
            'Colors', 'background'))
        img_check.connect('toggled', lambda b: b.get_active() \
            and [img_button.set_sensitive(True)] or img_button.set_sensitive(False))
        img_box = gtk.HBox()
        img_box.pack_start(img_check, False)
        img_box.pack_end(img_button)

        snd_check = gtk.CheckButton()
        snd_check.set_active(self.parser.getboolean('Colors', 'background'))
        snd_button = gtk.FileChooserButton(gtk.FileChooserDialog())
        snd_button.set_sensitive(self.parser.getboolean(
            'Colors', 'background'))
        snd_check.connect('toggled', lambda b: b.get_active() \
            and [snd_button.set_sensitive(True)] or snd_button.set_sensitive(False))
        snd_box = gtk.HBox()
        snd_box.pack_start(snd_check, False)
        snd_box.pack_end(snd_button)

        controls = (('hours', 'Hours',
                     gtk.SpinButton(gtk.Adjustment(0, 0, 72, 1, 5))),
                    ('minutes', 'Minutes',
                     gtk.SpinButton(gtk.Adjustment(0, 0, 59, 1, 5))),
                    ('seconds', 'Seconds',
                     gtk.SpinButton(gtk.Adjustment(0, 0, 59, 1, 5))),
                    ('name', 'Name', gtk.Entry()), ('fg', 'Foreground Color',
                                                    gtk.ColorButton()),
                    ('bg', 'Background Color',
                     bg_box), ('img', 'Use Image',
                               img_box), ('snd', 'Play Sound', snd_box))

        self.timeout_editables = {}
        for i in range(0, len(controls)):
            name, label, widget = controls[i]
            alignment = gtk.Alignment(0.0, 0.5)
            alignment.add(gtk.Label(label))
            table.attach(alignment, 0, 1, i, i + 1, gtk.FILL)
            table.attach(widget, 1, 2, i, i + 1)
            #id = widget.connect('changed', self.unselect_preset)
            self.timeout_editables[name] = {}
            self.timeout_editables[name]['widget'] = widget
            self.timeout_editables[name]['handler'] = id

        # Create advanced timer-setup ui
        table = gtk.Table(3, 2)
        table.set_col_spacings(20)
        table.set_row_spacings(10)
        self.advanced_control_container.pack_start(table, False)

        controls = (('name', 'Name', gtk.Entry()), )

        for i in range(0, len(controls)):
            name, label, widget = controls[i]
            alignment = gtk.Alignment(0.0, 0.5)
            alignment.add(gtk.Label(label))
            table.attach(alignment, 0, 1, i, i + 1, gtk.FILL)
            table.attach(widget, 1, 2, i, i + 1)
            id = widget.connect('changed', self.unselect_preset)
            self.timeout_editables[name] = {}
            self.timeout_editables[name]['widget'] = widget
            self.timeout_editables[name]['handler'] = id

        # Create presets control
        self.advanced_control_container.pack_start(gtk.HSeparator(),
                                                   False,
                                                   padding=5)

        alignment = gtk.Alignment(0.0, 0.5)
        alignment.add(gtk.Label('Presets'))
        self.advanced_control_container.pack_start(alignment, False, False)

        hbox = gtk.HBox()
        self.advanced_control_container.pack_start(hbox)

        # Create presets treeview
        presets_view = gtk.TreeView(self.presets_model)
        presets_view.set_headers_visible(False)
        presets_view.append_column(
            gtk.TreeViewColumn(None, gtk.CellRendererText(), text=0))

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(presets_view)
        hbox.pack_start(scroll)

        self.preset_selection = presets_view.get_selection()
        self.preset_selection.connect('changed', self.preset_selection_changed)

        # Create presets-control buttons
        button_box = gtk.VBox()
        hbox.pack_start(button_box, False)

        controls = (('Save', gtk.STOCK_SAVE, self.save_preset),
                    ('Delete', gtk.STOCK_DELETE, self.delete_preset))

        self.preset_buttons = {}
        for label, stock, callback in controls:
            button = gtk.Button(stock=stock)
            button_box.pack_start(button, False)
            button.connect('clicked', callback)
            self.preset_buttons[label] = button

        self.advanced_control_container.pack_start(gtk.HSeparator(),
                                                   False,
                                                   padding=5)

        # Create main control buttons
        start_button = gtk.Button(stock='timer-start')
        self.button_box.pack_start(start_button, False, False)
        start_button.connect('clicked', self.start_timer)

        advanced_mode_check = gtk.CheckButton()
        self.button_box.pack_end(gtk.Label('Advanced Mode'), False, False)
        self.button_box.pack_end(advanced_mode_check, False, False)
        advanced_mode_check.connect('clicked', self.toggle_advanced_mode)

        # Create tray icon
        self.tray = TrayIcon('timer-48.png')
        self.tray.fg_color = [
            self.parser.getfloat('Colors', 'foreground_' + x)
            for x in ('r', 'g', 'b')
        ]
        self.tray.bg_color = [
            self.parser.getfloat('Colors', 'background_' + x)
            for x in ('r', 'g', 'b')
        ]
        self.tray.status_icon.connect('activate', self.tray_activated)
        self.tray.status_icon.connect('popup-menu', self.show_tray_menu)

        # Create tray menu
        self.tray_menu = gtk.Menu()

        controls = (('start', 'timer-start', self.start_timer),
                    ('pause', 'timer-pause', self.toggle_timer),
                    ('continue', 'timer-continue', self.toggle_timer),
                    ('stop', 'timer-stop', self.stop_timer),
                    ('restart', 'timer-restart', self.restart_timer),
                    gtk.SeparatorMenuItem(),
                    ('preferences', gtk.STOCK_PREFERENCES, self.pref_dialog),
                    gtk.SeparatorMenuItem(), ('quit', gtk.STOCK_QUIT,
                                              gtk.main_quit))

        self.tray_menu_items = {}
        for row in controls:
            if type(row) != tuple:
                self.tray_menu.add(row)
            else:
                name, stock, callback = row
                item = gtk.ImageMenuItem(stock)
                item.connect('activate', callback)
                self.tray_menu.add(item)
                self.tray_menu_items[name] = item

        self.tray_menu.show_all()

        # Finalize UI
        self.window.show_all()

        self.toggle_ui()

        self.countdown_buttons['back'].hide()
        self.countdown_buttons['continue'].hide()
        self.countdown_buttons['restart'].hide()

        self.tray_menu_items['continue'].hide()
        self.tray_menu_items['restart'].hide()

        self.preset_buttons['Delete'].set_sensitive(False)
示例#17
0
文件: third.py 项目: direvus/third
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.connect("delete_event", self.delete_event)

        self.set_border_width(5)
        self.set_title("third")
        self.set_icon_from_file(os.path.join(_share_dir, "app.png"))
        
        self.bold = pango.FontDescription("sans bold 10")

        # Set up stock IDs and icon set aliases.
        stock = [('third-roll', "_Roll", 0, 0, None), 
                 ('third-clear', "_Clear", 0, 0, None),
                 ('third-add', "_Add", 0, 0, None),
                 ('third-rename', "Re_name", 0, 0, None),
                 ('third-save', "_Save", 0, 0, None),
                 ('third-remove', "R_emove", 0, 0, None)]

        aliases = [('third-roll', 'gtk-ok'),
                   ('third-clear', 'gtk-cancel'),
                   ('third-add', 'gtk-add'),
                   ('third-rename', 'gtk-edit'),
                   ('third-save', 'gtk-save'),
                   ('third-remove', 'gtk-remove')]

        gtk.stock_add(stock)
        factory = gtk.IconFactory()
        factory.add_default()
        for new, old in aliases:
            factory.add(new, gtk.icon_factory_lookup_default(old))

        self.dbox = DieBox()
        self.dbox.connect_updates(self.update_config)

        self.rollbutton = gtk.Button(stock="third-roll")
        self.rollbutton.connect("clicked", self.roll)
        self.resetbutton = gtk.Button(stock="third-clear")
        self.resetbutton.connect("clicked", self.reset)

        bb = gtk.VButtonBox()
        bb.set_layout(gtk.BUTTONBOX_EDGE)
        bb.add(self.rollbutton)
        bb.add(self.resetbutton)

        self.log = THIRDLog(str, str, int)
        self.logview = THIRDLogView(self.log)

        self.logscroll = gtk.ScrolledWindow()
        self.logscroll.set_policy(gtk.POLICY_AUTOMATIC,
                                  gtk.POLICY_ALWAYS)
        self.logscroll.set_shadow_type(gtk.SHADOW_IN)
        self.logscroll.add(self.logview)

        self.label = gtk.Label()
        self.label.modify_font(self.bold)
        self.label.set_alignment(0.0, 0.5)

        self.range = gtk.Label()
        self.range.set_alignment(1.0, 0.0)

        labelbox = gtk.HBox()
        labelbox.pack_start(gtk.Label("Range: "), False, False)
        labelbox.pack_end(self.range, True, True)

        self.slider = gtk.HScale()
        self.slider.set_increments(1, 1)
        self.slider.set_draw_value(False)

        self.resultbox = gtk.VBox(False, 5)
        self.resultbox.pack_start(self.label, False, False)
        self.resultbox.pack_start(labelbox, False, False)
        self.resultbox.pack_start(self.slider, False, False)
        self.resultbox.pack_start(self.logscroll, True, True)
        self.resultbox.pack_start(bb, False, False)

        self.mainbox = gtk.HBox(False, 10)
        self.mainbox.pack_start(gtk.VSeparator(), False, False)
        self.mainbox.pack_start(self.dbox, False, False)
        self.mainbox.pack_start(gtk.VSeparator(), False, False)
        self.mainbox.pack_end(self.resultbox, True, True)

        panes = gtk.HPaned()
        self.add(panes)

        self.profiles = []

        self.profilebox = THIRDProfileBox()
        self.profilebox.connect("changed", self.select_profile)
        self.presetmodel = THIRDPresets(str, str)
        self.presetview = THIRDPresetView(self.presetmodel)
        self.presetview.connect("cursor-changed", self.select_preset)
        self.presetview.connect("row-activated", self.activate_preset)
        self.presetscroll = gtk.ScrolledWindow()
        self.presetscroll.set_policy(gtk.POLICY_NEVER,
                                     gtk.POLICY_AUTOMATIC)
        self.presetscroll.set_shadow_type(gtk.SHADOW_IN)
        self.presetscroll.add(self.presetview)
        self.load_presets()

        bb = gtk.HBox(True, 0)
        size = gtk.ICON_SIZE_BUTTON

        box = gtk.VBox(False, 5)
        box.pack_start(self.profilebox, False, False)
        box.pack_end(bb, False, False)

        self.addprofilebutton = gtk.Button()
        image = gtk.image_new_from_stock("third-add", size)
        self.addprofilebutton.set_image(image)
        self.addprofilebutton.set_tooltip_text("Create a new profile")
        self.addprofilebutton.connect("clicked", self.add_profile)
        bb.pack_start(self.addprofilebutton, True, True)

        self.editprofilebutton = gtk.Button()
        image = gtk.image_new_from_stock("third-rename", size)
        self.editprofilebutton.set_image(image)
        self.editprofilebutton.set_tooltip_text("Rename the selected profile")
        self.editprofilebutton.connect("clicked", self.rename_profile)
        bb.pack_start(self.editprofilebutton, True, True)

        self.removeprofilebutton = gtk.Button()
        image = gtk.image_new_from_stock("third-remove", size)
        self.removeprofilebutton.set_image(image)
        self.removeprofilebutton.set_tooltip_text("Delete the selected profile")
        self.removeprofilebutton.connect("clicked", self.remove_profile)
        bb.pack_start(self.removeprofilebutton, True, True)

        profileframe = gtk.Frame("Profiles")
        profileframe.add(box)

        bb = gtk.HBox(True, 0)

        self.addbutton = gtk.Button()
        image = gtk.image_new_from_stock("third-add", size)
        self.addbutton.set_image(image)
        self.addbutton.set_tooltip_text("Save the current configuration "
                                        "as a new preset")
        self.addbutton.connect("clicked", self.add_preset)
        bb.pack_start(self.addbutton, True, True)

        self.editbutton = gtk.Button()
        image = gtk.image_new_from_stock("third-rename", size)
        self.editbutton.set_image(image)
        self.editbutton.set_tooltip_text("Rename the selected preset")
        self.editbutton.set_sensitive(False)
        self.editbutton.connect("clicked", self.edit_preset)
        bb.pack_start(self.editbutton, True, True)

        self.savebutton = gtk.Button()
        image = gtk.image_new_from_stock("third-save", size)
        self.savebutton.set_image(image)
        self.savebutton.set_tooltip_text("Save the current configuration "
                                         "into the selected preset")
        self.savebutton.set_sensitive(False)
        self.savebutton.connect("clicked", self.save_preset)
        bb.pack_start(self.savebutton, True, True)

        self.removebutton = gtk.Button()
        image = gtk.image_new_from_stock("third-remove", size)
        self.removebutton.set_image(image)
        self.removebutton.set_tooltip_text("Delete the selected preset")
        self.removebutton.set_sensitive(False)
        self.removebutton.connect("clicked", self.remove_preset)
        bb.pack_start(self.removebutton, True, True)

        box = gtk.VBox(False, 5)
        box.pack_start(self.presetscroll, True, True)
        box.pack_end(bb, False, False)

        presetframe = gtk.Frame("Presets")
        presetframe.add(box)

        box = gtk.VBox(False, 5)
        box.pack_start(profileframe, False, False)
        box.pack_start(presetframe, True, True)

        panes.add1(box)
        panes.add2(self.mainbox)

        self.update_config()

        self.show_all()