summaryrefslogtreecommitdiff
path: root/plugins/snippets/snippets/Placeholder.py
diff options
context:
space:
mode:
authormonsta <[email protected]>2017-02-24 17:20:31 +0300
committermonsta <[email protected]>2017-02-25 16:07:35 +0300
commitc45e91b0f617455d6cf2197e712f0c34c5b0090c (patch)
tree104643fa02e7214e0c8e972cb5ae5d009898fe32 /plugins/snippets/snippets/Placeholder.py
parent26b9f5eb6880b04f27dd4527a66f5b9e703c0450 (diff)
downloadpluma-c45e91b0f617455d6cf2197e712f0c34c5b0090c.tar.bz2
pluma-c45e91b0f617455d6cf2197e712f0c34c5b0090c.tar.xz
snippets plugin: port to gi and libpeas
mostly adapted from: https://git.gnome.org/browse/gedit/commit/?id=3f5c69427579f80e8614f551aafa89baa9bfd0ca https://git.gnome.org/browse/gedit/commit/?id=a2c9247c5fecea8d03917e7b0fa93447820439d2 https://git.gnome.org/browse/gedit/commit/?id=ccd39a71eab7fe04ea52cb10bd2282c95d8374c3 https://git.gnome.org/browse/gedit/commit/?id=2dbe5e048766a94b2ba42346b5d197edc92cd03d https://git.gnome.org/browse/gedit/commit/?id=b3f6fd5c7ab9e433dd7698a25d9dc00867c04ad9 https://git.gnome.org/browse/gedit/commit/?id=2273ba27e85588c10788039b66b083aba6b50660 https://git.gnome.org/browse/gedit/commit/?id=48d33cf9dd29d8a6d42e60e3254c883f1f9ffb56 https://git.gnome.org/browse/gedit/commit/?id=7f37ff4fa2c9dd8f42ff527f4e1d0a148c39eb0e https://git.gnome.org/browse/gedit/commit/?id=0d36d6e09a58210c365264c591fafb5d0b3d9323 https://git.gnome.org/browse/gedit/commit/?id=ac4f2048d6af5b2dbfc7ff6448bc51f3e2b324b6 https://git.gnome.org/browse/gedit/commit/?id=5540838a7dff1d025b995c251f51c1c29ce0c0ce https://git.gnome.org/browse/gedit/commit/?id=d48cd10bf0bb99ead7b1af1ead52f1e554ad239d https://git.gnome.org/browse/gedit/commit/?id=5169aa5cd4b1d95fb869df7c0b24c886cb33a1aa
Diffstat (limited to 'plugins/snippets/snippets/Placeholder.py')
-rwxr-xr-xplugins/snippets/snippets/Placeholder.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/plugins/snippets/snippets/Placeholder.py b/plugins/snippets/snippets/Placeholder.py
index 45b5b508..5fa6e559 100755
--- a/plugins/snippets/snippets/Placeholder.py
+++ b/plugins/snippets/snippets/Placeholder.py
@@ -20,12 +20,11 @@ import re
import os
import sys
import signal
-import select
import locale
import subprocess
-from SubstitutionParser import SubstitutionParser
-import gobject
+from gi.repository import GObject, GLib, Gtk
+from SubstitutionParser import SubstitutionParser
from Helper import *
# These are places in a view where the cursor can go and do things
@@ -138,7 +137,7 @@ class Placeholder:
eiter = self.end_iter()
if biter and eiter:
- return self.buf.get_text(self.begin_iter(), self.end_iter())
+ return self.buf.get_text(self.begin_iter(), self.end_iter(), False)
else:
return ''
else:
@@ -323,12 +322,12 @@ class PlaceholderExpand(Placeholder):
def remove_timeout(self):
if self.timeout_id != None:
- gobject.source_remove(self.timeout_id)
+ GLib.source_remove(self.timeout_id)
self.timeout_id = None
def install_timeout(self):
self.remove_timeout()
- self.timeout_id = gobject.timeout_add(1000, self.timeout_cb)
+ self.timeout_id = GLib.timeout_add(1000, self.timeout_cb)
def timeout_cb(self):
self.timeout_id = None
@@ -398,13 +397,13 @@ class PlaceholderShell(PlaceholderExpand):
if not self.shell:
return False
- gobject.source_remove(self.watch_id)
+ GLib.source_remove(self.watch_id)
self.close_shell()
if self.remove_me:
PlaceholderExpand.remove(self)
- message_dialog(None, gtk.MESSAGE_ERROR, 'Execution of the shell ' \
+ message_dialog(None, Gtk.MessageType.ERROR, 'Execution of the shell ' \
'command (%s) exceeded the maximum time; ' \
'execution aborted.' % self.command)
@@ -424,7 +423,7 @@ class PlaceholderShell(PlaceholderExpand):
PlaceholderExpand.remove(self, True)
def process_cb(self, source, condition):
- if condition & gobject.IO_IN:
+ if condition & GObject.IO_IN:
line = source.readline()
if len(line) > 0:
@@ -452,7 +451,7 @@ class PlaceholderShell(PlaceholderExpand):
self.remove_timeout()
if self.shell:
- gobject.source_remove(self.watch_id)
+ GLib.source_remove(self.watch_id)
self.close_shell()
popen_args = {
@@ -465,8 +464,8 @@ class PlaceholderShell(PlaceholderExpand):
self.command = text
self.shell = subprocess.Popen(text, **popen_args)
self.shell_output = ''
- self.watch_id = gobject.io_add_watch(self.shell.stdout, gobject.IO_IN | \
- gobject.IO_HUP, self.process_cb)
+ self.watch_id = GLib.io_add_watch(self.shell.stdout, GObject.IO_IN | \
+ GObject.IO_HUP, self.process_cb)
self.install_timeout()
return True
@@ -590,7 +589,7 @@ class PlaceholderEval(PlaceholderExpand):
except TimeoutError:
self.remove_timeout()
- message_dialog(None, gtk.MESSAGE_ERROR, \
+ message_dialog(None, Gtk.MessageType.ERROR, \
_('Execution of the Python command (%s) exceeds the maximum ' \
'time, execution aborted.') % self.command)
@@ -598,7 +597,7 @@ class PlaceholderEval(PlaceholderExpand):
except Exception, detail:
self.remove_timeout()
- message_dialog(None, gtk.MESSAGE_ERROR,
+ message_dialog(None, Gtk.MessageType.ERROR,
_('Execution of the Python command (%s) failed: %s') %
(self.command, detail))