diff options
author | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-07 02:31:52 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguzubiaga97@gmail.com> | 2011-12-07 02:31:52 (GMT) |
commit | 64e108f07c245df939521d3017d9d99df12ebe0f (patch) | |
tree | 6fde9e18517c7dc66a3ddcb8673c0977a3b0c048 | |
parent | 415d35ce73334472f479e3ead2b9db4e05dbccb1 (diff) |
New file button added, save file question in exit added.
Signed-off-by: Agustin Zubiaga <aguzubiaga97@gmail.com>
-rw-r--r-- | activity.py | 66 | ||||
-rw-r--r-- | icons/list-add.svg | 6 | ||||
-rw-r--r-- | icons/new.svg | 115 | ||||
-rw-r--r-- | icons/text-x-generic.2.svg | 115 |
4 files changed, 293 insertions, 9 deletions
diff --git a/activity.py b/activity.py index 2295e01..0d8bd25 100644 --- a/activity.py +++ b/activity.py @@ -98,10 +98,21 @@ class JAMEdit(activity.Activity): activity_toolbar.show_all() activity_toolbar.stop.hide() + + # Guardar como / Save As save_as = gtk.MenuItem(_("Save on the file system.")) activity_toolbar.keep.props.palette.menu.append(save_as) save_as.connect("activate", self.save_file_as) save_as.show() + + # Nuevo / New + new = ToolButton("new") + new.set_tooltip(_("New file")) + new.set_accelerator('<ctrl>n') + new.connect("clicked", self.new) + activity_toolbar.insert(new, 5) + new.show() + activity_toolbar.keep.show() self.toolbar_box.toolbar.insert(activity_button, 0) @@ -245,6 +256,17 @@ class JAMEdit(activity.Activity): self.editor._search_and_active_language(mime_type) file.close() + def new(self, widget): + self.save_file(None, type="exit") + self.metadata["mime_type"] = "text/x-generic" + self.editor.lang = None + self.editor.file = None + self.editor.lang_combo.set_active(0) + self.editor.buffer.set_highlight_syntax(False) + self.edit_toolbar.pep8_btn.hide() + self.editor.buffer.set_text("") + self.set_title(_("New")) + def save_file_as(self, widget): file_path = file_choosers.save_file_dialog() if file_path: @@ -259,18 +281,41 @@ class JAMEdit(activity.Activity): self.editor.file = file_path self.editor._search_and_active_language(mime_type) - def save_file(self, widget): - if self.editor.file: - file = open(self.editor.file, "w") - file.write(self.editor._get_all_text()) - file.close() - else: - file_path = file_choosers.save_file_dialog() - if file_path: - self.editor.file = file_path + def save_file(self, widget, type=None, mode=1): + if not type: + if self.editor.file: file = open(self.editor.file, "w") file.write(self.editor._get_all_text()) file.close() + else: + file_path = file_choosers.save_file_dialog() + if file_path: + self.editor.file = file_path + file = open(self.editor.file, "w") + file.write(self.editor._get_all_text()) + file.close() + if type == "exit": + dialog = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION) + dialog.add_buttons(gtk.STOCK_NO, gtk.RESPONSE_CANCEL, gtk.STOCK_YES, gtk.RESPONSE_ACCEPT) + dialog.set_markup("<b>%s</b>" % _("Save changes...")) + if mode == 1: + dialog.format_secondary_text(_("Do you want to save changes?")) + elif mode == 2: + dialog.format_secondary_text(_("Do you want to save changes\nin the file system?")) + response = dialog.run() + dialog.destroy() + if response == gtk.RESPONSE_ACCEPT: + if self.editor.file: + file = open(self.editor.file, "w") + file.write(self.editor._get_all_text()) + file.close() + else: + file_path = file_choosers.save_file_dialog() + if file_path: + self.editor.file = file_path + file = open(self.editor.file, "w") + file.write(self.editor._get_all_text()) + file.close() def write_file(self, file_path): if self.editor.lang: @@ -285,6 +330,9 @@ class JAMEdit(activity.Activity): jfile.write(self.editor._get_all_text()) jfile.close() + if not self.editor.file: + self.save_file(None, type="exit", mode=2) + def read_file(self, file_path): fpath = open(file_path, "r") text = fpath.read() diff --git a/icons/list-add.svg b/icons/list-add.svg new file mode 100644 index 0000000..1be20c8 --- /dev/null +++ b/icons/list-add.svg @@ -0,0 +1,6 @@ +<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#010101"> + <!ENTITY fill_color "#FFFFFF"> +]><svg enable-background="new 0 0 55.125 55" height="55px" version="1.1" viewBox="0 0 55.125 55" width="55.125px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="list-add"> + <path d="M43.467,11.644c-8.789-8.79-23.035-8.786-31.818-0.002 c-8.791,8.791-8.792,23.033-0.002,31.823c8.79,8.789,23.031,8.788,31.822-0.003C52.252,34.678,52.257,20.433,43.467,11.644z M30.768,38.767c-0.002,1.774-1.438,3.216-3.214,3.214c-0.889,0.001-1.693-0.359-2.275-0.941c-0.582-0.581-0.94-1.385-0.94-2.27 l0-8.146h-8.146c-0.886-0.001-1.689-0.359-2.271-0.94c-0.582-0.583-0.942-1.388-0.942-2.276c0-1.773,1.439-3.213,3.217-3.211h8.143 v-8.143c-0.003-1.776,1.438-3.217,3.212-3.217c1.774,0,3.218,1.438,3.215,3.215l0.001,8.145l8.146,0.001 c1.775-0.005,3.212,1.438,3.213,3.213c0.002,1.775-1.441,3.214-3.215,3.215h-8.143V38.767z" display="inline" fill="&fill_color;"/> +</g></svg>
\ No newline at end of file diff --git a/icons/new.svg b/icons/new.svg new file mode 100644 index 0000000..6bbe77d --- /dev/null +++ b/icons/new.svg @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 55 55" + height="55px" + version="1.1" + viewBox="0 0 55 55" + width="55px" + x="0px" + xml:space="preserve" + y="0px" + id="svg2" + inkscape:version="0.48.2 r9819" + sodipodi:docname="text-x-generic.2.svg"><metadata + id="metadata23"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs21" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1280" + inkscape:window-height="746" + id="namedview19" + showgrid="false" + inkscape:zoom="3.7297716" + inkscape:cx="10.990587" + inkscape:cy="27.502882" + inkscape:window-x="0" + inkscape:window-y="26" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" /><g + display="block" + id="clipping-text"> + <g + display="inline" + id="g5"> + <g + id="g7"> + <polygon + fill="#FFFFFF" + points="10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 " + stroke="#010101" + stroke-width="3.5" + id="polygon9" /> + <polyline + fill="none" + points="43.818,18.027 31.874,18.027 31.874,6.088 " + stroke="#010101" + stroke-width="3.5" + id="polyline11" /> + </g> + </g> + <line + display="inline" + fill="none" + stroke="#010101" + stroke-width="3.5" + x1="17.875" + x2="36.875" + y1="26.25" + y2="26.25" + id="line13" /> + <line + display="inline" + fill="none" + stroke="#010101" + stroke-width="3.5" + x1="17.875" + x2="36.875" + y1="33.25" + y2="33.25" + id="line15" /> + <line + display="inline" + fill="none" + stroke="#010101" + stroke-width="3.5" + x1="17.875" + x2="36.875" + y1="40.25" + y2="40.25" + id="line17" /> +</g><path + sodipodi:type="arc" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path3781" + sodipodi:cx="-64.43856" + sodipodi:cy="27.966103" + sodipodi:rx="8.9724579" + sodipodi:ry="8.3898306" + d="m -55.466103,27.966103 a 8.9724579,8.3898306 0 1 1 -17.944915,0 8.9724579,8.3898306 0 1 1 17.944915,0 z" + transform="matrix(0.95517734,0,0,0.95206466,102.61413,18.097623)" /><g + id="list-add" + display="block" + style="fill:#000000;display:block" + transform="matrix(0.37856905,0,0,0.35448431,30.381258,34.664459)"> + <path + id="path3003" + display="inline" + d="M 43.467,11.644 C 34.678,2.854 20.432,2.858 11.649,11.642 2.858,20.433 2.857,34.675 11.647,43.465 c 8.79,8.789 23.031,8.788 31.822,-0.003 8.783,-8.784 8.788,-23.029 -0.002,-31.818 z M 30.768,38.767 c -0.002,1.774 -1.438,3.216 -3.214,3.214 -0.889,10e-4 -1.693,-0.359 -2.275,-0.941 -0.582,-0.581 -0.94,-1.385 -0.94,-2.27 l 0,-8.146 h -8.146 c -0.886,-10e-4 -1.689,-0.359 -2.271,-0.94 -0.582,-0.583 -0.942,-1.388 -0.942,-2.276 0,-1.773 1.439,-3.213 3.217,-3.211 h 8.143 v -8.143 c -0.003,-1.776 1.438,-3.217 3.212,-3.217 1.774,0 3.218,1.438 3.215,3.215 l 0.001,8.145 8.146,0.001 c 1.775,-0.005 3.212,1.438 3.213,3.213 0.002,1.775 -1.441,3.214 -3.215,3.215 h -8.143 v 8.141 z" + inkscape:connector-curvature="0" + style="fill:#000000;display:inline" /> +</g></svg>
\ No newline at end of file diff --git a/icons/text-x-generic.2.svg b/icons/text-x-generic.2.svg new file mode 100644 index 0000000..4f508ef --- /dev/null +++ b/icons/text-x-generic.2.svg @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 55 55" + height="55px" + version="1.1" + viewBox="0 0 55 55" + width="55px" + x="0px" + xml:space="preserve" + y="0px" + id="svg2" + inkscape:version="0.48.2 r9819" + sodipodi:docname="text-x-generic.2.svg"><metadata + id="metadata23"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs21" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1280" + inkscape:window-height="746" + id="namedview19" + showgrid="false" + inkscape:zoom="3.7297716" + inkscape:cx="10.990587" + inkscape:cy="27.502882" + inkscape:window-x="0" + inkscape:window-y="26" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" /><g + display="block" + id="clipping-text"> + <g + display="inline" + id="g5"> + <g + id="g7"> + <polygon + fill="#FFFFFF" + points="10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 " + stroke="#010101" + stroke-width="3.5" + id="polygon9" /> + <polyline + fill="none" + points="43.818,18.027 31.874,18.027 31.874,6.088 " + stroke="#010101" + stroke-width="3.5" + id="polyline11" /> + </g> + </g> + <line + display="inline" + fill="none" + stroke="#010101" + stroke-width="3.5" + x1="17.875" + x2="36.875" + y1="26.25" + y2="26.25" + id="line13" /> + <line + display="inline" + fill="none" + stroke="#010101" + stroke-width="3.5" + x1="17.875" + x2="36.875" + y1="33.25" + y2="33.25" + id="line15" /> + <line + display="inline" + fill="none" + stroke="#010101" + stroke-width="3.5" + x1="17.875" + x2="36.875" + y1="40.25" + y2="40.25" + id="line17" /> +</g><path + sodipodi:type="arc" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path3781" + sodipodi:cx="-64.43856" + sodipodi:cy="27.966103" + sodipodi:rx="8.9724579" + sodipodi:ry="8.3898306" + d="m -55.466103,27.966103 a 8.9724579,8.3898306 0 1 1 -17.944915,0 8.9724579,8.3898306 0 1 1 17.944915,0 z" + transform="matrix(0.95517734,0,0,0.95206466,102.61413,18.097623)" /><g + id="list-add" + display="block" + style="fill:#000000;display:block" + transform="matrix(0.37856905,0,0,0.35448431,30.381258,34.664459)"> + <path + id="path3003" + display="inline" + d="M 43.467,11.644 C 34.678,2.854 20.432,2.858 11.649,11.642 2.858,20.433 2.857,34.675 11.647,43.465 c 8.79,8.789 23.031,8.788 31.822,-0.003 8.783,-8.784 8.788,-23.029 -0.002,-31.818 z M 30.768,38.767 c -0.002,1.774 -1.438,3.216 -3.214,3.214 -0.889,10e-4 -1.693,-0.359 -2.275,-0.941 -0.582,-0.581 -0.94,-1.385 -0.94,-2.27 l 0,-8.146 h -8.146 c -0.886,-10e-4 -1.689,-0.359 -2.271,-0.94 -0.582,-0.583 -0.942,-1.388 -0.942,-2.276 0,-1.773 1.439,-3.213 3.217,-3.211 h 8.143 v -8.143 c -0.003,-1.776 1.438,-3.217 3.212,-3.217 1.774,0 3.218,1.438 3.215,3.215 l 0.001,8.145 8.146,0.001 c 1.775,-0.005 3.212,1.438 3.213,3.213 0.002,1.775 -1.441,3.214 -3.215,3.215 h -8.143 v 8.141 z" + inkscape:connector-curvature="0" + style="fill:#000000;display:inline" /> +</g></svg>
\ No newline at end of file |