Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Vineet <saivineet89@gmail.com>2014-01-12 09:05:40 (GMT)
committer Sai Vineet <saivineet89@gmail.com>2014-01-12 09:05:40 (GMT)
commitc08db73a29f28d23723ad44270a61432d16151d9 (patch)
treea771a3926b61781eded8ee031763b5beefe9726f
parent9ae7eac046cadf80c6ec0f124c69e098ee4d0268 (diff)
Minor Changesgtk3
Import from library is now library.filename instead of just filename, but just filename works too, since its in the PYTHONPATH inside the program, used for importing pippy. Now the library button shows a list of files in library as palette Pressing Esc now hides the output box.
-rw-r--r--pippy_app.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/pippy_app.py b/pippy_app.py
index 2c8d98e..14fcb55 100644
--- a/pippy_app.py
+++ b/pippy_app.py
@@ -111,8 +111,6 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
self.loaded_session = []
self.session_data = []
- sys.path.append(os.path.join(self.get_activity_root(), 'Library'))
-
def initialize_display(self):
self._logger = logging.getLogger('pippy-activity')
@@ -139,6 +137,15 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
save_as_library = ToolButton('pippy-export-library')
save_as_library.set_tooltip(_('Save this file to the Pippy library'))
save_as_library.connect('clicked', self._save_as_library)
+
+ lib_dir = os.path.join(get_bundle_path(), 'library')
+ libfiles = self._list_files(lib_dir)
+ files_vb = Gtk.VBox()
+ for f in libfiles:
+ files_vb.add(Gtk.Label(label=f))
+ save_as_library.get_palette().set_content(files_vb)
+ files_vb.show_all()
+
save_as_library.show()
activity_toolbar.insert(save_as_library, -1)
@@ -333,11 +340,21 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
vpane.add2(outbox)
self.outbox = outbox
+ self.connect('key-press-event', self._key_press_cb)
+
return vpane
def after_init(self):
self.outbox.hide()
+ def _key_press_cb(self, window, event):
+ key_name = Gdk.keyval_name(event.keyval)
+ if key_name == 'Escape':
+ self.outbox.hide()
+ self.toggle_output.set_tooltip(_('Show output panel'))
+ self.toggle_output.set_icon_name('tray-show')
+ self.toggle_output.set_active(False)
+
def _toggle_output_cb(self, button):
shown = button.get_active()
if shown:
@@ -499,8 +516,8 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
['/bin/sh', '-c', 'python %s; sleep 1' % current_file,
'PYTHONPATH=%s/library:%s' % (get_bundle_path(),
os.getenv('PYTHONPATH', ''))],
- ['PYTHONPATH=%s/library:%s' % (get_bundle_path(),
- os.getenv('PYTHONPATH', ''))],
+ ['PYTHONPATH=%s:%s' % (get_bundle_path(),
+ os.getenv('PYTHONPATH', ''))],
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
None,
None,)
@@ -531,12 +548,19 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity):
alert = NotifyAlert(5)
alert.props.title = _('Python File added to Library')
IMPORT_MESSAGE = _('The file you selected has been added'
- ' to the library. Use "import {importname}"'
+ ' to the library. Use '
+ '"import library.{importname}"'
' to import the library for using.')
alert.props.msg = IMPORT_MESSAGE.format(importname=file_name[:-3])
alert.connect('response', self.remove_alert_cb)
self.add_alert(alert)
+ def _list_files(self, lib_dir):
+ files = [f[:-3] for f in os.listdir(lib_dir)
+ if os.path.isfile(os.path.join(lib_dir, f)) and
+ f != "__init__.py"]
+ return files
+
def _export_document_cb(self, __):
self.copy()