예제 #1
0
파일: EditBox.py 프로젝트: rox-desktop/memo
    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
예제 #2
0
    def __init__(self):
        self.tooltip = g.Tooltips()
        if tip.value == "": self.tooltip.disable()
        self.vbox = g.VBox(spacing=2)

        self.line1_label = g.Label("")
        if line1.value != "":
            self.vbox.add(self.line1_label)

        self.line2_label = g.Label("")
        if line2.value != "":
            self.vbox.add(self.line2_label)

        self.set_border_width(5)
        self.add(self.vbox)

        rox.app_options.add_notify(self.options_changed)

        self.add_events(g.gdk.BUTTON_PRESS_MASK)
        self.connect("button-press-event", self.button_press)

        self.connect("destroy", self.destroyed)

        self.update_clock()
        self.timeout = gobject.timeout_add(1000, self.update_clock)

        self.show_all()
예제 #3
0
파일: timer.py 프로젝트: rox-desktop/memo
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()
예제 #4
0
    def build_section(self, section, parent):
        """Create a new page for the notebook and a new entry in the
		sections tree, and build all the widgets inside the page."""
        page = g.VBox(False, 4)
        page.set_border_width(4)
        self.notebook.append_page(page, g.Label('unused'))

        iter = self.sections.append(parent)
        self.sections.set(iter, 0, self._(section.getAttribute('title')), 1,
                          self.notebook.page_num(page))
        for node in section.childNodes:
            if node.nodeType != Node.ELEMENT_NODE:
                continue
            name = node.localName
            if name == 'section':
                self.build_section(node, iter)
            else:
                self.build_widget(node, page)
        page.show_all()
예제 #5
0
    def build_frame(self, node, label):
        """<frame label='Title'>...</frame> to group options under a heading."""
        frame = g.Frame(label)
        frame.set_shadow_type(g.SHADOW_NONE)

        # Make the label bold...
        # (bug in pygtk => use set_markup)
        label_widget = frame.get_label_widget()
        label_widget.set_markup('<b>' + label + '</b>')
        #attr = pango.AttrWeight(pango.WEIGHT_BOLD)
        #attr.start_index = 0
        #attr.end_index = -1
        #list = pango.AttrList()
        #list.insert(attr)
        #label_widget.set_attributes(list)

        vbox = g.VBox(False, 4)
        vbox.set_border_width(12)
        frame.add(vbox)

        self.do_box(node, None, vbox)

        return [frame]
예제 #6
0
파일: EditBox.py 프로젝트: rox-desktop/memo
    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
예제 #7
0
파일: EditBox.py 프로젝트: rox-desktop/memo
    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)
예제 #8
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)
예제 #9
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()
예제 #10
0
 def build_vbox(self, node, label):
     """<vbox>...</vbox> to layout child widgets vertically."""
     return self.do_box(node, label, g.VBox(False, 0))
예제 #11
0
파일: Window.py 프로젝트: rox-desktop/memo
	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()
예제 #12
0
    def build_fixedlist(self, node, label, option):
        """<fixedlist name='...' label='...' selection='single|none|multiple'>Tooltip<listitem label='...'/><listitem label='...'/></fixedlist>"""
        select = str_attr(node, 'selection', 'single')

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

        if label:
            label_wid = 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)
        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'

        def sel_changed(sel, box):
            box.check_widget(option)

        selection.connect('changed', sel_changed, self)

        cell = g.CellRendererText()
        column = g.TreeViewColumn('', cell, text=0)
        view.append_column(column)

        for item in node.getElementsByTagName('listitem'):
            label = item.getAttribute('label')
            iter = model.append()
            model.set(iter, 0, label)

        self.may_add_tip(swin, node)

        def make_sel(model, path, iter, l):
            l.append(str(model.get_value(iter, 0)))

        def get():
            mode = view.get_selection().get_mode()
            if mode == int(g.SELECTION_NONE):
                return []
            elif mode == int(g.SELECTION_SINGLE):
                model, iter = view.get_selection().get_selected()
                return [str(model.get_value(iter, 0))]

            v = []
            view.get_selection().selected_foreach(make_sel, v)
            return v

        def set():
            sel = view.get_selection()
            mode = sel.get_mode()
            sel.unselect_all()
            for v in option.list_value:
                iter = model.get_iter_first()
                while iter:
                    if v == model.get_value(iter, 0):
                        sel.select_iter(iter)
                        break

                    iter = model.iter_next(iter)

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

        return [cont]