def on_more_actions_view_unified_diff(self): url1 = self.first_urls.get_active_text() rev1 = self.get_first_revision() rev2 = self.get_second_revision() url2 = self.second_urls.get_active_text() helper.launch_ui_window("diff", [ "%s@%s" % (url1, helper.to_text(rev1)), "%s@%s" % (url2, helper.to_text(rev2)), "--vcs=%s" % self.get_vcs_name() ])
def __init__(self, path, revision): """ @type path: string @param path: The path to open @type revision: string @param revision: The revision of the file to open """ InterfaceNonView.__init__(self) self.vcs = rabbitvcs.vcs.VCS() self.git = self.vcs.git(path) if revision: revision_obj = self.git.revision(revision) else: revision_obj = self.git.revision("HEAD") dest_dir = helper.get_tmp_path("rabbitvcs-" + helper.to_text(revision)) self.git.export(path, dest_dir, revision=revision_obj) repo_path = self.git.find_repository_path(path) relative_path = path if path.startswith(repo_path): relative_path = path[len(repo_path) + 1:] dest_path = "%s/%s" % (dest_dir, relative_path) helper.open_item(dest_path) raise SystemExit()
def get_file_menu_items(self, window, items): """ Menu activated with items selected. Nautilus also calls this function when rendering submenus, even though this is not needed since the entire menu has already been returned. Note that calling C{nautilusVFSFile.invalidate_extension_info()} will also cause get_file_items to be called. @type window: NautilusNavigationWindow @param window: @type items: list of NautilusVFSFile @param items: @rtype: list of MenuItems @return: The context menu entries to add to the menu. """ paths = [] for item in items: if self.valid_uri(item.get_uri()): path = realpath(to_text(self.get_local_path(item))) paths.append(path) self.nautilusVFSFile_table[path] = item if len(paths) == 0: return [] return ThunarxMainContextMenu(self, window.base_dir, paths).get_menu()
def get_folder_menu_items(self, window, item): """ Menu activated on entering a directory. Builds context menu for File menu and for window background. @type window: NautilusNavigationWindow @param window: @type item: NautilusVFSFile @param item: @rtype: list of MenuItems @return: The context menu entries to add to the menu. """ if not self.valid_uri(item.get_uri()): return path = realpath(to_text(self.get_local_path(item))) self.nautilusVFSFile_table[path] = item # log.debug("get_background_items() called") window.base_dir = path return ThunarxMainContextMenu(self, path, [path]).get_menu()
def show_edit(self, branch_name): self.state = STATE_EDIT branch_name = saxutils.unescape(branch_name) self.selected_branch = None for item in self.branch_list: if item.name == branch_name: self.selected_branch = item break self.save_button.set_label(_("Save")) if self.selected_branch: self.branch_entry.set_text(self.selected_branch.name) self.revision_label.set_text( helper.to_text(self.selected_branch.revision)) self.message_label.set_text( self.selected_branch.message.rstrip("\n")) if self.selected_branch.tracking: self.checkout_checkbox.set_active(True) self.checkout_checkbox.set_sensitive(False) else: self.checkout_checkbox.set_active(False) self.checkout_checkbox.set_sensitive(True) self.show_rows(self.view_rows) self.get_widget("detail_label").set_markup(_("<b>Branch Detail</b>"))
def generate_string_from_data(self): lines = [] for row in self.data: line = [] for cell in row: line.append(helper.to_text(cell)) lines.append("\t".join(line)) return "\n".join(lines)
def __init__(self, path, vcs=None, claim_domain=True): rabbitvcs.ui.GtkBuilderWidgetWrapper.__init__(self, claim_domain=claim_domain) self.path = path self.vcs = vcs or rabbitvcs.vcs.VCS() self.checker = StatusChecker() self.get_widget("file_name").set_text(os.path.basename(path)) self.status = self.checker.check_status(path, recurse = False, invalidate = False, summary = False) self.get_widget("vcs_type").set_text(self.status.vcs_type) self.get_widget("content_status").set_text(helper.to_text(self.status.simple_content_status())) self.get_widget("prop_status").set_text(helper.to_text(self.status.simple_metadata_status())) self.set_icon_from_status(self.get_widget("content_status_icon"), self.status.simple_content_status()) self.set_icon_from_status(self.get_widget("prop_status_icon"), self.status.simple_metadata_status()) self.set_icon_from_status(self.get_widget("vcs_icon"), self.status.single, Gtk.IconSize.DIALOG) additional_info = self.get_additional_info() if additional_info: additional_props_table = rabbitvcs.ui.widget.KeyValueTable( additional_info) additional_props_table.show() file_info_table = rabbitvcs.ui.widget.Box(self.get_widget("file_info_table"), vertical = True) file_info_table.pack_start(additional_props_table, expand=False, fill=False, padding=0)
def view_selected_diff(self, sidebyside=False): for row in self.selected_rows: url1 = self.changes_table.get_row(row)[0] url2 = url1 if url1 == ".": url1 = "" url2 = "" url1 = helper.url_join(self.first_urls.get_active_text(), url1) url2 = helper.url_join(self.second_urls.get_active_text(), url2) rev1 = self.get_first_revision() rev2 = self.get_second_revision() helper.launch_ui_window("diff", [ "%s@%s" % (url1, helper.to_text(rev1)), "%s@%s" % (url2, helper.to_text(rev2)), "%s" % (sidebyside and "-s" or ""), "--vcs=%s" % self.get_vcs_name() ])
def __init__(self, path, vcs=None, claim_domain=True): rabbitvcs.ui.GtkBuilderWidgetWrapper.__init__( self, claim_domain=claim_domain) self.path = path self.vcs = vcs or rabbitvcs.vcs.VCS() self.checker = StatusChecker() self.get_widget("file_name").set_text(os.path.basename(path)) self.status = self.checker.check_status(path, recurse=False, invalidate=False, summary=False) self.get_widget("vcs_type").set_text(self.status.vcs_type) self.get_widget("content_status").set_text( helper.to_text(self.status.simple_content_status())) self.get_widget("prop_status").set_text( helper.to_text(self.status.simple_metadata_status())) self.set_icon_from_status(self.get_widget("content_status_icon"), self.status.simple_content_status()) self.set_icon_from_status(self.get_widget("prop_status_icon"), self.status.simple_metadata_status()) self.set_icon_from_status(self.get_widget("vcs_icon"), self.status.single, Gtk.IconSize.DIALOG) additional_info = self.get_additional_info() if additional_info: additional_props_table = rabbitvcs.ui.widget.KeyValueTable( additional_info) additional_props_table.show() file_info_table = rabbitvcs.ui.widget.Box( self.get_widget("file_info_table"), vertical=True) file_info_table.pack_start(additional_props_table, expand=False, fill=False, padding=0)
def compare(self, widget, data=None): for row in self.caller.selected_rows: url1 = self.caller.changes_table.get_row(row)[0] url2 = url1 if url1 == ".": url1 = "" url2 = "" url1 = helper.url_join(self.caller.first_urls.get_active_text(), url1) url2 = helper.url_join(self.caller.second_urls.get_active_text(), url2) rev1 = self.caller.get_first_revision() rev2 = self.caller.get_second_revision() helper.launch_ui_window("diff", [ "%s@%s" % (url1, helper.to_text(rev1)), "%s@%s" % (url2, helper.to_text(rev2)), "-s", "--vcs=%s" % self.caller.get_vcs_name() ])
def update_branch_info(self): from_branch = self.from_branches.get_revision_object() if from_branch.value: log = self.git.log(self.path, limit=1, revision=from_branch, showtype="branch") if log: from_info = log[0] self.info['from']['author'].set_text(from_info.author) self.info['from']['date'].set_text(helper.format_datetime(from_info.date)) self.info['from']['revision'].set_text(helper.to_text(from_info.revision)[0:7]) self.info['from']['message'].set_text(helper.html_escape(helper.format_long_text(from_info.message, 500)))
def show_detail(self, tag_name): self.selected_tag = None for item in self.tag_list: if helper.to_text(item.name) == tag_name: self.selected_tag = item break self.save_button.set_label(_("Save")) if self.selected_tag: self.tag_entry.set_text(helper.to_text(self.selected_tag.name)) self.revision_label.set_text(helper.to_text(self.selected_tag.sha)) self.message_label.set_text( helper.to_text(self.selected_tag.message).rstrip("\n")) self.tagger_label.set_text(helper.to_text( self.selected_tag.tagger)) self.date_label.set_text( helper.format_datetime( datetime.fromtimestamp(self.selected_tag.tag_time))) self.show_rows(self.view_rows) self.get_widget("detail_label").set_markup(_("<b>Tag Detail</b>"))
def open_second(self, widget, data=None): path = self.caller.changes_table.get_row( self.caller.selected_rows[0])[0] if path == ".": path = "" url = helper.url_join(self.caller.second_urls.get_active_text(), path) rev = self.caller.get_second_revision() helper.launch_ui_window("open", [ "--vcs=%s" % self.caller.get_vcs_name(), url, "-r%s" % helper.to_text(rev) ])
def open_second(self, widget, data=None): path = self.caller.changes_table.get_row(self.caller.selected_rows[0])[0] if path == ".": path = "" url = helper.url_join(self.caller.second_urls.get_active_text(), path) rev = self.caller.get_second_revision() helper.launch_ui_window("open", [ "--vcs=%s" % self.caller.get_vcs_name(), url, "-r%s" % helper.to_text(rev) ])
def get_background_items_profile(self, window, item): import cProfile path = to_text(gnomevfs.get_local_path_from_uri(item.get_uri()), "utf-8").replace("/", ":") profile_data_file = os.path.join(get_home_folder(), "checkerservice_%s.stats" % path) prof = cProfile.Profile() retval = prof.runcall(self.get_background_items_real, window, item) prof.dump_stats(profile_data_file) log.debug("Dumped: %s" % profile_data_file) return retval
def get_background_items_profile(self, window, item): import cProfile import rabbitvcs.util.helper path = to_text(gnomevfs.get_local_path_from_uri(item.get_uri()), "utf-8").replace("/", ":") profile_data_file = os.path.join( rabbitvcs.util.helper.get_home_folder(), "checkerservice_%s.stats" % path) prof = cProfile.Profile() retval = prof.runcall(self.get_background_items_real, window, item) prof.dump_stats(profile_data_file) log.debug("Dumped: %s" % profile_data_file) return retval
def show_add(self): self.state = STATE_ADD revision = "HEAD" if self.revision: active_branch = self.git.get_active_branch() if active_branch: revision = helper.to_text(active_branch.name) self.items_treeview.unselect_all() self.branch_entry.set_text("") self.save_button.set_label(_("Add")) self.start_point_entry.set_text(revision) self.track_checkbox.set_active(True) self.checkout_checkbox.set_sensitive(True) self.checkout_checkbox.set_active(False) self.show_rows(self.add_rows) self.get_widget("detail_label").set_markup(_("<b>Add Branch</b>"))
def update_branch_info(self): from_branch = self.from_branches.get_revision_object() if from_branch.value: log = self.git.log(self.path, limit=1, revision=from_branch, showtype="branch") if log: from_info = log[0] self.info['from']['author'].set_text(from_info.author) self.info['from']['date'].set_text( helper.format_datetime(from_info.date)) self.info['from']['revision'].set_text( helper.to_text(from_info.revision)[0:7]) self.info['from']['message'].set_text( helper.html_escape( helper.format_long_text(from_info.message, 500)))
def get_property_pages(self, items): paths = [] for item in items: if self.valid_uri(item.get_uri()): path = realpath(to_text(self.get_local_path(item))) paths.append(path) self.nautilusVFSFile_table[path] = item if len(paths) == 0: return [] label = rabbitvcs.ui.property_page.PropertyPageLabel().get_widget() page = rabbitvcs.ui.property_page.PropertyPage(paths).get_widget() ppage = Thunarx.PropertyPage.new("") ppage.set_label_widget(label) ppage.add(page) return [ppage]
def __init__(self, path, revision): """ @type path: string @param path: The path to open @type revision: string @param revision: The revision of the file to open """ InterfaceNonView.__init__(self) self.vcs = rabbitvcs.vcs.VCS() self.git = self.vcs.git(path) if revision: revision_obj = self.git.revision(revision) else: revision_obj = self.git.revision("HEAD") dest_dir = helper.get_tmp_path("rabbitvcs-" + helper.to_text(revision)) self.git.export( path, dest_dir, revision=revision_obj ) repo_path = self.git.find_repository_path(path) relative_path = path if path.startswith(repo_path): relative_path = path[len(repo_path)+1:] dest_path = "%s/%s" % (dest_dir, relative_path) helper.open_item(dest_path) raise SystemExit()
def show_edit(self, branch_name): self.state = STATE_EDIT branch_name = saxutils.unescape(branch_name) self.selected_branch = None for item in self.branch_list: if item.name == branch_name: self.selected_branch = item break self.save_button.set_label(_("Save")) if self.selected_branch: self.branch_entry.set_text(self.selected_branch.name) self.revision_label.set_text(helper.to_text(self.selected_branch.revision)) self.message_label.set_text(self.selected_branch.message.rstrip("\n")) if self.selected_branch.tracking: self.checkout_checkbox.set_active(True) self.checkout_checkbox.set_sensitive(False) else: self.checkout_checkbox.set_active(False) self.checkout_checkbox.set_sensitive(True) self.show_rows(self.view_rows) self.get_widget("detail_label").set_markup(_("<b>Branch Detail</b>"))
def __unicode__(self): if self.value: return helper.to_text(self.value) else: return self.kind
def append(self, row): # Python 3 needs type conversions. self.data.append([item if coltype != GObject.TYPE_STRING else helper.to_text(item) for coltype, item in zip(self.coltypes, row)])
def append(self, row): # Python 3 needs type conversions. self.data.append([ item if coltype != GObject.TYPE_STRING else helper.to_text(item) for coltype, item in zip(self.coltypes, row) ])
def initialize_detail(self): self.detail_container = self.get_widget("detail_container") self.detail_grid = Gtk.Grid() self.detail_grid.set_row_spacing(4) self.detail_grid.set_column_spacing(6) self.detail_grid.set_hexpand(True) row = 0 # Set up the Tag line label = Gtk.Label(label=_("Name:")) label.set_properties(xalign=0, yalign=.5) self.tag_entry = Gtk.Entry() self.tag_entry.set_hexpand(True) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(self.tag_entry, 1, row, 2, 1) tag_name_row = row row = row + 1 # Set up the Commit-sha line label = Gtk.Label(label=_("Revision:")) label.set_properties(xalign=0, yalign=.5) self.start_point_entry = Gtk.Entry() self.start_point_entry.set_size_request(300, -1) self.start_point_entry.set_hexpand(True) if self.revision_obj.value: self.start_point_entry.set_text(helper.to_text(self.revision_obj)) self.log_dialog_button = Gtk.Button() self.log_dialog_button.connect("clicked", self.on_log_dialog_button_clicked) image = Gtk.Image() image.set_from_icon_name("rabbitvcs-show_log", Gtk.IconSize.SMALL_TOOLBAR) self.log_dialog_button.set_image(image) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(self.start_point_entry, 1, row, 1, 1) self.detail_grid.attach(self.log_dialog_button, 2, row, 1, 1) start_point_row = row row = row + 1 # Set up the Log Message Entry line label = Gtk.Label(label=_("Message:")) label.set_properties(xalign=0, yalign=0) self.message_entry = rabbitvcs.ui.widget.TextView() self.message_entry.view.set_size_request(300, 75) self.message_entry.view.set_hexpand(True) self.message_entry.view.set_vexpand(True) swin = Gtk.ScrolledWindow() swin.set_shadow_type(Gtk.ShadowType.ETCHED_IN) swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) swin.set_hexpand(True) swin.set_vexpand(True) swin.add(self.message_entry.view) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(swin, 1, row, 2, 1) message_entry_row = row row = row + 1 # Set up Save button self.save_button = Gtk.Button(label=_("Save")) self.save_button.set_halign(Gtk.Align.START) self.save_button.connect("clicked", self.on_save_clicked) self.detail_grid.attach(self.save_button, 1, row, 1, 1) save_row = row row = row + 1 # Set up the tagger line label = Gtk.Label(label=_("Tagger:")) label.set_properties(xalign=0, yalign=0) self.tagger_label = Gtk.Label(label="") self.tagger_label.set_properties(xalign=0, yalign=0, selectable=True) self.tagger_label.set_hexpand(True) self.tagger_label.set_line_wrap(True) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(self.tagger_label, 1, row, 2, 1) tagger_row = row row = row + 1 # Set up the Date line label = Gtk.Label(label=_("Date:")) label.set_properties(xalign=0, yalign=0) self.date_label = Gtk.Label(label="") self.date_label.set_properties(xalign=0, yalign=0, selectable=True) self.date_label.set_hexpand(True) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(self.date_label, 1, row, 2, 1) date_row = row row = row + 1 # Set up the Revision line label = Gtk.Label(label=_("Revision:")) label.set_properties(xalign=0, yalign=0) self.revision_label = Gtk.Label(label="") self.revision_label.set_properties(xalign=0, selectable=True) self.revision_label.set_hexpand(True) self.revision_label.set_line_wrap(True) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(self.revision_label, 1, row, 2, 1) revision_row = row row = row + 1 # Set up the Log Message line label = Gtk.Label(label=_("Message:")) label.set_properties(xalign=0, yalign=0) self.message_label = Gtk.Label(label="") self.message_label.set_properties(xalign=0, yalign=0, selectable=True) self.message_label.set_hexpand(True) self.message_label.set_vexpand(True) self.message_label.set_line_wrap(True) vport = Gtk.Viewport() vport.set_shadow_type(Gtk.ShadowType.NONE) vport.set_hexpand(True) vport.set_vexpand(True) vport.add(self.message_label) swin = Gtk.ScrolledWindow() swin.set_shadow_type(Gtk.ShadowType.NONE) swin.set_size_request(250, -1) swin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) swin.set_hexpand(True) swin.set_vexpand(True) swin.add(vport) self.detail_grid.attach(label, 0, row, 1, 1) self.detail_grid.attach(swin, 1, row, 2, 1) message_row = row row = row + 1 self.add_rows = [ tag_name_row, message_entry_row, start_point_row, save_row ] self.view_rows = [ tag_name_row, tagger_row, date_row, revision_row, message_row ] self.detail_grid.show() self.detail_container.add(self.detail_grid)
def short(self): if self.value: return helper.to_text(self.value)[0:7] else: return self.kind