Esempio n. 1
0
File: vcview.py Progetto: thics/meld
    def __init__(self):
        melddoc.MeldDoc.__init__(self)
        gnomeglade.Component.__init__(self, "vcview.ui", "vcview",
                                      ["VcviewActions", 'liststore_vcs'])
        bind_settings(self)

        self.ui_file = gnomeglade.ui_file("vcview-ui.xml")
        self.actiongroup = self.VcviewActions
        self.actiongroup.set_translation_domain("meld")
        self.model = VcTreeStore()
        self.widget.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self.widget)
        self.treeview.set_model(self.model)
        self.treeview.get_selection().connect(
            "changed", self.on_treeview_selection_changed)
        self.treeview.set_search_equal_func(
            self.model.treeview_search_cb, None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.name_column.set_attributes(
            self.emblem_renderer,
            icon_name=tree.COL_ICON,
            icon_tint=tree.COL_TINT)
        self.name_column.set_attributes(
            self.name_renderer,
            text=tree.COL_TEXT,
            foreground_rgba=tree.COL_FG,
            style=tree.COL_STYLE,
            weight=tree.COL_WEIGHT,
            strikethrough=tree.COL_STRIKE)
        self.location_column.set_attributes(
            self.location_renderer, markup=COL_LOCATION)
        self.status_column.set_attributes(
            self.status_renderer, markup=COL_STATUS)
        self.extra_column.set_attributes(
            self.extra_renderer, markup=COL_OPTIONS)
        self.location_column.bind_property(
            'visible', self.actiongroup.get_action("VcFlatten"), 'active')

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.vc = None

        settings.bind('vc-console-visible',
                      self.actiongroup.get_action('VcConsoleVisible'),
                      'active', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)

        for s in self.props.status_filters:
            if s in self.state_actions:
                self.actiongroup.get_action(
                    self.state_actions[s][0]).set_active(True)
Esempio n. 2
0
File: vcview.py Progetto: zbyna/meld
    def __init__(self):
        melddoc.MeldDoc.__init__(self)
        gnomeglade.Component.__init__(self, "vcview.ui", "vcview",
                                      ["VcviewActions", 'liststore_vcs'])
        bind_settings(self)

        self.ui_file = gnomeglade.ui_file("vcview-ui.xml")
        self.actiongroup = self.VcviewActions
        self.actiongroup.set_translation_domain("meld")
        self.model = VcTreeStore()
        self.widget.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self.widget)
        self.treeview.set_model(self.model)
        self.treeview.get_selection().connect(
            "changed", self.on_treeview_selection_changed)
        self.treeview.set_search_equal_func(self.model.treeview_search_cb,
                                            None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.name_column.set_attributes(self.emblem_renderer,
                                        icon_name=tree.COL_ICON,
                                        icon_tint=tree.COL_TINT)
        self.name_column.set_attributes(self.name_renderer,
                                        text=tree.COL_TEXT,
                                        foreground_rgba=tree.COL_FG,
                                        style=tree.COL_STYLE,
                                        weight=tree.COL_WEIGHT,
                                        strikethrough=tree.COL_STRIKE)
        self.location_column.set_attributes(self.location_renderer,
                                            markup=COL_LOCATION)
        self.status_column.set_attributes(self.status_renderer,
                                          markup=COL_STATUS)
        self.extra_column.set_attributes(self.extra_renderer,
                                         markup=COL_OPTIONS)
        self.location_column.bind_property(
            'visible', self.actiongroup.get_action("VcFlatten"), 'active')

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.vc = None

        settings.bind('vc-console-visible',
                      self.actiongroup.get_action('VcConsoleVisible'),
                      'active', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)

        for s in self.props.status_filters:
            if s in self.state_actions:
                self.actiongroup.get_action(
                    self.state_actions[s][0]).set_active(True)
Esempio n. 3
0
    def __init__(self, parent):
        super().__init__()

        self.set_transient_for(parent.get_toplevel())
        selected = parent._get_selected_files()

        try:
            to_commit = parent.vc.get_files_to_commit(selected)
            topdir = parent.vc.root
            if to_commit:
                to_commit = ["\t" + s for s in to_commit]
            else:
                to_commit = ["\t" + _("No files will be committed")]
        except NotImplementedError:
            topdir = os.path.dirname(os.path.commonprefix(selected))
            to_commit = ["\t" + s[len(topdir) + 1:] for s in selected]
        self.changedfiles.set_text("(in %s)\n%s" %
                                   (topdir, "\n".join(to_commit)))

        font = get_meld_settings().font

        self.textview.modify_font(font)
        commit_prefill = parent.vc.get_commit_message_prefill()
        if commit_prefill:
            buf = self.textview.get_buffer()
            buf.set_text(commit_prefill)
            buf.place_cursor(buf.get_start_iter())

        # Try and make the textview wide enough for a standard 80-character
        # commit message.
        context = self.textview.get_pango_context()
        metrics = context.get_metrics(None, None)
        char_width = metrics.get_approximate_char_width() / Pango.SCALE
        width_request, height_request = self.scrolledwindow1.get_size_request()
        self.scrolledwindow1.set_size_request(80 * char_width, height_request)

        settings.bind('vc-show-commit-margin', self.textview,
                      'show-right-margin', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-commit-margin', self.textview,
                      'right-margin-position', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-break-commit-message', self, 'break-commit-message',
                      Gio.SettingsBindFlags.DEFAULT)
        self.show_all()
Esempio n. 4
0
    def __init__(self, parent):
        super().__init__()
        self.init_template()

        self.set_transient_for(parent.get_toplevel())
        selected = parent._get_selected_files()

        try:
            to_commit = parent.vc.get_files_to_commit(selected)
            topdir = parent.vc.root
            if to_commit:
                to_commit = ["\t" + s for s in to_commit]
            else:
                to_commit = ["\t" + _("No files will be committed")]
        except NotImplementedError:
            topdir = os.path.dirname(os.path.commonprefix(selected))
            to_commit = ["\t" + s[len(topdir) + 1:] for s in selected]
        self.changedfiles.set_text("(in %s)\n%s" %
                                   (topdir, "\n".join(to_commit)))

        self.textview.modify_font(meldsettings.font)
        commit_prefill = parent.vc.get_commit_message_prefill()
        if commit_prefill:
            buf = self.textview.get_buffer()
            buf.set_text(commit_prefill)
            buf.place_cursor(buf.get_start_iter())

        # Try and make the textview wide enough for a standard 80-character
        # commit message.
        context = self.textview.get_pango_context()
        metrics = context.get_metrics(meldsettings.font,
                                      context.get_language())
        char_width = metrics.get_approximate_char_width() / Pango.SCALE
        self.scrolledwindow1.set_size_request(80 * char_width, -1)

        settings.bind('vc-show-commit-margin', self.textview,
                      'show-right-margin', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-commit-margin', self.textview,
                      'right-margin-position', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-break-commit-message', self,
                      'break-commit-message', Gio.SettingsBindFlags.DEFAULT)
        self.show_all()
Esempio n. 5
0
 def bind_to(self, key):
     settings.bind(
         key, self, 'gsettings-value', Gio.SettingsBindFlags.DEFAULT)
Esempio n. 6
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.init_template()

        bindings = [
            ('use-system-font', self.checkbutton_default_font, 'active'),
            ('custom-font', self.fontpicker, 'font'),
            ('indent-width', self.spinbutton_tabsize, 'value'),
            ('insert-spaces-instead-of-tabs',
             self.checkbutton_spaces_instead_of_tabs, 'active'),  # noqa: E501
            ('highlight-current-line', self.checkbutton_highlight_current_line,
             'active'),  # noqa: E501
            ('show-line-numbers', self.checkbutton_show_line_numbers,
             'active'),  # noqa: E501
            ('highlight-syntax', self.checkbutton_use_syntax_highlighting,
             'active'),  # noqa: E501
            ('use-system-editor', self.system_editor_checkbutton, 'active'),
            ('custom-editor-command', self.custom_edit_command_entry, 'text'),
            ('folder-shallow-comparison', self.checkbutton_shallow_compare,
             'active'),  # noqa: E501
            ('folder-filter-text', self.checkbutton_folder_filter_text,
             'active'),  # noqa: E501
            ('folder-ignore-symlinks', self.checkbutton_ignore_symlinks,
             'active'),  # noqa: E501
            ('vc-show-commit-margin', self.checkbutton_show_commit_margin,
             'active'),  # noqa: E501
            ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
            ('vc-break-commit-message', self.checkbutton_break_commit_lines,
             'active'),  # noqa: E501
            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines,
             'active'),  # noqa: E501
            # Sensitivity bindings must come after value bindings, or the key
            # writability in gsettings overrides manual sensitivity setting.
            ('vc-show-commit-margin', self.spinbutton_commit_margin,
             'sensitive'),  # noqa: E501
            ('vc-show-commit-margin', self.checkbutton_break_commit_lines,
             'sensitive'),  # noqa: E501
        ]
        for key, obj, attribute in bindings:
            settings.bind(key, obj, attribute, Gio.SettingsBindFlags.DEFAULT)

        invert_bindings = [
            ('use-system-editor', self.custom_edit_command_entry, 'sensitive'),
            ('use-system-font', self.fontpicker, 'sensitive'),
            ('folder-shallow-comparison', self.checkbutton_folder_filter_text,
             'sensitive'),  # noqa: E501
        ]
        for key, obj, attribute in invert_bindings:
            settings.bind(
                key, obj, attribute, Gio.SettingsBindFlags.DEFAULT
                | Gio.SettingsBindFlags.INVERT_BOOLEAN)

        self.checkbutton_wrap_text.bind_property('active',
                                                 self.checkbutton_wrap_word,
                                                 'sensitive',
                                                 GObject.BindingFlags.DEFAULT)

        # TODO: Fix once bind_with_mapping is available
        self.checkbutton_show_whitespace.set_active(
            bool(settings.get_flags('draw-spaces')))

        wrap_mode = settings.get_enum('wrap-mode')
        self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
        self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)

        filefilter = FilterList(
            filter_type=FilterEntry.SHELL,
            settings_key="filename-filters",
        )
        self.file_filters_vbox.pack_start(filefilter, True, True, 0)

        textfilter = FilterList(
            filter_type=FilterEntry.REGEX,
            settings_key="text-filters",
        )
        self.text_filters_vbox.pack_start(textfilter, True, True, 0)

        columnlist = ColumnList(settings_key="folder-columns")
        self.column_list_vbox.pack_start(columnlist, True, True, 0)

        self.combo_timestamp.bind_to('folder-time-resolution')
        self.combo_file_order.bind_to('vc-left-is-local')
        self.combo_merge_order.bind_to('vc-merge-file-order')

        # Fill color schemes
        manager = GtkSource.StyleSchemeManager.get_default()
        for scheme_id in manager.get_scheme_ids():
            scheme = manager.get_scheme(scheme_id)
            self.syntaxschemestore.append([scheme_id, scheme.get_name()])
        self.combobox_style_scheme.bind_to('style-scheme')

        self.show()
Esempio n. 7
0
 def bind_to(self, key):
     settings.bind(key, self, 'gsettings-value',
                   Gio.SettingsBindFlags.DEFAULT)
Esempio n. 8
0
    def __init__(self):
        super().__init__("meldapp.ui", "meldapp")
        self.widget.set_name("meldapp")

        actions = (
            ("FileMenu", None, _("_File")),
            ("New", Gtk.STOCK_NEW, _("_New Comparison…"), "<Primary>N",
             _("Start a new comparison"), self.on_menu_file_new_activate),
            ("Save", Gtk.STOCK_SAVE, None, None, _("Save the current file"),
             self.on_menu_save_activate),
            ("SaveAs", Gtk.STOCK_SAVE_AS, _("Save As…"), "<Primary><shift>S",
             _("Save the current file with a different name"),
             self.on_menu_save_as_activate),
            ("Close", Gtk.STOCK_CLOSE, None, None, _("Close the current file"),
             self.on_menu_close_activate),
            ("EditMenu", None, _("_Edit")),
            ("Undo", Gtk.STOCK_UNDO, None, "<Primary>Z",
             _("Undo the last action"), self.on_menu_undo_activate),
            ("Redo", Gtk.STOCK_REDO, None, "<Primary><shift>Z",
             _("Redo the last undone action"), self.on_menu_redo_activate),
            ("Cut", Gtk.STOCK_CUT, None, None, _("Cut the selection"),
             self.on_menu_cut_activate),
            ("Copy", Gtk.STOCK_COPY, None, None, _("Copy the selection"),
             self.on_menu_copy_activate),
            ("Paste", Gtk.STOCK_PASTE, None, None, _("Paste the clipboard"),
             self.on_menu_paste_activate),
            ("Find", Gtk.STOCK_FIND, _("Find…"), None, _("Search for text"),
             self.on_menu_find_activate),
            ("FindNext", None, _("Find Ne_xt"), "<Primary>G",
             _("Search forwards for the same text"),
             self.on_menu_find_next_activate),
            ("FindPrevious", None, _("Find _Previous"), "<Primary><shift>G",
             _("Search backwards for the same text"),
             self.on_menu_find_previous_activate),
            ("Replace",
             Gtk.STOCK_FIND_AND_REPLACE, _("_Replace…"), "<Primary>H",
             _("Find and replace text"), self.on_menu_replace_activate),
            ("GoToLine", None, _("Go to _Line"), "<Primary>I",
             _("Go to a specific line"), self.on_menu_go_to_line_activate),
            ("ChangesMenu", None, _("_Changes")),
            ("NextChange", Gtk.STOCK_GO_DOWN, _("Next Change"), "<Alt>Down",
             _("Go to the next change"), self.on_menu_edit_down_activate),
            ("PrevChange", Gtk.STOCK_GO_UP, _("Previous Change"), "<Alt>Up",
             _("Go to the previous change"), self.on_menu_edit_up_activate),
            ("OpenExternal", None, _("Open Externally"), None,
             _("Open selected file or directory in the default external "
               "application"), self.on_open_external),
            ("ViewMenu", None, _("_View")),
            ("FileStatus", None, _("File Status")),
            ("VcStatus", None, _("Version Status")),
            ("FileFilters", None, _("File Filters")),
            ("Stop", Gtk.STOCK_STOP, None, "Escape",
             _("Stop the current action"), self.on_toolbar_stop_clicked),
            ("Refresh", Gtk.STOCK_REFRESH, None, "<Primary>R",
             _("Refresh the view"), self.on_menu_refresh_activate),
        )
        toggleactions = (
            ("Fullscreen", None, _("Fullscreen"), "F11",
             _("View the comparison in fullscreen"),
             self.on_action_fullscreen_toggled, False),
            ("ToolbarVisible", None, _("_Toolbar"), None,
             _("Show or hide the toolbar"), None, True),
        )
        self.actiongroup = Gtk.ActionGroup(name='MainActions')
        self.actiongroup.set_translation_domain("meld")
        self.actiongroup.add_actions(actions)
        self.actiongroup.add_toggle_actions(toggleactions)

        recent_action = Gtk.RecentAction(name="Recent",
                                         label=_("Open Recent"),
                                         tooltip=_("Open recent files"),
                                         stock_id=None)
        recent_action.set_show_private(True)
        recent_action.set_filter(recent_comparisons.recent_filter)
        recent_action.set_sort_type(Gtk.RecentSortType.MRU)
        recent_action.connect("item-activated", self.on_action_recent)
        self.actiongroup.add_action(recent_action)

        self.ui = Gtk.UIManager()
        self.ui.insert_action_group(self.actiongroup, 0)
        self.ui.add_ui_from_file(ui_file("meldapp-ui.xml"))

        # Manually handle shells that don't show an application menu
        gtk_settings = Gtk.Settings.get_default()
        if not gtk_settings.props.gtk_shell_shows_app_menu:
            from meld.meldapp import app

            def make_app_action(name):
                def app_action(*args):
                    app.lookup_action(name).activate(None)

                return app_action

            app_actions = (
                ("AppMenu", None, _("_Meld")),
                ("Quit", Gtk.STOCK_QUIT, None, None, _("Quit the program"),
                 make_app_action('quit')),
                ("Preferences", Gtk.STOCK_PREFERENCES, _("Prefere_nces"), None,
                 _("Configure the application"),
                 make_app_action('preferences')),
                ("Help", Gtk.STOCK_HELP, _("_Contents"), "F1",
                 _("Open the Meld manual"), make_app_action('help')),
                ("About", Gtk.STOCK_ABOUT, None, None,
                 _("About this application"), make_app_action('about')),
            )

            app_actiongroup = Gtk.ActionGroup(name="AppActions")
            app_actiongroup.set_translation_domain("meld")
            app_actiongroup.add_actions(app_actions)
            self.ui.insert_action_group(app_actiongroup, 0)

            self.ui.add_ui_from_file(ui_file("appmenu-fallback.xml"))
            self.widget.set_show_menubar(False)

        for menuitem in ("Save", "Undo"):
            self.actiongroup.get_action(menuitem).props.is_important = True
        self.widget.add_accel_group(self.ui.get_accel_group())
        self.menubar = self.ui.get_widget('/Menubar')
        self.toolbar = self.ui.get_widget('/Toolbar')
        self.toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        settings.bind('toolbar-visible',
                      self.actiongroup.get_action('ToolbarVisible'), 'active',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('toolbar-visible', self.toolbar, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        interface_settings.bind('toolbar-style', self.toolbar, 'toolbar-style',
                                Gio.SettingsBindFlags.DEFAULT)

        # Alternate keybindings for a few commands.
        extra_accels = (
            ("<Primary>D", self.on_menu_edit_down_activate),
            ("<Primary>E", self.on_menu_edit_up_activate),
            ("<Alt>KP_Down", self.on_menu_edit_down_activate),
            ("<Alt>KP_Up", self.on_menu_edit_up_activate),
            ("F5", self.on_menu_refresh_activate),
        )

        accel_group = self.ui.get_accel_group()
        for accel, callback in extra_accels:
            keyval, mask = Gtk.accelerator_parse(accel)
            accel_group.connect(keyval, mask, 0, callback)

        # Initialise sensitivity for important actions
        self.actiongroup.get_action("Stop").set_sensitive(False)
        self._update_page_action_sensitivity()

        self.appvbox.pack_start(self.menubar, False, True, 0)
        self.toolbar_holder.pack_start(self.toolbar, True, True, 0)

        # Double toolbars to work around UIManager integration issues
        self.secondary_toolbar = Gtk.Toolbar()
        self.secondary_toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
        self.toolbar_holder.pack_end(self.secondary_toolbar, False, True, 0)

        # Manually handle GAction additions
        actions = (("close", self.on_menu_close_activate, None), )
        for (name, callback, accel) in actions:
            action = Gio.SimpleAction.new(name, None)
            action.connect('activate', callback)
            self.widget.add_action(action)

        # Create a secondary toolbar, just to hold our progress spinner
        toolbutton = Gtk.ToolItem()
        self.spinner = Gtk.Spinner()
        # Fake out the spinner on Windows. See Gitlab issue #133.
        if os.name == 'nt':
            for attr in ('stop', 'hide', 'show', 'start'):
                setattr(self.spinner, attr, lambda *args: True)
        toolbutton.add(self.spinner)
        self.secondary_toolbar.insert(toolbutton, -1)
        # Set a minimum size because the spinner requests nothing
        self.secondary_toolbar.set_size_request(30, -1)
        self.secondary_toolbar.show_all()

        self.widget.drag_dest_set(
            Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT
            | Gtk.DestDefaults.DROP, None, Gdk.DragAction.COPY)
        self.widget.drag_dest_add_uri_targets()
        self.widget.connect("drag_data_received",
                            self.on_widget_drag_data_received)

        self.window_state = SavedWindowState()
        self.window_state.bind(self.widget)

        self.should_close = False
        self.idle_hooked = 0
        self.scheduler = LifoScheduler()
        self.scheduler.connect("runnable", self.on_scheduler_runnable)

        self.ui.ensure_update()
        self.diff_handler = None
        self.undo_handlers = tuple()
        self.widget.connect('focus_in_event', self.on_focus_change)
        self.widget.connect('focus_out_event', self.on_focus_change)

        # Set tooltip on map because the recentmenu is lazily created
        rmenu = self.ui.get_widget('/Menubar/FileMenu/Recent').get_submenu()
        rmenu.connect("map", self._on_recentmenu_map)

        builder = meld.ui.util.get_builder("shortcuts.ui")
        shortcut_window = builder.get_object("shortcuts-meld")
        self.widget.set_help_overlay(shortcut_window)
Esempio n. 9
0
    def __init__(self):
        super().__init__()
        # FIXME:
        # This unimaginable hack exists because GObject (or GTK+?)
        # doesn't actually correctly chain init calls, even if they're
        # not to GObjects. As a workaround, we *should* just be able to
        # put our class first, but because of Gtk.Template we can't do
        # that if it's a GObject, because GObject doesn't support
        # multiple inheritance and we need to inherit from our Widget
        # parent to make Template work.
        MeldDoc.__init__(self)
        self.init_template()
        bind_settings(self)

        # Set up per-view action group for top-level menu insertion
        self.view_action_group = Gio.SimpleActionGroup()

        property_actions = (('vc-console-visible', self.console_vbox,
                             'visible'), )
        for action_name, obj, prop_name in property_actions:
            action = Gio.PropertyAction.new(action_name, obj, prop_name)
            self.view_action_group.add_action(action)

        # Manually handle GAction additions
        actions = (
            ('compare', self.action_diff),
            ('find', self.action_find),
            ('next-change', self.action_next_change),
            ('open-external', self.action_open_external),
            ('previous-change', self.action_previous_change),
            ('refresh', self.action_refresh),
            ('vc-add', self.action_add),
            ('vc-commit', self.action_commit),
            ('vc-delete-locally', self.action_delete),
            ('vc-push', self.action_push),
            ('vc-remove', self.action_remove),
            ('vc-resolve', self.action_resolved),
            ('vc-revert', self.action_revert),
            ('vc-update', self.action_update),
        )
        for name, callback in actions:
            action = Gio.SimpleAction.new(name, None)
            action.connect('activate', callback)
            self.view_action_group.add_action(action)

        new_boolean = GLib.Variant.new_boolean
        stateful_actions = (
            ('vc-flatten', self.action_filter_state_change,
             new_boolean('flatten' in self.props.status_filters)),
            ('vc-status-modified', self.action_filter_state_change,
             new_boolean('modified' in self.props.status_filters)),
            ('vc-status-normal', self.action_filter_state_change,
             new_boolean('normal' in self.props.status_filters)),
            ('vc-status-unknown', self.action_filter_state_change,
             new_boolean('unknown' in self.props.status_filters)),
            ('vc-status-ignored', self.action_filter_state_change,
             new_boolean('ignored' in self.props.status_filters)),
        )
        for (name, callback, state) in stateful_actions:
            action = Gio.SimpleAction.new_stateful(name, None, state)
            action.connect('change-state', callback)
            self.view_action_group.add_action(action)

        builder = Gtk.Builder.new_from_resource(
            '/org/gnome/meld/ui/vcview-menus.ui')
        context_menu = builder.get_object('vcview-context-menu')
        self.popup_menu = Gtk.Menu.new_from_model(context_menu)
        self.popup_menu.attach_to_widget(self)

        self.model = VcTreeStore()
        self.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self)
        self.treeview.set_model(self.model)
        self.treeview.get_selection().connect(
            "changed", self.on_treeview_selection_changed)
        self.treeview.set_search_equal_func(tree.treeview_search_cb, None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.name_column.set_attributes(self.emblem_renderer,
                                        icon_name=tree.COL_ICON,
                                        icon_tint=tree.COL_TINT)
        self.name_column.set_attributes(self.name_renderer,
                                        text=tree.COL_TEXT,
                                        foreground_rgba=tree.COL_FG,
                                        style=tree.COL_STYLE,
                                        weight=tree.COL_WEIGHT,
                                        strikethrough=tree.COL_STRIKE)
        self.location_column.set_attributes(self.location_renderer,
                                            markup=COL_LOCATION)
        self.status_column.set_attributes(self.status_renderer,
                                          markup=COL_STATUS)
        self.extra_column.set_attributes(self.extra_renderer,
                                         markup=COL_OPTIONS)

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.vc = None

        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)
Esempio n. 10
0
    def __init__(self):
        gnomeglade.Component.__init__(self, "meldapp.ui", "meldapp")
        self.widget.set_name("meldapp")

        actions = (
            ("FileMenu", None, _("_File")),
            ("New", Gtk.STOCK_NEW, _("_New Comparison..."), "<control>N",
                _("Start a new comparison"),
                self.on_menu_file_new_activate),
            ("Save", Gtk.STOCK_SAVE, None, None,
                _("Save the current file"),
                self.on_menu_save_activate),
            ("SaveAs", Gtk.STOCK_SAVE_AS, _("Save As..."), "<control><shift>S",
                _("Save the current file with a different name"),
                self.on_menu_save_as_activate),
            ("Close", Gtk.STOCK_CLOSE, None, None,
                _("Close the current file"),
                self.on_menu_close_activate),

            ("EditMenu", None, _("_Edit")),
            ("Undo", Gtk.STOCK_UNDO, None, "<control>Z",
                _("Undo the last action"),
                self.on_menu_undo_activate),
            ("Redo", Gtk.STOCK_REDO, None, "<control><shift>Z",
                _("Redo the last undone action"),
                self.on_menu_redo_activate),
            ("Cut", Gtk.STOCK_CUT, None, None, _("Cut the selection"),
                self.on_menu_cut_activate),
            ("Copy", Gtk.STOCK_COPY, None, None, _("Copy the selection"),
                self.on_menu_copy_activate),
            ("Paste", Gtk.STOCK_PASTE, None, None, _("Paste the clipboard"),
                self.on_menu_paste_activate),
            ("Find", Gtk.STOCK_FIND, _("Find..."), None, _("Search for text"),
                self.on_menu_find_activate),
            ("FindNext", None, _("Find Ne_xt"), "<control>G",
                _("Search forwards for the same text"),
                self.on_menu_find_next_activate),
            ("FindPrevious", None, _("Find _Previous"), "<control><shift>G",
                _("Search backwards for the same text"),
                self.on_menu_find_previous_activate),
            ("Replace", Gtk.STOCK_FIND_AND_REPLACE,
                _("_Replace..."), "<control>H",
                _("Find and replace text"),
                self.on_menu_replace_activate),

            ("ChangesMenu", None, _("_Changes")),
            ("NextChange", Gtk.STOCK_GO_DOWN, _("Next Change"), "<Alt>Down",
                _("Go to the next change"),
                self.on_menu_edit_down_activate),
            ("PrevChange", Gtk.STOCK_GO_UP, _("Previous Change"), "<Alt>Up",
                _("Go to the previous change"),
                self.on_menu_edit_up_activate),
            ("OpenExternal", None, _("Open Externally"), None,
                _("Open selected file or directory in the default external "
                  "application"),
                self.on_open_external),

            ("ViewMenu", None, _("_View")),
            ("FileStatus", None, _("File Status")),
            ("VcStatus", None, _("Version Status")),
            ("FileFilters", None, _("File Filters")),
            ("Stop", Gtk.STOCK_STOP, None, "Escape",
                _("Stop the current action"),
                self.on_toolbar_stop_clicked),
            ("Refresh", Gtk.STOCK_REFRESH, None, "<control>R",
                _("Refresh the view"),
                self.on_menu_refresh_activate),

            ("TabMenu", None, _("_Tabs")),
            ("PrevTab",   None, _("_Previous Tab"), "<Ctrl><Alt>Page_Up",
                _("Activate previous tab"),
                self.on_prev_tab),
            ("NextTab",   None, _("_Next Tab"), "<Ctrl><Alt>Page_Down",
                _("Activate next tab"),
                self.on_next_tab),
            ("MoveTabPrev", None,
                _("Move Tab _Left"), "<Ctrl><Alt><Shift>Page_Up",
                _("Move current tab to left"),
                self.on_move_tab_prev),
            ("MoveTabNext", None,
                _("Move Tab _Right"), "<Ctrl><Alt><Shift>Page_Down",
                _("Move current tab to right"),
                self.on_move_tab_next),
        )
        toggleactions = (
            ("Fullscreen", None, _("Fullscreen"), "F11",
                _("View the comparison in fullscreen"),
                self.on_action_fullscreen_toggled, False),
            ("ToolbarVisible", None, _("_Toolbar"), None,
                _("Show or hide the toolbar"),
                None, True),
        )
        ui_file = gnomeglade.ui_file("meldapp-ui.xml")
        self.actiongroup = Gtk.ActionGroup(name='MainActions')
        self.actiongroup.set_translation_domain("meld")
        self.actiongroup.add_actions(actions)
        self.actiongroup.add_toggle_actions(toggleactions)

        recent_action = Gtk.RecentAction(name="Recent",  label=_("Open Recent"),
                                         tooltip=_("Open recent files"), stock_id=None)
        recent_action.set_show_private(True)
        recent_action.set_filter(recent_comparisons.recent_filter)
        recent_action.set_sort_type(Gtk.RecentSortType.MRU)
        recent_action.connect("item-activated", self.on_action_recent)
        self.actiongroup.add_action(recent_action)

        self.ui = Gtk.UIManager()
        self.ui.insert_action_group(self.actiongroup, 0)
        self.ui.add_ui_from_file(ui_file)
        self.tab_switch_actiongroup = None
        self.tab_switch_merge_id = None

        for menuitem in ("Save", "Undo"):
            self.actiongroup.get_action(menuitem).props.is_important = True
        self.widget.add_accel_group(self.ui.get_accel_group())
        self.menubar = self.ui.get_widget('/Menubar')
        self.toolbar = self.ui.get_widget('/Toolbar')
        self.toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        settings.bind('toolbar-visible',
                      self.actiongroup.get_action('ToolbarVisible'), 'active',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('toolbar-visible', self.toolbar, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        interface_settings.bind('toolbar-style', self.toolbar, 'toolbar-style',
                                Gio.SettingsBindFlags.DEFAULT)

        # Add alternate keybindings for Prev/Next Change
        accels = self.ui.get_accel_group()
        (keyval, mask) = Gtk.accelerator_parse("<Ctrl>D")
        accels.connect(keyval, mask, 0, self.on_menu_edit_down_activate)
        (keyval, mask) = Gtk.accelerator_parse("<Ctrl>E")
        accels.connect(keyval, mask, 0, self.on_menu_edit_up_activate)
        (keyval, mask) = Gtk.accelerator_parse("F5")
        accels.connect(keyval, mask, 0, self.on_menu_refresh_activate)

        # Initialise sensitivity for important actions
        self.actiongroup.get_action("Stop").set_sensitive(False)
        self._update_page_action_sensitivity()

        self.appvbox.pack_start(self.menubar, False, True, 0)
        self.toolbar_holder.pack_start(self.toolbar, True, True, 0)

        # Double toolbars to work around UIManager integration issues
        self.secondary_toolbar = Gtk.Toolbar()
        self.secondary_toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
        self.toolbar_holder.pack_end(self.secondary_toolbar, False, True, 0)

        toolbutton = Gtk.ToolItem()
        self.spinner = Gtk.Spinner()
        toolbutton.add(self.spinner)
        self.secondary_toolbar.insert(toolbutton, -1)
        # Set a minimum size because the spinner requests nothing
        self.secondary_toolbar.set_size_request(30, -1)
        self.secondary_toolbar.show_all()

        self.widget.drag_dest_set(
            Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT |
            Gtk.DestDefaults.DROP,
            None, Gdk.DragAction.COPY)
        self.widget.drag_dest_add_uri_targets()
        self.widget.connect("drag_data_received",
                            self.on_widget_drag_data_received)
        self.idle_hooked = 0
        self.scheduler = task.LifoScheduler()
        self.scheduler.connect("runnable", self.on_scheduler_runnable)
        window_size = settings.get_value('window-size')
        self.widget.set_default_size(window_size[0], window_size[1])
        self.ui.ensure_update()
        self.diff_handler = None
        self.undo_handlers = tuple()
        self.widget.connect('focus_in_event', self.on_focus_change)
        self.widget.connect('focus_out_event', self.on_focus_change)
Esempio n. 11
0
    def __init__(self, parent):
        Component.__init__(self, "preferences.ui", "preferencesdialog",
                           ["adjustment1", "adjustment2", "fileorderstore",
                            "sizegroup_editor", "timestampstore",
                            "mergeorderstore", "sizegroup_file_order_labels",
                            "sizegroup_file_order_combos"])
        self.widget.set_transient_for(parent)

        bindings = [
            ('use-system-font', self.checkbutton_default_font, 'active'),
            ('custom-font', self.fontpicker, 'font'),
            ('indent-width', self.spinbutton_tabsize, 'value'),
            ('insert-spaces-instead-of-tabs', self.checkbutton_spaces_instead_of_tabs, 'active'),
            ('highlight-current-line', self.checkbutton_highlight_current_line, 'active'),
            ('show-line-numbers', self.checkbutton_show_line_numbers, 'active'),
            ('highlight-syntax', self.checkbutton_use_syntax_highlighting, 'active'),
            ('use-system-editor', self.system_editor_checkbutton, 'active'),
            ('custom-editor-command', self.custom_edit_command_entry, 'text'),
            ('folder-shallow-comparison', self.checkbutton_shallow_compare, 'active'),
            ('folder-ignore-symlinks', self.checkbutton_ignore_symlinks, 'active'),
            ('vc-show-commit-margin', self.checkbutton_show_commit_margin, 'active'),
            ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
            ('vc-break-commit-message', self.checkbutton_break_commit_lines, 'active'),
            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines, 'active'),
            # Sensitivity bindings must come after value bindings, or the key
            # writability in gsettings overrides manual sensitivity setting.
            ('vc-show-commit-margin', self.spinbutton_commit_margin, 'sensitive'),
            ('vc-show-commit-margin', self.checkbutton_break_commit_lines, 'sensitive'),
        ]
        for key, obj, attribute in bindings:
            settings.bind(key, obj, attribute, Gio.SettingsBindFlags.DEFAULT)

        settings.bind(
            'use-system-editor', self.custom_edit_command_entry, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)
        settings.bind(
            'use-system-font', self.fontpicker, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)

        self.checkbutton_wrap_text.bind_property(
            'active', self.checkbutton_wrap_word, 'sensitive',
            GObject.BindingFlags.DEFAULT)

        # TODO: Fix once bind_with_mapping is available
        self.checkbutton_show_whitespace.set_active(
            bool(settings.get_flags('draw-spaces')))

        wrap_mode = settings.get_enum('wrap-mode')
        self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
        self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)

        filefilter = FilterList("filename-filters", FilterEntry.SHELL)
        self.file_filters_vbox.pack_start(filefilter.widget, True, True, 0)

        textfilter = FilterList("text-filters", FilterEntry.REGEX)
        self.text_filters_vbox.pack_start(textfilter.widget, True, True, 0)

        columnlist = ColumnList("folder-columns")
        self.column_list_vbox.pack_start(columnlist.widget, True, True, 0)

        self.combo_timestamp.bind_to('folder-time-resolution')
        self.combo_file_order.bind_to('vc-left-is-local')
        self.combo_merge_order.bind_to('vc-merge-file-order')

        self.widget.show()
Esempio n. 12
0
    def __init__(self):
        Component.__init__(self, "meldapp.ui", "meldapp")
        self.widget.set_name("meldapp")

        actions = (
            ("FileMenu", None, _("_File")),
            ("New", Gtk.STOCK_NEW, _("_New Comparison…"), "<Primary>N",
                _("Start a new comparison"),
                self.on_menu_file_new_activate),
            ("Save", Gtk.STOCK_SAVE, None, None,
                _("Save the current file"),
                self.on_menu_save_activate),
            ("SaveAs", Gtk.STOCK_SAVE_AS, _("Save As…"), "<Primary><shift>S",
                _("Save the current file with a different name"),
                self.on_menu_save_as_activate),
            ("Close", Gtk.STOCK_CLOSE, None, None,
                _("Close the current file"),
                self.on_menu_close_activate),

            ("EditMenu", None, _("_Edit")),
            ("Undo", Gtk.STOCK_UNDO, None, "<Primary>Z",
                _("Undo the last action"),
                self.on_menu_undo_activate),
            ("Redo", Gtk.STOCK_REDO, None, "<Primary><shift>Z",
                _("Redo the last undone action"),
                self.on_menu_redo_activate),
            ("Cut", Gtk.STOCK_CUT, None, None, _("Cut the selection"),
                self.on_menu_cut_activate),
            ("Copy", Gtk.STOCK_COPY, None, None, _("Copy the selection"),
                self.on_menu_copy_activate),
            ("Paste", Gtk.STOCK_PASTE, None, None, _("Paste the clipboard"),
                self.on_menu_paste_activate),
            ("Find", Gtk.STOCK_FIND, _("Find…"), None, _("Search for text"),
                self.on_menu_find_activate),
            ("FindNext", None, _("Find Ne_xt"), "<Primary>G",
                _("Search forwards for the same text"),
                self.on_menu_find_next_activate),
            ("FindPrevious", None, _("Find _Previous"), "<Primary><shift>G",
                _("Search backwards for the same text"),
                self.on_menu_find_previous_activate),
            ("Replace", Gtk.STOCK_FIND_AND_REPLACE,
                _("_Replace…"), "<Primary>H",
                _("Find and replace text"),
                self.on_menu_replace_activate),
            ("GoToLine", None, _("Go to _Line"), "<Primary>I",
                _("Go to a specific line"),
                self.on_menu_go_to_line_activate),

            ("ChangesMenu", None, _("_Changes")),
            ("NextChange", Gtk.STOCK_GO_DOWN, _("Next Change"), "<Alt>Down",
                _("Go to the next change"),
                self.on_menu_edit_down_activate),
            ("PrevChange", Gtk.STOCK_GO_UP, _("Previous Change"), "<Alt>Up",
                _("Go to the previous change"),
                self.on_menu_edit_up_activate),
            ("OpenExternal", None, _("Open Externally"), None,
                _("Open selected file or directory in the default external "
                  "application"),
                self.on_open_external),

            ("ViewMenu", None, _("_View")),
            ("FileStatus", None, _("File Status")),
            ("VcStatus", None, _("Version Status")),
            ("FileFilters", None, _("File Filters")),
            ("Stop", Gtk.STOCK_STOP, None, "Escape",
                _("Stop the current action"),
                self.on_toolbar_stop_clicked),
            ("Refresh", Gtk.STOCK_REFRESH, None, "<Primary>R",
                _("Refresh the view"),
                self.on_menu_refresh_activate),
        )
        toggleactions = (
            ("Fullscreen", None, _("Fullscreen"), "F11",
                _("View the comparison in fullscreen"),
                self.on_action_fullscreen_toggled, False),
            ("ToolbarVisible", None, _("_Toolbar"), None,
                _("Show or hide the toolbar"),
                None, True),
        )
        self.actiongroup = Gtk.ActionGroup(name='MainActions')
        self.actiongroup.set_translation_domain("meld")
        self.actiongroup.add_actions(actions)
        self.actiongroup.add_toggle_actions(toggleactions)

        recent_action = Gtk.RecentAction(
            name="Recent",  label=_("Open Recent"),
            tooltip=_("Open recent files"), stock_id=None)
        recent_action.set_show_private(True)
        recent_action.set_filter(recent_comparisons.recent_filter)
        recent_action.set_sort_type(Gtk.RecentSortType.MRU)
        recent_action.connect("item-activated", self.on_action_recent)
        self.actiongroup.add_action(recent_action)

        self.ui = Gtk.UIManager()
        self.ui.insert_action_group(self.actiongroup, 0)
        self.ui.add_ui_from_file(ui_file("meldapp-ui.xml"))

        # Manually handle shells that don't show an application menu
        gtk_settings = Gtk.Settings.get_default()
        if not gtk_settings.props.gtk_shell_shows_app_menu:
            from meld.meldapp import app

            def make_app_action(name):
                def app_action(*args):
                    app.lookup_action(name).activate(None)
                return app_action

            app_actions = (
                ("AppMenu", None, _("_Meld")),
                ("Quit", Gtk.STOCK_QUIT, None, None, _("Quit the program"),
                 make_app_action('quit')),
                ("Preferences", Gtk.STOCK_PREFERENCES, _("Prefere_nces"), None,
                 _("Configure the application"),
                 make_app_action('preferences')),
                ("Help", Gtk.STOCK_HELP, _("_Contents"), "F1",
                 _("Open the Meld manual"), make_app_action('help')),
                ("About", Gtk.STOCK_ABOUT, None, None,
                 _("About this application"), make_app_action('about')),
            )

            app_actiongroup = Gtk.ActionGroup(name="AppActions")
            app_actiongroup.set_translation_domain("meld")
            app_actiongroup.add_actions(app_actions)
            self.ui.insert_action_group(app_actiongroup, 0)

            self.ui.add_ui_from_file(ui_file("appmenu-fallback.xml"))
            self.widget.set_show_menubar(False)

        for menuitem in ("Save", "Undo"):
            self.actiongroup.get_action(menuitem).props.is_important = True
        self.widget.add_accel_group(self.ui.get_accel_group())
        self.menubar = self.ui.get_widget('/Menubar')
        self.toolbar = self.ui.get_widget('/Toolbar')
        self.toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        settings.bind('toolbar-visible',
                      self.actiongroup.get_action('ToolbarVisible'), 'active',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('toolbar-visible', self.toolbar, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        interface_settings.bind('toolbar-style', self.toolbar, 'toolbar-style',
                                Gio.SettingsBindFlags.DEFAULT)

        # Add alternate keybindings for Prev/Next Change
        accels = self.ui.get_accel_group()
        (keyval, mask) = Gtk.accelerator_parse("<Primary>D")
        accels.connect(keyval, mask, 0, self.on_menu_edit_down_activate)
        (keyval, mask) = Gtk.accelerator_parse("<Primary>E")
        accels.connect(keyval, mask, 0, self.on_menu_edit_up_activate)
        (keyval, mask) = Gtk.accelerator_parse("F5")
        accels.connect(keyval, mask, 0, self.on_menu_refresh_activate)

        # Initialise sensitivity for important actions
        self.actiongroup.get_action("Stop").set_sensitive(False)
        self._update_page_action_sensitivity()

        self.appvbox.pack_start(self.menubar, False, True, 0)
        self.toolbar_holder.pack_start(self.toolbar, True, True, 0)

        # Double toolbars to work around UIManager integration issues
        self.secondary_toolbar = Gtk.Toolbar()
        self.secondary_toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
        self.toolbar_holder.pack_end(self.secondary_toolbar, False, True, 0)

        # Manually handle GAction additions
        actions = (
            ("close", self.on_menu_close_activate, None),
        )
        for (name, callback, accel) in actions:
            action = Gio.SimpleAction.new(name, None)
            action.connect('activate', callback)
            self.widget.add_action(action)

        # Create a secondary toolbar, just to hold our progress spinner
        toolbutton = Gtk.ToolItem()
        self.spinner = Gtk.Spinner()
        # Fake out the spinner on Windows. See Gitlab issue #133.
        if os.name == 'nt':
            for attr in ('stop', 'hide', 'show', 'start'):
                setattr(self.spinner, attr, lambda *args: True)
        toolbutton.add(self.spinner)
        self.secondary_toolbar.insert(toolbutton, -1)
        # Set a minimum size because the spinner requests nothing
        self.secondary_toolbar.set_size_request(30, -1)
        self.secondary_toolbar.show_all()

        self.widget.drag_dest_set(
            Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT |
            Gtk.DestDefaults.DROP,
            None, Gdk.DragAction.COPY)
        self.widget.drag_dest_add_uri_targets()
        self.widget.connect("drag_data_received",
                            self.on_widget_drag_data_received)

        self.window_state = SavedWindowState()
        self.window_state.bind(self.widget)

        self.should_close = False
        self.idle_hooked = 0
        self.scheduler = LifoScheduler()
        self.scheduler.connect("runnable", self.on_scheduler_runnable)

        self.ui.ensure_update()
        self.diff_handler = None
        self.undo_handlers = tuple()
        self.widget.connect('focus_in_event', self.on_focus_change)
        self.widget.connect('focus_out_event', self.on_focus_change)

        # Set tooltip on map because the recentmenu is lazily created
        rmenu = self.ui.get_widget('/Menubar/FileMenu/Recent').get_submenu()
        rmenu.connect("map", self._on_recentmenu_map)

        builder = meld.ui.util.get_builder("shortcuts.ui")
        shortcut_window = builder.get_object("shortcuts-meld")
        self.widget.set_help_overlay(shortcut_window)
Esempio n. 13
0
    def __init__(self):
        super().__init__()
        # FIXME:
        # This unimaginable hack exists because GObject (or GTK+?)
        # doesn't actually correctly chain init calls, even if they're
        # not to GObjects. As a workaround, we *should* just be able to
        # put our class first, but because of Gtk.Template we can't do
        # that if it's a GObject, because GObject doesn't support
        # multiple inheritance and we need to inherit from our Widget
        # parent to make Template work.
        MeldDoc.__init__(self)
        self.init_template()
        bind_settings(self)

        self.ui_file = ui_file("vcview-ui.xml")
        self.actiongroup = self.VcviewActions
        self.actiongroup.set_translation_domain("meld")
        self.model = VcTreeStore()
        self.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self)
        self.treeview.set_model(self.model)
        self.treeview.get_selection().connect(
            "changed", self.on_treeview_selection_changed)
        self.treeview.set_search_equal_func(tree.treeview_search_cb, None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.name_column.set_attributes(
            self.emblem_renderer,
            icon_name=tree.COL_ICON,
            icon_tint=tree.COL_TINT)
        self.name_column.set_attributes(
            self.name_renderer,
            text=tree.COL_TEXT,
            foreground_rgba=tree.COL_FG,
            style=tree.COL_STYLE,
            weight=tree.COL_WEIGHT,
            strikethrough=tree.COL_STRIKE)
        self.location_column.set_attributes(
            self.location_renderer, markup=COL_LOCATION)
        self.status_column.set_attributes(
            self.status_renderer, markup=COL_STATUS)
        self.extra_column.set_attributes(
            self.extra_renderer, markup=COL_OPTIONS)
        self.location_column.bind_property(
            'visible', self.actiongroup.get_action("VcFlatten"), 'active')

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.vc = None

        settings.bind('vc-console-visible',
                      self.actiongroup.get_action('VcConsoleVisible'),
                      'active', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)

        for s in self.props.status_filters:
            if s in self.state_actions:
                self.actiongroup.get_action(
                    self.state_actions[s][0]).set_active(True)
Esempio n. 14
0
File: vcview.py Progetto: GNOME/meld
    def __init__(self):
        super().__init__()
        # FIXME:
        # This unimaginable hack exists because GObject (or GTK+?)
        # doesn't actually correctly chain init calls, even if they're
        # not to GObjects. As a workaround, we *should* just be able to
        # put our class first, but because of Gtk.Template we can't do
        # that if it's a GObject, because GObject doesn't support
        # multiple inheritance and we need to inherit from our Widget
        # parent to make Template work.
        MeldDoc.__init__(self)
        self.init_template()
        bind_settings(self)

        # Set up per-view action group for top-level menu insertion
        self.view_action_group = Gio.SimpleActionGroup()

        property_actions = (
            ('vc-console-visible', self.console_vbox, 'visible'),
        )
        for action_name, obj, prop_name in property_actions:
            action = Gio.PropertyAction.new(action_name, obj, prop_name)
            self.view_action_group.add_action(action)

        # Manually handle GAction additions
        actions = (
            ('compare', self.action_diff),
            ('find', self.action_find),
            ('next-change', self.action_next_change),
            ('open-external', self.action_open_external),
            ('previous-change', self.action_previous_change),
            ('refresh', self.action_refresh),
            ('vc-add', self.action_add),
            ('vc-commit', self.action_commit),
            ('vc-delete-locally', self.action_delete),
            ('vc-push', self.action_push),
            ('vc-remove', self.action_remove),
            ('vc-resolve', self.action_resolved),
            ('vc-revert', self.action_revert),
            ('vc-update', self.action_update),
        )
        for name, callback in actions:
            action = Gio.SimpleAction.new(name, None)
            action.connect('activate', callback)
            self.view_action_group.add_action(action)

        new_boolean = GLib.Variant.new_boolean
        stateful_actions = (
            ('vc-flatten', self.action_filter_state_change,
                new_boolean('flatten' in self.props.status_filters)),
            ('vc-status-modified', self.action_filter_state_change,
                new_boolean('modified' in self.props.status_filters)),
            ('vc-status-normal', self.action_filter_state_change,
                new_boolean('normal' in self.props.status_filters)),
            ('vc-status-unknown', self.action_filter_state_change,
                new_boolean('unknown' in self.props.status_filters)),
            ('vc-status-ignored', self.action_filter_state_change,
                new_boolean('ignored' in self.props.status_filters)),
        )
        for (name, callback, state) in stateful_actions:
            action = Gio.SimpleAction.new_stateful(name, None, state)
            action.connect('change-state', callback)
            self.view_action_group.add_action(action)

        builder = Gtk.Builder.new_from_resource(
            '/org/gnome/meld/ui/vcview-menus.ui')
        context_menu = builder.get_object('vcview-context-menu')
        self.popup_menu = Gtk.Menu.new_from_model(context_menu)
        self.popup_menu.attach_to_widget(self)

        self.model = VcTreeStore()
        self.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self)
        self.treeview.set_model(self.model)
        self.treeview.get_selection().connect(
            "changed", self.on_treeview_selection_changed)
        self.treeview.set_search_equal_func(tree.treeview_search_cb, None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.name_column.set_attributes(
            self.emblem_renderer,
            icon_name=tree.COL_ICON,
            icon_tint=tree.COL_TINT)
        self.name_column.set_attributes(
            self.name_renderer,
            text=tree.COL_TEXT,
            foreground_rgba=tree.COL_FG,
            style=tree.COL_STYLE,
            weight=tree.COL_WEIGHT,
            strikethrough=tree.COL_STRIKE)
        self.location_column.set_attributes(
            self.location_renderer, markup=COL_LOCATION)
        self.status_column.set_attributes(
            self.status_renderer, markup=COL_STATUS)
        self.extra_column.set_attributes(
            self.extra_renderer, markup=COL_OPTIONS)

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.vc = None

        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)
Esempio n. 15
0
    def __init__(self, parent):
        Component.__init__(self, "preferences.ui", "preferencesdialog",
                           ["adjustment1", "adjustment2", "fileorderstore",
                            "sizegroup_editor", "timestampstore",
                            "mergeorderstore", "sizegroup_file_order_labels",
                            "sizegroup_file_order_combos",
                            'syntaxschemestore'])
        self.widget.set_transient_for(parent)

        bindings = [
            ('use-system-font', self.checkbutton_default_font, 'active'),
            ('custom-font', self.fontpicker, 'font'),
            ('indent-width', self.spinbutton_tabsize, 'value'),
            ('insert-spaces-instead-of-tabs', self.checkbutton_spaces_instead_of_tabs, 'active'),
            ('highlight-current-line', self.checkbutton_highlight_current_line, 'active'),
            ('show-line-numbers', self.checkbutton_show_line_numbers, 'active'),
            ('highlight-syntax', self.checkbutton_use_syntax_highlighting, 'active'),
            ('use-system-editor', self.system_editor_checkbutton, 'active'),
            ('custom-editor-command', self.custom_edit_command_entry, 'text'),
            ('folder-shallow-comparison', self.checkbutton_shallow_compare, 'active'),
            ('folder-ignore-symlinks', self.checkbutton_ignore_symlinks, 'active'),
            ('vc-show-commit-margin', self.checkbutton_show_commit_margin, 'active'),
            ('vc-commit-margin', self.spinbutton_commit_margin, 'value'),
            ('vc-break-commit-message', self.checkbutton_break_commit_lines, 'active'),
            ('ignore-blank-lines', self.checkbutton_ignore_blank_lines, 'active'),
            # Sensitivity bindings must come after value bindings, or the key
            # writability in gsettings overrides manual sensitivity setting.
            ('vc-show-commit-margin', self.spinbutton_commit_margin, 'sensitive'),
            ('vc-show-commit-margin', self.checkbutton_break_commit_lines, 'sensitive'),
        ]
        for key, obj, attribute in bindings:
            settings.bind(key, obj, attribute, Gio.SettingsBindFlags.DEFAULT)

        settings.bind(
            'use-system-editor', self.custom_edit_command_entry, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)
        settings.bind(
            'use-system-font', self.fontpicker, 'sensitive',
            Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN)

        self.checkbutton_wrap_text.bind_property(
            'active', self.checkbutton_wrap_word, 'sensitive',
            GObject.BindingFlags.DEFAULT)

        # TODO: Fix once bind_with_mapping is available
        self.checkbutton_show_whitespace.set_active(
            bool(settings.get_flags('draw-spaces')))

        wrap_mode = settings.get_enum('wrap-mode')
        self.checkbutton_wrap_text.set_active(wrap_mode != Gtk.WrapMode.NONE)
        self.checkbutton_wrap_word.set_active(wrap_mode == Gtk.WrapMode.WORD)

        filefilter = FilterList("filename-filters", FilterEntry.SHELL)
        self.file_filters_vbox.pack_start(filefilter.widget, True, True, 0)

        textfilter = FilterList("text-filters", FilterEntry.REGEX)
        self.text_filters_vbox.pack_start(textfilter.widget, True, True, 0)

        columnlist = ColumnList("folder-columns")
        self.column_list_vbox.pack_start(columnlist.widget, True, True, 0)

        self.combo_timestamp.bind_to('folder-time-resolution')
        self.combo_file_order.bind_to('vc-left-is-local')
        self.combo_merge_order.bind_to('vc-merge-file-order')

        # Fill color schemes
        manager = GtkSource.StyleSchemeManager.get_default()
        for scheme_id in manager.get_scheme_ids():
            scheme = manager.get_scheme(scheme_id)
            self.syntaxschemestore.append([scheme_id, scheme.get_name()])
        self.combobox_style_scheme.bind_to('style-scheme')

        self.widget.show()
Esempio n. 16
0
    def __init__(self):
        gnomeglade.Component.__init__(self, "meldapp.ui", "meldapp")
        self.widget.set_name("meldapp")

        actions = (
            ("FileMenu", None, _("_File")),
            ("New", Gtk.STOCK_NEW, _("_New Comparison..."), "<control>N",
             _("Start a new comparison"), self.on_menu_file_new_activate),
            ("Save", Gtk.STOCK_SAVE, None, None, _("Save the current file"),
             self.on_menu_save_activate),
            ("SaveAs", Gtk.STOCK_SAVE_AS, _("Save As..."), "<control><shift>S",
             _("Save the current file with a different name"),
             self.on_menu_save_as_activate),
            ("Close", Gtk.STOCK_CLOSE, None, None, _("Close the current file"),
             self.on_menu_close_activate),
            ("EditMenu", None, _("_Edit")),
            ("Undo", Gtk.STOCK_UNDO, None, "<control>Z",
             _("Undo the last action"), self.on_menu_undo_activate),
            ("Redo", Gtk.STOCK_REDO, None, "<control><shift>Z",
             _("Redo the last undone action"), self.on_menu_redo_activate),
            ("Cut", Gtk.STOCK_CUT, None, None, _("Cut the selection"),
             self.on_menu_cut_activate),
            ("Copy", Gtk.STOCK_COPY, None, None, _("Copy the selection"),
             self.on_menu_copy_activate),
            ("Paste", Gtk.STOCK_PASTE, None, None, _("Paste the clipboard"),
             self.on_menu_paste_activate),
            ("Find", Gtk.STOCK_FIND, _("Find..."), None, _("Search for text"),
             self.on_menu_find_activate),
            ("FindNext", None, _("Find Ne_xt"), "<control>G",
             _("Search forwards for the same text"),
             self.on_menu_find_next_activate),
            ("FindPrevious", None, _("Find _Previous"), "<control><shift>G",
             _("Search backwards for the same text"),
             self.on_menu_find_previous_activate),
            ("Replace",
             Gtk.STOCK_FIND_AND_REPLACE, _("_Replace..."), "<control>H",
             _("Find and replace text"), self.on_menu_replace_activate),
            ("ChangesMenu", None, _("_Changes")),
            ("NextChange", Gtk.STOCK_GO_DOWN, _("Next Change"), "<Alt>Down",
             _("Go to the next change"), self.on_menu_edit_down_activate),
            ("PrevChange", Gtk.STOCK_GO_UP, _("Previous Change"), "<Alt>Up",
             _("Go to the previous change"), self.on_menu_edit_up_activate),
            ("OpenExternal", None, _("Open Externally"), None,
             _("Open selected file or directory in the default external "
               "application"), self.on_open_external),
            ("ViewMenu", None, _("_View")),
            ("FileStatus", None, _("File Status")),
            ("VcStatus", None, _("Version Status")),
            ("FileFilters", None, _("File Filters")),
            ("Stop", Gtk.STOCK_STOP, None, "Escape",
             _("Stop the current action"), self.on_toolbar_stop_clicked),
            ("Refresh", Gtk.STOCK_REFRESH, None, "<control>R",
             _("Refresh the view"), self.on_menu_refresh_activate),
            ("TabMenu", None, _("_Tabs")),
            ("PrevTab", None, _("_Previous Tab"), "<Ctrl><Alt>Page_Up",
             _("Activate previous tab"), self.on_prev_tab),
            ("NextTab", None, _("_Next Tab"), "<Ctrl><Alt>Page_Down",
             _("Activate next tab"), self.on_next_tab),
            ("MoveTabPrev", None,
             _("Move Tab _Left"), "<Ctrl><Alt><Shift>Page_Up",
             _("Move current tab to left"), self.on_move_tab_prev),
            ("MoveTabNext", None,
             _("Move Tab _Right"), "<Ctrl><Alt><Shift>Page_Down",
             _("Move current tab to right"), self.on_move_tab_next),
        )
        toggleactions = (
            ("Fullscreen", None, _("Fullscreen"), "F11",
             _("View the comparison in fullscreen"),
             self.on_action_fullscreen_toggled, False),
            ("ToolbarVisible", None, _("_Toolbar"), None,
             _("Show or hide the toolbar"), None, True),
        )
        ui_file = gnomeglade.ui_file("meldapp-ui.xml")
        self.actiongroup = Gtk.ActionGroup(name='MainActions')
        self.actiongroup.set_translation_domain("meld")
        self.actiongroup.add_actions(actions)
        self.actiongroup.add_toggle_actions(toggleactions)

        recent_action = Gtk.RecentAction(name="Recent",
                                         label=_("Open Recent"),
                                         tooltip=_("Open recent files"),
                                         stock_id=None)
        recent_action.set_show_private(True)
        recent_action.set_filter(recent_comparisons.recent_filter)
        recent_action.set_sort_type(Gtk.RecentSortType.MRU)
        recent_action.connect("item-activated", self.on_action_recent)
        self.actiongroup.add_action(recent_action)

        self.ui = Gtk.UIManager()
        self.ui.insert_action_group(self.actiongroup, 0)
        self.ui.add_ui_from_file(ui_file)

        # Manually handle shells that don't show an application menu
        gtk_settings = Gtk.Settings.get_default()
        if not gtk_settings.props.gtk_shell_shows_app_menu:
            from meldapp import app

            def make_app_action(name):
                def app_action(*args):
                    app.lookup_action(name).activate(None)

                return app_action

            app_actions = (
                ("AppMenu", None, _("_Meld")),
                ("Quit", Gtk.STOCK_QUIT, None, None, _("Quit the program"),
                 make_app_action('quit')),
                ("Preferences", Gtk.STOCK_PREFERENCES, _("Prefere_nces"), None,
                 _("Configure the application"),
                 make_app_action('preferences')),
                ("Help", Gtk.STOCK_HELP, _("_Contents"), "F1",
                 _("Open the Meld manual"), make_app_action('help')),
                ("About", Gtk.STOCK_ABOUT, None, None,
                 _("About this application"), make_app_action('about')),
            )

            app_actiongroup = Gtk.ActionGroup(name="AppActions")
            app_actiongroup.set_translation_domain("meld")
            app_actiongroup.add_actions(app_actions)
            self.ui.insert_action_group(app_actiongroup, 0)

            ui_file = gnomeglade.ui_file("appmenu-fallback.xml")
            self.ui.add_ui_from_file(ui_file)
            self.widget.set_show_menubar(False)

        self.tab_switch_actiongroup = None
        self.tab_switch_merge_id = None

        for menuitem in ("Save", "Undo"):
            self.actiongroup.get_action(menuitem).props.is_important = True
        self.widget.add_accel_group(self.ui.get_accel_group())
        self.menubar = self.ui.get_widget('/Menubar')
        self.toolbar = self.ui.get_widget('/Toolbar')
        self.toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        settings.bind('toolbar-visible',
                      self.actiongroup.get_action('ToolbarVisible'), 'active',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('toolbar-visible', self.toolbar, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        interface_settings.bind('toolbar-style', self.toolbar, 'toolbar-style',
                                Gio.SettingsBindFlags.DEFAULT)

        # Add alternate keybindings for Prev/Next Change
        accels = self.ui.get_accel_group()
        (keyval, mask) = Gtk.accelerator_parse("<Ctrl>D")
        accels.connect(keyval, mask, 0, self.on_menu_edit_down_activate)
        (keyval, mask) = Gtk.accelerator_parse("<Ctrl>E")
        accels.connect(keyval, mask, 0, self.on_menu_edit_up_activate)
        (keyval, mask) = Gtk.accelerator_parse("F5")
        accels.connect(keyval, mask, 0, self.on_menu_refresh_activate)

        # Initialise sensitivity for important actions
        self.actiongroup.get_action("Stop").set_sensitive(False)
        self._update_page_action_sensitivity()

        self.appvbox.pack_start(self.menubar, False, True, 0)
        self.toolbar_holder.pack_start(self.toolbar, True, True, 0)

        # Double toolbars to work around UIManager integration issues
        self.secondary_toolbar = Gtk.Toolbar()
        self.secondary_toolbar.get_style_context().add_class(
            Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
        self.toolbar_holder.pack_end(self.secondary_toolbar, False, True, 0)

        toolbutton = Gtk.ToolItem()
        self.spinner = Gtk.Spinner()
        toolbutton.add(self.spinner)
        self.secondary_toolbar.insert(toolbutton, -1)
        # Set a minimum size because the spinner requests nothing
        self.secondary_toolbar.set_size_request(30, -1)
        self.secondary_toolbar.show_all()

        self.widget.drag_dest_set(
            Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT
            | Gtk.DestDefaults.DROP, None, Gdk.DragAction.COPY)
        self.widget.drag_dest_add_uri_targets()
        self.widget.connect("drag_data_received",
                            self.on_widget_drag_data_received)
        self.idle_hooked = 0
        self.scheduler = task.LifoScheduler()
        self.scheduler.connect("runnable", self.on_scheduler_runnable)
        window_size = settings.get_value('window-size')
        self.widget.set_default_size(window_size[0], window_size[1])
        window_state = settings.get_string('window-state')
        if window_state == 'maximized':
            self.widget.maximize()
        self.ui.ensure_update()
        self.diff_handler = None
        self.undo_handlers = tuple()
        self.widget.connect('focus_in_event', self.on_focus_change)
        self.widget.connect('focus_out_event', self.on_focus_change)

        # Set tooltip on map because the recentmenu is lazily created
        rmenu = self.ui.get_widget('/Menubar/FileMenu/Recent').get_submenu()
        rmenu.connect("map", self._on_recentmenu_map)
Esempio n. 17
0
    def __init__(self):
        melddoc.MeldDoc.__init__(self)
        gnomeglade.Component.__init__(self, "vcview.ui", "vcview",
                                      ["VcviewActions", 'liststore_vcs'])
        bind_settings(self)

        self.ui_file = gnomeglade.ui_file("vcview-ui.xml")
        self.actiongroup = self.VcviewActions
        self.actiongroup.set_translation_domain("meld")
        self.model = VcTreeStore()
        self.widget.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self.widget)
        self.treeview.set_model(self.model)
        selection = self.treeview.get_selection()
        selection.set_mode(Gtk.SelectionMode.MULTIPLE)
        selection.connect("changed", self.on_treeview_selection_changed)
        self.treeview.set_headers_visible(1)
        self.treeview.set_search_equal_func(
            self.model.treeview_search_cb, None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.column_name_map = {}
        col_index = self.model.column_index
        column = Gtk.TreeViewColumn(_("Name"))
        column.set_resizable(True)
        renicon = emblemcellrenderer.EmblemCellRenderer()
        column.pack_start(renicon, False)
        column.set_attributes(renicon,
                              icon_name=col_index(tree.COL_ICON, 0),
                              icon_tint=col_index(tree.COL_TINT, 0))
        rentext = Gtk.CellRendererText()
        column.pack_start(rentext, True)
        column.set_attributes(rentext,
                              text=col_index(tree.COL_TEXT, 0),
                              foreground=col_index(tree.COL_FG, 0),
                              style=col_index(tree.COL_STYLE, 0),
                              weight=col_index(tree.COL_WEIGHT, 0),
                              strikethrough=col_index(tree.COL_STRIKE, 0))
        column_index = self.treeview.append_column(column) - 1
        self.column_name_map[vc.DATA_NAME] = column_index

        def addCol(name, num, data_name=None):
            column = Gtk.TreeViewColumn(name)
            column.set_resizable(True)
            rentext = Gtk.CellRendererText()
            column.pack_start(rentext, True)
            column.set_attributes(rentext,
                                  markup=self.model.column_index(num, 0))
            column_index = self.treeview.append_column(column) - 1
            if data_name:
                self.column_name_map[data_name] = column_index
            return column

        self.treeview_column_location = addCol(_("Location"), COL_LOCATION)
        addCol(_("Status"), COL_STATUS, vc.DATA_STATE)
        addCol(_("Revision"), COL_REVISION, vc.DATA_REVISION)
        addCol(_("Options"), COL_OPTIONS, vc.DATA_OPTIONS)

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active())
        self.vc = None
        self.valid_vc_actions = tuple()

        cell = Gtk.CellRendererText()
        self.combobox_vcs.pack_start(cell, False)
        self.combobox_vcs.add_attribute(cell, 'text', 0)
        self.combobox_vcs.add_attribute(cell, 'sensitive', 2)
        self.combobox_vcs.lock = False

        settings.bind('vc-console-visible',
                      self.actiongroup.get_action('VcConsoleVisible'),
                      'active', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)

        self.state_filters = []
        for s in self.state_actions:
            if s in self.props.status_filters:
                action_name = self.state_actions[s][0]
                self.state_filters.append(s)
                self.actiongroup.get_action(action_name).set_active(True)
Esempio n. 18
0
File: vcview.py Progetto: fy2/meld
    def __init__(self):
        melddoc.MeldDoc.__init__(self)
        gnomeglade.Component.__init__(self, "vcview.ui", "vcview",
                                      ["VcviewActions", 'liststore_vcs'])
        bind_settings(self)

        self.ui_file = gnomeglade.ui_file("vcview-ui.xml")
        self.actiongroup = self.VcviewActions
        self.actiongroup.set_translation_domain("meld")
        self.model = VcTreeStore()
        self.widget.connect("style-updated", self.model.on_style_updated)
        self.model.on_style_updated(self.widget)
        self.treeview.set_model(self.model)
        selection = self.treeview.get_selection()
        selection.set_mode(Gtk.SelectionMode.MULTIPLE)
        selection.connect("changed", self.on_treeview_selection_changed)
        self.treeview.set_headers_visible(1)
        self.treeview.set_search_equal_func(
            self.model.treeview_search_cb, None)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.column_name_map = {}
        col_index = self.model.column_index
        column = Gtk.TreeViewColumn(_("Name"))
        column.set_resizable(True)
        renicon = emblemcellrenderer.EmblemCellRenderer()
        column.pack_start(renicon, False)
        column.set_attributes(renicon,
                              icon_name=col_index(tree.COL_ICON, 0),
                              icon_tint=col_index(tree.COL_TINT, 0))
        rentext = Gtk.CellRendererText()
        column.pack_start(rentext, True)
        column.set_attributes(rentext,
                              text=col_index(tree.COL_TEXT, 0),
                              foreground=col_index(tree.COL_FG, 0),
                              style=col_index(tree.COL_STYLE, 0),
                              weight=col_index(tree.COL_WEIGHT, 0),
                              strikethrough=col_index(tree.COL_STRIKE, 0))
        column_index = self.treeview.append_column(column) - 1
        self.column_name_map[vc.DATA_NAME] = column_index

        def addCol(name, num, data_name=None):
            column = Gtk.TreeViewColumn(name)
            column.set_resizable(True)
            rentext = Gtk.CellRendererText()
            column.pack_start(rentext, True)
            column.set_attributes(rentext,
                                  markup=self.model.column_index(num, 0))
            column_index = self.treeview.append_column(column) - 1
            if data_name:
                self.column_name_map[data_name] = column_index
            return column

        self.treeview_column_location = addCol(_("Location"), COL_LOCATION)
        addCol(_("Status"), COL_STATUS, vc.DATA_STATE)
        addCol(_("Revision"), COL_REVISION, vc.DATA_REVISION)
        addCol(_("Options"), COL_OPTIONS, vc.DATA_OPTIONS)

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active())
        self.vc = None
        self.valid_vc_actions = tuple()

        cell = Gtk.CellRendererText()
        self.combobox_vcs.pack_start(cell, False)
        self.combobox_vcs.add_attribute(cell, 'text', 0)
        self.combobox_vcs.add_attribute(cell, 'sensitive', 2)
        self.combobox_vcs.lock = False

        settings.bind('vc-console-visible',
                      self.actiongroup.get_action('VcConsoleVisible'),
                      'active', Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-visible', self.console_vbox, 'visible',
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind('vc-console-pane-position', self.vc_console_vpaned,
                      'position', Gio.SettingsBindFlags.DEFAULT)

        self.state_filters = []
        for s in self.state_actions:
            if s in self.props.status_filters:
                action_name = self.state_actions[s][0]
                self.state_filters.append(s)
                self.actiongroup.get_action(action_name).set_active(True)
Esempio n. 19
0
 def late_bind(self):
     settings.bind(
         'show-line-numbers', self, 'show-line-numbers',
         Gio.SettingsBindFlags.DEFAULT)