def __init__(self, columns, prefs, key): gnomeglade.Component.__init__(self, paths.ui_dir("meldapp.glade"), "listwidget") self.prefs = prefs self.key = key self.treeview.set_model( gtk.ListStore( *[c[1] for c in columns] ) ) view = self.treeview def addTextCol(label, colnum): model = view.get_model() rentext = gtk.CellRendererText() rentext.props.editable = 1 def change_text(ren, path, text): model[path][colnum] = text self._update_filter_string() rentext.connect("edited", change_text) column = gtk.TreeViewColumn(label, rentext, text=colnum) view.append_column(column) def addToggleCol(label, colnum): model = view.get_model() rentoggle = gtk.CellRendererToggle() def change_toggle(ren, path): model[path][colnum] = not ren.get_active() self._update_filter_string() rentoggle.connect("toggled", change_toggle) column = gtk.TreeViewColumn(label, rentoggle, active=colnum) view.append_column(column) for c,i in zip( columns, range(len(columns))): if c[1] == type(""): addTextCol(c[0], i) elif c[1] == type(0): addToggleCol( c[0], 1) view.get_selection().connect('changed', self._update_sensitivity) view.get_model().connect('row-inserted', self._update_sensitivity) view.get_model().connect('rows-reordered', self._update_sensitivity) self._update_sensitivity() self._update_filter_model()
def __init__(self, filediff): ui_file = paths.ui_dir("patch-dialog.ui") gnomeglade.Component.__init__(self, ui_file, "patchdialog") self.widget.set_transient_for(filediff.widget.get_toplevel()) self.prefs = filediff.prefs self.prefs.notify_add(self.on_preference_changed) self.filediff = filediff buf = srcviewer.GtkTextBuffer() self.textview.set_buffer(buf) lang = srcviewer.get_language_from_mime_type("text/x-diff") srcviewer.set_language(buf, lang) srcviewer.set_highlight_syntax(buf, True) fontdesc = pango.FontDescription(self.prefs.get_current_font()) self.textview.modify_font(fontdesc) self.textview.set_editable(False) self.index_map = { self.left_radiobutton: (0, 1), self.right_radiobutton: (1, 2) } self.left_patch = True self.reverse_patch = self.reverse_checkbutton.get_active() if self.filediff.num_panes < 3: self.label3.hide() self.hbox2.hide()
def __init__(self, filediff): ui_file = paths.ui_dir("patch-dialog.ui") gnomeglade.Component.__init__(self, ui_file, "patchdialog") self.widget.set_transient_for(filediff.widget.get_toplevel()) self.prefs = filediff.prefs self.prefs.notify_add(self.on_preference_changed) self.filediff = filediff buf = srcviewer.GtkTextBuffer() self.textview.set_buffer(buf) lang = srcviewer.get_language_from_mime_type("text/x-diff") srcviewer.set_language(buf, lang) srcviewer.set_highlight_syntax(buf, True) fontdesc = pango.FontDescription(self.prefs.get_current_font()) self.textview.modify_font(fontdesc) self.textview.set_editable(False) self.index_map = {self.left_radiobutton: (0, 1), self.right_radiobutton: (1, 2)} self.left_patch = True self.reverse_patch = self.reverse_checkbutton.get_active() if self.filediff.num_panes < 3: self.label3.hide() self.hbox2.hide()
def __init__(self, parent, prefs): gnomeglade.Component.__init__(self, paths.ui_dir("preferences.ui"), "preferencesdialog", ["adjustment1"]) self.widget.set_transient_for(parent) self.prefs = prefs if not self.prefs.use_custom_font: self.checkbutton_default_font.set_active(True) self.fontpicker.set_sensitive(False) else: self.checkbutton_default_font.set_active(False) self.fontpicker.set_sensitive(True) self.fontpicker.set_font_name(self.prefs.custom_font) self.fontpicker.set_font_name( self.prefs.custom_font ) self.spinbutton_tabsize.set_value( self.prefs.tab_size ) if srcviewer.gsv is not None: self.checkbutton_spaces_instead_of_tabs.set_active( self.prefs.spaces_instead_of_tabs ) self.checkbutton_show_line_numbers.set_active( self.prefs.show_line_numbers ) self.checkbutton_show_whitespace.set_active(self.prefs.show_whitespace) self.checkbutton_use_syntax_highlighting.set_active( self.prefs.use_syntax_highlighting ) else: no_sourceview_text = \ _("Only available if you have gnome-python-desktop installed") for w in (self.checkbutton_spaces_instead_of_tabs, self.checkbutton_show_line_numbers, self.checkbutton_use_syntax_highlighting, self.checkbutton_show_whitespace): w.set_sensitive(False) w.set_tooltip_text(no_sourceview_text) # TODO: This doesn't restore the state of character wrapping when word # wrapping is disabled, but this is hard with our existing gconf keys if self.prefs.edit_wrap_lines != gtk.WRAP_NONE: if self.prefs.edit_wrap_lines == gtk.WRAP_CHAR: self.checkbutton_split_words.set_active(False) self.checkbutton_wrap_text.set_active(True) size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) size_group.add_widget(self.label1) size_group.add_widget(self.label2) size_group.add_widget(self.label16) use_default = self.prefs.edit_command_type == "internal" or \ self.prefs.edit_command_type == "gnome" self.system_editor_checkbutton.set_active(use_default) self.custom_edit_command_entry.set_sensitive(not use_default) custom_command = " ".join(self.prefs.get_editor_command([], "custom")) self.custom_edit_command_entry.set_text(custom_command) # file filters self.filefilter = FilterList(self.prefs, "filters", meldapp.FilterEntry.SHELL) self.file_filters_tab.pack_start(self.filefilter.widget) self.checkbutton_ignore_symlinks.set_active( self.prefs.ignore_symlinks) # text filters self.textfilter = FilterList(self.prefs, "regexes", meldapp.FilterEntry.REGEX) self.text_filters_tab.pack_start(self.textfilter.widget) self.checkbutton_ignore_blank_lines.set_active( self.prefs.ignore_blank_lines ) # encoding self.entry_text_codecs.set_text( self.prefs.text_codecs ) self.widget.show()
def on_menu_about_activate(self, *extra): gtk.about_dialog_set_url_hook(lambda dialog, uri: misc.open_uri(uri)) about = gtk.glade.XML(paths.ui_dir("meldapp.glade"), "about").get_widget("about") about.props.version = version about.set_transient_for(self.widget) about.run() about.hide()
def __init__(self, parent): gnomeglade.Component.__init__(self, paths.ui_dir("vcview.ui"), "commitdialog") self.parent = parent self.widget.set_transient_for( parent.widget.get_toplevel() ) selected = parent._get_selected_files() topdir = _commonprefix(selected) selected = [ s[len(topdir):] for s in selected ] self.changedfiles.set_text( ("(in %s) "%topdir) + " ".join(selected) ) self.widget.show_all()
def __init__(self, parentapp): gnomeglade.Component.__init__(self, paths.ui_dir("meldapp.ui"), "newdialog") self.map_widgets_into_lists(["fileentry", "direntry", "vcentry", "three_way_compare"]) self.entrylists = self.fileentry, self.direntry, self.vcentry self.widget.set_transient_for(parentapp.widget) self.fileentry[0].set_sensitive(self.three_way_compare[0].get_active()) self.direntry[0].set_sensitive(self.three_way_compare[1].get_active()) self.diff_methods = (parentapp.append_filediff, parentapp.append_dirdiff, parentapp.append_vcview) self.widget.show_all()
def __init__(self, parentapp): gnomeglade.Component.__init__(self, paths.ui_dir("meldapp.glade"), "preferencesdialog") self.widget.set_transient_for(parentapp.widget) self.prefs = parentapp.prefs # editor self.map_widgets_into_lists(["editor_command"]) if self.prefs.use_custom_font: self.radiobutton_custom_font.set_active(1) else: self.radiobutton_gnome_font.set_active(1) self.fontpicker.set_font_name(self.prefs.custom_font) self.spinbutton_tabsize.set_value(self.prefs.tab_size) if srcviewer: self.checkbutton_spaces_instead_of_tabs.set_active( self.prefs.spaces_instead_of_tabs) self.checkbutton_show_line_numbers.set_active( self.prefs.show_line_numbers) self.checkbutton_use_syntax_highlighting.set_active( self.prefs.use_syntax_highlighting) else: self.checkbutton_spaces_instead_of_tabs.set_sensitive(False) self.checkbutton_show_line_numbers.set_sensitive(False) self.checkbutton_use_syntax_highlighting.set_sensitive(False) if gtk.pygtk_version >= (2, 12, 0): no_sourceview_text = _( "Only available if you have gnome-python-desktop installed" ) self.checkbutton_spaces_instead_of_tabs.set_tooltip_text( no_sourceview_text) self.checkbutton_show_line_numbers.set_tooltip_text( no_sourceview_text) self.checkbutton_use_syntax_highlighting.set_tooltip_text( no_sourceview_text) self.option_wrap_lines.set_history(self.prefs.edit_wrap_lines) self.checkbutton_supply_newline.set_active(self.prefs.supply_newline) self.editor_command[self.editor_radio_values.get( self.prefs.edit_command_type, "internal")].set_active(1) self.gnome_default_editor_label.set_text( "(%s)" % " ".join(self.prefs.get_gnome_editor_command([]))) self.custom_edit_command_entry.set_text(" ".join( self.prefs.get_custom_editor_command([]))) # file filters cols = [(_("Name"), type("")), (_("Active"), type(0)), (_("Pattern"), type(""))] self.filefilter = ListWidget(cols, self.prefs, "filters") self.file_filters_tab.pack_start(self.filefilter.widget) self.checkbutton_ignore_symlinks.set_active(self.prefs.ignore_symlinks) # text filters cols = [(_("Name"), type("")), (_("Active"), type(0)), (_("Regex"), type(""))] self.textfilter = ListWidget(cols, self.prefs, "regexes") self.text_filters_tab.pack_start(self.textfilter.widget) self.checkbutton_ignore_blank_lines.set_active( self.prefs.ignore_blank_lines) # encoding self.entry_text_codecs.set_text(self.prefs.text_codecs)
def on_menu_about_activate(self, *extra): gtk.about_dialog_set_url_hook(lambda dialog, uri: misc.open_uri(uri)) builder = gtk.Builder() # FIXME: domain literal duplicated from bin/meld builder.set_translation_domain("meld") builder.add_objects_from_file(paths.ui_dir("meldapp.ui"), ["about"]) about = builder.get_object("about") about.props.version = app.version about.set_transient_for(self.widget) about.run() about.hide()
def __init__(self, parentapp): gnomeglade.Component.__init__(self, paths.ui_dir("meldapp.glade"), "newdialog") self.map_widgets_into_lists( ["fileentry", "direntry", "vcentry", "three_way_compare"]) self.entrylists = self.fileentry, self.direntry, self.vcentry self.widget.set_transient_for(parentapp.widget) self.fileentry[0].set_sensitive(self.three_way_compare[0].get_active()) self.direntry[0].set_sensitive(self.three_way_compare[1].get_active()) self.diff_methods = (parentapp.append_filediff, parentapp.append_dirdiff, parentapp.append_vcview) self.widget.show_all()
def __init__(self, columns, prefs, key): gnomeglade.Component.__init__(self, paths.ui_dir("meldapp.glade"), "listwidget") self.prefs = prefs self.key = key self.treeview.set_model(gtk.ListStore(*[c[1] for c in columns])) view = self.treeview def addTextCol(label, colnum): model = view.get_model() rentext = gtk.CellRendererText() rentext.props.editable = 1 def change_text(ren, path, text): model[path][colnum] = text self._update_filter_string() rentext.connect("edited", change_text) column = gtk.TreeViewColumn(label, rentext, text=colnum) view.append_column(column) def addToggleCol(label, colnum): model = view.get_model() rentoggle = gtk.CellRendererToggle() def change_toggle(ren, path): model[path][colnum] = not ren.get_active() self._update_filter_string() rentoggle.connect("toggled", change_toggle) column = gtk.TreeViewColumn(label, rentoggle, active=colnum) view.append_column(column) for c, i in zip(columns, range(len(columns))): if c[1] == type(""): addTextCol(c[0], i) elif c[1] == type(0): addToggleCol(c[0], 1) view.get_selection().connect('changed', self._update_sensitivity) view.get_model().connect('row-inserted', self._update_sensitivity) view.get_model().connect('rows-reordered', self._update_sensitivity) self._update_sensitivity() self._update_filter_model()
def __init__(self, parentapp): gnomeglade.Component.__init__(self, paths.ui_dir("meldapp.glade"), "preferencesdialog") self.widget.set_transient_for(parentapp.widget) self.prefs = parentapp.prefs # editor self.map_widgets_into_lists( ["editor_command"] ) if self.prefs.use_custom_font: self.radiobutton_custom_font.set_active(1) else: self.radiobutton_gnome_font.set_active(1) self.fontpicker.set_font_name( self.prefs.custom_font ) self.spinbutton_tabsize.set_value( self.prefs.tab_size ) if srcviewer: self.checkbutton_spaces_instead_of_tabs.set_active( self.prefs.spaces_instead_of_tabs ) self.checkbutton_show_line_numbers.set_active( self.prefs.show_line_numbers ) self.checkbutton_use_syntax_highlighting.set_active( self.prefs.use_syntax_highlighting ) else: self.checkbutton_spaces_instead_of_tabs.set_sensitive(False) self.checkbutton_show_line_numbers.set_sensitive(False) self.checkbutton_use_syntax_highlighting.set_sensitive(False) if gtk.pygtk_version >= (2, 12, 0): no_sourceview_text = _("Only available if you have gnome-python-desktop installed") self.checkbutton_spaces_instead_of_tabs.set_tooltip_text(no_sourceview_text) self.checkbutton_show_line_numbers.set_tooltip_text(no_sourceview_text) self.checkbutton_use_syntax_highlighting.set_tooltip_text(no_sourceview_text) self.option_wrap_lines.set_history( self.prefs.edit_wrap_lines ) self.checkbutton_supply_newline.set_active( self.prefs.supply_newline ) self.editor_command[ self.editor_radio_values.get(self.prefs.edit_command_type, "internal") ].set_active(1) self.gnome_default_editor_label.set_text( "(%s)" % " ".join(self.prefs.get_gnome_editor_command([])) ) self.custom_edit_command_entry.set_text( " ".join(self.prefs.get_custom_editor_command([])) ) # file filters cols = [ (_("Name"), type("")), (_("Active"), type(0)), (_("Pattern"), type("")) ] self.filefilter = ListWidget( cols, self.prefs, "filters") self.file_filters_tab.pack_start(self.filefilter.widget) self.checkbutton_ignore_symlinks.set_active( self.prefs.ignore_symlinks) # text filters cols = [ (_("Name"), type("")), (_("Active"), type(0)), (_("Regex"), type("")) ] self.textfilter = ListWidget( cols, self.prefs, "regexes") self.text_filters_tab.pack_start(self.textfilter.widget) self.checkbutton_ignore_blank_lines.set_active( self.prefs.ignore_blank_lines ) # encoding self.entry_text_codecs.set_text( self.prefs.text_codecs )
def __init__(self): gladefile = paths.ui_dir("meldapp.ui") gnomeglade.Component.__init__(self, gladefile, "meldapp") actions = ( ("FileMenu", None, _("_File")), ("New", gtk.STOCK_NEW, _("_New..."), "<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, None, "<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), ("Quit", gtk.STOCK_QUIT, None, None, _("Quit the program"), self.on_menu_quit_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, None, 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), ("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None, _("Configure the application"), self.on_menu_preferences_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), ("Reload", gtk.STOCK_REFRESH, _("Reload"), "<control><shift>R", _("Reload the comparison"), self.on_menu_reload_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), ("HelpMenu", None, _("_Help")), ("Help", gtk.STOCK_HELP, _("_Contents"), "F1", _("Open the Meld manual"), self.on_menu_help_activate), ("BugReport", gtk.STOCK_DIALOG_WARNING, _("Report _Bug"), None, _("Report a bug in Meld"), self.on_menu_help_bug_activate), ("About", gtk.STOCK_ABOUT, None, None, _("About this program"), self.on_menu_about_activate), ) toggleactions = ( ("Fullscreen", None, _("Full Screen"), "F11", _("View the comparison in full screen"), self.on_action_fullscreen_toggled, False), ("ToolbarVisible", None, _("_Toolbar"), None, _("Show or hide the toolbar"), self.on_menu_toolbar_toggled, app.prefs.toolbar_visible), ("StatusbarVisible", None, _("_Statusbar"), None, _("Show or hide the statusbar"), self.on_menu_statusbar_toggled, app.prefs.statusbar_visible) ) ui_file = paths.ui_dir("meldapp-ui.xml") self.actiongroup = gtk.ActionGroup('MainActions') self.actiongroup.set_translation_domain("meld") self.actiongroup.add_actions(actions) self.actiongroup.add_toggle_actions(toggleactions) self.ui = gtk.UIManager() self.ui.insert_action_group(self.actiongroup, 0) self.ui.add_ui_from_file(ui_file) self.ui.connect("connect-proxy", self._on_uimanager_connect_proxy) self.ui.connect("disconnect-proxy", self._on_uimanager_disconnect_proxy) 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') # Add alternate keybindings for Prev/Next Change accels = self.ui.get_accel_group() (keyval, mask) = gtk.accelerator_parse("<Ctrl>D") accels.connect_group(keyval, mask, 0, self.on_menu_edit_down_activate) (keyval, mask) = gtk.accelerator_parse("<Ctrl>E") accels.connect_group(keyval, mask, 0, self.on_menu_edit_up_activate) self.appvbox.pack_start(self.menubar, expand=False) self.appvbox.pack_start(self.toolbar, expand=False) # TODO: should possibly use something other than doc_status self._menu_context = self.doc_status.get_context_id("Tooltips") self.statusbar = MeldStatusBar(self.task_progress, self.task_status, self.doc_status) self.widget.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [ ('text/uri-list', 0, 0) ], gtk.gdk.ACTION_COPY) self.widget.connect("drag_data_received", self.on_widget_drag_data_received) self.toolbar.set_style(app.prefs.get_toolbar_style()) self.toolbar.props.visible = app.prefs.toolbar_visible self.status_box.props.visible = app.prefs.statusbar_visible app.prefs.notify_add(self.on_preference_changed) self.idle_hooked = 0 self.scheduler = task.LifoScheduler() self.scheduler.connect("runnable", self.on_scheduler_runnable ) self.widget.set_default_size(app.prefs.window_size_x, app.prefs.window_size_y) self.ui.ensure_update() self.widget.show() self.diff_handler = None self.widget.connect('focus_in_event', self.on_focus_change) self.widget.connect('focus_out_event', self.on_focus_change)
def __init__(self, parent, prefs): gnomeglade.Component.__init__(self, paths.ui_dir("preferences.ui"), "preferencesdialog", ["adjustment1"]) self.widget.set_transient_for(parent) self.prefs = prefs if not self.prefs.use_custom_font: self.checkbutton_default_font.set_active(True) self.fontpicker.set_sensitive(False) else: self.checkbutton_default_font.set_active(False) self.fontpicker.set_sensitive(True) self.fontpicker.set_font_name(self.prefs.custom_font) self.fontpicker.set_font_name(self.prefs.custom_font) self.spinbutton_tabsize.set_value(self.prefs.tab_size) if srcviewer.gsv is not None: self.checkbutton_spaces_instead_of_tabs.set_active( self.prefs.spaces_instead_of_tabs) self.checkbutton_show_line_numbers.set_active( self.prefs.show_line_numbers) self.checkbutton_show_whitespace.set_active( self.prefs.show_whitespace) self.checkbutton_use_syntax_highlighting.set_active( self.prefs.use_syntax_highlighting) else: no_sourceview_text = \ _("Only available if you have gnome-python-desktop installed") for w in (self.checkbutton_spaces_instead_of_tabs, self.checkbutton_show_line_numbers, self.checkbutton_use_syntax_highlighting, self.checkbutton_show_whitespace): w.set_sensitive(False) w.set_tooltip_text(no_sourceview_text) # TODO: This doesn't restore the state of character wrapping when word # wrapping is disabled, but this is hard with our existing gconf keys if self.prefs.edit_wrap_lines != gtk.WRAP_NONE: if self.prefs.edit_wrap_lines == gtk.WRAP_CHAR: self.checkbutton_split_words.set_active(False) self.checkbutton_wrap_text.set_active(True) size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) size_group.add_widget(self.label1) size_group.add_widget(self.label2) size_group.add_widget(self.label16) use_default = self.prefs.edit_command_type == "internal" or \ self.prefs.edit_command_type == "gnome" self.system_editor_checkbutton.set_active(use_default) self.custom_edit_command_entry.set_sensitive(not use_default) custom_command = " ".join(self.prefs.get_editor_command([], "custom")) self.custom_edit_command_entry.set_text(custom_command) # file filters self.filefilter = FilterList(self.prefs, "filters", meldapp.FilterEntry.SHELL) self.file_filters_tab.pack_start(self.filefilter.widget) self.checkbutton_ignore_symlinks.set_active(self.prefs.ignore_symlinks) # text filters self.textfilter = FilterList(self.prefs, "regexes", meldapp.FilterEntry.REGEX) self.text_filters_tab.pack_start(self.textfilter.widget) self.checkbutton_ignore_blank_lines.set_active( self.prefs.ignore_blank_lines) # encoding self.entry_text_codecs.set_text(self.prefs.text_codecs) self.widget.show()
def __init__(self, prefs): melddoc.MeldDoc.__init__(self, prefs) gnomeglade.Component.__init__(self, paths.ui_dir("vcview.ui"), "vcview") actions = ( ("VcCompare", gtk.STOCK_DIALOG_INFO, _("_Compare"), None, _("Compare selected"), self.on_button_diff_clicked), ("VcCommit", "vc-commit-24", _("Co_mmit"), None, _("Commit"), self.on_button_commit_clicked), ("VcUpdate", "vc-update-24", _("_Update"), None, _("Update"), self.on_button_update_clicked), ("VcAdd", "vc-add-24", _("_Add"), None, _("Add to VC"), self.on_button_add_clicked), ("VcAddBinary", None, _("Add _Binary"), None, _("Add binary to VC"), self.on_button_add_binary_clicked), ("VcRemove", "vc-remove-24", _("_Remove"), None, _("Remove from VC"), self.on_button_remove_clicked), ("VcResolved", "vc-resolve-24", _("_Resolved"), None, _("Mark as resolved for VC"), self.on_button_resolved_clicked), ("VcRevert", gtk.STOCK_REVERT_TO_SAVED, None, None, _("Revert to original"), self.on_button_revert_clicked), ("VcDeleteLocally", gtk.STOCK_DELETE, None, None, _("Delete locally"), self.on_button_delete_clicked), ) toggleactions = ( ("VcFlatten", gtk.STOCK_GOTO_BOTTOM, _("_Flatten"), None, _("Flatten directories"), self.on_button_flatten_toggled, False), ("VcShowModified","filter-modified-24", _("_Modified"), None, _("Show modified"), self.on_filter_state_toggled, False), ("VcShowNormal", "filter-normal-24", _("_Normal"), None, _("Show normal"), self.on_filter_state_toggled, False), ("VcShowNonVC", "filter-nonvc-24", _("Non _VC"), None, _("Show unversioned files"), self.on_filter_state_toggled, False), ("VcShowIgnored", "filter-ignored-24", _("Ignored"), None, _("Show ignored files"), self.on_filter_state_toggled, False), ) self.ui_file = paths.ui_dir("vcview-ui.xml") self.actiongroup = gtk.ActionGroup('VcviewActions') self.actiongroup.set_translation_domain("meld") self.actiongroup.add_actions(actions) self.actiongroup.add_toggle_actions(toggleactions) for action in ("VcCompare", "VcFlatten", "VcShowModified", "VcShowNormal", "VcShowNonVC", "VcShowIgnored"): self.actiongroup.get_action(action).props.is_important = True for action in ("VcCommit", "VcUpdate", "VcAdd", "VcRemove", "VcShowModified", "VcShowNormal", "VcShowNonVC", "VcShowIgnored", "VcResolved"): button = self.actiongroup.get_action(action) button.props.icon_name = button.props.stock_id self.tempdirs = [] self.model = VcTreeStore() self.treeview.set_model(self.model) self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.treeview.set_headers_visible(1) self.treeview.set_search_equal_func(self.treeview_search_cb) self.current_path, self.prev_path, self.next_path = None, None, None column = gtk.TreeViewColumn( _("Name") ) renicon = ui.emblemcellrenderer.EmblemCellRenderer() rentext = gtk.CellRendererText() column.pack_start(renicon, expand=0) column.pack_start(rentext, expand=1) col_index = self.model.column_index column.set_attributes(renicon, icon_name=col_index(tree.COL_ICON, 0), icon_tint=col_index(tree.COL_TINT, 0)) column.set_attributes(rentext, markup=col_index(tree.COL_TEXT, 0)) self.treeview.append_column(column) def addCol(name, num): column = gtk.TreeViewColumn(name) rentext = gtk.CellRendererText() column.pack_start(rentext, expand=0) column.set_attributes(rentext, markup=self.model.column_index(num, 0)) self.treeview.append_column(column) return column self.treeview_column_location = addCol( _("Location"), COL_LOCATION) addCol(_("Status"), COL_STATUS) addCol(_("Rev"), COL_REVISION) addCol(_("Tag"), COL_TAG) addCol(_("Options"), COL_OPTIONS) self.state_filters = [] for s in self.state_actions: if s in self.prefs.vc_status_filters: action_name = self.state_actions[s][0] self.state_filters.append(s) self.actiongroup.get_action(action_name).set_active(True) class ConsoleStream(object): def __init__(self, textview): self.textview = textview b = textview.get_buffer() self.mark = b.create_mark("END", b.get_end_iter(), 0) def write(self, s): if s: b = self.textview.get_buffer() b.insert(b.get_end_iter(), s) self.textview.scroll_mark_onscreen( self.mark ) self.consolestream = ConsoleStream(self.consoleview) self.location = None self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active()) self.fileentry.show() #TODO: remove once bug 97503 is fixed if not self.prefs.vc_console_visible: self.on_console_view_toggle(self.console_hide_box) self.vc = None # VC ComboBox self.combobox_vcs = gtk.ComboBox() self.combobox_vcs.lock = True self.combobox_vcs.set_model(gtk.ListStore(str, object, bool)) 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 self.hbox2.pack_end(self.combobox_vcs, expand=False) self.combobox_vcs.show() self.combobox_vcs.connect("changed", self.on_vc_change)
def __init__(self): gnomeglade.Component.__init__(self, paths.ui_dir("findbar.glade"), "findbar") gnomeglade.connect_signal_handlers(self) self.textview = None self.orig_base_color = self.find_entry.get_style().base[0]
def __init__(self): gladefile = paths.ui_dir("meldapp.glade") gtk.window_set_default_icon_name("icon") if getattr(gobject, "pygobject_version", ()) >= (2, 16, 0): gobject.set_application_name("Meld") gnomeglade.Component.__init__(self, gladefile, "meldapp") self.prefs = MeldPreferences() actions = ( ("FileMenu", None, _("_File")), ("New", gtk.STOCK_NEW, _("_New..."), "<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, None, "<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), ("Quit", gtk.STOCK_QUIT, None, None, _("Quit the program"), self.on_menu_quit_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, None, 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), ("Replace", gtk.STOCK_FIND_AND_REPLACE, _("_Replace"), "<control>H", _("Find and replace text"), self.on_menu_replace_activate), ("Down", gtk.STOCK_GO_DOWN, None, "<control>D", _("Go to the next difference"), self.on_menu_edit_down_activate), ("Up", gtk.STOCK_GO_UP, None, "<control>E", _("Go to the previous difference"), self.on_menu_edit_up_activate), ("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None, _("Configure the application"), self.on_menu_preferences_activate), ("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), ("Reload", gtk.STOCK_REFRESH, _("Reload"), "<control><shift>R", _("Reload the comparison"), self.on_menu_reload_activate), ("HelpMenu", None, _("_Help")), ("Help", gtk.STOCK_HELP, _("_Contents"), "F1", _("Open the Meld manual"), self.on_menu_help_activate), ("BugReport", gtk.STOCK_DIALOG_WARNING, _("Report _Bug"), None, _("Report a bug in Meld"), self.on_menu_help_bug_activate), ("About", gtk.STOCK_ABOUT, None, None, _("About this program"), self.on_menu_about_activate), ) toggleactions = (("Fullscreen", None, _("Full Screen"), "F11", _("View the comparison in full screen"), self.on_action_fullscreen_toggled, False), ("ToolbarVisible", None, _("_Toolbar"), None, _("Show or hide the toolbar"), self.on_menu_toolbar_toggled, self.prefs.toolbar_visible), ("StatusbarVisible", None, _("_Statusbar"), None, _("Show or hide the statusbar"), self.on_menu_statusbar_toggled, self.prefs.statusbar_visible)) ui_file = paths.ui_dir("meldapp-ui.xml") self.actiongroup = gtk.ActionGroup('MainActions') self.actiongroup.set_translation_domain("meld") self.actiongroup.add_actions(actions) self.actiongroup.add_toggle_actions(toggleactions) self.ui = gtk.UIManager() self.ui.insert_action_group(self.actiongroup, 0) self.ui.add_ui_from_file(ui_file) self.ui.connect("connect-proxy", self._on_uimanager_connect_proxy) self.ui.connect("disconnect-proxy", self._on_uimanager_disconnect_proxy) 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.appvbox.pack_start(self.menubar, expand=False) self.appvbox.pack_start(self.toolbar, expand=False) # TODO: should possibly use something other than doc_status self._menu_context = self.doc_status.get_context_id("Tooltips") self.statusbar = MeldStatusBar(self.task_progress, self.task_status, self.doc_status) self.widget.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [('text/uri-list', 0, 0)], gtk.gdk.ACTION_COPY) if gnomevfs_available: self.widget.connect('drag_data_received', self.on_widget_drag_data_received) self.toolbar.set_style(self.prefs.get_toolbar_style()) self.toolbar.props.visible = self.prefs.toolbar_visible self.status_box.props.visible = self.prefs.statusbar_visible self.prefs.notify_add(self.on_preference_changed) self.idle_hooked = 0 self.scheduler = task.LifoScheduler() self.scheduler.connect("runnable", self.on_scheduler_runnable) self.widget.set_default_size(self.prefs.window_size_x, self.prefs.window_size_y) self.ui.ensure_update() self.widget.show() self.widget.connect('focus_in_event', self.on_focus_change) self.widget.connect('focus_out_event', self.on_focus_change)