diff options
author | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-09 17:15:29 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-09 17:15:29 (GMT) |
commit | 754761db9136383ee6c8435a168ba41a98c51894 (patch) | |
tree | 3625bcbf88c043e76be047e68509918abca6effc | |
parent | fb9627fc7ecdc80143c4a905a8db2cd759ca2d79 (diff) |
Some bugs removed and edit toolbar redesign
Signed-off-by: Agustin Zubiaga <aguzubiaga97@gmail.com>
-rw-r--r-- | activity.py | 16 | ||||
-rw-r--r-- | pep8_check.py | 45 |
2 files changed, 41 insertions, 20 deletions
diff --git a/activity.py b/activity.py index 0319b27..c53a3a5 100644 --- a/activity.py +++ b/activity.py @@ -137,6 +137,15 @@ class JAMEdit(activity.Activity): separator.set_expand(True) edit_toolbar.insert(separator, -1) + edit_toolbar.pep8_btn = ToolButton('pep8') + edit_toolbar.pep8_btn.set_tooltip(_("PEP 8 Check")) + edit_toolbar.pep8_btn.connect("clicked", self.pep8_check) + edit_toolbar.insert(edit_toolbar.pep8_btn, -1) + + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + edit_toolbar.insert(separator, -1) + insert_datetime = ToolButton("insert-datetime") insert_datetime.connect("clicked", self.editor._insert_date_time) @@ -144,11 +153,6 @@ class JAMEdit(activity.Activity): edit_toolbar.insert(insert_datetime, -1) insert_datetime.show_all() - edit_toolbar.pep8_btn = ToolButton('pep8') - edit_toolbar.pep8_btn.set_tooltip(_("PEP 8 Check")) - edit_toolbar.pep8_btn.connect("clicked", self.pep8_check) - edit_toolbar.insert(edit_toolbar.pep8_btn, -1) - edit_toolbar.copy.connect("clicked", self.editor._copy_cb) edit_toolbar.paste.connect("clicked", self.editor._paste_cb) edit_toolbar.undo.connect("clicked", self.editor._undo_cb) @@ -266,6 +270,7 @@ class JAMEdit(activity.Activity): activity.Activity.close(self) def open_file(self, widget): + self.editor.pep8.check_exit() self.save_file(None, type="exit") file_path = file_choosers.open_file_dialog() if file_path != None: @@ -280,6 +285,7 @@ class JAMEdit(activity.Activity): file.close() def new(self, widget): + self.editor.pep8.check_exit() _continue = self.save_file(None, type="exit") if _continue: self.metadata["mime_type"] = "text/x-generic" diff --git a/pep8_check.py b/pep8_check.py index a1c2dd7..6b627d4 100644 --- a/pep8_check.py +++ b/pep8_check.py @@ -44,7 +44,7 @@ class PEP8_Check(): def highlight_errors(self, editor, chk): text = editor._get_all_text() editor.buffer.set_text("") - num = -1 + num = 0 for line in text.split("\n"): num += 1 if str(num) in chk: @@ -89,17 +89,32 @@ class PEP8_Check(): return checks def set_bar_text(self, widget, step_size, count, extend_selection, check): - if step_size == gtk.MOVEMENT_DISPLAY_LINES: - cursor_position = widget.buffer.get_property("cursor-position") - offset_iter = widget.buffer.get_iter_at_offset(cursor_position) - line = offset_iter.get_line() - print line - if str(line) in check: - this_line_error = check[str(line)] - char = this_line_error.split(":")[0] - this_line_error = this_line_error.split(":")[1] - self.activity.pep8_bar.label.set_text( - str(line)+":"+char+" "+this_line_error) - print this_line_error - self.activity.pep8_bar.show_all() - else: self.activity.pep8_bar.hide() + cursor_position = widget.buffer.get_property("cursor-position") + offset_iter = widget.buffer.get_iter_at_offset(cursor_position) + line = offset_iter.get_line()+2 + if str(line) in check: + this_line_error = check[str(line)] + char = this_line_error.split(":")[0] + this_line_error = this_line_error.split(":")[1] + self.activity.pep8_bar.label.set_text( + str(line)+":"+char+" "+this_line_error) + print this_line_error + self.activity.pep8_bar.show_all() + else: pass + + def check_exit(self): + text = self.activity.editor._get_all_text() + self.activity.editor.buffer.set_text("") + editor = self.activity.editor + num = 0 + for line in text.split("\n"): + num += 1 + line_iter = editor.buffer.get_iter_at_line(num) + if num == len(text.split("\n"))-1: + editor.buffer.insert_with_tags_by_name(line_iter, line) + else: + editor.buffer.insert_with_tags_by_name(line_iter, \ + line+"\n") + + self.activity.pep8_bar.hide() + self.activity.pep8_bar.label.set_text("") |