Permalink
Browse files

The Great Renaming. gtk3 porting basically

  • Loading branch information...
1 parent 52aa54a commit 1e10187f31742a337ae0c235555cd3f35f0f8cd7 @aeischeid committed Oct 19, 2011
Showing with 16 additions and 15 deletions.
  1. +5 −4 zencoding/plugin.py
  2. +11 −11 zencoding/zen_dialog.py
View
@@ -5,8 +5,9 @@
# Author Franck Marcia (franck.marcia@gmail.com)
#
-import gedit, gobject, gtk, os
+import gedit, gobject, os
+from gi.repository import Gtk
from zen_editor import ZenEditor
zencoding_ui_str = """
@@ -56,7 +57,7 @@ def activate(self, window):
]
windowdata = dict()
window.set_data("ZenCodingPluginDataKey", windowdata)
- windowdata["action_group"] = gtk.ActionGroup("GeditZenCodingPluginActions")
+ windowdata["action_group"] = Gtk.ActionGroup("GeditZenCodingPluginActions")
windowdata["action_group"].add_actions(actions, window)
manager = window.get_ui_manager()
manager.insert_action_group(windowdata["action_group"], -1)
@@ -65,8 +66,8 @@ def activate(self, window):
self.editor = ZenEditor()
error = self.editor.get_user_settings_error()
if error:
- md = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
- gtk.BUTTONS_CLOSE, "There is an error in user settings:")
+ md = Gtk.MessageDialog(window, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.CLOSE, "There is an error in user settings:")
message = "{0} on line {1} at character {2}\n\nUser settings will not be available."
md.set_title("Zen Coding error")
md.format_secondary_text(message.format(error['msg'], error['lineno'], error['offset']))
View
@@ -2,9 +2,9 @@
@author Franck Marcia (franck.marcia@gmail.com)
'''
-import pygtk
-pygtk.require('2.0')
-import gtk
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk
class ZenDialog():
@@ -16,23 +16,23 @@ def __init__(self, editor, x, y, callback, text=""):
self.abbreviation = text
self.callback = callback
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
self.window.set_decorated(False)
self.window.connect("destroy", self.quit)
self.window.connect("focus-out-event", self.focus_lost)
self.window.connect("key-press-event", self.key_pressed)
self.window.set_resizable(False)
self.window.move(x, y - 27)
- self.frame = gtk.Frame()
+ self.frame = Gtk.Frame()
self.window.add(self.frame)
self.frame.show()
- self.box = gtk.HBox()
+ self.box = Gtk.HBox(False, 0)
self.frame.add(self.box)
self.box.show()
- self.entry = gtk.Entry()
+ self.entry = Gtk.Entry()
self.entry.connect("changed", self.update)
self.entry.set_text(text)
self.entry.set_has_frame(False)
@@ -67,10 +67,10 @@ def update(self, entry):
def quit(self, widget=None, event=None):
self.window.hide()
self.window.destroy()
- gtk.main_quit()
+ Gtk.main_quit()
def main(self):
- gtk.main()
+ Gtk.main()
def main(editor, window, callback, text=""):
@@ -81,9 +81,9 @@ def main(editor, window, callback, text=""):
offset_start, offset_end = editor.get_selection_range()
insert = editor.buffer.get_iter_at_offset(offset_start)
location = editor.view.get_iter_location(insert)
- window = editor.view.get_window(gtk.TEXT_WINDOW_TEXT)
+ window = editor.view.get_window(Gtk.TextWindowType.TEXT)
xo, yo = window.get_origin()
- xb, yb = editor.view.buffer_to_window_coords(gtk.TEXT_WINDOW_TEXT, location.x + location.width, location.y)
+ xb, yb = editor.view.buffer_to_window_coords(Gtk.TextWindowType.TEXT, location.x + location.width, location.y)
# Open dialog at coordinates with eventual text.
my_zen_dialog = ZenDialog(editor, xo + xb, yo + yb, callback, text)

0 comments on commit 1e10187

Please sign in to comment.