From 69ea341d2709766781d45f330f541a45e289cfce Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Tue, 30 Jul 2013 21:50:54 +0400 Subject: QuickRepliesPlugin.available in py3 --- quick_replies/__init__.py | 2 +- quick_replies/manifest.ini | 2 +- quick_replies/plugin.py | 42 ++++++++++++++++++++++-------------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/quick_replies/__init__.py b/quick_replies/__init__.py index 8c4cd0b..67ad452 100644 --- a/quick_replies/__init__.py +++ b/quick_replies/__init__.py @@ -1 +1 @@ -from plugin import QuickRepliesPlugin +from .plugin import QuickRepliesPlugin diff --git a/quick_replies/manifest.ini b/quick_replies/manifest.ini index 6f1c8f9..cf722bf 100644 --- a/quick_replies/manifest.ini +++ b/quick_replies/manifest.ini @@ -5,4 +5,4 @@ version: 0.0.2 description: Plugin for quick insert template message and add your own template messages authors = Evgeniy Popov homepage = http://trac-plugins.gajim.org/wiki/QuickRepliesPlugin -max_gajim_version: 0.15.9 +mix_gajim_version: 0.16.10 diff --git a/quick_replies/plugin.py b/quick_replies/plugin.py index 91d309e..01c8de8 100644 --- a/quick_replies/plugin.py +++ b/quick_replies/plugin.py @@ -1,4 +1,6 @@ -import gtk +from gi.repository import Gtk +from gi.repository import GdkPixbuf + import gtkgui_helpers from common import gajim @@ -63,30 +65,29 @@ class Base(object): self.plugin = plugin self.chat_control = chat_control - self.create_menu() self.create_button() + self.create_menu() def create_button(self): actions_hbox = self.chat_control.xml.get_object('actions_hbox') - self.button = gtk.Button(label=None, stock=None, use_underline=True) - self.button.set_property('relief', gtk.RELIEF_NONE) + self.button = Gtk.Button(label=None, stock=None, use_underline=True) + self.button.set_property('relief', Gtk.ReliefStyle.NONE) self.button.set_property('can-focus', False) - img = gtk.Image() + img = Gtk.Image() img_path = self.plugin.local_file_path('quick_replies.png') - pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) - iconset = gtk.IconSet(pixbuf=pixbuf) - factory = gtk.IconFactory() + pixbuf = GdkPixbuf.Pixbuf.new_from_file(img_path) + iconset = Gtk.IconSet(pixbuf=pixbuf) + factory = Gtk.IconFactory() factory.add('quickreplies', iconset) factory.add_default() - img.set_from_stock('quickreplies', gtk.ICON_SIZE_MENU) + img.set_from_stock('quickreplies', Gtk.IconSize.MENU) self.button.set_image(img) self.button.set_tooltip_text(_('Quick replies')) send_button = self.chat_control.xml.get_object('send_button') - send_button_pos = actions_hbox.child_get_property(send_button, - 'position') - actions_hbox.add_with_properties(self.button, 'position', - send_button_pos - 1, 'expand', False) + actions_hbox.pack_start(self.button, False, False , 0) + actions_hbox.reorder_child(self.button, + len(actions_hbox.get_children()) - 3) id_ = self.button.connect('clicked', self.on_button_cliecked) self.chat_control.handlers[id_] = self.button self.button.show() @@ -105,16 +106,17 @@ class Base(object): def create_menu(self): - self.menu = gtk.Menu() + self.menu = Gtk.Menu() - for count in xrange(1, 11): + for count in range(1, 11): text = self.plugin.config['entry' + str(count)] if not text: continue - item = gtk.MenuItem(text) + item = Gtk.MenuItem(text) item.connect('activate', self.on_insert, text) self.menu.append(item) self.menu.show_all() + self.menu.attach_to_widget(self.button, None) def disconnect_from_chat_control(self): actions_hbox = self.chat_control.xml.get_object('actions_hbox') @@ -127,22 +129,22 @@ class QuickRepliesPluginConfigDialog(GajimPluginConfigDialog): self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( 'config_dialog.ui') - self.xml = gtk.Builder() + self.xml = Gtk.Builder() self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['table1']) hbox = self.xml.get_object('table1') - self.child.pack_start(hbox) + self.get_child().pack_start(hbox, True, True, 0) self.xml.connect_signals(self) def on_run(self): - for count in xrange(1, 11): + for count in range(1, 11): self.xml.get_object('entry' + str(count)).set_text( self.plugin.config['entry' + str(count)]) def entry_changed(self, widget): - name = gtk.Buildable.get_name(widget) + name = Gtk.Buildable.get_name(widget) self.plugin.config[name] = widget.get_text() for control in self.plugin.controls: control.create_menu() -- cgit v1.2.3