!1 package init for openEuler
From: @dou33 Reviewed-by: @handsome_feng Signed-off-by: @handsome_feng
This commit is contained in:
commit
066f6dc34e
BIN
pluma-1.22.2.tar.xz
Normal file
BIN
pluma-1.22.2.tar.xz
Normal file
Binary file not shown.
173
pluma.spec
Normal file
173
pluma.spec
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
# Conditional for release and snapshot builds. Uncomment for release-builds.
|
||||||
|
%global rel_build 1
|
||||||
|
|
||||||
|
# This is needed, because src-url contains branched part of versioning-scheme.
|
||||||
|
%global branch 1.22
|
||||||
|
|
||||||
|
# Settings used for build from snapshots.
|
||||||
|
%{!?rel_build:%global commit c1ca209172a8b3a0751ac0a1e2dbec33c1894290}
|
||||||
|
%{!?rel_build:%global commit_date 20140712}
|
||||||
|
%{!?rel_build:%global shortcommit %(c=%{commit};echo ${c:0:7})}
|
||||||
|
%{!?rel_build:%global git_ver git%{commit_date}-%{shortcommit}}
|
||||||
|
%{!?rel_build:%global git_rel .git%{commit_date}.%{shortcommit}}
|
||||||
|
%{!?rel_build:%global git_tar %{name}-%{version}-%{git_ver}.tar.xz}
|
||||||
|
|
||||||
|
Summary: Text editor for the MATE desktop
|
||||||
|
Name: pluma
|
||||||
|
Version: %{branch}.2
|
||||||
|
%if 0%{?rel_build}
|
||||||
|
Release: 1
|
||||||
|
%else
|
||||||
|
Release: 0.7%{?git_rel}
|
||||||
|
%endif
|
||||||
|
License: GPLv2+ and LGPLv2+
|
||||||
|
URL: http://mate-desktop.org
|
||||||
|
|
||||||
|
# for downloading the tarball use 'spectool -g -R pluma.spec'
|
||||||
|
# Source for release-builds.
|
||||||
|
%{?rel_build:Source0: http://pub.mate-desktop.org/releases/%{branch}/%{name}-%{version}.tar.xz}
|
||||||
|
# Source for snapshot-builds.
|
||||||
|
%{!?rel_build:Source0: http://git.mate-desktop.org/%{name}/snapshot/%{name}-%{commit}.tar.xz#/%{git_tar}}
|
||||||
|
|
||||||
|
# https://github.com/mate-desktop/pluma/commit/e88a2ea
|
||||||
|
Patch1: pluma_0001-Reindent-all-Python-sources-to-ts-4.-Strip-trailing-1.22.patch
|
||||||
|
# https://github.com/mate-desktop/pluma/pull/433
|
||||||
|
Patch2: pluma_0001-quickopen-plugin-change-code-for-Python-2-3-compatib.patch
|
||||||
|
# https://github.com/mate-desktop/pluma/pull/434
|
||||||
|
Patch3: pluma_0001-pythonconsole-plugin-change-source-code-for-Python-2.patch
|
||||||
|
# https://github.com/mate-desktop/pluma/pull/435
|
||||||
|
Patch4: pluma_0001-externaltools-plugin-change-code-for-Python-2-3-comp.patch
|
||||||
|
# https://github.com/mate-desktop/pluma/pull/436
|
||||||
|
Patch5: pluma_0001-snippets-plugin-change-code-for-Python-2-3-compatibi.patch
|
||||||
|
# https://github.com/mate-desktop/pluma/pull/437
|
||||||
|
Patch6: pluma_0001-Switch-to-Python-3.patch
|
||||||
|
|
||||||
|
BuildRequires: desktop-file-utils
|
||||||
|
BuildRequires: enchant-devel
|
||||||
|
BuildRequires: libpeas-devel
|
||||||
|
BuildRequires: gtk3-devel
|
||||||
|
BuildRequires: gtksourceview3-devel
|
||||||
|
BuildRequires: iso-codes-devel
|
||||||
|
BuildRequires: libSM-devel
|
||||||
|
BuildRequires: mate-common
|
||||||
|
BuildRequires: pygobject3-devel
|
||||||
|
BuildRequires: python3-devel
|
||||||
|
|
||||||
|
Requires: %{name}-data = %{version}-%{release}
|
||||||
|
# needed to get a gsettings schema, #959607
|
||||||
|
Requires: mate-desktop-libs
|
||||||
|
# needed to get a gsettings schema, #959607
|
||||||
|
# Requires: caja-schemas
|
||||||
|
# the run-command plugin uses zenity
|
||||||
|
Requires: zenity
|
||||||
|
# libpeas isn't splited in rhel7
|
||||||
|
%if 0%{?fedora} && 0%{?fedora} <= 29
|
||||||
|
Requires: libpeas-loader-python3
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%description
|
||||||
|
pluma is a small, but powerful text editor designed specifically for
|
||||||
|
the MATE desktop. It has most standard text editor functions and fully
|
||||||
|
supports international text in Unicode. Advanced features include syntax
|
||||||
|
highlighting and automatic indentation of source code, printing and editing
|
||||||
|
of multiple documents in one window.
|
||||||
|
|
||||||
|
pluma is extensible through a plugin system, which currently includes
|
||||||
|
support for spell checking, comparing files, viewing CVS ChangeLogs, and
|
||||||
|
adjusting indentation levels.
|
||||||
|
|
||||||
|
%package data
|
||||||
|
Summary: Data files for pluma
|
||||||
|
BuildArch: noarch
|
||||||
|
Requires: %{name} = %{version}-%{release}
|
||||||
|
|
||||||
|
%description data
|
||||||
|
This package contains shared data needed for pluma.
|
||||||
|
|
||||||
|
|
||||||
|
%package devel
|
||||||
|
Summary: Support for developing plugins for the pluma text editor
|
||||||
|
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||||
|
Requires: gtksourceview3-devel
|
||||||
|
|
||||||
|
%description devel
|
||||||
|
Development files for pluma
|
||||||
|
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%if 0%{?rel_build}
|
||||||
|
%autosetup -p1
|
||||||
|
%else
|
||||||
|
%autosetup -n %{name}-%{commit} -p1
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%if 0%{?rel_build}
|
||||||
|
# for releases
|
||||||
|
#NOCONFIGURE=1 ./autogen.sh
|
||||||
|
%else
|
||||||
|
# needed for git snapshots
|
||||||
|
NOCONFIGURE=1 ./autogen.sh
|
||||||
|
%endif
|
||||||
|
|
||||||
|
# with python3
|
||||||
|
sed -i 's|#!\/usr\/bin/\python|#!\/usr\/bin\/python3|g' plugins/externaltools/data/switch-c.tool.in
|
||||||
|
|
||||||
|
# Patch 5
|
||||||
|
NOCONFIGURE=1 ./autogen.sh
|
||||||
|
|
||||||
|
# Fix debug permissions with messy hack
|
||||||
|
find ./*/* -type f -exec chmod 644 {} \;
|
||||||
|
find ./*/*/* -type f -exec chmod 644 {} \;
|
||||||
|
|
||||||
|
%build
|
||||||
|
%configure \
|
||||||
|
--disable-static \
|
||||||
|
--enable-gtk-doc-html \
|
||||||
|
--enable-gvfs-metadata \
|
||||||
|
--disable-schemas-compile
|
||||||
|
|
||||||
|
make %{?_smp_mflags} V=1
|
||||||
|
|
||||||
|
%install
|
||||||
|
%{make_install}
|
||||||
|
|
||||||
|
desktop-file-install \
|
||||||
|
--delete-original \
|
||||||
|
--dir %{buildroot}%{_datadir}/applications \
|
||||||
|
%{buildroot}%{_datadir}/applications/*.desktop
|
||||||
|
|
||||||
|
# clean up all the static libs for plugins
|
||||||
|
find %{buildroot} -name '*.la' -exec rm -f {} ';'
|
||||||
|
find %{buildroot} -name '*.a' -exec rm -f {} ';'
|
||||||
|
|
||||||
|
%find_lang %{name} --with-gnome --all-name
|
||||||
|
|
||||||
|
|
||||||
|
%files
|
||||||
|
%{_bindir}/pluma
|
||||||
|
%{_libdir}/pluma/
|
||||||
|
%{_libexecdir}/pluma/
|
||||||
|
%{_libdir}/girepository-1.0/Pluma-1.0.typelib
|
||||||
|
%{_datadir}/applications/pluma.desktop
|
||||||
|
%{_datadir}/metainfo/pluma.appdata.xml
|
||||||
|
%{_datadir}/glib-2.0/schemas/org.mate.pluma.gschema.xml
|
||||||
|
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.filebrowser.gschema.xml
|
||||||
|
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.pythonconsole.gschema.xml
|
||||||
|
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.time.gschema.xml
|
||||||
|
%{_datadir}/glib-2.0/schemas/org.mate.pluma.plugins.spell.gschema.xml
|
||||||
|
|
||||||
|
%files data -f %{name}.lang
|
||||||
|
%doc README COPYING AUTHORS
|
||||||
|
%{_datadir}/pluma/
|
||||||
|
%{_mandir}/man1/pluma.1.*
|
||||||
|
|
||||||
|
%files devel
|
||||||
|
%{_includedir}/pluma/
|
||||||
|
%{_libdir}/pkgconfig/pluma.pc
|
||||||
|
%{_datadir}/gtk-doc/html/pluma/
|
||||||
|
%{_datadir}/gir-1.0/Pluma-1.0.gir
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Fri Dec 11 2020 douyan <douyan@kylinos.cn> - 1.22.2-1
|
||||||
|
- package init for openEuler
|
||||||
File diff suppressed because it is too large
Load Diff
87
pluma_0001-Switch-to-Python-3.patch
Normal file
87
pluma_0001-Switch-to-Python-3.patch
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
From d76c3e37d1212eaa3cac2f293d539bddf9a250f9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Patrick Monnerat <patrick@monnerat.net>
|
||||||
|
Date: Mon, 27 May 2019 15:56:31 +0200
|
||||||
|
Subject: [PATCH 1/2] Switch to Python 3
|
||||||
|
|
||||||
|
---
|
||||||
|
configure.ac | 2 +-
|
||||||
|
plugins/externaltools/externaltools.plugin.desktop.in | 2 +-
|
||||||
|
plugins/pythonconsole/pythonconsole.plugin.desktop.in | 2 +-
|
||||||
|
plugins/quickopen/quickopen.plugin.desktop.in | 2 +-
|
||||||
|
plugins/snippets/snippets.plugin.desktop.in | 2 +-
|
||||||
|
pluma/pluma-plugins-engine.c | 2 +-
|
||||||
|
6 files changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index ceb9a5c..c381583 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -189,7 +189,7 @@ else
|
||||||
|
have_introspection=no
|
||||||
|
fi
|
||||||
|
|
||||||
|
-AM_PATH_PYTHON([2.7])
|
||||||
|
+AM_PATH_PYTHON([3.0])
|
||||||
|
|
||||||
|
dnl ================================================================
|
||||||
|
dnl GSettings related settings
|
||||||
|
diff --git a/plugins/externaltools/externaltools.plugin.desktop.in b/plugins/externaltools/externaltools.plugin.desktop.in
|
||||||
|
index b3261e7..b1a7f8b 100644
|
||||||
|
--- a/plugins/externaltools/externaltools.plugin.desktop.in
|
||||||
|
+++ b/plugins/externaltools/externaltools.plugin.desktop.in
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
[Plugin]
|
||||||
|
-Loader=python
|
||||||
|
+Loader=python3
|
||||||
|
Module=externaltools
|
||||||
|
IAge=2
|
||||||
|
_Name=External Tools
|
||||||
|
diff --git a/plugins/pythonconsole/pythonconsole.plugin.desktop.in b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
|
||||||
|
index 50d2a7a..4ecbd30 100644
|
||||||
|
--- a/plugins/pythonconsole/pythonconsole.plugin.desktop.in
|
||||||
|
+++ b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
[Plugin]
|
||||||
|
-Loader=python
|
||||||
|
+Loader=python3
|
||||||
|
Module=pythonconsole
|
||||||
|
IAge=2
|
||||||
|
_Name=Python Console
|
||||||
|
diff --git a/plugins/quickopen/quickopen.plugin.desktop.in b/plugins/quickopen/quickopen.plugin.desktop.in
|
||||||
|
index 891a0c3..547e430 100644
|
||||||
|
--- a/plugins/quickopen/quickopen.plugin.desktop.in
|
||||||
|
+++ b/plugins/quickopen/quickopen.plugin.desktop.in
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
[Plugin]
|
||||||
|
-Loader=python
|
||||||
|
+Loader=python3
|
||||||
|
Module=quickopen
|
||||||
|
IAge=2
|
||||||
|
_Name=Quick Open
|
||||||
|
diff --git a/plugins/snippets/snippets.plugin.desktop.in b/plugins/snippets/snippets.plugin.desktop.in
|
||||||
|
index ea960f3..ba1ecbc 100644
|
||||||
|
--- a/plugins/snippets/snippets.plugin.desktop.in
|
||||||
|
+++ b/plugins/snippets/snippets.plugin.desktop.in
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
[Plugin]
|
||||||
|
-Loader=python
|
||||||
|
+Loader=python3
|
||||||
|
Module=snippets
|
||||||
|
IAge=2
|
||||||
|
_Name=Snippets
|
||||||
|
diff --git a/pluma/pluma-plugins-engine.c b/pluma/pluma-plugins-engine.c
|
||||||
|
index e765b0f..c670e62 100644
|
||||||
|
--- a/pluma/pluma-plugins-engine.c
|
||||||
|
+++ b/pluma/pluma-plugins-engine.c
|
||||||
|
@@ -60,7 +60,7 @@ pluma_plugins_engine_init (PlumaPluginsEngine *engine)
|
||||||
|
|
||||||
|
pluma_debug (DEBUG_PLUGINS);
|
||||||
|
|
||||||
|
- peas_engine_enable_loader (PEAS_ENGINE (engine), "python");
|
||||||
|
+ peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");
|
||||||
|
|
||||||
|
engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
|
||||||
|
PLUMA_TYPE_PLUGINS_ENGINE,
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,798 @@
|
|||||||
|
From a54a8e7bf8e86f87316b5026e6e85d6d3fdab226 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Patrick Monnerat <patrick@monnerat.net>
|
||||||
|
Date: Wed, 22 May 2019 18:02:59 +0200
|
||||||
|
Subject: [PATCH] pythonconsole plugin: change source code for Python 2 & 3
|
||||||
|
compatibility.
|
||||||
|
|
||||||
|
Also drop mateconf and use gsettings for preferences.
|
||||||
|
Preferences are now triggered as a PeasGtk.Configurable.
|
||||||
|
---
|
||||||
|
configure.ac | 1 +
|
||||||
|
plugins/pythonconsole/Makefile.am | 19 +-
|
||||||
|
...pluma.plugins.pythonconsole.gschema.xml.in | 30 +++
|
||||||
|
.../pythonconsole/pythonconsole/__init__.py | 37 +--
|
||||||
|
plugins/pythonconsole/pythonconsole/config.py | 158 ++++++------
|
||||||
|
plugins/pythonconsole/pythonconsole/config.ui | 224 +++++++++---------
|
||||||
|
.../pythonconsole/pythonconsole/console.py | 68 ++++--
|
||||||
|
7 files changed, 304 insertions(+), 233 deletions(-)
|
||||||
|
create mode 100644 plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in
|
||||||
|
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index 1cdbb7e..ceb9a5c 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -250,6 +250,7 @@ plugins/filebrowser/org.mate.pluma.plugins.filebrowser.gschema.xml
|
||||||
|
plugins/modelines/Makefile
|
||||||
|
plugins/pythonconsole/Makefile
|
||||||
|
plugins/pythonconsole/pythonconsole/Makefile
|
||||||
|
+plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml
|
||||||
|
plugins/quickopen/Makefile
|
||||||
|
plugins/quickopen/quickopen/Makefile
|
||||||
|
plugins/snippets/data/lang/Makefile
|
||||||
|
diff --git a/plugins/pythonconsole/Makefile.am b/plugins/pythonconsole/Makefile.am
|
||||||
|
index 0a9ff96..51a2e4a 100644
|
||||||
|
--- a/plugins/pythonconsole/Makefile.am
|
||||||
|
+++ b/plugins/pythonconsole/Makefile.am
|
||||||
|
@@ -7,9 +7,22 @@ plugin_in_files = pythonconsole.plugin.desktop.in
|
||||||
|
|
||||||
|
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||||
|
|
||||||
|
-EXTRA_DIST = $(plugin_in_files)
|
||||||
|
+pythonconsole_gschema_in = org.mate.pluma.plugins.pythonconsole.gschema.xml.in
|
||||||
|
+gsettings_SCHEMAS = $(pythonconsole_gschema_in:.xml.in=.xml)
|
||||||
|
+@GSETTINGS_RULES@
|
||||||
|
|
||||||
|
-CLEANFILES = $(plugin_DATA)
|
||||||
|
-DISTCLEANFILES = $(plugin_DATA)
|
||||||
|
+EXTRA_DIST = \
|
||||||
|
+ $(plugin_in_files) \
|
||||||
|
+ $(pythonconsole_gschema_in)
|
||||||
|
+
|
||||||
|
+CLEANFILES = \
|
||||||
|
+ $(plugin_DATA) \
|
||||||
|
+ $(gsettings_SCHEMAS_in) \
|
||||||
|
+ $(gsettings_SCHEMAS)
|
||||||
|
+
|
||||||
|
+DISTCLEANFILES = \
|
||||||
|
+ $(plugin_DATA) \
|
||||||
|
+ $(gsettings_SCHEMAS_in) \
|
||||||
|
+ $(gsettings_SCHEMAS)
|
||||||
|
|
||||||
|
-include $(top_srcdir)/git.mk
|
||||||
|
diff --git a/plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in b/plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..7897fa9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in
|
||||||
|
@@ -0,0 +1,30 @@
|
||||||
|
+<schemalist>
|
||||||
|
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.pluma.plugins.pythonconsole" path="/org/mate/pluma/plugins/pythonconsole/">
|
||||||
|
+ <key name="command-color" type="s">
|
||||||
|
+ <default>'#314e6c'</default>
|
||||||
|
+ <summary>Command Color Text</summary>
|
||||||
|
+ <description>The command color text</description>
|
||||||
|
+ </key>
|
||||||
|
+ <key name="error-color" type="s">
|
||||||
|
+ <default>'#990000'</default>
|
||||||
|
+ <summary>Error Color Text</summary>
|
||||||
|
+ <description>The error color text</description>
|
||||||
|
+ </key>
|
||||||
|
+ <key name="use-system-font" type="b">
|
||||||
|
+ <default>true</default>
|
||||||
|
+ <summary>Whether to use the system font</summary>
|
||||||
|
+ <description>
|
||||||
|
+ If true, the terminal will use the desktop-global standard
|
||||||
|
+ font if it’s monospace (and the most similar font it can
|
||||||
|
+ come up with otherwise).
|
||||||
|
+ </description>
|
||||||
|
+ </key>
|
||||||
|
+ <key name="font" type="s">
|
||||||
|
+ <default>'Monospace 10'</default>
|
||||||
|
+ <summary>Font</summary>
|
||||||
|
+ <description>
|
||||||
|
+ A Pango font name. Examples are “Sans 12” or “Monospace Bold 14”.
|
||||||
|
+ </description>
|
||||||
|
+ </key>
|
||||||
|
+ </schema>
|
||||||
|
+</schemalist>
|
||||||
|
diff --git a/plugins/pythonconsole/pythonconsole/__init__.py b/plugins/pythonconsole/pythonconsole/__init__.py
|
||||||
|
index 07d13c7..171b367 100755
|
||||||
|
--- a/plugins/pythonconsole/pythonconsole/__init__.py
|
||||||
|
+++ b/plugins/pythonconsole/pythonconsole/__init__.py
|
||||||
|
@@ -24,22 +24,22 @@
|
||||||
|
# Bits from pluma Python Console Plugin
|
||||||
|
# Copyrignt (C), 2005 Raphaël Slinckx
|
||||||
|
|
||||||
|
-from gi.repository import GObject, Gtk, Peas, Pluma
|
||||||
|
+from gi.repository import GObject, Gtk, Peas, PeasGtk, Pluma
|
||||||
|
|
||||||
|
-from console import PythonConsole
|
||||||
|
-from config import PythonConsoleConfigDialog
|
||||||
|
-from config import PythonConsoleConfig
|
||||||
|
+from .console import PythonConsole
|
||||||
|
+from .config import PythonConsoleConfigWidget
|
||||||
|
+from .config import PythonConsoleConfig
|
||||||
|
|
||||||
|
PYTHON_ICON = 'text-x-python'
|
||||||
|
|
||||||
|
-class PythonConsolePlugin(GObject.Object, Peas.Activatable):
|
||||||
|
+class PythonConsolePlugin(GObject.Object, Peas.Activatable, PeasGtk.Configurable):
|
||||||
|
__gtype_name__ = "PythonConsolePlugin"
|
||||||
|
|
||||||
|
object = GObject.Property(type=GObject.Object)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
GObject.Object.__init__(self)
|
||||||
|
- self.dlg = None
|
||||||
|
+ self.config_widget = None
|
||||||
|
|
||||||
|
def do_activate(self):
|
||||||
|
window = self.object
|
||||||
|
@@ -47,8 +47,8 @@ class PythonConsolePlugin(GObject.Object, Peas.Activatable):
|
||||||
|
self._console = PythonConsole(namespace = {'__builtins__' : __builtins__,
|
||||||
|
'pluma' : Pluma,
|
||||||
|
'window' : window})
|
||||||
|
- self._console.eval('print "You can access the main window through ' \
|
||||||
|
- '\'window\' :\\n%s" % window', False)
|
||||||
|
+ self._console.eval('print("You can access the main window through ' \
|
||||||
|
+ '\'window\' :\\n%s" % window)', False)
|
||||||
|
bottom = window.get_bottom_panel()
|
||||||
|
image = Gtk.Image()
|
||||||
|
image.set_from_icon_name(PYTHON_ICON, Gtk.IconSize.MENU)
|
||||||
|
@@ -61,22 +61,9 @@ class PythonConsolePlugin(GObject.Object, Peas.Activatable):
|
||||||
|
bottom = window.get_bottom_panel()
|
||||||
|
bottom.remove_item(self._console)
|
||||||
|
|
||||||
|
-def create_configure_dialog(self):
|
||||||
|
-
|
||||||
|
- if not self.dlg:
|
||||||
|
- self.dlg = PythonConsoleConfigDialog(self.get_data_dir())
|
||||||
|
-
|
||||||
|
- dialog = self.dlg.dialog()
|
||||||
|
- window = pluma.app_get_default().get_active_window()
|
||||||
|
- if window:
|
||||||
|
- dialog.set_transient_for(window)
|
||||||
|
-
|
||||||
|
- return dialog
|
||||||
|
-
|
||||||
|
-# Here we dynamically insert create_configure_dialog based on if configuration
|
||||||
|
-# is enabled. This has to be done like this because pluma checks if a plugin
|
||||||
|
-# is configurable solely on the fact that it has this member defined or not
|
||||||
|
-if PythonConsoleConfig.enabled():
|
||||||
|
- PythonConsolePlugin.create_configure_dialog = create_configure_dialog
|
||||||
|
+ def do_create_configure_widget(self):
|
||||||
|
+ if not self.config_widget:
|
||||||
|
+ self.config_widget = PythonConsoleConfigWidget(self.plugin_info.get_data_dir())
|
||||||
|
+ return self.config_widget.configure_widget()
|
||||||
|
|
||||||
|
# ex:et:ts=4:
|
||||||
|
diff --git a/plugins/pythonconsole/pythonconsole/config.py b/plugins/pythonconsole/pythonconsole/config.py
|
||||||
|
index fce0c9d..f973e38 100755
|
||||||
|
--- a/plugins/pythonconsole/pythonconsole/config.py
|
||||||
|
+++ b/plugins/pythonconsole/pythonconsole/config.py
|
||||||
|
@@ -25,110 +25,126 @@
|
||||||
|
# Copyrignt (C), 2005 Raphaël Slinckx
|
||||||
|
|
||||||
|
import os
|
||||||
|
-import gtk
|
||||||
|
+from gi.repository import Gio, Gtk, Gdk
|
||||||
|
|
||||||
|
-__all__ = ('PythonConsoleConfig', 'PythonConsoleConfigDialog')
|
||||||
|
-
|
||||||
|
-MATECONF_KEY_BASE = '/apps/pluma/plugins/pythonconsole'
|
||||||
|
-MATECONF_KEY_COMMAND_COLOR = MATECONF_KEY_BASE + '/command-color'
|
||||||
|
-MATECONF_KEY_ERROR_COLOR = MATECONF_KEY_BASE + '/error-color'
|
||||||
|
-
|
||||||
|
-DEFAULT_COMMAND_COLOR = '#314e6c' # Blue Shadow
|
||||||
|
-DEFAULT_ERROR_COLOR = '#990000' # Accent Red Dark
|
||||||
|
+__all__ = ('PythonConsoleConfig', 'PythonConsoleConfigWidget')
|
||||||
|
|
||||||
|
class PythonConsoleConfig(object):
|
||||||
|
- try:
|
||||||
|
- import mateconf
|
||||||
|
- except ImportError:
|
||||||
|
- mateconf = None
|
||||||
|
-
|
||||||
|
- def __init__(self):
|
||||||
|
- pass
|
||||||
|
|
||||||
|
- @staticmethod
|
||||||
|
- def enabled():
|
||||||
|
- return PythonConsoleConfig.mateconf != None
|
||||||
|
+ CONSOLE_KEY_BASE = 'org.mate.pluma.plugins.pythonconsole'
|
||||||
|
+ CONSOLE_KEY_COMMAND_COLOR = 'command-color'
|
||||||
|
+ CONSOLE_KEY_ERROR_COLOR = 'error-color'
|
||||||
|
+ CONSOLE_KEY_USE_SYSTEM_FONT = 'use-system-font'
|
||||||
|
+ CONSOLE_KEY_FONT = 'font'
|
||||||
|
|
||||||
|
- @staticmethod
|
||||||
|
- def add_handler(handler):
|
||||||
|
- if PythonConsoleConfig.mateconf:
|
||||||
|
- PythonConsoleConfig.mateconf.client_get_default().notify_add(MATECONF_KEY_BASE, handler)
|
||||||
|
+ INTERFACE_KEY_BASE = 'org.mate.interface'
|
||||||
|
+ INTERFACE_KEY_MONOSPACE_FONT_NAME = 'monospace-font-name'
|
||||||
|
|
||||||
|
color_command = property(
|
||||||
|
- lambda self: self.mateconf_get_str(MATECONF_KEY_COMMAND_COLOR, DEFAULT_COMMAND_COLOR),
|
||||||
|
- lambda self, value: self.mateconf_set_str(MATECONF_KEY_COMMAND_COLOR, value))
|
||||||
|
+ lambda self: self.console_settings.get_string(self.CONSOLE_KEY_COMMAND_COLOR),
|
||||||
|
+ lambda self, value: self.console_settings.set_string(self.CONSOLE_KEY_COMMAND_COLOR, value)
|
||||||
|
+ )
|
||||||
|
|
||||||
|
color_error = property(
|
||||||
|
- lambda self: self.mateconf_get_str(MATECONF_KEY_ERROR_COLOR, DEFAULT_ERROR_COLOR),
|
||||||
|
- lambda self, value: self.mateconf_set_str(MATECONF_KEY_ERROR_COLOR, value))
|
||||||
|
+ lambda self: self.console_settings.get_string(self.CONSOLE_KEY_ERROR_COLOR),
|
||||||
|
+ lambda self, value: self.console_settings.set_string(self.CONSOLE_KEY_ERROR_COLOR, value)
|
||||||
|
+ )
|
||||||
|
|
||||||
|
- @staticmethod
|
||||||
|
- def mateconf_get_str(key, default=''):
|
||||||
|
- if not PythonConsoleConfig.mateconf:
|
||||||
|
- return default
|
||||||
|
+ use_system_font = property(
|
||||||
|
+ lambda self: self.console_settings.get_boolean(self.CONSOLE_KEY_USE_SYSTEM_FONT),
|
||||||
|
+ lambda self, value: self.console_settings.set_boolean(self.CONSOLE_KEY_USE_SYSTEM_FONT, value)
|
||||||
|
+ )
|
||||||
|
|
||||||
|
- val = PythonConsoleConfig.mateconf.client_get_default().get(key)
|
||||||
|
- if val is not None and val.type == mateconf.VALUE_STRING:
|
||||||
|
- return val.get_string()
|
||||||
|
- else:
|
||||||
|
- return default
|
||||||
|
+ font = property(
|
||||||
|
+ lambda self: self.console_settings.get_string(self.CONSOLE_KEY_FONT),
|
||||||
|
+ lambda self, value: self.console_settings.set_string(self.CONSOLE_KEY_FONT, value)
|
||||||
|
+ )
|
||||||
|
|
||||||
|
- @staticmethod
|
||||||
|
- def mateconf_set_str(key, value):
|
||||||
|
- if not PythonConsoleConfig.mateconf:
|
||||||
|
- return
|
||||||
|
+ monospace_font_name = property(
|
||||||
|
+ lambda self: self.interface_settings.get_string(self.INTERFACE_KEY_MONOSPACE_FONT_NAME)
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ console_settings = Gio.Settings.new(CONSOLE_KEY_BASE)
|
||||||
|
+ interface_settings = Gio.Settings.new(INTERFACE_KEY_BASE)
|
||||||
|
+
|
||||||
|
+ def __init__(self):
|
||||||
|
+ object.__init__(self)
|
||||||
|
+
|
||||||
|
+ @classmethod
|
||||||
|
+ def enabled(self):
|
||||||
|
+ return self.console_settings != None
|
||||||
|
+
|
||||||
|
+ @classmethod
|
||||||
|
+ def add_handler(self, handler):
|
||||||
|
+ self.console_settings.connect("changed", handler)
|
||||||
|
+ self.interface_settings.connect("changed", handler)
|
||||||
|
|
||||||
|
- v = PythonConsoleConfig.mateconf.Value(mateconf.VALUE_STRING)
|
||||||
|
- v.set_string(value)
|
||||||
|
- PythonConsoleConfig.mateconf.client_get_default().set(key, v)
|
||||||
|
|
||||||
|
-class PythonConsoleConfigDialog(object):
|
||||||
|
+class PythonConsoleConfigWidget(object):
|
||||||
|
+
|
||||||
|
+ CONSOLE_KEY_BASE = 'org.mate.pluma.plugins.pythonconsole'
|
||||||
|
+ CONSOLE_KEY_COMMAND_COLOR = 'command-color'
|
||||||
|
+ CONSOLE_KEY_ERROR_COLOR = 'error-color'
|
||||||
|
|
||||||
|
def __init__(self, datadir):
|
||||||
|
object.__init__(self)
|
||||||
|
- self._dialog = None
|
||||||
|
+ self._widget = None
|
||||||
|
self._ui_path = os.path.join(datadir, 'ui', 'config.ui')
|
||||||
|
- self.config = PythonConsoleConfig()
|
||||||
|
+ self._config = PythonConsoleConfig()
|
||||||
|
+ self._ui = Gtk.Builder()
|
||||||
|
|
||||||
|
- def dialog(self):
|
||||||
|
- if self._dialog is None:
|
||||||
|
- self._ui = gtk.Builder()
|
||||||
|
+ def configure_widget(self):
|
||||||
|
+ if self._widget is None:
|
||||||
|
self._ui.add_from_file(self._ui_path)
|
||||||
|
|
||||||
|
self.set_colorbutton_color(self._ui.get_object('colorbutton-command'),
|
||||||
|
- self.config.color_command)
|
||||||
|
+ self._config.color_command)
|
||||||
|
self.set_colorbutton_color(self._ui.get_object('colorbutton-error'),
|
||||||
|
- self.config.color_error)
|
||||||
|
-
|
||||||
|
+ self._config.color_error)
|
||||||
|
+ checkbox = self._ui.get_object('checkbox-system-font')
|
||||||
|
+ checkbox.set_active(self._config.use_system_font)
|
||||||
|
+ self._fontbutton = self._ui.get_object('fontbutton-font')
|
||||||
|
+ self._fontbutton.set_font_name(self._config.font)
|
||||||
|
+ self.on_checkbox_system_font_toggled(checkbox)
|
||||||
|
self._ui.connect_signals(self)
|
||||||
|
|
||||||
|
- self._dialog = self._ui.get_object('dialog-config')
|
||||||
|
- self._dialog.show_all()
|
||||||
|
- else:
|
||||||
|
- self._dialog.present()
|
||||||
|
+ self._widget = self._ui.get_object('widget-config')
|
||||||
|
+ self._widget.show_all()
|
||||||
|
|
||||||
|
- return self._dialog
|
||||||
|
+ return self._widget
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_colorbutton_color(colorbutton, value):
|
||||||
|
- try:
|
||||||
|
- color = gtk.gdk.color_parse(value)
|
||||||
|
- except ValueError:
|
||||||
|
- pass # Default color in config.ui used
|
||||||
|
- else:
|
||||||
|
- colorbutton.set_color(color)
|
||||||
|
+ rgba = Gdk.RGBA()
|
||||||
|
+ parsed = rgba.parse(value)
|
||||||
|
|
||||||
|
- def on_dialog_config_response(self, dialog, response_id):
|
||||||
|
- self._dialog.destroy()
|
||||||
|
-
|
||||||
|
- def on_dialog_config_destroy(self, dialog):
|
||||||
|
- self._dialog = None
|
||||||
|
- self._ui = None
|
||||||
|
+ if parsed:
|
||||||
|
+ colorbutton.set_rgba(rgba)
|
||||||
|
|
||||||
|
def on_colorbutton_command_color_set(self, colorbutton):
|
||||||
|
- self.config.color_command = colorbutton.get_color().to_string()
|
||||||
|
+ self._config.color_command = colorbutton.get_color().to_string()
|
||||||
|
|
||||||
|
def on_colorbutton_error_color_set(self, colorbutton):
|
||||||
|
- self.config.color_error = colorbutton.get_color().to_string()
|
||||||
|
+ self._config.color_error = colorbutton.get_color().to_string()
|
||||||
|
+
|
||||||
|
+ def on_checkbox_system_font_toggled(self, checkbox):
|
||||||
|
+ val = checkbox.get_active()
|
||||||
|
+ self._config.use_system_font = val
|
||||||
|
+ self._fontbutton.set_sensitive(not val)
|
||||||
|
+
|
||||||
|
+ def on_fontbutton_font_set(self, fontbutton):
|
||||||
|
+ self._config.font = fontbutton.get_font_name()
|
||||||
|
+
|
||||||
|
+ def on_widget_config_parent_set(self, widget, oldparent):
|
||||||
|
+ # Set icon in dialog close button.
|
||||||
|
+ try:
|
||||||
|
+ actionarea = widget.get_toplevel().get_action_area()
|
||||||
|
+ image = Gtk.Image.new_from_icon_name("window-close",
|
||||||
|
+ Gtk.IconSize.BUTTON)
|
||||||
|
+ for button in actionarea.get_children():
|
||||||
|
+ button.set_image(image)
|
||||||
|
+ button.set_property("always-show-image", True)
|
||||||
|
+ except:
|
||||||
|
+ pass
|
||||||
|
|
||||||
|
# ex:et:ts=4:
|
||||||
|
diff --git a/plugins/pythonconsole/pythonconsole/config.ui b/plugins/pythonconsole/pythonconsole/config.ui
|
||||||
|
index 8d337d6..392be7d 100644
|
||||||
|
--- a/plugins/pythonconsole/pythonconsole/config.ui
|
||||||
|
+++ b/plugins/pythonconsole/pythonconsole/config.ui
|
||||||
|
@@ -1,126 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
-<!-- Generated with glade 3.20.2 -->
|
||||||
|
+<!-- Generated with glade 3.22.1 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.0"/>
|
||||||
|
- <object class="GtkImage" id="image1">
|
||||||
|
+ <object class="GtkGrid" id="widget-config">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
- <property name="icon_name">window-close</property>
|
||||||
|
- </object>
|
||||||
|
- <object class="GtkDialog" id="dialog-config">
|
||||||
|
- <property name="can_focus">False</property>
|
||||||
|
- <property name="window_position">center-on-parent</property>
|
||||||
|
- <property name="destroy_with_parent">True</property>
|
||||||
|
- <property name="type_hint">dialog</property>
|
||||||
|
- <signal name="destroy" handler="on_dialog_config_destroy" swapped="no"/>
|
||||||
|
- <signal name="response" handler="on_dialog_config_response" swapped="no"/>
|
||||||
|
- <child internal-child="vbox">
|
||||||
|
- <object class="GtkBox" id="dialog-vbox1">
|
||||||
|
+ <property name="margin_left">6</property>
|
||||||
|
+ <property name="margin_right">6</property>
|
||||||
|
+ <property name="margin_top">6</property>
|
||||||
|
+ <property name="margin_bottom">6</property>
|
||||||
|
+ <property name="orientation">vertical</property>
|
||||||
|
+ <property name="row_spacing">6</property>
|
||||||
|
+ <property name="column_spacing">6</property>
|
||||||
|
+ <signal name="parent-set" handler="on_widget_config_parent_set" swapped="no"/>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkLabel" id="label-error">
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">False</property>
|
||||||
|
+ <property name="label" translatable="yes">_Error color:</property>
|
||||||
|
+ <property name="use_underline">True</property>
|
||||||
|
+ <property name="xalign">0</property>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">0</property>
|
||||||
|
+ <property name="top_attach">1</property>
|
||||||
|
+ </packing>
|
||||||
|
+ </child>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkColorButton" id="colorbutton-error">
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">True</property>
|
||||||
|
+ <property name="receives_default">True</property>
|
||||||
|
+ <property name="rgba">rgb(153,0,0)</property>
|
||||||
|
+ <signal name="color-set" handler="on_colorbutton_error_color_set" swapped="no"/>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">1</property>
|
||||||
|
+ <property name="top_attach">1</property>
|
||||||
|
+ </packing>
|
||||||
|
+ </child>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkColorButton" id="colorbutton-command">
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">True</property>
|
||||||
|
+ <property name="receives_default">True</property>
|
||||||
|
+ <property name="rgba">rgb(49,78,108)</property>
|
||||||
|
+ <signal name="color-set" handler="on_colorbutton_command_color_set" swapped="no"/>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">1</property>
|
||||||
|
+ <property name="top_attach">0</property>
|
||||||
|
+ </packing>
|
||||||
|
+ </child>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkLabel" id="label-command">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
- <child internal-child="action_area">
|
||||||
|
- <object class="GtkButtonBox" id="dialog-action_area1">
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">False</property>
|
||||||
|
- <property name="layout_style">end</property>
|
||||||
|
- <child>
|
||||||
|
- <object class="GtkButton" id="button1">
|
||||||
|
- <property name="label" translatable="yes">_Close</property>
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">True</property>
|
||||||
|
- <property name="receives_default">True</property>
|
||||||
|
- <property name="image">image1</property>
|
||||||
|
- <property name="use_underline">True</property>
|
||||||
|
- </object>
|
||||||
|
- <packing>
|
||||||
|
- <property name="expand">True</property>
|
||||||
|
- <property name="fill">True</property>
|
||||||
|
- <property name="position">0</property>
|
||||||
|
- </packing>
|
||||||
|
- </child>
|
||||||
|
- </object>
|
||||||
|
- <packing>
|
||||||
|
- <property name="expand">False</property>
|
||||||
|
- <property name="fill">False</property>
|
||||||
|
- <property name="pack_type">end</property>
|
||||||
|
- <property name="position">0</property>
|
||||||
|
- </packing>
|
||||||
|
- </child>
|
||||||
|
- <child>
|
||||||
|
- <object class="GtkTable" id="table2">
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">False</property>
|
||||||
|
- <property name="border_width">6</property>
|
||||||
|
- <property name="n_rows">2</property>
|
||||||
|
- <property name="n_columns">2</property>
|
||||||
|
- <property name="column_spacing">6</property>
|
||||||
|
- <property name="row_spacing">6</property>
|
||||||
|
- <child>
|
||||||
|
- <object class="GtkLabel" id="label-command">
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">False</property>
|
||||||
|
- <property name="label" translatable="yes">C_ommand color:</property>
|
||||||
|
- <property name="use_underline">True</property>
|
||||||
|
- <property name="mnemonic_widget">colorbutton-command</property>
|
||||||
|
- <property name="xalign">0</property>
|
||||||
|
- </object>
|
||||||
|
- </child>
|
||||||
|
- <child>
|
||||||
|
- <object class="GtkLabel" id="label-error">
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">False</property>
|
||||||
|
- <property name="label" translatable="yes">_Error color:</property>
|
||||||
|
- <property name="use_underline">True</property>
|
||||||
|
- <property name="mnemonic_widget">colorbutton-error</property>
|
||||||
|
- <property name="xalign">0</property>
|
||||||
|
- </object>
|
||||||
|
- <packing>
|
||||||
|
- <property name="top_attach">1</property>
|
||||||
|
- <property name="bottom_attach">2</property>
|
||||||
|
- </packing>
|
||||||
|
- </child>
|
||||||
|
- <child>
|
||||||
|
- <object class="GtkColorButton" id="colorbutton-command">
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">True</property>
|
||||||
|
- <property name="receives_default">True</property>
|
||||||
|
- <property name="color">#31314e4e6c6c</property>
|
||||||
|
- <signal name="color-set" handler="on_colorbutton_command_color_set" swapped="no"/>
|
||||||
|
- </object>
|
||||||
|
- <packing>
|
||||||
|
- <property name="left_attach">1</property>
|
||||||
|
- <property name="right_attach">2</property>
|
||||||
|
- </packing>
|
||||||
|
- </child>
|
||||||
|
- <child>
|
||||||
|
- <object class="GtkColorButton" id="colorbutton-error">
|
||||||
|
- <property name="visible">True</property>
|
||||||
|
- <property name="can_focus">True</property>
|
||||||
|
- <property name="receives_default">True</property>
|
||||||
|
- <property name="color">#999900000000</property>
|
||||||
|
- <signal name="color-set" handler="on_colorbutton_error_color_set" swapped="no"/>
|
||||||
|
- </object>
|
||||||
|
- <packing>
|
||||||
|
- <property name="left_attach">1</property>
|
||||||
|
- <property name="right_attach">2</property>
|
||||||
|
- <property name="top_attach">1</property>
|
||||||
|
- <property name="bottom_attach">2</property>
|
||||||
|
- </packing>
|
||||||
|
- </child>
|
||||||
|
- </object>
|
||||||
|
- <packing>
|
||||||
|
- <property name="expand">False</property>
|
||||||
|
- <property name="fill">True</property>
|
||||||
|
- <property name="position">1</property>
|
||||||
|
- </packing>
|
||||||
|
- </child>
|
||||||
|
+ <property name="label" translatable="yes">C_ommand color:</property>
|
||||||
|
+ <property name="use_underline">True</property>
|
||||||
|
+ <property name="xalign">0</property>
|
||||||
|
</object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">0</property>
|
||||||
|
+ <property name="top_attach">0</property>
|
||||||
|
+ </packing>
|
||||||
|
</child>
|
||||||
|
- <action-widgets>
|
||||||
|
- <action-widget response="-7">button1</action-widget>
|
||||||
|
- </action-widgets>
|
||||||
|
<child>
|
||||||
|
- <placeholder/>
|
||||||
|
+ <object class="GtkLabel">
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">False</property>
|
||||||
|
+ <property name="vexpand">True</property>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">0</property>
|
||||||
|
+ <property name="top_attach">2</property>
|
||||||
|
+ <property name="width">2</property>
|
||||||
|
+ </packing>
|
||||||
|
+ </child>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkCheckButton" id="checkbox-system-font">
|
||||||
|
+ <property name="label" translatable="yes">Use system fixed width font</property>
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">True</property>
|
||||||
|
+ <property name="receives_default">False</property>
|
||||||
|
+ <property name="halign">start</property>
|
||||||
|
+ <property name="hexpand">True</property>
|
||||||
|
+ <property name="draw_indicator">True</property>
|
||||||
|
+ <signal name="toggled" handler="on_checkbox_system_font_toggled" swapped="no"/>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">0</property>
|
||||||
|
+ <property name="top_attach">3</property>
|
||||||
|
+ <property name="width">2</property>
|
||||||
|
+ </packing>
|
||||||
|
+ </child>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkLabel">
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">False</property>
|
||||||
|
+ <property name="halign">start</property>
|
||||||
|
+ <property name="label" translatable="yes">Font:</property>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">0</property>
|
||||||
|
+ <property name="top_attach">4</property>
|
||||||
|
+ </packing>
|
||||||
|
+ </child>
|
||||||
|
+ <child>
|
||||||
|
+ <object class="GtkFontButton" id="fontbutton-font">
|
||||||
|
+ <property name="visible">True</property>
|
||||||
|
+ <property name="can_focus">True</property>
|
||||||
|
+ <property name="receives_default">True</property>
|
||||||
|
+ <property name="font">Sans 12</property>
|
||||||
|
+ <property name="preview_text"/>
|
||||||
|
+ <signal name="font-set" handler="on_fontbutton_font_set" swapped="no"/>
|
||||||
|
+ </object>
|
||||||
|
+ <packing>
|
||||||
|
+ <property name="left_attach">1</property>
|
||||||
|
+ <property name="top_attach">4</property>
|
||||||
|
+ </packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
|
diff --git a/plugins/pythonconsole/pythonconsole/console.py b/plugins/pythonconsole/pythonconsole/console.py
|
||||||
|
index 75f60e4..0fd9c7c 100755
|
||||||
|
--- a/plugins/pythonconsole/pythonconsole/console.py
|
||||||
|
+++ b/plugins/pythonconsole/pythonconsole/console.py
|
||||||
|
@@ -30,7 +30,7 @@ import re
|
||||||
|
import traceback
|
||||||
|
from gi.repository import GObject, Gdk, Gtk, Pango
|
||||||
|
|
||||||
|
-from config import PythonConsoleConfig
|
||||||
|
+from .config import PythonConsoleConfig
|
||||||
|
|
||||||
|
__all__ = ('PythonConsole', 'OutFile')
|
||||||
|
|
||||||
|
@@ -40,13 +40,14 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
'grab-focus' : 'override',
|
||||||
|
}
|
||||||
|
|
||||||
|
+ DEFAULT_FONT = "Monospace 10"
|
||||||
|
+
|
||||||
|
def __init__(self, namespace = {}):
|
||||||
|
Gtk.ScrolledWindow.__init__(self)
|
||||||
|
|
||||||
|
self.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||||
|
self.set_shadow_type(Gtk.ShadowType.IN)
|
||||||
|
self.view = Gtk.TextView()
|
||||||
|
- self.view.modify_font(Pango.font_description_from_string('Monospace'))
|
||||||
|
self.view.set_editable(True)
|
||||||
|
self.view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
|
||||||
|
self.add(self.view)
|
||||||
|
@@ -57,7 +58,8 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
self.error = buffer.create_tag("error")
|
||||||
|
self.command = buffer.create_tag("command")
|
||||||
|
|
||||||
|
- PythonConsoleConfig.add_handler(self.apply_preferences)
|
||||||
|
+ self.config = PythonConsoleConfig()
|
||||||
|
+ self.config.add_handler(self.apply_preferences)
|
||||||
|
self.apply_preferences()
|
||||||
|
|
||||||
|
self.__spaces_pattern = re.compile(r'^\s+')
|
||||||
|
@@ -88,9 +90,28 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
self.view.grab_focus()
|
||||||
|
|
||||||
|
def apply_preferences(self, *args):
|
||||||
|
- config = PythonConsoleConfig()
|
||||||
|
- self.error.set_property("foreground", config.color_error)
|
||||||
|
- self.command.set_property("foreground", config.color_command)
|
||||||
|
+ self.error.set_property("foreground", self.config.color_error)
|
||||||
|
+ self.command.set_property("foreground", self.config.color_command)
|
||||||
|
+
|
||||||
|
+ if self.config.use_system_font:
|
||||||
|
+ font_name = self.config.monospace_font_name
|
||||||
|
+ else:
|
||||||
|
+ font_name = self.config.font
|
||||||
|
+
|
||||||
|
+ font_desc = None
|
||||||
|
+ try:
|
||||||
|
+ font_desc = Pango.FontDescription(font_name)
|
||||||
|
+ except:
|
||||||
|
+ try:
|
||||||
|
+ font_desc = Pango.FontDescription(self.config.monospace_font_name)
|
||||||
|
+ except:
|
||||||
|
+ try:
|
||||||
|
+ font_desc = Pango.FontDescription(self.DEFAULT_FONT)
|
||||||
|
+ except:
|
||||||
|
+ pass
|
||||||
|
+
|
||||||
|
+ if font_desc:
|
||||||
|
+ self.view.modify_font(font_desc)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.namespace = None
|
||||||
|
@@ -98,11 +119,13 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
def __key_press_event_cb(self, view, event):
|
||||||
|
modifier_mask = Gtk.accelerator_get_default_mod_mask()
|
||||||
|
event_state = event.state & modifier_mask
|
||||||
|
+ keyname = Gdk.keyval_name(event.keyval)
|
||||||
|
|
||||||
|
- if event.keyval == Gdk.KEY_D and event_state == Gdk.ModifierType.CONTROL_MASK:
|
||||||
|
+ if keyname == "d" and event_state == Gdk.ModifierType.CONTROL_MASK:
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
|
- elif event.keyval == Gdk.KEY_Return and event_state == Gdk.ModifierType.CONTROL_MASK:
|
||||||
|
+ elif keyname == "Return" and \
|
||||||
|
+ event_state == Gdk.ModifierType.CONTROL_MASK:
|
||||||
|
# Get the command
|
||||||
|
buffer = view.get_buffer()
|
||||||
|
inp_mark = buffer.get_mark("input")
|
||||||
|
@@ -128,7 +151,7 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
GObject.idle_add(self.scroll_to_end)
|
||||||
|
return True
|
||||||
|
|
||||||
|
- elif event.keyval == Gdk.KEY_Return:
|
||||||
|
+ elif keyname == "Return":
|
||||||
|
# Get the marks
|
||||||
|
buffer = view.get_buffer()
|
||||||
|
lin_mark = buffer.get_mark("input-line")
|
||||||
|
@@ -172,22 +195,22 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
GObject.idle_add(self.scroll_to_end)
|
||||||
|
return True
|
||||||
|
|
||||||
|
- elif event.keyval == Gdk.KEY_KP_Down or event.keyval == Gdk.KEY_Down:
|
||||||
|
+ elif keyname == "KP_Down" or keyname == "Down":
|
||||||
|
# Next entry from history
|
||||||
|
view.emit_stop_by_name("key_press_event")
|
||||||
|
self.history_down()
|
||||||
|
GObject.idle_add(self.scroll_to_end)
|
||||||
|
return True
|
||||||
|
|
||||||
|
- elif event.keyval == Gdk.KEY_KP_Up or event.keyval == Gdk.KEY_Up:
|
||||||
|
+ elif keyname == "KP_Up" or keyname == "Up":
|
||||||
|
# Previous entry from history
|
||||||
|
view.emit_stop_by_name("key_press_event")
|
||||||
|
self.history_up()
|
||||||
|
GObject.idle_add(self.scroll_to_end)
|
||||||
|
return True
|
||||||
|
|
||||||
|
- elif event.keyval == Gdk.KEY_KP_Left or event.keyval == Gdk.KEY_Left or \
|
||||||
|
- event.keyval == Gdk.KEY_BackSpace:
|
||||||
|
+ elif keyname == "KP_Left" or keyname == "Left" or \
|
||||||
|
+ keyname == "BackSpace":
|
||||||
|
buffer = view.get_buffer()
|
||||||
|
inp = buffer.get_iter_at_mark(buffer.get_mark("input"))
|
||||||
|
cur = buffer.get_iter_at_mark(buffer.get_insert())
|
||||||
|
@@ -200,7 +223,7 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
# For the console we enable smart/home end behavior incoditionally
|
||||||
|
# since it is useful when editing python
|
||||||
|
|
||||||
|
- elif (event.keyval == Gdk.KEY_KP_Home or event.keyval == Gdk.KEY_Home) and \
|
||||||
|
+ elif (keyname == "KP_Home" or keyname == "Home") and \
|
||||||
|
event_state == event_state & (Gdk.ModifierType.SHIFT_MASK|Gdk.ModifierType.CONTROL_MASK):
|
||||||
|
# Go to the begin of the command instead of the begin of the line
|
||||||
|
buffer = view.get_buffer()
|
||||||
|
@@ -219,7 +242,7 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
buffer.place_cursor(iter)
|
||||||
|
return True
|
||||||
|
|
||||||
|
- elif (event.keyval == Gdk.KEY_KP_End or event.keyval == Gdk.KEY_End) and \
|
||||||
|
+ elif (keyname == "KP_End" or keyname == "End") and \
|
||||||
|
event_state == event_state & (Gdk.ModifierType.SHIFT_MASK|Gdk.ModifierType.CONTROL_MASK):
|
||||||
|
|
||||||
|
buffer = view.get_buffer()
|
||||||
|
@@ -323,15 +346,18 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
# eval and exec are broken in how they deal with utf8-encoded
|
||||||
|
# strings so we have to explicitly decode the command before
|
||||||
|
# passing it along
|
||||||
|
- command = command.decode('utf8')
|
||||||
|
+ try:
|
||||||
|
+ command = command.decode('utf8')
|
||||||
|
+ except:
|
||||||
|
+ pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
r = eval(command, self.namespace, self.namespace)
|
||||||
|
if r is not None:
|
||||||
|
- print `r`
|
||||||
|
+ print(repr(r))
|
||||||
|
except SyntaxError:
|
||||||
|
- exec command in self.namespace
|
||||||
|
+ exec(command, self.namespace)
|
||||||
|
except:
|
||||||
|
if hasattr(sys, 'last_type') and sys.last_type == SystemExit:
|
||||||
|
self.destroy()
|
||||||
|
@@ -343,7 +369,7 @@ class PythonConsole(Gtk.ScrolledWindow):
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
pass
|
||||||
|
- #gtk.ScrolledWindow.destroy(self)
|
||||||
|
+ #Gtk.ScrolledWindow.destroy(self)
|
||||||
|
|
||||||
|
class OutFile:
|
||||||
|
"""A fake output file object. It sends output to a TK test widget,
|
||||||
|
@@ -361,8 +387,8 @@ class OutFile:
|
||||||
|
def readlines(self): return []
|
||||||
|
def write(self, s): self.console.write(s, self.tag)
|
||||||
|
def writelines(self, l): self.console.write(l, self.tag)
|
||||||
|
- def seek(self, a): raise IOError, (29, 'Illegal seek')
|
||||||
|
- def tell(self): raise IOError, (29, 'Illegal seek')
|
||||||
|
+ def seek(self, a): raise IOError(29, 'Illegal seek')
|
||||||
|
+ def tell(self): raise IOError(29, 'Illegal seek')
|
||||||
|
truncate = tell
|
||||||
|
|
||||||
|
# ex:et:ts=4:
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
||||||
@ -0,0 +1,427 @@
|
|||||||
|
From bcb21731aacc344cdcd73631346633b6c50d4ec0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Patrick Monnerat <patrick@monnerat.net>
|
||||||
|
Date: Thu, 23 May 2019 20:20:13 +0200
|
||||||
|
Subject: [PATCH] quickopen plugin: change code for Python 2 & 3 compatibility.
|
||||||
|
|
||||||
|
---
|
||||||
|
plugins/quickopen/quickopen/__init__.py | 2 +-
|
||||||
|
plugins/quickopen/quickopen/popup.py | 124 ++++++++++++--------
|
||||||
|
plugins/quickopen/quickopen/virtualdirs.py | 8 +-
|
||||||
|
plugins/quickopen/quickopen/windowhelper.py | 28 +++--
|
||||||
|
4 files changed, 94 insertions(+), 68 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/plugins/quickopen/quickopen/__init__.py b/plugins/quickopen/quickopen/__init__.py
|
||||||
|
index 3ae72a4..17ccdf7 100644
|
||||||
|
--- a/plugins/quickopen/quickopen/__init__.py
|
||||||
|
+++ b/plugins/quickopen/quickopen/__init__.py
|
||||||
|
@@ -18,7 +18,7 @@
|
||||||
|
# Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
from gi.repository import GObject, Peas
|
||||||
|
-from windowhelper import WindowHelper
|
||||||
|
+from .windowhelper import WindowHelper
|
||||||
|
|
||||||
|
class QuickOpenPlugin(GObject.Object, Peas.Activatable):
|
||||||
|
__gtype_name__ = "QuickOpenPlugin"
|
||||||
|
diff --git a/plugins/quickopen/quickopen/popup.py b/plugins/quickopen/quickopen/popup.py
|
||||||
|
index c6cc801..be40509 100644
|
||||||
|
--- a/plugins/quickopen/quickopen/popup.py
|
||||||
|
+++ b/plugins/quickopen/quickopen/popup.py
|
||||||
|
@@ -18,10 +18,11 @@
|
||||||
|
# Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
import os
|
||||||
|
+import sys
|
||||||
|
import fnmatch
|
||||||
|
import xml.sax.saxutils
|
||||||
|
from gi.repository import GObject, Gio, GLib, Gdk, Gtk, Pango, Pluma
|
||||||
|
-from virtualdirs import VirtualDirectory
|
||||||
|
+from .virtualdirs import VirtualDirectory
|
||||||
|
|
||||||
|
class Popup(Gtk.Dialog):
|
||||||
|
__gtype_name__ = "QuickOpenPopup"
|
||||||
|
@@ -30,11 +31,12 @@ class Popup(Gtk.Dialog):
|
||||||
|
Gtk.Dialog.__init__(self,
|
||||||
|
title=_('Quick Open'),
|
||||||
|
parent=window,
|
||||||
|
- flags=Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
|
||||||
|
- buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
|
||||||
|
-
|
||||||
|
- self._open_button = self.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT)
|
||||||
|
+ flags=Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL)
|
||||||
|
|
||||||
|
+ self._add_button(_("_Cancel"), Gtk.ResponseType.CANCEL, "process-stop")
|
||||||
|
+ self._open_button = self._add_button(_("_Open"),
|
||||||
|
+ Gtk.ResponseType.ACCEPT,
|
||||||
|
+ "document-open")
|
||||||
|
self._handler = handler
|
||||||
|
self._build_ui()
|
||||||
|
|
||||||
|
@@ -48,7 +50,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.keyval_from_name('l'),
|
||||||
|
+ Gdk.ModifierType.CONTROL_MASK,
|
||||||
|
+ 0,
|
||||||
|
+ self.on_focus_entry)
|
||||||
|
|
||||||
|
self.add_accel_group(accel_group)
|
||||||
|
|
||||||
|
@@ -63,10 +68,11 @@ class Popup(Gtk.Dialog):
|
||||||
|
return self._size
|
||||||
|
|
||||||
|
def _build_ui(self):
|
||||||
|
+ self.set_border_width(5)
|
||||||
|
vbox = self.get_content_area()
|
||||||
|
vbox.set_spacing(3)
|
||||||
|
|
||||||
|
- self._entry = Gtk.Entry()
|
||||||
|
+ self._entry = Gtk.SearchEntry()
|
||||||
|
|
||||||
|
self._entry.connect('changed', self.on_changed)
|
||||||
|
self._entry.connect('key-press-event', self.on_key_press_event)
|
||||||
|
@@ -78,7 +84,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
|
||||||
|
@@ -106,7 +115,7 @@ class Popup(Gtk.Dialog):
|
||||||
|
vbox.pack_start(sw, True, True, 0)
|
||||||
|
|
||||||
|
lbl = Gtk.Label()
|
||||||
|
- lbl.set_alignment(0, 0.5)
|
||||||
|
+ lbl.set_halign(Gtk.Align.START)
|
||||||
|
lbl.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
|
||||||
|
self._info_label = lbl
|
||||||
|
|
||||||
|
@@ -129,19 +138,22 @@ class Popup(Gtk.Dialog):
|
||||||
|
cell.set_property('cell-background-set', False)
|
||||||
|
cell.set_property('style-set', False)
|
||||||
|
|
||||||
|
- def _icon_from_stock(self, stock):
|
||||||
|
- theme = Gtk.icon_theme_get_default()
|
||||||
|
- size = Gtk.icon_size_lookup(Gtk.IconSize.MENU)
|
||||||
|
- pixbuf = theme.load_icon(stock, size[0], Gtk.IconLookupFlags.USE_BUILTIN)
|
||||||
|
-
|
||||||
|
- return pixbuf
|
||||||
|
+ def _add_button(self, label, response, icon=None):
|
||||||
|
+ button = self.add_button(label, response)
|
||||||
|
+ if icon:
|
||||||
|
+ image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.BUTTON)
|
||||||
|
+ button.set_image(image)
|
||||||
|
+ button.set_property("always-show-image", True)
|
||||||
|
+ return button
|
||||||
|
|
||||||
|
def _list_dir(self, gfile):
|
||||||
|
entries = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
- ret = gfile.enumerate_children("standard::*", Gio.FileQueryInfoFlags.NONE, None)
|
||||||
|
- except GLib.GError:
|
||||||
|
+ ret = gfile.enumerate_children("standard::*",
|
||||||
|
+ Gio.FileQueryInfoFlags.NONE,
|
||||||
|
+ None)
|
||||||
|
+ except GLib.Error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if isinstance(ret, Gio.FileEnumerator):
|
||||||
|
@@ -151,27 +163,23 @@ class Popup(Gtk.Dialog):
|
||||||
|
if not entry:
|
||||||
|
break
|
||||||
|
|
||||||
|
- entries.append((gfile.get_child(entry.get_name()), entry))
|
||||||
|
+ if not entry.get_is_backup():
|
||||||
|
+ entries.append((gfile.get_child(entry.get_name()), entry))
|
||||||
|
else:
|
||||||
|
entries = ret
|
||||||
|
|
||||||
|
children = []
|
||||||
|
|
||||||
|
for entry in entries:
|
||||||
|
- children.append((entry[0], entry[1].get_name(), entry[1].get_file_type(), entry[1].get_icon()))
|
||||||
|
+ children.append((entry[0],
|
||||||
|
+ entry[1].get_name(),
|
||||||
|
+ entry[1].get_file_type(),
|
||||||
|
+ entry[1].get_icon()))
|
||||||
|
|
||||||
|
return children
|
||||||
|
|
||||||
|
- def _compare_entries(self, a, b, lpart):
|
||||||
|
- if lpart in a:
|
||||||
|
- if lpart in b:
|
||||||
|
- return cmp(a.index(lpart), b.index(lpart))
|
||||||
|
- else:
|
||||||
|
- return -1
|
||||||
|
- elif lpart in b:
|
||||||
|
- return 1
|
||||||
|
- else:
|
||||||
|
- return 0
|
||||||
|
+ def _key_entries(self, pos):
|
||||||
|
+ return pos if pos >= 0 else sys.maxsize
|
||||||
|
|
||||||
|
def _match_glob(self, s, glob):
|
||||||
|
if glob:
|
||||||
|
@@ -185,8 +193,7 @@ class Popup(Gtk.Dialog):
|
||||||
|
|
||||||
|
if not d in self._cache:
|
||||||
|
entries = self._list_dir(d)
|
||||||
|
- entries.sort(lambda x, y: cmp(x[1].lower(), y[1].lower()))
|
||||||
|
-
|
||||||
|
+ entries.sort(key=lambda x: x[1].lower())
|
||||||
|
self._cache[d] = entries
|
||||||
|
else:
|
||||||
|
entries = self._cache[d]
|
||||||
|
@@ -212,7 +219,7 @@ class Popup(Gtk.Dialog):
|
||||||
|
(not lpart or len(parts) == 1):
|
||||||
|
found.append(entry)
|
||||||
|
|
||||||
|
- found.sort(lambda a, b: self._compare_entries(a[1].lower(), b[1].lower(), lpart))
|
||||||
|
+ found.sort(key=lambda x: self._key_entries(x[1].lower().find(lpart)))
|
||||||
|
|
||||||
|
if lpart == '..':
|
||||||
|
newdirs.append(d.get_parent())
|
||||||
|
@@ -251,7 +258,9 @@ class Popup(Gtk.Dialog):
|
||||||
|
return os.sep.join(out)
|
||||||
|
|
||||||
|
def _get_icon(self, f):
|
||||||
|
- query = f.query_info(Gio.FILE_ATTRIBUTE_STANDARD_ICON, Gio.FileQueryInfoFlags.NONE, None)
|
||||||
|
+ query = f.query_info(Gio.FILE_ATTRIBUTE_STANDARD_ICON,
|
||||||
|
+ Gio.FileQueryInfoFlags.NONE,
|
||||||
|
+ None)
|
||||||
|
|
||||||
|
if not query:
|
||||||
|
return None
|
||||||
|
@@ -304,7 +313,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:
|
||||||
|
@@ -337,14 +349,17 @@ 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.get_window().set_cursor(None)
|
||||||
|
self._set_busy(False)
|
||||||
|
|
||||||
|
def do_show(self):
|
||||||
|
@@ -366,7 +381,7 @@ class Popup(Gtk.Dialog):
|
||||||
|
model, rows = selection.get_selected_rows()
|
||||||
|
start = rows[0]
|
||||||
|
|
||||||
|
- self._shift_start = Gtk.TreeRowReference(self._store, start)
|
||||||
|
+ self._shift_start = Gtk.TreeRowReference.new(self._store, start)
|
||||||
|
else:
|
||||||
|
start = self._shift_start.get_path()
|
||||||
|
|
||||||
|
@@ -419,7 +434,7 @@ class Popup(Gtk.Dialog):
|
||||||
|
else:
|
||||||
|
self._select_index(num - 1, hasctrl, hasshift)
|
||||||
|
else:
|
||||||
|
- idx = path[0]
|
||||||
|
+ idx = path.get_indices()[0]
|
||||||
|
|
||||||
|
if idx + howmany < 0:
|
||||||
|
self._select_index(0, hasctrl, hasshift)
|
||||||
|
@@ -461,19 +476,22 @@ class Popup(Gtk.Dialog):
|
||||||
|
if text[i] == os.sep:
|
||||||
|
break
|
||||||
|
|
||||||
|
- self._entry.set_text(os.path.join(text[:i], os.path.basename(info[0].get_uri())) + os.sep)
|
||||||
|
+ self._entry.set_text(os.path.join(text[:i],
|
||||||
|
+ os.path.basename(info[0].get_uri())) + os.sep)
|
||||||
|
self._entry.set_position(-1)
|
||||||
|
self._entry.grab_focus()
|
||||||
|
return True
|
||||||
|
|
||||||
|
if rows and ret:
|
||||||
|
- self.destroy()
|
||||||
|
+ # We destroy the popup in an idle callback to work around a crash that happens with
|
||||||
|
+ # GTK_IM_MODULE=xim. See https://bugzilla.gnome.org/show_bug.cgi?id=737711 .
|
||||||
|
+ GLib.idle_add(self.destroy)
|
||||||
|
|
||||||
|
if not rows:
|
||||||
|
gfile = self._direct_file()
|
||||||
|
|
||||||
|
if gfile and self._handler(gfile):
|
||||||
|
- self.destroy()
|
||||||
|
+ GLib.idle_add(self.destroy)
|
||||||
|
else:
|
||||||
|
ret = False
|
||||||
|
else:
|
||||||
|
@@ -495,20 +513,24 @@ class Popup(Gtk.Dialog):
|
||||||
|
|
||||||
|
def on_key_press_event(self, widget, event):
|
||||||
|
move_mapping = {
|
||||||
|
- Gdk.KEY_Down: 1,
|
||||||
|
- Gdk.KEY_Up: -1,
|
||||||
|
- Gdk.KEY_Page_Down: 5,
|
||||||
|
- Gdk.KEY_Page_Up: -5
|
||||||
|
+ "Down": 1,
|
||||||
|
+ "Up": -1,
|
||||||
|
+ "Page_Down": 5,
|
||||||
|
+ "Page_Up": -5
|
||||||
|
}
|
||||||
|
|
||||||
|
- if event.keyval == Gdk.KEY_Escape:
|
||||||
|
+ keyname = Gdk.keyval_name(event.keyval)
|
||||||
|
+
|
||||||
|
+ if keyname == "Escape":
|
||||||
|
self.destroy()
|
||||||
|
return True
|
||||||
|
- elif event.keyval in move_mapping:
|
||||||
|
- return self._move_selection(move_mapping[event.keyval], event.state & Gdk.ModifierType.CONTROL_MASK, event.state & Gdk.ModifierType.SHIFT_MASK)
|
||||||
|
- elif event.keyval in [Gdk.KEY_Return, Gdk.KEY_KP_Enter, Gdk.KEY_Tab, Gdk.KEY_ISO_Left_Tab]:
|
||||||
|
+ elif keyname in move_mapping:
|
||||||
|
+ return self._move_selection(move_mapping[keyname],
|
||||||
|
+ event.state & Gdk.ModifierType.CONTROL_MASK,
|
||||||
|
+ event.state & Gdk.ModifierType.SHIFT_MASK)
|
||||||
|
+ elif keyname in ["Return", "KP_Enter", "Tab", "ISO_Left_Tab"]:
|
||||||
|
return self._activate()
|
||||||
|
- elif event.keyval == Gdk.KEY_space and event.state & Gdk.ModifierType.CONTROL_MASK:
|
||||||
|
+ elif keyname == "space" and event.state & Gdk.ModifierType.CONTROL_MASK:
|
||||||
|
self.toggle_cursor()
|
||||||
|
|
||||||
|
return False
|
||||||
|
diff --git a/plugins/quickopen/quickopen/virtualdirs.py b/plugins/quickopen/quickopen/virtualdirs.py
|
||||||
|
index 53d716a..7bf66b8 100644
|
||||||
|
--- a/plugins/quickopen/quickopen/virtualdirs.py
|
||||||
|
+++ b/plugins/quickopen/quickopen/virtualdirs.py
|
||||||
|
@@ -38,7 +38,9 @@ class VirtualDirectory(object):
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
- info = child.query_info("standard::*", Gio.FileQueryInfoFlags.NONE, None)
|
||||||
|
+ info = child.query_info("standard::*",
|
||||||
|
+ Gio.FileQueryInfoFlags.NONE,
|
||||||
|
+ None)
|
||||||
|
|
||||||
|
if info:
|
||||||
|
self._children.append((child, info))
|
||||||
|
@@ -46,7 +48,7 @@ class VirtualDirectory(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class RecentDocumentsDirectory(VirtualDirectory):
|
||||||
|
- def __init__(self, maxitems=10):
|
||||||
|
+ def __init__(self, maxitems=200):
|
||||||
|
VirtualDirectory.__init__(self, 'recent')
|
||||||
|
|
||||||
|
self._maxitems = maxitems
|
||||||
|
@@ -56,7 +58,7 @@ class RecentDocumentsDirectory(VirtualDirectory):
|
||||||
|
manager = Gtk.RecentManager.get_default()
|
||||||
|
|
||||||
|
items = manager.get_items()
|
||||||
|
- items.sort(lambda a, b: cmp(b.get_visited(), a.get_visited()))
|
||||||
|
+ items.sort(key=lambda a: a.get_visited(), reverse=True)
|
||||||
|
|
||||||
|
added = 0
|
||||||
|
|
||||||
|
diff --git a/plugins/quickopen/quickopen/windowhelper.py b/plugins/quickopen/quickopen/windowhelper.py
|
||||||
|
index 19e44cb..7f9ab12 100644
|
||||||
|
--- a/plugins/quickopen/quickopen/windowhelper.py
|
||||||
|
+++ b/plugins/quickopen/quickopen/windowhelper.py
|
||||||
|
@@ -17,11 +17,12 @@
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
# Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
-from popup import Popup
|
||||||
|
import os
|
||||||
|
+import codecs
|
||||||
|
from gi.repository import Gio, GLib, Gtk, Pluma
|
||||||
|
-from virtualdirs import RecentDocumentsDirectory
|
||||||
|
-from virtualdirs import CurrentDocumentsDirectory
|
||||||
|
+from .popup import Popup
|
||||||
|
+from .virtualdirs import RecentDocumentsDirectory
|
||||||
|
+from .virtualdirs import CurrentDocumentsDirectory
|
||||||
|
|
||||||
|
ui_str = """<ui>
|
||||||
|
<menubar name="MenuBar">
|
||||||
|
@@ -60,12 +61,13 @@ class WindowHelper:
|
||||||
|
|
||||||
|
def _install_menu(self):
|
||||||
|
manager = self._window.get_ui_manager()
|
||||||
|
+ action = Gtk.Action.new("QuickOpen",
|
||||||
|
+ _("Quick open"),
|
||||||
|
+ _("Quickly open documents"))
|
||||||
|
+ action.set_icon_name("document-open")
|
||||||
|
+ action.connect("activate", self.on_quick_open_activate)
|
||||||
|
self._action_group = Gtk.ActionGroup("PlumaQuickOpenPluginActions")
|
||||||
|
- self._action_group.add_actions([
|
||||||
|
- ("QuickOpen", Gtk.STOCK_OPEN, _("Quick open"),
|
||||||
|
- '<Ctrl><Alt>O', _("Quickly open documents"),
|
||||||
|
- self.on_quick_open_activate)
|
||||||
|
- ])
|
||||||
|
+ self._action_group.add_action_with_accel(action, "<Ctrl><Alt>O")
|
||||||
|
|
||||||
|
manager.insert_action_group(self._action_group, -1)
|
||||||
|
self._ui_id = manager.add_ui_from_string(ui_str)
|
||||||
|
@@ -95,10 +97,10 @@ class WindowHelper:
|
||||||
|
if uri:
|
||||||
|
gfile = Gio.file_new_for_uri(uri)
|
||||||
|
|
||||||
|
- if gfile.is_native():
|
||||||
|
+ if gfile and gfile.is_native():
|
||||||
|
paths.append(gfile)
|
||||||
|
|
||||||
|
- except StandardError:
|
||||||
|
+ except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Recent documents
|
||||||
|
@@ -128,14 +130,14 @@ class WindowHelper:
|
||||||
|
self._popup.connect('destroy', self.on_popup_destroy)
|
||||||
|
|
||||||
|
def _local_bookmarks(self):
|
||||||
|
- filename = os.path.expanduser('~/.gtk-bookmarks')
|
||||||
|
+ filename = os.path.expanduser('~/.config/gtk-3.0/bookmarks')
|
||||||
|
|
||||||
|
if not os.path.isfile(filename):
|
||||||
|
return []
|
||||||
|
|
||||||
|
paths = []
|
||||||
|
|
||||||
|
- for line in file(filename, 'r').xreadlines():
|
||||||
|
+ for line in codecs.open(filename, 'r', encoding='utf-8'):
|
||||||
|
uri = line.strip().split(" ")[0]
|
||||||
|
f = Gio.file_new_for_uri(uri)
|
||||||
|
|
||||||
|
@@ -160,7 +162,7 @@ class WindowHelper:
|
||||||
|
desktopdir = None
|
||||||
|
|
||||||
|
if os.path.isfile(config):
|
||||||
|
- for line in file(config, 'r').xreadlines():
|
||||||
|
+ for line in codecs.open(config, 'r', encoding='utf-8'):
|
||||||
|
line = line.strip()
|
||||||
|
|
||||||
|
if line.startswith('XDG_DESKTOP_DIR'):
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user