diff --git a/plugins/joinlines/joinlines.py b/plugins/joinlines/joinlines.py
index 4372e7f..921fae9 100644
--- a/plugins/joinlines/joinlines.py
+++ b/plugins/joinlines/joinlines.py
@@ -19,7 +19,7 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330,
 #  Boston, MA 02111-1307, USA.
 
-import gedit, gtk
+from gi.repository import GObject, Gtk, GtkSource, Gedit
 import gettext
 
 try:
@@ -43,16 +43,17 @@ ui_str = """
 </ui>
 """
 
-class JoinLinesPlugin(gedit.Plugin):
+class JoinLinesPlugin(GObject.Object, Gedit.WindowActivatable):
+    __gtype_name__ = "JoinLinesPlugin"
+
     def __init__(self):
-        gedit.Plugin.__init__(self)
+        GObject.Object.__init__(self)
 
-    def activate(self, window):
+    def do_activate(self, window):
         manager = window.get_ui_manager()
-        data = dict()
 
-        data["action_group"] = gtk.ActionGroup("GeditJoinLinesPluginActions")
-        data["action_group"].add_actions(
+        self._action_group = Gtk.ActionGroup()
+        self._action_group.add_actions(
             [("JoinLines", None, _("_Join Lines"), "<Ctrl>J",
               _("Join the selected lines"),
               lambda a, w: join_lines(w)),
@@ -61,28 +62,24 @@ class JoinLinesPlugin(gedit.Plugin):
               lambda a, w: split_lines(w))],
             window)
 
-        manager.insert_action_group(data["action_group"], -1)
-        data["ui_id"] = manager.add_ui_from_string(ui_str)
+        manager.insert_action_group(self._action_group, -1)
+        self._ui_id = manager.add_ui_from_string(ui_str)
 
-        window.set_data("JoinLinesPluginInfo", data)
-        update_sensitivity(window)
+        self.update_sensitivity(window)
 
-    def deactivate(self, window):
-        data = window.get_data("JoinLinesPluginInfo")
+    def do_deactivate(self, window):
         manager = window.get_ui_manager()
-        manager.remove_ui(data["ui_id"])
-        manager.remove_action_group(data["action_group"])
+        manager.remove_ui(self._ui_id)
+        manager.remove_action_group(self._action_group)
         manager.ensure_update()
-        window.set_data("JoinLinesPluginInfo", None)
 
-    def update_ui(self, window):
-        update_sensitivity(window)
+    def do_update_state(self, window):
+        self.update_sensitivity(window)
 
-def update_sensitivity(window):
-    data = window.get_data("JoinLinesPluginInfo")
-    view = window.get_active_view()
-    data["action_group"].set_sensitive(view is not None and \
-                                       view.get_editable())
+    def update_sensitivity(self, window):
+        view = window.get_active_view()
+        self._action_group.set_sensitive(view is not None and \
+                                         view.get_editable())
 
 def join_lines(window):
     document = window.get_active_document()
@@ -100,7 +97,7 @@ def join_lines(window):
         end = start.copy()
         end.forward_line()
 
-    end_mark = document.create_mark(None, end)
+    end_mark = document.create_mark(None, end, False)
 
     if not start.ends_line():
         start.forward_to_line_end()
@@ -129,10 +126,10 @@ def split_lines(window):
 
     document.begin_user_action()
 
-    try:
-        # get selection bounds
-        start, end = document.get_selection_bounds()
+    # get selection bounds
+    selected, start, end = document.get_selection_bounds()
 
+    if selected:
         # measure indent until selection start
         indent_iter = start.copy()
         indent_iter.set_line_offset(0)
@@ -143,7 +140,7 @@ def split_lines(window):
             else:
                 indent = indent + ' '
             indent_iter.forward_char()
-    except ValueError:
+    else:
         # select from start to line end
         start = document.get_iter_at_mark(document.get_insert())
         start.set_line_offset(0)
@@ -158,7 +155,7 @@ def split_lines(window):
             indent = indent + indent_iter.get_char()
             indent_iter.forward_char()
 
-    end_mark = document.create_mark(None, end)
+    end_mark = document.create_mark(None, end, False)
 
     # ignore first word
     previous_word_end = start.copy()
