[gedit] quickpopen: pep8 fixes
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] quickpopen: pep8 fixes
- Date: Sun, 13 Apr 2014 13:45:23 +0000 (UTC)
commit 0e9b28f3c61c851adcba540a33e58c440589b56d
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Apr 13 14:51:13 2014 +0200
quickpopen: pep8 fixes
plugins/quickopen/quickopen/__init__.py | 5 ++-
plugins/quickopen/quickopen/popup.py | 48 ++++++++++++++++++---------
plugins/quickopen/quickopen/virtualdirs.py | 3 ++
3 files changed, 39 insertions(+), 17 deletions(-)
---
diff --git a/plugins/quickopen/quickopen/__init__.py b/plugins/quickopen/quickopen/__init__.py
index 9cf874f..b8b54b0 100644
--- a/plugins/quickopen/quickopen/__init__.py
+++ b/plugins/quickopen/quickopen/__init__.py
@@ -21,6 +21,7 @@ from gi.repository import GObject, Gio, GLib, Gtk, Gedit
from .virtualdirs import RecentDocumentsDirectory
from .virtualdirs import CurrentDocumentsDirectory
+
class QuickOpenAppActivatable(GObject.Object, Gedit.AppActivatable):
app = GObject.property(type=Gedit.App)
@@ -37,6 +38,7 @@ class QuickOpenAppActivatable(GObject.Object, Gedit.AppActivatable):
def do_deactivate(self):
self.app.remove_accelerator("win.quickopen", None)
+
class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
__gtype_name__ = "QuickOpenPlugin"
@@ -151,7 +153,8 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
if line.startswith('XDG_DESKTOP_DIR'):
parts = line.split('=', 1)
- desktopdir = os.path.expandvars(parts[1].strip('"').strip("'"))
+ desktopdir = parts[1].strip('"').strip("'")
+ desktopdir = os.path.expandvars(desktopdir)
break
if not desktopdir:
diff --git a/plugins/quickopen/quickopen/popup.py b/plugins/quickopen/quickopen/popup.py
index 45249e1..17c60f4 100644
--- a/plugins/quickopen/quickopen/popup.py
+++ b/plugins/quickopen/quickopen/popup.py
@@ -23,18 +23,20 @@ from gi.repository import Gio, GObject, Pango, Gtk, Gdk, Gedit
import xml.sax.saxutils
from .virtualdirs import VirtualDirectory
+
class Popup(Gtk.Dialog):
__gtype_name__ = "QuickOpenPopup"
def __init__(self, window, paths, handler):
Gtk.Dialog.__init__(self,
- title=_('Quick Open'),
- transient_for=window,
- modal=True,
- destroy_with_parent=True)
+ title=_('Quick Open'),
+ transient_for=window,
+ modal=True,
+ destroy_with_parent=True)
self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
- self._open_button = self.add_button(_("_Open"), Gtk.ResponseType.ACCEPT)
+ self._open_button = self.add_button(_("_Open"),
+ Gtk.ResponseType.ACCEPT)
self._handler = handler
self._build_ui()
@@ -49,7 +51,10 @@ class Popup(Gtk.Dialog):
self._busy_cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
accel_group = Gtk.AccelGroup()
- accel_group.connect(Gdk.KEY_l, Gdk.ModifierType.CONTROL_MASK, 0, self.on_focus_entry)
+ accel_group.connect(Gdk.KEY_l,
+ Gdk.ModifierType.CONTROL_MASK,
+ 0,
+ self.on_focus_entry)
self.add_accel_group(accel_group)
@@ -86,7 +91,10 @@ class Popup(Gtk.Dialog):
tv = Gtk.TreeView()
tv.set_headers_visible(False)
- self._store = Gtk.ListStore(Gio.Icon, str, GObject.Object, Gio.FileType)
+ self._store = Gtk.ListStore(Gio.Icon,
+ str,
+ GObject.Object,
+ Gio.FileType)
tv.set_model(self._store)
self._treeview = tv
@@ -162,7 +170,9 @@ class Popup(Gtk.Dialog):
entries = []
try:
- ret = gfile.enumerate_children("standard::*", Gio.FileQueryInfoFlags.NONE, None)
+ ret = gfile.enumerate_children("standard::*",
+ Gio.FileQueryInfoFlags.NONE,
+ None)
except GObject.Error as e:
pass
@@ -245,7 +255,7 @@ class Popup(Gtk.Dialog):
else:
found.append(entry)
elif entry[2] == Gio.FileType.REGULAR and \
- (not lpart or len(parts) == 1):
+ (not lpart or len(parts) == 1):
found.append(entry)
found.sort(key=functools.cmp_to_key(lambda a, b: self._compare_entries(a[1].lower(), b[1].lower(),
lpart)))
@@ -278,7 +288,6 @@ class Popup(Gtk.Dialog):
return out + xml.sax.saxutils.escape(s[last:])
-
def make_markup(self, parts, path):
out = []
@@ -345,7 +354,10 @@ class Popup(Gtk.Dialog):
for d in self._dirs:
if isinstance(d, VirtualDirectory):
for entry in d.enumerate_children("standard::*", 0, None):
- self._append_to_store((entry[1].get_icon(),
xml.sax.saxutils.escape(entry[1].get_name()), entry[0], entry[1].get_file_type()))
+ self._append_to_store((entry[1].get_icon(),
+ xml.sax.saxutils.escape(entry[1].get_name()),
+ entry[0],
+ entry[1].get_file_type()))
def _set_busy(self, busy):
if busy:
@@ -377,18 +389,22 @@ class Popup(Gtk.Dialog):
for d in self._dirs:
for entry in self.do_search_dir(parts, d):
pathparts = self._make_parts(d, entry[0], parts)
- self._append_to_store((entry[3], self.make_markup(parts, pathparts), entry[0], entry[2]))
+ self._append_to_store((entry[3],
+ self.make_markup(parts, pathparts),
+ entry[0],
+ entry[2]))
piter = self._store.get_iter_first()
if piter:
- self._treeview.get_selection().select_path(self._store.get_path(piter))
+ path = self._store.get_path(piter)
+ self._treeview.get_selection().select_path(path)
self._set_busy(False)
- #FIXME: override doesn't work anymore for some reason, if we override
+ # FIXME: override doesn't work anymore for some reason, if we override
# the widget is not realized
def on_show(self, data=None):
- #Gtk.Window.do_show(self)
+ # Gtk.Window.do_show(self)
self._entry.grab_focus()
self._entry.set_text("")
@@ -582,7 +598,7 @@ class Popup(Gtk.Dialog):
else:
fname = xml.sax.saxutils.escape(gfile.get_uri())
- self._open_button.set_sensitive(fname != None)
+ self._open_button.set_sensitive(fname is not None)
self._info_label.set_markup(fname or '')
def on_focus_entry(self, group, accel, keyval, modifier):
diff --git a/plugins/quickopen/quickopen/virtualdirs.py b/plugins/quickopen/quickopen/virtualdirs.py
index f405e81..e080e27 100644
--- a/plugins/quickopen/quickopen/virtualdirs.py
+++ b/plugins/quickopen/quickopen/virtualdirs.py
@@ -17,6 +17,7 @@
from gi.repository import Gio, Gtk
+
class VirtualDirectory(object):
def __init__(self, name):
self._name = name
@@ -45,6 +46,7 @@ class VirtualDirectory(object):
except Exception as e:
pass
+
class RecentDocumentsDirectory(VirtualDirectory):
def __init__(self, maxitems=200):
VirtualDirectory.__init__(self, 'recent')
@@ -68,6 +70,7 @@ class RecentDocumentsDirectory(VirtualDirectory):
if added >= self._maxitems:
break
+
class CurrentDocumentsDirectory(VirtualDirectory):
def __init__(self, window):
VirtualDirectory.__init__(self, 'documents')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]