Пример #1
0
    def __init__(self, model):
        InsertedObjectWidget.__init__(self)
        self.textarea_width = 0
        self.model = model

        # used in pageview
        self._has_cursor = False  # Skip table object, if someone moves cursor around in textview

        # used here
        self._timer = None  # NONE or number of current GObject.timer, which is running
        self._keep_toolbar_open = False  # a cell is currently edited, toolbar should not be hidden
        self._cellinput_canceled = None  # cell changes should be skipped
        self._toolbar_enabled = True  # sets if toolbar should be shown beneath a selected table

        # Toolbar for table actions
        self.toolbar = self.create_toolbar()
        self.toolbar.show_all()
        self.toolbar.set_no_show_all(True)
        self.toolbar.hide()

        # Create treeview
        self._init_treeview(model)

        # package gui elements
        self.vbox = Gtk.VBox()
        self.add(self.vbox)
        self.vbox.pack_end(self.toolbar, True, True, 0)
        self.scroll_win = ScrolledWindow(self.treeview, Gtk.PolicyType.NEVER,
                                         Gtk.PolicyType.NEVER,
                                         Gtk.ShadowType.NONE)
        self.vbox.pack_start(self.scroll_win, True, True, 0)

        # signals
        model.connect('model-changed', self.on_model_changed)
Пример #2
0
    def __init__(self, buffer):
        InsertedObjectWidget.__init__(self)
        self.set_has_cursor(True)
        self.buffer = buffer
        self.buffer.object_attrib.connect('changed', self.on_attrib_changed)

        self.view = GtkSource.View()
        self.view.set_buffer(self.buffer)
        self.view.modify_font(Pango.FontDescription('monospace'))
        self.view.set_auto_indent(True)
        self.view.set_smart_home_end(True)
        self.view.set_highlight_current_line(True)
        self.view.set_right_margin_position(80)
        self.view.set_show_right_margin(True)
        self.view.set_tab_width(4)
        self.view.set_show_line_numbers(buffer.object_attrib['linenumbers'])

        # simple toolbar
        #~ bar = Gtk.HBox() # FIXME: use Gtk.Toolbar stuff
        #~ lang_selector = Gtk.ComboBoxText()
        #~ lang_selector.append_text('(None)')
        #~ for l in lang_names: lang_selector.append_text(l)
        #~ try:
        #~ lang_selector.set_active(lang_ids.index(self._attrib['lang'])+1)
        #~ self.set_language(self._attrib['lang'] or None, False)
        #~ except (ValueError, KeyError):
        #~ lang_selector.set_active(0)
        #~ self.set_language(None, False)
        #~ lang_selector.connect('changed', self.on_lang_changed)
        #~ bar.pack_start(lang_selector, False, False)

        #~ line_numbers = Gtk.ToggleButton('Line numbers')
        #~ try:
        #~ line_numbers.set_active(self._attrib['linenumbers']=='true')
        #~ self.show_line_numbers(self._attrib['linenumbers'], False)
        #~ except (ValueError, KeyError):
        #~ line_numbers.set_active(True)
        #~ self.show_line_numbers(True, False)
        #~ line_numbers.connect('toggled', self.on_line_numbers_toggled)
        #~ bar.pack_start(line_numbers, False, False)

        # TODO: other toolbar options
        # TODO: autohide toolbar if textbuffer is not active

        # Pack everything
        #~ self.add_header(bar)
        win = ScrolledWindow(self.view, Gtk.PolicyType.AUTOMATIC,
                             Gtk.PolicyType.NEVER, Gtk.ShadowType.NONE)
        self.add(win)

        # Hook up signals
        self._init_signals()
        self.view.connect('populate-popup', self.on_populate_popup)
Пример #3
0
    def __init__(self, model):

        InsertedObjectWidget.__init__(self)
        self.model = model
        self.cont = Gtk.HBox()
        link = Gtk.LinkButton(label="Previous")
        link.connect('button-press-event', self.on_button_press_event)
        self.cont.add(link)
        self.cont.add(Gtk.LinkButton(label="This"))
        self.cont.add(Gtk.LinkButton(label="Advance"))

        self.add(self.cont)

        # signals
        model.connect('model-changed', self.on_model_changed)