Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo n.º 5
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]
Exemplo n.º 6
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]