Ejemplo n.º 1
0
    def make_at_box(self):
        # The time of day setting
        hbox = g.HBox(FALSE, 0)

        self.at = g.CheckButton(_('At'))
        hbox.pack_start(self.at, FALSE, TRUE, 4)
        self.at.connect('toggled', self.at_toggled)

        at_box = g.HBox(FALSE, 0)
        self.at_box = at_box
        hbox.pack_start(at_box, FALSE, TRUE, 0)

        arrow = Arrow(g.ARROW_LEFT, self.adj_time, -60)
        at_box.pack_start(arrow, FALSE, TRUE, 0)
        arrow = Arrow(g.ARROW_RIGHT, self.adj_time, 60)
        at_box.pack_start(arrow, FALSE, TRUE, 0)

        self.time_display = g.Label(str_time(self.hour, self.min))
        self.time_display.set_padding(4, 0)
        frame = g.Frame()
        frame.add(self.time_display)
        at_box.pack_start(frame, FALSE, TRUE, 0)

        arrow = Arrow(g.ARROW_LEFT, self.adj_time, -1)
        at_box.pack_start(arrow, FALSE, TRUE, 0)
        arrow = Arrow(g.ARROW_RIGHT, self.adj_time, 1)
        at_box.pack_start(arrow, FALSE, TRUE, 0)

        return hbox
Ejemplo n.º 2
0
    def build_filechooser(self, node, label, option):
        """<filechooser name='...' label='...'/>Tooltip</filechooser>.
		Lets the user choose a file (using a GtkFileChooser or by drag-and-drop).
		Note: requires GTK >= 2.6
		"""
        filebutton = g.FileChooserButton(label)
        eb = g.EventBox()
        eb.add(filebutton)
        self.may_add_tip(eb, node)

        clearbutton = g.Button(stock=g.STOCK_CLEAR)
        hbox = g.HBox(False, 4)
        if label:
            hbox.pack_start(g.Label(label + ":"), False, True, 0)
        hbox.pack_start(eb, True, True, 0)
        hbox.pack_start(clearbutton, False, True, 0)

        self.handlers[option] = (lambda: filebutton.get_filename(),
                                 lambda: filebutton.set_filename(option.value))
        filebutton.connect('selection-changed',
                           lambda w: self.check_widget(option))

        def clear(w):
            filebutton.set_filename("")
            self.check_widget(option)

        clearbutton.connect('clicked', clear)

        return [hbox or eb]
Ejemplo n.º 3
0
    def build_numentry(self, node, label, option):
        """<numentry name='...' label='...' min='0' max='100' step='1'>Tooltip</numentry>.
		Lets the user choose a number from min to max."""
        minv = int(node.getAttribute('min'))
        maxv = int(node.getAttribute('max'))
        step = node.getAttribute('step')
        if step:
            step = int(step)
        else:
            step = 1
        unit = self._(node.getAttribute('unit'))

        hbox = g.HBox(False, 4)
        if label:
            widget = g.Label(label)
            widget.set_alignment(1.0, 0.5)
            hbox.pack_start(widget, False, True, 0)

        spin = g.SpinButton(g.Adjustment(minv, minv, maxv, step))
        spin.set_width_chars(max(len(str(minv)), len(str(maxv))))
        hbox.pack_start(spin, False, True, 0)
        self.may_add_tip(spin, node)

        if unit:
            hbox.pack_start(g.Label(unit), False, True, 0)

        self.handlers[option] = (lambda: str(spin.get_value()),
                                 lambda: spin.set_value(option.int_value))

        spin.connect('value-changed', lambda w: self.check_widget(option))

        return [hbox]
Ejemplo n.º 4
0
def op_button(text, stock, command, message, dialog=None):
    button = g.Button()

    hbox = g.HBox(False, 0)
    button.add(hbox)

    image = g.Image()
    image.set_from_stock(stock, g.ICON_SIZE_BUTTON)
    hbox.pack_start(image, False, True, 4)

    label = g.Label('')
    label.set_text_with_mnemonic(text)
    label.set_alignment(0, 0.5)
    hbox.pack_start(label, True, True, 0)

    # No need for clickable buttons if no command is set
    tmp = command.strip()
    if tmp:

        def invoke(button):
            print >> sys.stderr, message
            os.system(command)
            if dialog:
                dialog.response(g.RESPONSE_ACCEPT)

        button.connect('clicked', invoke)
    else:
        button.set_sensitive(False)

    button.unset_flags(g.CAN_FOCUS)
    return button
Ejemplo n.º 5
0
    def build_label(self, node, label):
        widget = g.Label(self._(data(node)))
        help = int(node.getAttribute('help') or '0')
        if help:
            widget.set_alignment(0, 0.5)
        else:
            widget.set_alignment(0, 1)
        widget.set_justify(g.JUSTIFY_LEFT)
        widget.set_line_wrap(True)

        if help:
            hbox = g.HBox(False, 4)
            image = g.Image()
            image.set_from_stock(g.STOCK_DIALOG_INFO, g.ICON_SIZE_BUTTON)
            align = g.Alignment(0, 0, 0, 0)

            align.add(image)
            hbox.pack_start(align, False, True, 0)
            hbox.pack_start(widget, False, True, 0)

            spacer = g.EventBox()
            spacer.set_size_request(6, 6)

            return [hbox, spacer]
        return [widget]
Ejemplo n.º 6
0
 def build_location_option_widget(box, node, label, option):
     label_widget = g.Label(label)
     value_widget = g.Label()
     button = g.Button(stock=g.STOCK_FIND)
     box.may_add_tip(button, node)
 
     box.handlers[option] = (lambda: str(value_widget.get_label()), 
                             lambda: value_widget.set_label(option.value))
 
     def button_clicked(button):
         def dialog_response(dialog, response):
             if response == g.RESPONSE_ACCEPT:
                 selection = dialog.result_list.get_selection()
                 model, it = selection.get_selected()
                 if it:
                     code = model.get_value(it, 1)
                     if code:
                         name = str(model.get_value(it, 0))
                         value_widget.set_label("%s (%s)" % (str(code), name))
             dialog.destroy()
             box.check_widget(option)
         dialog = LocationSearchDialog()
         dialog.connect('response', dialog_response)
         dialog.show()
 
     button.connect('clicked', button_clicked)
 
     hbox = g.HBox(spacing = 5)
     hbox.pack_start(label_widget)
     hbox.pack_start(value_widget)
     hbox.pack_start(button)
 
     return [hbox]
Ejemplo n.º 7
0
    def do_entry(self, node, label, option):
        "Helper function for entry and secretentry widgets"
        box = g.HBox(False, 4)
        entry = g.Entry()

        if label:
            label_wid = g.Label(label)
            label_wid.set_alignment(1.0, 0.5)
            box.pack_start(label_wid, False, True, 0)
            box.pack_start(entry, True, True, 0)
        else:
            box = None

        self.may_add_tip(entry, node)

        entry.connect('changed', lambda e: self.check_widget(option))

        def get():
            return entry.get_chars(0, -1)

        def set():
            entry.set_text(option.value)

        self.handlers[option] = (get, set)

        return (entry, [box or entry])
Ejemplo n.º 8
0
    def make_text_view(self):
        # The TextView / time of day settings
        vbox = g.VBox(FALSE, 0)
        l = g.Label(_('Message:'))
        l.set_alignment(0, 1)
        l.set_padding(0, 4)
        vbox.pack_start(l, FALSE, TRUE, 0)

        frame = g.Frame()
        vbox.pack_start(frame, TRUE, TRUE, 0)
        frame.set_shadow_type(g.SHADOW_IN)

        hbox = g.HBox(FALSE, 0)
        frame.add(hbox)

        text = g.TextView()
        hbox.pack_start(text, TRUE, TRUE, 0)
        text.set_wrap_mode(g.WRAP_WORD)

        scrollbar = g.VScrollbar()
        adj = scrollbar.get_adjustment()
        text.set_scroll_adjustments(None, adj)
        hbox.pack_start(scrollbar, FALSE, TRUE, 0)

        text.set_size_request(200, 200)

        self.text = text

        return vbox
Ejemplo n.º 9
0
    def build_menu(self, node, label, option):
        """Build an OptionMenu widget, only one item of which may be selected.
		<menu name='...' label='...'>
		  <item value='...' label='...'/>
		  <item value='...' label='...'/>
		</menu>"""

        values = []

        has_combo = hasattr(g, 'combo_box_new_text')
        if has_combo:
            option_menu = g.combo_box_new_text()
            option_menu.get_history = option_menu.get_active
            option_menu.set_history = option_menu.set_active
        else:
            option_menu = g.OptionMenu()
            menu = g.Menu()

        if label:
            box = g.HBox(False, 4)
            label_wid = self.make_sized_label(label)
            label_wid.set_alignment(1.0, 0.5)
            box.pack_start(label_wid, False, True, 0)
            box.pack_start(option_menu, True, True, 0)
        else:
            box = None

        #self.may_add_tip(option_menu, node)

        for item in node.getElementsByTagName('item'):
            assert item.hasAttribute('value')
            value = item.getAttribute('value')
            label_item = self.trans(item.getAttribute('label')) or value

            if has_combo:
                option_menu.append_text(label_item)
            else:
                menu.append(g.MenuItem(label_item))

            values.append(value)

        if not has_combo:
            menu.show_all()
            option_menu.set_menu(menu)
        option_menu.connect('changed', lambda e: self.check_widget(option))

        def get():
            return values[option_menu.get_history()]

        def set():
            try:
                option_menu.set_history(values.index(option.value))
            except ValueError:
                print "Value '%s' not in combo list" % option.value

        self.handlers[option] = (get, set)

        return [box or option_menu]
Ejemplo n.º 10
0
def edit_timer(timer):
    global edit_timer_box
    if edit_timer_box:
        edit_timer_box.destroy()

    if timer.end_time:
        if confirm(_('The timer is already set - clear it?'), g.STOCK_CLEAR):
            timer.clear_timer()
        return

    edit_timer_box = Dialog(title=_('Memo Timer'),
                            parent=timer.get_toplevel(),
                            flags=g.DIALOG_NO_SEPARATOR)

    def destroyed(box):
        global edit_timer_box
        assert edit_timer_box is box
        edit_timer_box = None

    edit_timer_box.connect('destroy', destroyed)

    def response(d, resp):
        if resp == int(g.RESPONSE_OK):
            timer.set_timer(min.value * 60 + sec.value)
        d.destroy()

    edit_timer_box.connect('response', response)

    vbox = g.VBox(False, 0)
    vbox.set_border_width(8)
    edit_timer_box.vbox.pack_start(vbox, True, True, 0)
    vbox.pack_start(g.Label(_('Set the count-down timer and click OK.')), True,
                    True, 0)

    hbox = g.HBox(False, 0)
    vbox.pack_start(hbox, False, True, 8)

    min = g.Adjustment(0, 0, 999, 1, 1)
    spin = g.SpinButton(min)
    spin.set_digits(0)
    spin.set_activates_default(True)
    hbox.pack_start(spin, True, True, 0)
    hbox.pack_start(g.Label(_('min ')), False, True, 2)

    sec = g.Adjustment(0, 0, 59, 1, 1)
    spin = g.SpinButton(sec)
    spin.set_digits(0)
    spin.set_activates_default(True)
    hbox.pack_start(spin, True, True, 0)
    hbox.pack_start(g.Label(_('sec')), False, True, 2)

    edit_timer_box.add_button(g.STOCK_CANCEL, g.RESPONSE_CANCEL)
    edit_timer_box.add_button(g.STOCK_OK, g.RESPONSE_OK)
    edit_timer_box.set_default_response(g.RESPONSE_OK)

    edit_timer_box.show_all()
Ejemplo n.º 11
0
    def build_window_frame(self, add_frame=True):
        "Create the main structure of the window."
        hbox = g.HBox(False, 4)
        self.vbox.pack_start(hbox, True, True, 0)

        # scrolled window for the tree view
        sw = g.ScrolledWindow()
        sw.set_shadow_type(g.SHADOW_IN)
        sw.set_policy(g.POLICY_NEVER, g.POLICY_AUTOMATIC)
        hbox.pack_start(sw, False, True, 0)
        self.sections_swin = sw  # Used to hide it...

        # tree view
        model = g.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
        tv = g.TreeView(model)
        sel = tv.get_selection()
        sel.set_mode(g.SELECTION_BROWSE)
        tv.set_headers_visible(False)
        self.sections = model
        self.tree_view = tv
        tv.unset_flags(g.CAN_FOCUS)  # Stop irritating highlight

        # Add a column to display column 0 of the store...
        cell = g.CellRendererText()
        column = g.TreeViewColumn('Section', cell, text=0)
        tv.append_column(column)

        sw.add(tv)

        # main options area
        notebook = g.Notebook()
        notebook.set_show_tabs(False)
        notebook.set_show_border(False)
        self.notebook = notebook

        if add_frame:
            frame = g.Frame()
            frame.set_shadow_type(g.SHADOW_IN)
            hbox.pack_start(frame, True, True, 0)
            frame.add(notebook)
        else:
            hbox.pack_start(notebook, True, True, 0)

        # Flip pages
        def change_page(sel, notebook):
            selected = sel.get_selected()
            if not selected:
                return
            model, titer = selected
            page = model.get_value(titer, 1)
            notebook.set_current_page(page)

        sel.connect('changed', change_page, notebook)

        self.vbox.show_all()
Ejemplo n.º 12
0
    def build_font(self, node, label, option):
        "<font name='...' label='...'>Tooltip</font>"
        button = FontButton(self, option, label)

        self.may_add_tip(button, node)

        hbox = g.HBox(False, 4)
        hbox.pack_start(self.make_sized_label(label), False, True, 0)
        hbox.pack_start(button, False, True, 0)

        self.handlers[option] = (button.get, button.set)

        return [hbox]
Ejemplo n.º 13
0
    def build_colour(self, node, label, option):
        "<colour name='...' label='...'>Tooltip</colour>"
        button = ColourButton(self, option, label)

        self.may_add_tip(button, node)

        hbox = g.HBox(False, 4)
        hbox.pack_start(g.Label(label), False, True, 0)
        hbox.pack_start(button, False, True, 0)

        self.handlers[option] = (button.get, button.set)

        return [hbox]
Ejemplo n.º 14
0
    def build_menu(self, node, label, option):
        """Build an OptionMenu widget, only one item of which may be selected.
		<menu name='...' label='...'>
		  <item value='...' label='...'/>
		  <item value='...' label='...'/>
		</menu>"""

        values = []

        option_menu = g.OptionMenu()
        menu = g.Menu()
        option_menu.set_menu(menu)

        if label:
            box = g.HBox(False, 4)
            label_wid = g.Label(label)
            label_wid.set_alignment(1.0, 0.5)
            box.pack_start(label_wid, False, True, 0)
            box.pack_start(option_menu, True, True, 0)
        else:
            box = None

        #self.may_add_tip(option_menu, node)

        for item in node.getElementsByTagName('item'):
            value = item.getAttribute('value')
            assert value
            label_item = item.getAttribute('label') or value

            menu.append(g.MenuItem(label_item))
            values.append(value)

        option_menu.connect('changed', lambda e: self.check_widget(option))

        def get():
            return values[option_menu.get_history()]

        def set():
            try:
                option_menu.set_history(values.index(option.value))
            except ValueError:
                print "Value '%s' not in combo list" % option.value

        self.handlers[option] = (get, set)

        return [box or option_menu]
Ejemplo n.º 15
0
def build_i18n_message(box, node, label):
    widget = g.Label(
        _("""Note that you must save your choices, 
log out and log back in for the new language
setting to take full effect."""))
    widget.set_alignment(0, 0.5)
    widget.set_justify(g.JUSTIFY_LEFT)
    widget.set_line_wrap(True)

    hbox = g.HBox(False, 4)
    image = g.image_new_from_stock(g.STOCK_DIALOG_INFO, g.ICON_SIZE_BUTTON)
    align = g.Alignment(0, 0, 0, 0)

    align.add(image)
    hbox.pack_start(align, False, True, 0)
    hbox.pack_start(widget, False, True, 0)

    return [hbox]
Ejemplo n.º 16
0
    def build_slider(self, node, label, option):
        minv = int(node.getAttribute('min'))
        maxv = int(node.getAttribute('max'))
        fixed = int(node.getAttribute('fixed') or "0")
        showvalue = int(node.getAttribute('showvalue') or "0")
        end = node.getAttribute('end')

        hbox = g.HBox(False, 4)
        if label:
            widget = self.make_sized_label(label)
            hbox.pack_start(widget, False, True, 0)

        if end:
            hbox.pack_end(
                self.make_sized_label(self.trans(end), suffix='-unit'), False,
                True, 0)

        adj = g.Adjustment(minv, minv, maxv, 1, 10, 0)
        slide = g.HScale(adj)

        if fixed:
            slide.set_size_request(adj.upper, 24)
        else:
            slide.set_size_request(120, -1)
        if showvalue:
            slide.set_draw_value(True)
            slide.set_value_pos(g.POS_LEFT)
            slide.set_digits(0)
        else:
            slide.set_draw_value(False)

        self.may_add_tip(slide, node)
        hbox.pack_start(slide, not fixed, True, 0)

        self.handlers[option] = (lambda: str(adj.get_value()),
                                 lambda: adj.set_value(option.int_value))

        slide.connect('value-changed', lambda w: self.check_widget(option))

        return [hbox]
Ejemplo n.º 17
0
    def make_advanced_box(self):
        # The advanced settings
        expander = g.Expander(_('Advanced Options'))
        expandvbox = g.VBox(FALSE, 4)
        expander.add(expandvbox)

        sound_frame = g.Frame(_('Sound'))
        #sound_frame.set_shadow_type(g.SHADOW_NONE)
        label_widget = sound_frame.get_label_widget()
        label_widget.set_markup('<b>' + _('Sound') + '</b>')

        expandvbox.pack_start(sound_frame, FALSE, TRUE, 0)

        sound_box = g.HBox(FALSE, 4)
        sound_box.set_border_width(8)
        sound_frame.add(sound_box)

        sound_choice = g.combo_box_new_text()
        self.sound_choice = sound_choice
        sound_choice.append_text(_('Use default sound'))
        sound_choice.append_text(_('Use custom sound'))
        sound_choice.append_text(_('Disabled'))
        sound_choice.set_active(0)
        sound_box.pack_start(sound_choice, FALSE, FALSE, 0)

        #sound_entry = g.Entry()
        sound_entry = g.FileChooserButton('Sound File')
        self.sound_entry = sound_entry
        sound_entry.set_sensitive(False)
        sound_box.pack_start(sound_entry, TRUE, TRUE, 0)

        sound_choice.connect('changed', self.sound_choice_changed)

        # TODO: More advanced options can be added to the 'expandbox' vbox, each
        # in its own frame.

        return expander
Ejemplo n.º 18
0
    def __init__(self, program, purpose, version, author, website):
        g.Dialog.__init__(self)
        self.website = website

        def close(iw, event=None, data=None):
            iw.hide()

        self.connect("delete_event", close)

        hbox = g.HBox()
        self.vbox.pack_start(hbox)
        hbox.show()

        try:
            path = os.path.join(rox.app_dir, '.DirIcon')
            pixbuf = g.gdk.pixbuf_new_from_file(path)
            icon = g.Image()
            icon.set_from_pixbuf(pixbuf)
            hbox.pack_start(icon)
            icon.show()
        except:
            #rox.report_exception()
            pass

        table = g.Table(5, 2)
        hbox.pack_start(table)

        label = g.Label("Program")
        table.attach(label, 0, 1, 0, 1)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 0, 1)

        label = g.Label(program or '')
        frame.add(label)

        label = g.Label("Purpose")
        table.attach(label, 0, 1, 1, 2)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 1, 2)

        label = g.Label(purpose or '')
        frame.add(label)

        label = g.Label("Version")
        table.attach(label, 0, 1, 2, 3)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 2, 3)

        label = g.Label(version or '')
        frame.add(label)

        label = g.Label("Authors")
        table.attach(label, 0, 1, 3, 4)

        frame = g.Frame()
        frame.set_shadow_type(g.SHADOW_IN)
        table.attach(frame, 1, 2, 3, 4)

        label = g.Label(author or '')
        frame.add(label)

        label = g.Label("Web site")
        table.attach(label, 0, 1, 5, 6)

        if website:
            button = g.Button(website)
            table.attach(button, 1, 2, 5, 6)

            def goto_website(widget, iw):
                webbrowser.open(iw.website)

            button.connect("clicked", goto_website, self)

        else:
            frame = g.Frame()
            frame.set_shadow_type(g.SHADOW_IN)
            table.attach(frame, 1, 2, 5, 6)

        hbox = self.action_area

        button = g.Button(stock=g.STOCK_CLOSE)
        hbox.pack_start(button)

        def dismiss(widget, iw):
            iw.hide()

        button.connect("clicked", dismiss, self)
        button.show()

        self.vbox.show_all()
Ejemplo n.º 19
0
    def __init__(self, memo=None):
        g.Dialog.__init__(self)
        self.set_has_separator(FALSE)

        self.add_button(g.STOCK_HELP, g.RESPONSE_HELP)

        if memo:
            self.add_button(g.STOCK_DELETE, DELETE)

            button = rox.ButtonMixed(g.STOCK_ZOOM_OUT, _('_Hide'))
            button.set_flags(g.CAN_DEFAULT)
            self.add_action_widget(button, HIDE)

        self.add_button(g.STOCK_CANCEL, g.RESPONSE_CANCEL)

        button = rox.ButtonMixed(g.STOCK_YES, _('_Set'))
        button.set_flags(g.CAN_DEFAULT)
        self.add_action_widget(button, g.RESPONSE_YES)

        self.memo = memo
        if memo:
            self.set_title(_("Edit memo:"))
            t = time.localtime(memo.time)
        else:
            self.set_title(_("Create memo:"))
            t = time.localtime(time.time() + 5 * 60)

        year, month, day, hour, minute, second, weekday, julian, dst = t
        self.hour = hour
        self.min = minute

        self.cal = g.Calendar()
        self.cal.select_month(month - 1, year)
        self.cal.select_day(day)

        at_box = self.make_at_box()
        self.advanced_box = self.make_advanced_box()

        text_frame = self.make_text_view()

        # Time/Date on the left, Text on the right
        hbox = g.HBox(FALSE, 0)
        self.vbox.pack_start(hbox, TRUE, TRUE, 0)

        self.vbox.pack_start(self.advanced_box, FALSE, TRUE, 0)

        # Date above time
        vbox = g.VBox(FALSE, 0)
        hbox.pack_start(vbox, FALSE, TRUE, 0)
        vbox.set_border_width(4)
        vbox.pack_start(self.cal, FALSE, TRUE, 0)

        spacer = g.Alignment()
        vbox.pack_start(spacer, FALSE, TRUE, 2)

        vbox.pack_start(at_box, FALSE, TRUE, 0)

        hbox.pack_start(text_frame, TRUE, TRUE, 0)

        self.vbox.show_all()

        if memo:
            buffer = self.text.get_buffer()
            try:
                buffer.insert_at_cursor(memo.message)
            except TypeError:
                buffer.insert_at_cursor(memo.message, -1)
        if memo and memo.at:
            self.at.set_active(TRUE)
            self.at.set_label(_('At'))
            self.advanced_box.set_sensitive(TRUE)
        if memo == None or memo.at == 0:
            self.at_box.hide()
            self.at.set_label(_('At') + "...")
            self.advanced_box.set_sensitive(FALSE)
        if memo:
            if memo.nosound:
                self.sound_choice.set_active(2)
            elif memo.soundfile is not None and memo.soundfile != "":
                self.sound_choice.set_active(1)
                self.sound_entry.set_filename(memo.soundfile)
                self.sound_entry.set_sensitive(TRUE)
            else:
                self.sound_choice.set_active(0)

        self.connect('response', self.response)
        self.text.grab_focus()
        self.set_default_response(g.RESPONSE_YES)

        self.connect('destroy', lambda w: refleak_bug_workaround.remove(self))
        refleak_bug_workaround.append(self)
Ejemplo n.º 20
0
    def build_varlist(self, node, label, option):
        """<varlist name='...' label='...' edit='yes|no' extend='yes|no' selection='single|none|multiple'>Tooltip</varlist>"""
        edit = bool_attr(node, 'edit')
        reorder = bool_attr(node, 'reorder')
        extend = bool_attr(node, 'extend')
        select = str_attr(node, 'selection', 'single')

        cont = rox.g.VBox(False, 4)
        cont._rox_lib_expand = True

        if label:
            label_wid = rox.g.Label(label)
            cont.pack_start(label_wid, False, True, 0)
            label_wid.show()

        swin = g.ScrolledWindow()
        swin.set_border_width(4)
        swin.set_policy(g.POLICY_NEVER, g.POLICY_ALWAYS)
        swin.set_shadow_type(g.SHADOW_IN)
        #swin.set_size_request(-1, 128)
        cont.pack_start(swin, True, True, 0)

        model = g.ListStore(str, str)
        view = g.TreeView(model)
        swin.add(view)

        selection = view.get_selection()
        if select == 'none':
            selection.set_mode(g.SELECTION_NONE)
        elif select == 'multiple':
            selection.set_mode(g.SELECTION_MULTIPLE)
        else:
            selection.set_mode(g.SELECTION_SINGLE)
            select = 'single'

        if reorder:
            view.set_reorderable(True)

        def cell_edited(ell, path, new_text, col):
            if col == 0 and new_text.find('=') >= 0:
                return
            iter = model.get_iter_from_string(path)
            model.set(iter, col, new_text)
            self.check_widget(option)

        cell = g.CellRendererText()
        column = g.TreeViewColumn('Variable', cell, text=0)
        view.append_column(column)
        if edit:
            cell.set_property('editable', True)
            cell.connect('edited', cell_edited, 0)

        cell = g.CellRendererText()
        column = g.TreeViewColumn('Value', cell, text=1)
        view.append_column(column)
        if edit:
            cell.set_property('editable', True)
            cell.connect('edited', cell_edited, 1)

        def add(widget, box):
            iter = model.append()
            model.set(iter, 0, 'newvar', 1, 'new value')
            if select == 'single':
                view.get_selection().select_iter(iter)
            box.check_widget(option)

        if extend:
            hbox = g.HBox(False, 2)
            cont.pack_start(hbox, False)

            but = g.Button(stock=g.STOCK_ADD)
            but.connect('clicked', add, self)
            hbox.pack_start(but, False)

        self.may_add_tip(swin, node)

        def get():
            v = []
            iter = model.get_iter_first()
            while iter:
                var = model.get_value(iter, 0)
                val = model.get_value(iter, 1)
                v.append(var + '=' + val)

                iter = model.iter_next(iter)
            return v

        def set():
            model.clear()
            for v in option.list_value:
                var, val = v.split('=', 1)
                iter = model.append()
                model.set(iter, 0, var, 1, val)

        self.handlers[option] = (get, set)

        return [cont]
Ejemplo n.º 21
0
    def __init__(self, vertical=False):
        rox.setup_app_options("Weather", 'Options.xml', "dtomas")
        self.o_update_interval = options.Option("update_interval", 15)
        self.o_location = options.Option("location_code",
                                         "GMXX0049 (Hamburg, Germany)")
        self.o_units = options.Option("units", "m")
        self.o_forecast_days = options.Option("forecast_days", 4)
        rox.app_options.notify()

        self.forecast_window = None

        if vertical:
            box = g.VBox()
        else:
            box = g.HBox()
        self.image = g.Image()
        self.label = g.Label("n.a.")

        box.pack_start(self.image)
        box.pack_start(self.label)
        box.set_border_width(2)
        self.add(box)

        self.size = 0
        self.set_image('-')

        self.menu = g.Menu()

        self.weather = Weather()

        item = g.ImageMenuItem(g.STOCK_HELP)
        item.connect("activate", self.show_help)
        self.menu.add(item)

        item = g.ImageMenuItem(g.STOCK_DIALOG_INFO)
        item.connect("activate", self.show_info)
        self.menu.add(item)

        self.menu.append(g.SeparatorMenuItem())

        item = g.ImageMenuItem(_("Forecast"))
        item.get_image().set_from_file(
            os.path.join(rox.app_dir, 'icons', 'forecast.png'))
        item.connect("activate", self.show_forecast)
        self.menu.append(item)

        item = g.ImageMenuItem(g.STOCK_REFRESH)
        item.connect("activate", self.update_now)
        self.menu.append(item)

        self.menu.append(g.SeparatorMenuItem())

        item = g.ImageMenuItem(g.STOCK_PREFERENCES)
        item.connect("activate", self.show_options)
        self.menu.append(item)

        self.menu.append(g.SeparatorMenuItem())

        item = g.ImageMenuItem(g.STOCK_QUIT)
        item.connect("activate", self.quit)
        self.menu.append(item)

        self.menu.show_all()

        self.add_events(g.gdk.BUTTON_PRESS_MASK)
        self.connect("button-press-event", self.button_pressed)
        self.connect("destroy", self.destroyed)

        rox.app_options.add_notify(self.options_changed)
        self.image_resizing = False
        tooltips.set_tip(self, 'n.a.')

        self.update_event = 0

        self.connect('size-allocate', self.size_allocate)
        self.connect_after('map-event', self.map_event)
Ejemplo n.º 22
0
    def __init__(self):
        g.Dialog.__init__(self)
        self.set_title(_('All memos'))
        self.set_has_separator(FALSE)

        self.add_button(g.STOCK_CLOSE, g.RESPONSE_CANCEL)

        frame = g.Frame()
        self.vbox.pack_start(frame, TRUE, TRUE, 0)
        frame.set_shadow_type(g.SHADOW_IN)

        hbox = g.HBox(FALSE, 0)
        frame.add(hbox)

        scroll = g.VScrollbar()
        hbox.pack_end(scroll, FALSE, TRUE, 0)

        self.list = g.TreeView(memo_list)
        hbox.pack_start(self.list, TRUE, TRUE, 0)
        self.list.set_scroll_adjustments(None, scroll.get_adjustment())
        self.list.set_size_request(-1, 12)
        self.set_default_size(-1, 300)

        text = g.CellRendererText()

        toggle = g.CellRendererToggle()
        column = g.TreeViewColumn(_('Hide'), toggle, active=memos.HIDDEN)
        self.list.append_column(column)
        toggle.connect('toggled',
                       lambda t, path: memo_list.toggle_hidden(path))

        column = g.TreeViewColumn(_('Time'), text, text=memos.TIME)
        self.list.append_column(column)

        column = g.TreeViewColumn(_('Message'), text, text=memos.BRIEF)
        self.list.append_column(column)

        self.list.set_headers_visible(TRUE)

        sel = self.list.get_selection()
        sel.set_mode(g.SELECTION_MULTIPLE)

        def activate(view, path, column):
            memo = memo_list.get_memo_by_path(path)
            from EditBox import EditBox
            EditBox(memo).show()

        self.add_events(g.gdk.BUTTON_PRESS_MASK)
        self.list.connect('row-activated', activate)

        self.connect('response', self.response)

        self.set_default_response(g.RESPONSE_CANCEL)

        actions = g.HButtonBox()
        self.vbox.pack_start(actions, FALSE, TRUE, 0)
        actions.set_layout(g.BUTTONBOX_END)
        actions.set_border_width(5)
        actions.set_spacing(4)

        def new(b):
            from EditBox import EditBox
            EditBox().show()

        button = g.Button(stock=g.STOCK_NEW)
        actions.add(button)
        button.connect('clicked', new)

        def delete(b):
            sel = self.list.get_selection()
            memos = []
            for iter in memo_list:
                if sel.iter_is_selected(iter):
                    m = memo_list.get_memo_by_iter(iter)
                    memos.append(m)
            if not memos:
                rox.alert(_('You need to select some memos first!'))
                return
            l = len(memos)
            if l == 1:
                message = _("Really delete memo '%s'?") % memos[0].brief
            else:
                message = _('Really delete %d memos?') % l

            box = g.MessageDialog(None, 0, g.MESSAGE_QUESTION,
                                  g.BUTTONS_CANCEL, message)

            if rox.confirm(message, g.STOCK_DELETE):
                for m in memos:
                    memo_list.delete(m, update=0)
                memo_list.notify_changed()

        button = g.Button(stock=g.STOCK_DELETE)
        actions.add(button)
        button.connect('clicked', delete)

        def edit(b):
            sel = self.list.get_selection()
            memos = []
            for iter in memo_list:
                if sel.iter_is_selected(iter):
                    m = memo_list.get_memo_by_iter(iter)
                    memos.append(m)
            if len(memos) != 1:
                rox.alert(_('You need to select exactly one memo first!'))
                return
            from EditBox import EditBox
            EditBox(memos[0]).show()

        button = rox.ButtonMixed(g.STOCK_PROPERTIES, _('_Edit'))
        actions.add(button)
        button.connect('clicked', edit)

        self.show_all()
Ejemplo n.º 23
0
	def __init__(self, tb):
		g.Frame.__init__(self, _('Stack trace (innermost last)'))

		vbox = g.VBox(False, 0)
		self.add(vbox)

		inner = g.Frame()
		inner.set_shadow_type(g.SHADOW_IN)
		vbox.pack_start(inner, False, True, 0)

		self.savebox = None

		self.tb = tb
		
		self.model = g.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT,
					 gobject.TYPE_STRING, gobject.TYPE_STRING,
					 gobject.TYPE_STRING)
		tree = g.TreeView(self.model)
		inner.add(tree)

		cell = g.CellRendererText()

		column = g.TreeViewColumn('File', cell, text = ExceptionExplorer.LEAF)
		cell.set_property('xalign', 1)
		tree.append_column(column)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Line', cell, text = ExceptionExplorer.LINE)
		tree.append_column(column)
		column = g.TreeViewColumn('Func', cell, text = ExceptionExplorer.FUNC)
		tree.append_column(column)
		column = g.TreeViewColumn('Code', cell, text = ExceptionExplorer.CODE)
		tree.append_column(column)

		inner.set_border_width(5)

		frames = []
		while tb is not None:
			frames.insert(0, (tb.tb_frame, traceback.tb_lineno(tb)))
			tb = tb.tb_next
		f = self.tb.tb_frame
		if f:
			f = f.f_back	# Skip the reporting frame
		while f is not None:
			frames.append((f, f.f_lineno))
			f = f.f_back

		frames.reverse()

		new = None
		for f, lineno in frames:
			co = f.f_code
			filename = co.co_filename
			name = co.co_name
			line = linecache.getline(filename, lineno).strip()

			leafname = os.path.basename(filename)
			
			new = self.model.append()
			self.model.set(new, ExceptionExplorer.LEAF, leafname,
					    ExceptionExplorer.LINE, lineno,
					    ExceptionExplorer.FUNC, name,
					    ExceptionExplorer.CODE, line,
					    ExceptionExplorer.FILE, filename)

		def selected_frame():
			selected = sel.get_selected()
			assert selected
			model, titer = selected
			frame, = model.get_path(titer)
			return frames[frame][0]

		vars = g.ListStore(str, str)
		sel = tree.get_selection()
		sel.set_mode(g.SELECTION_BROWSE)
		def select_frame(tree):
			vars.clear()
			for n, v in selected_frame().f_locals.iteritems():
				value = `v`
				if len(value) > 500:
					value = value[:500] + ' ...'
				new = vars.append()
				vars.set(new, 0, str(n), 1, value)
		sel.connect('changed', select_frame)
		def show_source(tree, path, column):
			line = self.model[path][ExceptionExplorer.LINE]
			file = self.model[path][ExceptionExplorer.FILE]
			import launch
			launch.launch('http://rox.sourceforge.net/2005/interfaces/Edit',
					'-l%d' % line, file)
			
		tree.connect('row-activated', show_source)

		# Area to show the local variables
		tree = g.TreeView(vars)

		vbox.pack_start(g.Label(_('Local variables in selected frame:')),
				False, True, 0)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Name', cell, text = 0)
		cell.set_property('xalign', 1)
		tree.append_column(column)
		cell = g.CellRendererText()
		column = g.TreeViewColumn('Value', cell, text = 1)
		tree.append_column(column)

		inner = g.ScrolledWindow()
		inner.set_size_request(-1, 200)
		inner.set_policy(g.POLICY_AUTOMATIC, g.POLICY_ALWAYS)
		inner.set_shadow_type(g.SHADOW_IN)
		inner.add(tree)
		inner.set_border_width(5)
		vbox.pack_start(inner, True, True, 0)

		if new:
			sel.select_iter(new)

		hbox = g.HBox(False, 4)
		hbox.set_border_width(5)
		vbox.pack_start(hbox, False, True, 0)
		hbox.pack_start(g.Label('>>>'), False, True, 0)

		expr = g.Entry()
		hbox.pack_start(expr, True, True, 0)
		def activate(entry):
			expr = entry.get_text()
			frame = selected_frame()
			try:
				info(`eval(expr, frame.f_locals, frame.f_globals)`)
			except:
				extype, value = sys.exc_info()[:2]
				brief = ''.join(traceback.format_exception_only(extype, value))
				alert(brief)
			entry.grab_focus()
		expr.connect('activate', activate)

		vbox.show_all()
Ejemplo n.º 24
0
	def __init__(self, memo_list):
		rox.Window.__init__(self)
		MenuWindow.__init__(self)
		self.set_wmclass('Memo', 'Memo')
		self.set_title('Memo')
		self.set_resizable(False)
		if hasattr(self, 'set_deletable'):
			self.set_deletable(False)
		#self.set_type_hint(g.gdk.WINDOW_TYPE_HINT_DIALOG)

		self.tips = g.Tooltips()

		if main_sticky.int_value:
			self.stick()

		self.memo_list = memo_list
		self.last_day = None
		self.prime_in_progress = False

		vbox = g.VBox(FALSE, 0)
		self.add(vbox)

		hbox = g.HBox(False, 0)
		vbox.pack_start(hbox, expand = False)

		self.time_label = g.Label('')
		self.time_button = g.Button()
		self.time_button.add(self.time_label)
		self.time_button.unset_flags(g.CAN_FOCUS)
		hbox.pack_start(self.time_button, expand = True)

		hbox.pack_start(timer.TimerButton(), expand = False)

		self.list = g.TreeView(memo_list.visible)
		vbox.pack_start(self.list, expand = TRUE)
		self.list.unset_flags(g.CAN_FOCUS)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Time', cell, text = 0)
		cell.set_property('xalign', 1)
		self.list.append_column(column)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Message', cell, text = 1)
		self.list.append_column(column)

		self.list.set_headers_visible(FALSE)
		
		sel = self.list.get_selection()
		sel.set_mode(g.SELECTION_NONE)

		def activate(view, path, column):
			memo = memo_list.visible.get_memo_by_path(path)
			from EditBox import EditBox
			EditBox(memo).show()
		
		self.add_events(g.gdk.BUTTON_PRESS_MASK)
		self.list.connect('button-press-event', self.button_press)
		self.list.connect('row-activated', activate)
		self.time_button.add_events(g.gdk.BUTTON1_MOTION_MASK)
		self.time_button.connect('button-press-event', self.button_press)
		self.time_button.connect('motion-notify-event', self.button_motion)
		self.time_button.connect('clicked', self.time_button_clicked)

		self.update()
		gobject.timeout_add(10000, self.update)	# Update clock

		self.timeout = None	# For next alarm
		self.alert_box = None
		self.show_all_box = None
		self.save_box = None
		self.prime()

		# If we had more than one window, we'd need a remove too...
		memo_list.connect("MemoListChanged", self.prime)
		app_options.add_notify(self.options_changed)
		
		vbox.show_all()
Ejemplo n.º 25
0
 def build_hbox(self, node, label):
     """<hbox>...</hbox> to layout child widgets horizontally."""
     return self.do_box(node, label, g.HBox(False, 4))