diff --git a/data/gui/account_creation_wizard_window.ui b/data/gui/account_creation_wizard_window.ui index 41b6a87a9..ea32887cc 100644 --- a/data/gui/account_creation_wizard_window.ui +++ b/data/gui/account_creation_wizard_window.ui @@ -1,31 +1,51 @@ - + - - + + + + + + + + + None + + + + + server_liststore + 0 + + + server_liststore + 0 + + False 12 Gajim: Account Creation Wizard False dialog - + True - vertical + False 6 True - False + False False True - vertical + False 12 True + False 0 You need to have an account in order to connect to the Jabber network. @@ -39,26 +59,31 @@ to the Jabber network. True + False 0 none True + False 5 12 True + False 6 - vertical 6 I already have an account I want to _use + False True True False + False True + 0 True @@ -70,10 +95,13 @@ to the Jabber network. I want to _register for a new account + False True True False + False True + 0 True use_existing_account_radiobutton @@ -90,6 +118,7 @@ to the Jabber network. True + False <b>Please choose one of the options below:</b> True @@ -106,6 +135,7 @@ to the Jabber network. True + False False @@ -114,12 +144,13 @@ to the Jabber network. True + False 6 - vertical 12 True + False 0 <b>Please fill in the data for your existing account</b> True @@ -133,25 +164,30 @@ to the Jabber network. True + False 3 4 12 6 + + + True True - + 1 2 - + True + False 0 _Password: True @@ -161,21 +197,24 @@ to the Jabber network. 2 3 GTK_FILL - + Save pass_word + False True True False If checked, Gajim will remember the password for this account + False True False + 0.5 True True - + 2 @@ -183,7 +222,7 @@ to the Jabber network. 2 3 GTK_FILL - + @@ -198,12 +237,13 @@ to the Jabber network. 2 2 3 - + True + False 0 _Jabber ID: True @@ -211,41 +251,34 @@ to the Jabber network. GTK_FILL - + True + False 0 @ 2 3 - - - - - - True - - - 3 - 4 - GTK_FILL - GTK_FILL + Anon_ymous authentication + False True True False + False True + 0.5 True - + 1 @@ -255,11 +288,29 @@ to the Jabber network. - + + True + False + True + 0 + 1 + + + True + + server_entrycompletion + + + + + 3 + 4 + False + True 1 @@ -271,6 +322,7 @@ to the Jabber network. True + False 1 @@ -280,12 +332,13 @@ to the Jabber network. True + False 6 - vertical 12 True + False 0 <b>Please select a server</b> True @@ -299,10 +352,12 @@ to the Jabber network. True + False 6 True + False 0 _Server: True @@ -314,10 +369,22 @@ to the Jabber network. - + True + False + True + 0 + 1 + + + True + server_entrycompletion1 + + + True + True 1 @@ -331,14 +398,18 @@ to the Jabber network. Anon_ymous authentication + False True True False + False True + 0.5 True False + True 2 @@ -349,6 +420,7 @@ to the Jabber network. True + False 5 3 3 @@ -357,18 +429,20 @@ to the Jabber network. True + False 0 Prox_y: True GTK_FILL - + True + False liststore1 @@ -386,44 +460,51 @@ to the Jabber network. Manage... + False True True False + False True - + 2 3 - - + + Use custom hostname/port + False True True False + False True + 0.5 True - + 3 1 2 - + True False + False 6 True + False 0 _Hostname: True @@ -441,12 +522,15 @@ to the Jabber network. True + True + True 1 True + False 0 _Port: True @@ -467,6 +551,7 @@ to the Jabber network. False + True 3 @@ -484,12 +569,15 @@ to the Jabber network. True + False _Advanced True + True + True 3 @@ -501,6 +589,7 @@ to the Jabber network. True + False 2 @@ -510,34 +599,41 @@ to the Jabber network. True - vertical + False True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-dialog-warning 5 False + True 0 True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True 1 + True False 0 @@ -547,13 +643,17 @@ to the Jabber network. Add this certificate to the list of trusted certificates. SHA1 fingerprint of the certificate: + False True True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + 0.5 True + True False 1 @@ -566,6 +666,7 @@ SHA1 fingerprint of the certificate: True + False 3 @@ -575,7 +676,7 @@ SHA1 fingerprint of the certificate: True - vertical + False @@ -587,6 +688,7 @@ SHA1 fingerprint of the certificate: True + False 4 @@ -596,10 +698,11 @@ SHA1 fingerprint of the certificate: True - vertical + False True + False <b>Connecting to server</b> Please wait... @@ -607,6 +710,7 @@ Please wait... center + True False 0 @@ -614,6 +718,7 @@ Please wait... True + False 0.10000000149 @@ -630,6 +735,7 @@ Please wait... True + False 5 @@ -639,14 +745,16 @@ Please wait... True - vertical + False True + False 12 True + False gtk-missing-image @@ -658,26 +766,34 @@ Please wait... True + False 0.10000000149011612 True True + True + True 1 + True + True 0 Connect when I press Finish + False True True False + False True + 0.5 True True @@ -690,10 +806,13 @@ Please wait... Set my profile when I connect + False True True False + False True + 0.5 True True @@ -711,6 +830,7 @@ Please wait... True + False 6 @@ -719,23 +839,28 @@ Please wait... + True + True 0 True + False 12 end gtk-cancel + False True True True False + False True - + False @@ -746,13 +871,15 @@ Please wait... gtk-go-back + False True False True True False + False True - + False @@ -763,13 +890,15 @@ Please wait... gtk-go-forward + False True True True True False + False True - + False @@ -779,23 +908,28 @@ Please wait... + False True True False True - + False + True + False 0 0 True + False 2 True + False gtk-preferences @@ -807,6 +941,7 @@ Please wait... True + False _Advanced True @@ -829,23 +964,28 @@ Please wait... + False True True False True - + False + True + False 0 0 True + False 2 True + False gtk-apply @@ -857,6 +997,7 @@ Please wait... True + False _Finish True @@ -880,21 +1021,17 @@ Please wait... False + True 1 - + - + - - - None - - diff --git a/data/gui/message_window.ui b/data/gui/message_window.ui index b801f8290..5e97df69e 100644 --- a/data/gui/message_window.ui +++ b/data/gui/message_window.ui @@ -13,7 +13,6 @@ True True - 0 diff --git a/setup_win32.py b/setup_win32.py index 00c53e831..04d05f1db 100644 --- a/setup_win32.py +++ b/setup_win32.py @@ -31,7 +31,7 @@ if 'gtk' in os.listdir('.'): options = { 'build_exe': { - 'includes': ['gtk.keysyms', 'dumbdbm', 'dbhash', 'bsddb', 'new', + 'includes': ['Gdk.KEY_, 'dumbdbm', 'dbhash', 'bsddb', 'new', 'goocanvas', 'Crypto.PublicKey.DSA', 'Crypto.Hash.HMAC', 'numbers'], 'base': 'Win32GUI', diff --git a/src/adhoc_commands.py b/src/adhoc_commands.py index f2edcd3ef..8fd2559aa 100644 --- a/src/adhoc_commands.py +++ b/src/adhoc_commands.py @@ -25,8 +25,8 @@ # FIXME: think if we need caching command list. it may be wrong if there will # be entities that often change the list, it may be slow to fetch it every time -import gobject -import gtk +from gi.repository import GObject +from gi.repository import Gtk import nbxmpp from common import gajim @@ -91,7 +91,7 @@ class CommandWindow: self.data_form_widget.destroy() self.data_form_widget = dataforms_widget.DataFormWidget() self.data_form_widget.show() - self.sending_form_stage_vbox.pack_start(self.data_form_widget) + self.sending_form_stage_vbox.pack_start(self.data_form_widget, True, True, 0) if self.commandnode: # Execute command @@ -236,13 +236,13 @@ class CommandWindow: # build the commands list radiobuttons first_radio = None for (commandnode, commandname) in self.commandlist: - radio = gtk.RadioButton(first_radio, label=commandname) + radio = Gtk.RadioButton(first_radio, label=commandname) radio.connect("toggled", self.on_command_radiobutton_toggled, commandnode) if not first_radio: first_radio = radio self.commandnode = commandnode - self.command_list_vbox.pack_start(radio, expand=False) + self.command_list_vbox.pack_start(radio, False, True, 0) self.command_list_vbox.show_all() self.stage_finish = self.stage2_finish @@ -321,8 +321,8 @@ class CommandWindow: dialog.destroy() cb() - dialog = dialogs.HigDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT \ - | gtk.DIALOG_MODAL, gtk.BUTTONS_YES_NO, _('Cancel confirmation'), + dialog = dialogs.HigDialog(self.window, Gtk.DialogFlags.DESTROY_WITH_PARENT \ + | Gtk.DialogFlags.MODAL, Gtk.ButtonsType.YES_NO, _('Cancel confirmation'), _('You are in process of executing command. Do you really want to ' 'cancel it?'), on_response_yes=on_yes) dialog.popup() @@ -550,21 +550,21 @@ class CommandWindow: progressbar.pulse() method """ assert not self.pulse_id - assert isinstance(progressbar, gtk.ProgressBar) + assert isinstance(progressbar, Gtk.ProgressBar) def callback(): progressbar.pulse() return True # important to keep callback be called back! # 12 times per second (80 miliseconds) - self.pulse_id = gobject.timeout_add(80, callback) + self.pulse_id = GObject.timeout_add(80, callback) def remove_pulsing(self): """ Stop pulsing, useful when especially when removing widget """ if self.pulse_id: - gobject.source_remove(self.pulse_id) + GObject.source_remove(self.pulse_id) self.pulse_id = None # handling xml stanzas diff --git a/src/advanced_configuration_window.py b/src/advanced_configuration_window.py index c76f3afa5..3df0ebf4b 100644 --- a/src/advanced_configuration_window.py +++ b/src/advanced_configuration_window.py @@ -23,9 +23,9 @@ ## along with Gajim. If not, see . ## -import gtk +from gi.repository import Gtk import gtkgui_helpers -import gobject +from gi.repository import GObject from common import gajim @@ -50,12 +50,12 @@ def rate_limit(rate): timeout = [None] def f(*args, **kwargs): if timeout[0] is not None: - gobject.source_remove(timeout[0]) + GObject.source_remove(timeout[0]) timeout[0] = None def timeout_func(): func(*args, **kwargs) timeout[0] = None - timeout[0] = gobject.timeout_add(int(1000.0 / rate), timeout_func) + timeout[0] = GObject.timeout_add(int(1000.0 / rate), timeout_func) return f return decorator @@ -76,7 +76,7 @@ class AdvancedConfigurationWindow(object): def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('advanced_configuration_window.ui') self.window = self.xml.get_object('advanced_configuration_window') - self.window.set_transient_for( + self.set_transient_for( gajim.interface.instances['preferences'].window) self.entry = self.xml.get_object('advanced_entry') self.desc_label = self.xml.get_object('advanced_desc_label') @@ -98,18 +98,18 @@ class AdvancedConfigurationWindow(object): treeview = self.xml.get_object('advanced_treeview') self.treeview = treeview - self.model = gtk.TreeStore(str, str, str) + self.model = Gtk.TreeStore(str, str, str) self.fill_model() - self.model.set_sort_column_id(0, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING) self.modelfilter = self.model.filter_new() self.modelfilter.set_visible_func(self.visible_func) - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() col = treeview.insert_column_with_attributes(-1, _('Preference Name'), renderer_text, text = 0) col.set_resizable(True) - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() renderer_text.connect('edited', self.on_config_edited) col = treeview.insert_column_with_attributes(-1, _('Value'), renderer_text, text = 1) @@ -118,7 +118,7 @@ class AdvancedConfigurationWindow(object): col.props.resizable = True col.set_max_width(250) - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() treeview.insert_column_with_attributes(-1, _('Type'), renderer_text, text = 2) diff --git a/src/atom_window.py b/src/atom_window.py index 6c9f9ec52..f0cb83f76 100644 --- a/src/atom_window.py +++ b/src/atom_window.py @@ -22,8 +22,8 @@ ## -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject import gtkgui_helpers from common import helpers @@ -70,8 +70,8 @@ class AtomWindow: self.xml.connect_signals(self) self.window.show_all() - self.entry_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK) - self.feed_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK) + self.entry_title_eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) + self.feed_title_eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) def displayNextEntry(self): """ @@ -85,23 +85,23 @@ class AtomWindow: if newentry.feed_link is not None: self.feed_title_label.set_markup( u'%s' % \ - gobject.markup_escape_text(newentry.feed_title)) + GObject.markup_escape_text(newentry.feed_title)) else: self.feed_title_label.set_markup( - gobject.markup_escape_text(newentry.feed_title)) + GObject.markup_escape_text(newentry.feed_title)) self.feed_tagline_label.set_markup( u'%s' % \ - gobject.markup_escape_text(newentry.feed_tagline)) + GObject.markup_escape_text(newentry.feed_tagline)) if newentry.title: if newentry.uri is not None: self.entry_title_label.set_markup( u'%s' % \ - gobject.markup_escape_text(newentry.title)) + GObject.markup_escape_text(newentry.title)) else: self.entry_title_label.set_markup( - gobject.markup_escape_text(newentry.title)) + GObject.markup_escape_text(newentry.title)) else: self.entry_title_label.set_markup('') diff --git a/src/cell_renderer_image.py b/src/cell_renderer_image.py index d2e6c4a8b..873c323e4 100644 --- a/src/cell_renderer_image.py +++ b/src/cell_renderer_image.py @@ -22,18 +22,19 @@ ## -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject -class CellRendererImage(gtk.GenericCellRenderer): +class CellRendererImage(Gtk.CellRendererPixbuf): __gproperties__ = { - 'image': (gobject.TYPE_OBJECT, 'Image', - 'Image', gobject.PARAM_READWRITE), + 'image': (GObject.TYPE_OBJECT, 'Image', + 'Image', GObject.PARAM_READWRITE), } def __init__(self, col_index, tv_index): - self.__gobject_init__() + super(CellRendererImage, self).__init__() self.image = None self.col_index = col_index self.tv_index = tv_index @@ -45,6 +46,14 @@ class CellRendererImage(gtk.GenericCellRenderer): def do_get_property(self, pspec): return getattr(self, pspec.name) + def do_activate(event, widget, path, bg_area, cell_area, flags): + """Renderers cannot be activated; always return True.""" + return True + + def do_editing_started(event, widget, path, fb_area, cell_area, flags): + """Renderers cannot be edited; always return None.""" + return None + def func(self, model, path, iter_, image_tree): image, tree = image_tree if model.get_value(iter_, self.tv_index) != image: @@ -57,7 +66,7 @@ class CellRendererImage(gtk.GenericCellRenderer): cell_area.width, cell_area.height) def animation_timeout(self, tree, image): - if image.get_storage_type() != gtk.IMAGE_ANIMATION: + if image.get_storage_type() != Gtk.ImageType.ANIMATION: return self.redraw = 0 iter_ = self.iters[image] @@ -66,58 +75,48 @@ class CellRendererImage(gtk.GenericCellRenderer): if model: model.foreach(self.func, (image, tree)) if self.redraw: - gobject.timeout_add(iter_.get_delay_time(), + GObject.timeout_add(iter_.get_delay_time(), self.animation_timeout, tree, image) elif image in self.iters: del self.iters[image] - def on_render(self, window, widget, background_area, cell_area, - expose_area, flags): + def do_render(self, ctx, widget, background_area, cell_area, flags): if not self.image: return - pix_rect = gtk.gdk.Rectangle() - pix_rect.x, pix_rect.y, pix_rect.width, pix_rect.height = \ - self.on_get_size(widget, cell_area) - pix_rect.x += cell_area.x - pix_rect.y += cell_area.y - pix_rect.width -= 2 * self.get_property('xpad') - pix_rect.height -= 2 * self.get_property('ypad') - - draw_rect = cell_area.intersect(pix_rect) - draw_rect = expose_area.intersect(draw_rect) - - if self.image.get_storage_type() == gtk.IMAGE_ANIMATION: + if self.image.get_storage_type() == Gtk.ImageType.ANIMATION: if self.image not in self.iters: - if not isinstance(widget, gtk.TreeView): + if not isinstance(widget, Gtk.TreeView): return animation = self.image.get_animation() iter_ = animation.get_iter() self.iters[self.image] = iter_ - gobject.timeout_add(iter_.get_delay_time(), - self.animation_timeout, widget, self.image) + GObject.timeout_add(iter_.get_delay_time(), + self.animation_timeout, widget, self.image) pix = self.iters[self.image].get_pixbuf() - elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF: + elif self.image.get_storage_type() == Gtk.ImageType.PIXBUF: pix = self.image.get_pixbuf() else: return - if draw_rect.x < 1: - return - window.draw_pixbuf(widget.style.black_gc, pix, - draw_rect.x - pix_rect.x, - draw_rect.y - pix_rect.y, - draw_rect.x, draw_rect.y, - draw_rect.width, draw_rect.height, - gtk.gdk.RGB_DITHER_NONE, 0, 0) - def on_get_size(self, widget, cell_area): + Gdk.cairo_set_source_pixbuf(ctx, pix, cell_area.x, cell_area.y) + ctx.paint() + + def do_get_size(self, widget, cell_area): + """ + Return the size we need for this cell. + + Each cell is drawn individually and is only as wide as it needs + to be, we let the TreeViewColumn take care of making them all + line up. + """ if not self.image: return 0, 0, 0, 0 - if self.image.get_storage_type() == gtk.IMAGE_ANIMATION: + if self.image.get_storage_type() == Gtk.ImageType.ANIMATION: animation = self.image.get_animation() pix = animation.get_iter().get_pixbuf() - elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF: + elif self.image.get_storage_type() == Gtk.ImageType.PIXBUF: pix = self.image.get_pixbuf() else: return 0, 0, 0, 0 diff --git a/src/chat_control.py b/src/chat_control.py index 466ce7ba0..39335ea74 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -29,9 +29,11 @@ import os import time -import gtk -import pango -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GdkPixbuf +from gi.repository import Pango +from gi.repository import GObject import gtkgui_helpers import gui_menu_builder import message_control @@ -97,7 +99,7 @@ langs = {_('English'): 'en', _('Belarusian'): 'be', _('Bulgarian'): 'bg', if gajim.config.get('use_speller') and HAS_GTK_SPELL: # loop removing non-existent dictionaries # iterating on a copy - tv = gtk.TextView() + tv = Gtk.TextView() spell = gtkspell.Spell(tv) for lang in dict(langs): try: @@ -115,13 +117,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): A base class containing a banner, ConversationTextview, MessageTextView """ - keymap = gtk.gdk.keymap_get_default() + keymap = Gdk.Keymap.get_default() try: - keycode_c = keymap.get_entries_for_keyval(gtk.keysyms.c)[0][0] + keycode_c = keymap.get_entries_for_keyval(Gdk.KEY_c)[0][0] except TypeError: keycode_c = 54 try: - keycode_ins = keymap.get_entries_for_keyval(gtk.keysyms.Insert)[0][0] + keycode_ins = keymap.get_entries_for_keyval(Gdk.KEY_Insert)[0][0] except TypeError: keycode_ins = 118 @@ -142,22 +144,22 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): bannerfontattrs = gajim.config.get_per('themes', theme, 'bannerfontattrs') if bannerfont: - font = pango.FontDescription(bannerfont) + font = Pango.FontDescription(bannerfont) else: - font = pango.FontDescription('Normal') + font = Pango.FontDescription('Normal') if bannerfontattrs: # B attribute is set by default if 'B' in bannerfontattrs: - font.set_weight(pango.WEIGHT_HEAVY) + font.set_weight(Pango.Weight.HEAVY) if 'I' in bannerfontattrs: - font.set_style(pango.STYLE_ITALIC) + font.set_style(Pango.Style.ITALIC) font_attrs = 'font_desc="%s"' % font.to_string() # in case there is no font specified we use x-large font size if font.get_size() == 0: font_attrs = '%s size="x-large"' % font_attrs - font.set_weight(pango.WEIGHT_NORMAL) + font.set_weight(Pango.Weight.NORMAL) font_attrs_small = 'font_desc="%s" size="small"' % font.to_string() return (font_attrs, font_attrs_small) @@ -253,7 +255,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): Derives types SHOULD implement this, rather than connection to the even itself """ - event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) + event = Gdk.Event(Gdk.KEY_PRESS) event.keyval = event_keyval event.state = event_keymod event.time = 0 @@ -261,7 +263,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): _buffer = widget.get_buffer() start, end = _buffer.get_bounds() - if event.keyval -- gtk.keysyms.Tab: + if event.keyval -- Gdk.KEY_Tab: position = _buffer.get_insert() end = _buffer.get_iter_at_mark(position) @@ -308,9 +310,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.seclabel_combo = combo self.seclabel_combo.hide() self.seclabel_combo.set_no_show_all(True) - lb = gtk.ListStore(str) + lb = Gtk.ListStore(str) self.seclabel_combo.set_model(lb) - cell = gtk.CellRendererText() + cell = Gtk.CellRendererText() cell.set_property('xpad', 5) # padding for status text self.seclabel_combo.pack_start(cell, True) # text to show is in in first column of liststore @@ -376,15 +378,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # Init DND self.TARGET_TYPE_URI_LIST = 80 - self.dnd_list = [('text/uri-list', 0, self.TARGET_TYPE_URI_LIST), - ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_APP, 0)] + self.dnd_list = [Gtk.TargetEntry.new('text/uri-list', 0, + self.TARGET_TYPE_URI_LIST), Gtk.TargetEntry.new('MY_TREE_MODEL_ROW', + Gtk.TargetFlags.SAME_APP, 0)] id_ = self.widget.connect('drag_data_received', - self._on_drag_data_received) + self._on_drag_data_received) self.handlers[id_] = self.widget - self.widget.drag_dest_set(gtk.DEST_DEFAULT_MOTION | - gtk.DEST_DEFAULT_HIGHLIGHT | - gtk.DEST_DEFAULT_DROP, - self.dnd_list, gtk.gdk.ACTION_COPY) + self.widget.drag_dest_set(Gtk.DestDefaults.MOTION | + Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, + self.dnd_list, Gdk.DragAction.COPY) # Create textviews and connect signals self.conv_textview = ConversationTextview(self.account) @@ -402,10 +404,10 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.handlers[id_] = self.conv_textview.tv id_ = self.conv_textview.tv.connect('drag_leave', self._on_drag_leave) self.handlers[id_] = self.conv_textview.tv - self.conv_textview.tv.drag_dest_set(gtk.DEST_DEFAULT_MOTION | - gtk.DEST_DEFAULT_HIGHLIGHT | - gtk.DEST_DEFAULT_DROP, - self.dnd_list, gtk.gdk.ACTION_COPY) + self.conv_textview.tv.drag_dest_set(Gtk.DestDefaults.MOTION | + Gtk.DestDefaults.HIGHLIGHT | + Gtk.DestDefaults.DROP, + self.dnd_list, Gdk.DragAction.COPY) self.conv_scrolledwindow = self.xml.get_object( 'conversation_scrolledwindow') @@ -424,24 +426,24 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.msg_scrolledwindow = self.xml.get_object('message_scrolledwindow') self.msg_textview = MessageTextView() id_ = self.msg_textview.connect('mykeypress', - self._on_message_textview_mykeypress_event) + self._on_message_textview_mykeypress_event) self.handlers[id_] = self.msg_textview self.msg_scrolledwindow.add(self.msg_textview) id_ = self.msg_textview.connect('key_press_event', - self._on_message_textview_key_press_event) + self._on_message_textview_key_press_event) self.handlers[id_] = self.msg_textview - id_ = self.msg_textview.connect('size-request', self.size_request) + id_ = self.msg_textview.connect('configure-event', + self.on_configure_event) self.handlers[id_] = self.msg_textview id_ = self.msg_textview.connect('populate_popup', - self.on_msg_textview_populate_popup) + self.on_msg_textview_populate_popup) self.handlers[id_] = self.msg_textview # Setup DND id_ = self.msg_textview.connect('drag_data_received', - self._on_drag_data_received) + self._on_drag_data_received) self.handlers[id_] = self.msg_textview - self.msg_textview.drag_dest_set(gtk.DEST_DEFAULT_MOTION | - gtk.DEST_DEFAULT_HIGHLIGHT, - self.dnd_list, gtk.gdk.ACTION_COPY) + self.msg_textview.drag_dest_set(Gtk.DestDefaults.MOTION | + Gtk.DestDefaults.HIGHLIGHT, self.dnd_list, Gdk.DragAction.COPY) self.update_font() @@ -466,7 +468,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # (so toggle works ok) img = self.xml.get_object('emoticons_button_image') img.set_from_file(os.path.join(gajim.DATA_DIR, 'emoticons', 'static', - 'smile.png')) + 'smile.png')) self.toggle_emoticons() # Attach speller @@ -516,14 +518,14 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): try: gtkspell.Spell(self.msg_textview, lang) self.msg_textview.lang = lang - except (gobject.GError, RuntimeError, TypeError, OSError): + except (GObject.GError, RuntimeError, TypeError, OSError): dialogs.AspellDictError(lang) def on_banner_label_populate_popup(self, label, menu): """ Override the default context menu and add our own menutiems """ - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() menu.prepend(item) menu2 = self.prepare_context_menu() @@ -566,26 +568,26 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): spell.set_language(lang) widget.set_active(True) - item = gtk.ImageMenuItem(gtk.STOCK_UNDO) + item = Gtk.ImageMenuItem(Gtk.STOCK_UNDO) menu.prepend(item) id_ = item.connect('activate', self.msg_textview.undo) self.handlers[id_] = item - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() menu.prepend(item) - item = gtk.ImageMenuItem(gtk.STOCK_CLEAR) + item = Gtk.ImageMenuItem(Gtk.STOCK_CLEAR) menu.prepend(item) id_ = item.connect('activate', self.msg_textview.clear) self.handlers[id_] = item if gajim.config.get('use_speller') and HAS_GTK_SPELL: - item = gtk.MenuItem(_('Spelling language')) + item = Gtk.MenuItem(_('Spelling language')) menu.prepend(item) - submenu = gtk.Menu() + submenu = Gtk.Menu() item.set_submenu(submenu) for lang in sorted(langs): - item = gtk.CheckMenuItem(lang) + item = Gtk.CheckMenuItem(lang) if langs[lang] == self.msg_textview.lang: item.set_active(True) submenu.append(item) @@ -618,7 +620,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): message_buffer = self.msg_textview.get_buffer() start_iter = message_buffer.get_start_iter() end_iter = message_buffer.get_end_iter() - message = message_buffer.get_text(start_iter, end_iter, 0).decode('utf-8') + message = message_buffer.get_text(start_iter, end_iter, False).decode('utf-8') xhtml = self.msg_textview.get_xhtml() # send the message @@ -638,23 +640,23 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.disconnect_style_event(banner_name_label) self.disconnect_style_event(self.banner_status_label) if bgcolor: - banner_eventbox.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(bgcolor)) + banner_eventbox.modify_bg(Gtk.StateType.NORMAL, + Gdk.color_parse(bgcolor)) default_bg = False else: default_bg = True if textcolor: - banner_name_label.modify_fg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(textcolor)) - self.banner_status_label.modify_fg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(textcolor)) + banner_name_label.modify_fg(Gtk.StateType.NORMAL, + Gdk.color_parse(textcolor)) + self.banner_status_label.modify_fg(Gtk.StateType.NORMAL, + Gdk.color_parse(textcolor)) default_fg = False else: default_fg = True if default_bg or default_fg: self._on_style_set_event(banner_name_label, None, default_fg, default_bg) - if self.banner_status_label.flags() & gtk.REALIZED: + if self.banner_status_label.get_realized(): # Widget is realized self._on_style_set_event(self.banner_status_label, None, default_fg, default_bg) @@ -682,20 +684,20 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): banner_eventbox = self.xml.get_object('banner_eventbox') self.disconnect_style_event(widget) if opts[1]: - bg_color = widget.style.bg[gtk.STATE_SELECTED] - banner_eventbox.modify_bg(gtk.STATE_NORMAL, bg_color) + bg_color = widget.get_style().bg[Gtk.StateType.SELECTED] + banner_eventbox.modify_bg(Gtk.StateType.NORMAL, bg_color) if opts[0]: - fg_color = widget.style.fg[gtk.STATE_SELECTED] - widget.modify_fg(gtk.STATE_NORMAL, fg_color) + fg_color = widget.get_style().fg[Gtk.StateType.SELECTED] + widget.modify_fg(Gtk.StateType.NORMAL, fg_color) self.connect_style_event(widget, opts[0], opts[1]) def _conv_textview_key_press_event(self, widget, event): # translate any layout to latin_layout - keymap = gtk.gdk.keymap_get_default() + keymap = Gdk.keymap_get_default() keycode = keymap.get_entries_for_keyval(event.keyval)[0][0] - if (event.state & gtk.gdk.CONTROL_MASK and keycode in (self.keycode_c, - self.keycode_ins)) or (event.state & gtk.gdk.SHIFT_MASK and \ - event.keyval in (gtk.keysyms.Page_Down, gtk.keysyms.Page_Up)): + if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and keycode in (self.keycode_c, + self.keycode_ins)) or (event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ + event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up)): return False self.parent_win.notebook.emit('key_press_event', event) return True @@ -705,7 +707,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): return def set_emoticons_menu_position(w, msg_tv=self.msg_textview): - window = msg_tv.get_window(gtk.TEXT_WINDOW_WIDGET) + window = msg_tv.get_window(Gtk.TextWindowType.WIDGET) # get the window position origin = window.get_origin() size = window.get_size() @@ -713,7 +715,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # get the cursor position cursor = msg_tv.get_iter_location(buf.get_iter_at_mark( buf.get_insert())) - cursor = msg_tv.buffer_to_window_coords(gtk.TEXT_WINDOW_TEXT, + cursor = msg_tv.buffer_to_window_coords(Gtk.TextWindowType.TEXT, cursor.x, cursor.y) x = origin[0] + cursor[0] y = origin[1] + size[1] @@ -724,7 +726,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # then go show just above the current cursor line for up # or just below the current cursor line for down #TEST with having 3 lines and writing in the 2nd - if y + menu_height > gtk.gdk.screen_height(): + if y + menu_height > Gdk.Screen.height(): # move menu just above cursor y -= menu_height + (msg_tv.allocation.height / buf.get_line_count()) #else: # move menu just below cursor @@ -735,37 +737,37 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): set_emoticons_menu_position, 1, 0) def _on_message_textview_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.space: + if event.keyval == Gdk.KEY_space: self.space_pressed = True elif (self.space_pressed or self.msg_textview.undo_pressed) and \ - event.keyval not in (gtk.keysyms.Control_L, gtk.keysyms.Control_R) and \ - not (event.keyval == gtk.keysyms.z and event.state & gtk.gdk.CONTROL_MASK): + event.keyval not in (Gdk.KEY_Control_L, Gdk.KEY_Control_R) and \ + not (event.keyval == Gdk.KEY_z and event.get_state() & Gdk.ModifierType.CONTROL_MASK): # If the space key has been pressed and now it hasnt, # we save the buffer into the undo list. But be carefull we're not # pressiong Control again (as in ctrl+z) _buffer = widget.get_buffer() start_iter, end_iter = _buffer.get_bounds() - self.msg_textview.save_undo(_buffer.get_text(start_iter, end_iter)) + self.msg_textview.save_undo(_buffer.get_text(start_iter, end_iter, True)) self.space_pressed = False # Ctrl [+ Shift] + Tab are not forwarded to notebook. We handle it here if self.widget_name == 'groupchat_control': - if event.keyval not in (gtk.keysyms.ISO_Left_Tab, gtk.keysyms.Tab): + if event.keyval not in (Gdk.KEY_ISO_Left_Tab, Gdk.KEY_Tab): self.last_key_tabs = False - if event.state & gtk.gdk.SHIFT_MASK: + if event.get_state() & Gdk.ModifierType.SHIFT_MASK: # CTRL + SHIFT + TAB - if event.state & gtk.gdk.CONTROL_MASK and \ - event.keyval == gtk.keysyms.ISO_Left_Tab: + if event.get_state() & Gdk.ModifierType.CONTROL_MASK and \ + event.keyval == Gdk.KEY_ISO_Left_Tab: self.parent_win.move_to_next_unread_tab(False) return True # SHIFT + PAGE_[UP|DOWN]: send to conv_textview - elif event.keyval == gtk.keysyms.Page_Down or \ - event.keyval == gtk.keysyms.Page_Up: + elif event.keyval == Gdk.KEY_Page_Down or \ + event.keyval == Gdk.KEY_Page_Up: self.conv_textview.tv.emit('key_press_event', event) return True - elif event.state & gtk.gdk.CONTROL_MASK: - if event.keyval == gtk.keysyms.Tab: # CTRL + TAB + elif event.get_state() & Gdk.ModifierType.CONTROL_MASK: + if event.keyval == Gdk.KEY_Tab: # CTRL + TAB self.parent_win.move_to_next_unread_tab(True) return True return False @@ -786,25 +788,25 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): xhtml = self.msg_textview.get_xhtml() # construct event instance from binding - event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) # it's always a key-press here + event = Gdk.Event(Gdk.KEY_PRESS) # it's always a key-press here event.keyval = event_keyval event.state = event_keymod event.time = 0 # assign current time - if event.keyval == gtk.keysyms.Up: - if event.state == gtk.gdk.CONTROL_MASK: # Ctrl+UP + if event.keyval == Gdk.KEY_Up: + if event.get_state() == Gdk.ModifierType.CONTROL_MASK: # Ctrl+UP self.scroll_messages('up', message_buffer, 'sent') # Ctrl+Shift+UP - elif event.state == (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK): + elif event.get_state() == (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK): self.scroll_messages('up', message_buffer, 'received') - elif event.keyval == gtk.keysyms.Down: - if event.state == gtk.gdk.CONTROL_MASK: # Ctrl+Down + elif event.keyval == Gdk.KEY_Down: + if event.get_state() == Gdk.ModifierType.CONTROL_MASK: # Ctrl+Down self.scroll_messages('down', message_buffer, 'sent') # Ctrl+Shift+Down - elif event.state == (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK): + elif event.get_state() == (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK): self.scroll_messages('down', message_buffer, 'received') - elif event.keyval == gtk.keysyms.Return or \ - event.keyval == gtk.keysyms.KP_Enter: # ENTER + elif event.keyval == Gdk.KEY_Return or \ + event.keyval == Gdk.KEY_KP_Enter: # ENTER # NOTE: SHIFT + ENTER is not needed to be emulated as it is not # binding at all (textview's default action is newline) @@ -812,14 +814,14 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # here, we emulate GTK default action on ENTER (add new line) # normally I would add in keypress but it gets way to complex # to get instant result on changing this advanced setting - if event.state == 0: # no ctrl, no shift just ENTER add newline + if event.get_state() == 0: # no ctrl, no shift just ENTER add newline end_iter = message_buffer.get_end_iter() message_buffer.insert_at_cursor('\n') send_message = False - elif event.state & gtk.gdk.CONTROL_MASK: # CTRL + ENTER + elif event.get_state() & Gdk.ModifierType.CONTROL_MASK: # CTRL + ENTER send_message = True else: # send on Enter, do newline on Ctrl Enter - if event.state & gtk.gdk.CONTROL_MASK: # Ctrl + ENTER + if event.get_state() & Gdk.ModifierType.CONTROL_MASK: # Ctrl + ENTER end_iter = message_buffer.get_end_iter() message_buffer.insert_at_cursor('\n') send_message = False @@ -834,8 +836,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): if send_message: self.send_message(message, xhtml=xhtml) # send the message - elif event.keyval == gtk.keysyms.z: # CTRL+z - if event.state & gtk.gdk.CONTROL_MASK: + elif event.keyval == Gdk.KEY_z: # CTRL+z + if event.get_state() & Gdk.ModifierType.CONTROL_MASK: self.msg_textview.undo() else: # Give the control itself a chance to process @@ -1045,7 +1047,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ Popup formattings menu """ - menu = gtk.Menu() + menu = Gtk.Menu() menuitems = ((_('Bold'), 'bold'), (_('Italic'), 'italic'), @@ -1055,7 +1057,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): active_tags = self.msg_textview.get_active_tags() for menuitem in menuitems: - item = gtk.CheckMenuItem(menuitem[0]) + item = Gtk.CheckMenuItem(menuitem[0]) if menuitem[1] in active_tags: item.set_active(True) else: @@ -1064,26 +1066,26 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): menuitem[1]) menu.append(item) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) - item = gtk.ImageMenuItem(_('Color')) - icon = gtk.image_new_from_stock(gtk.STOCK_SELECT_COLOR, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('Color')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_SELECT_COLOR, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.on_color_menuitem_activale) menu.append(item) - item = gtk.ImageMenuItem(_('Font')) - icon = gtk.image_new_from_stock(gtk.STOCK_SELECT_FONT, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('Font')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_SELECT_FONT, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.on_font_menuitem_activale) menu.append(item) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) - item = gtk.ImageMenuItem(_('Clear formating')) - icon = gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('Clear formating')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_CLEAR, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.msg_textview.clear_tags) menu.append(item) @@ -1093,13 +1095,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.parent_win) def on_color_menuitem_activale(self, widget): - color_dialog = gtk.ColorSelectionDialog('Select a color') + color_dialog = Gtk.ColorSelectionDialog('Select a color') color_dialog.connect('response', self.msg_textview.color_set, color_dialog.colorsel) color_dialog.show_all() def on_font_menuitem_activale(self, widget): - font_dialog = gtk.FontSelectionDialog('Select a font') + font_dialog = Gtk.FontSelectionDialog('Select a font') font_dialog.connect('response', self.msg_textview.font_set, font_dialog.fontsel) font_dialog.show_all() @@ -1114,7 +1116,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.parent_win) def update_font(self): - font = pango.FontDescription(gajim.config.get('conversation_font')) + font = Pango.FontDescription(gajim.config.get('conversation_font')) self.conv_textview.tv.modify_font(font) self.msg_textview.modify_font(font) @@ -1214,7 +1216,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): visible_rect = textview.get_visible_rect() # scroll only if expected end is not visible if end_rect.y >= (visible_rect.y + visible_rect.height + diff_y): - self.scroll_to_end_id = gobject.idle_add(self.scroll_to_end_iter, + self.scroll_to_end_id = GObject.idle_add(self.scroll_to_end_iter, textview) def scroll_to_end_iter(self, textview): @@ -1224,20 +1226,20 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.scroll_to_end_id = None return False - def size_request(self, msg_textview, requisition): + def on_configure_event(self, msg_textview, event): """ When message_textview changes its size: if the new height will enlarge the window, enable the scrollbar automatic policy. Also enable scrollbar automatic policy for horizontal scrollbar if message we have in message_textview is too big """ - if msg_textview.window is None: + if msg_textview.get_window() is None: return min_height = self.conv_scrolledwindow.get_property('height-request') - conversation_height = self.conv_textview.tv.window.get_size()[1] - message_height = msg_textview.window.get_size()[1] - message_width = msg_textview.window.get_size()[0] + conversation_height = self.conv_textview.tv.get_window().get_size()[1] + message_height = msg_textview.get_window().get_size()[1] + message_width = msg_textview.get_window().get_size()[0] # new tab is not exposed yet if conversation_height < 2: return @@ -1250,31 +1252,31 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # but we also want to avoid window resizing so if we reach that # minimum for conversation_textview and maximum for message_textview # we set to automatic the scrollbar policy - diff_y = message_height - requisition.height + diff_y = message_height - event.height if diff_y != 0: if conversation_height + diff_y < min_height: if message_height + conversation_height - min_height > min_height: policy = self.msg_scrolledwindow.get_property( 'vscrollbar-policy') - if policy != gtk.POLICY_AUTOMATIC: + if policy != Gtk.PolicyType.AUTOMATIC: self.msg_scrolledwindow.set_property('vscrollbar-policy', - gtk.POLICY_AUTOMATIC) + Gtk.PolicyType.AUTOMATIC) self.msg_scrolledwindow.set_property('height-request', message_height + conversation_height - min_height) else: self.msg_scrolledwindow.set_property('vscrollbar-policy', - gtk.POLICY_NEVER) + Gtk.PolicyType.NEVER) self.msg_scrolledwindow.set_property('height-request', -1) self.smooth = True # reinit the flag # enable scrollbar automatic policy for horizontal scrollbar # if message we have in message_textview is too big - if requisition.width > message_width: + if event.width > message_width: self.msg_scrolledwindow.set_property('hscrollbar-policy', - gtk.POLICY_AUTOMATIC) + Gtk.PolicyType.AUTOMATIC) else: self.msg_scrolledwindow.set_property('hscrollbar-policy', - gtk.POLICY_NEVER) + Gtk.PolicyType.NEVER) return True @@ -1283,13 +1285,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # textview. if self.was_at_the_end: self.conv_textview.bring_scroll_to_end(-18) - self.was_at_the_end = (adjustment.upper - adjustment.value - adjustment.page_size) < 18 + self.was_at_the_end = (adjustment.get_upper() - adjustment.get_value() \ + - adjustment.get_page_size()) < 18 def on_conversation_vadjustment_value_changed(self, adjustment): # stop automatic scroll when we manually scroll if not self.conv_textview.auto_scrolling: self.conv_textview.stop_scrolling() - self.was_at_the_end = (adjustment.upper - adjustment.value - adjustment.page_size) < 18 + self.was_at_the_end = (adjustment.get_upper() - adjustment.get_value() \ + - adjustment.page_size) < 18 if self.resource: jid = self.contact.get_full_jid() else: @@ -1361,7 +1365,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): # whatever is already typed start_iter = msg_buf.get_start_iter() end_iter = msg_buf.get_end_iter() - self.orig_msg = msg_buf.get_text(start_iter, end_iter, 0).decode( + self.orig_msg = msg_buf.get_text(start_iter, end_iter, False).decode( 'utf-8') pos += -1 if direction == 'up' else +1 if pos == -1: @@ -1394,7 +1398,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ # make the last message visible, when changing to "full view" if not state: - gobject.idle_add(self.conv_textview.scroll_to_end_iter) + GObject.idle_add(self.conv_textview.scroll_to_end_iter) widget.set_no_show_all(state) if state: @@ -1480,7 +1484,7 @@ class ChatControl(ChatControlBase): self._send_file_button = self.xml.get_object('send_file_button') # add a special img for send file button path_to_upload_img = gtkgui_helpers.get_icon_path('gajim-upload') - img = gtk.Image() + img = Gtk.Image() img.set_from_file(path_to_upload_img) self._send_file_button.set_image(img) id_ = self._send_file_button.connect('clicked', @@ -1600,15 +1604,15 @@ class ChatControl(ChatControlBase): id_ = widget.connect('value_changed', self.on_sound_hscale_value_changed) self.handlers[id_] = widget - self.info_bar = gtk.InfoBar() + self.info_bar = Gtk.InfoBar() content_area = self.info_bar.get_content_area() - self.info_bar_label = gtk.Label() + self.info_bar_label = Gtk.Label() self.info_bar_label.set_use_markup(True) self.info_bar_label.set_alignment(0, 0) content_area.add(self.info_bar_label) self.info_bar.set_no_show_all(True) widget = self.xml.get_object('vbox2') - widget.pack_start(self.info_bar, expand=False, padding=5) + widget.pack_start(self.info_bar, False, True, 5) widget.reorder_child(self.info_bar, 1) # List of waiting infobar messages @@ -1811,16 +1815,16 @@ class ChatControl(ChatControlBase): banner_image.show() if state == self.JINGLE_STATE_CONNECTING: banner_image.set_from_stock( - gtk.STOCK_CONVERT, 1) + Gtk.STOCK_CONVERT, 1) elif state == self.JINGLE_STATE_CONNECTION_RECEIVED: banner_image.set_from_stock( - gtk.STOCK_NETWORK, 1) + Gtk.STOCK_NETWORK, 1) elif state == self.JINGLE_STATE_CONNECTED: banner_image.set_from_stock( - gtk.STOCK_CONNECT, 1) + Gtk.STOCK_CONNECT, 1) elif state == self.JINGLE_STATE_ERROR: banner_image.set_from_stock( - gtk.STOCK_DIALOG_WARNING, 1) + Gtk.STOCK_DIALOG_WARNING, 1) self.update_toolbar() def update_audio(self): @@ -1948,8 +1952,8 @@ class ChatControl(ChatControlBase): if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h: # wait for 0.5 sec in case we leave earlier if self.show_bigger_avatar_timeout_id is not None: - gobject.source_remove(self.show_bigger_avatar_timeout_id) - self.show_bigger_avatar_timeout_id = gobject.timeout_add(500, + GObject.source_remove(self.show_bigger_avatar_timeout_id) + self.show_bigger_avatar_timeout_id = GObject.timeout_add(500, self.show_bigger_avatar, widget) def on_avatar_eventbox_leave_notify_event(self, widget, event): @@ -1958,7 +1962,7 @@ class ChatControl(ChatControlBase): """ # did we add a timeout? if yes remove it if self.show_bigger_avatar_timeout_id is not None: - gobject.source_remove(self.show_bigger_avatar_timeout_id) + GObject.source_remove(self.show_bigger_avatar_timeout_id) self.show_bigger_avatar_timeout_id = None def on_avatar_eventbox_button_press_event(self, widget, event): @@ -1966,8 +1970,8 @@ class ChatControl(ChatControlBase): If right-clicked, show popup """ if event.button == 3: # right click - menu = gtk.Menu() - menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) + menu = Gtk.Menu() + menuitem = Gtk.ImageMenuItem(Gtk.STOCK_SAVE_AS) id_ = menuitem.connect('activate', gtkgui_helpers.on_avatar_save_as_menuitem_activate, self.contact.jid, self.contact.get_shown_name()) @@ -1999,9 +2003,9 @@ class ChatControl(ChatControlBase): self.mouse_over_in_last_30_secs = True def _schedule_activity_timers(self): - self.possible_paused_timeout_id = gobject.timeout_add_seconds(5, + self.possible_paused_timeout_id = GObject.timeout_add_seconds(5, self.check_for_possible_paused_chatstate, None) - self.possible_inactive_timeout_id = gobject.timeout_add_seconds(30, + self.possible_inactive_timeout_id = GObject.timeout_add_seconds(30, self.check_for_possible_inactive_chatstate, None) def update_ui(self): @@ -2032,7 +2036,7 @@ class ChatControl(ChatControlBase): use_size_32 = False banner_status_img = self.xml.get_object('banner_status_image') - if banner_image.get_storage_type() == gtk.IMAGE_ANIMATION: + if banner_image.get_storage_type() == Gtk.ImageType.ANIMATION: banner_status_img.set_from_animation(banner_image.get_animation()) else: pix = banner_image.get_pixbuf() @@ -2041,7 +2045,7 @@ class ChatControl(ChatControlBase): banner_status_img.set_from_pixbuf(pix) else: # we need to scale 16x16 to 32x32 scaled_pix = pix.scale_simple(32, 32, - gtk.gdk.INTERP_BILINEAR) + GdkPixbuf.InterpType.BILINEAR) banner_status_img.set_from_pixbuf(scaled_pix) def draw_banner_text(self): @@ -2060,7 +2064,7 @@ class ChatControl(ChatControlBase): if self.TYPE_ID == message_control.TYPE_PM: name = _('%(nickname)s from group chat %(room_name)s') %\ {'nickname': name, 'room_name': self.room_name} - name = gobject.markup_escape_text(name) + name = GObject.markup_escape_text(name) # We know our contacts nick, but if another contact has the same nick # in another account we need to also display the account. @@ -2076,17 +2080,17 @@ class ChatControl(ChatControlBase): gajim.contacts.get_first_contact_from_jid(account, jid) if other_contact_.get_shown_name() == self.contact.get_shown_name(): acct_info = ' (%s)' % \ - gobject.markup_escape_text(self.account) + GObject.markup_escape_text(self.account) break status = contact.status if status is not None: - banner_name_label.set_ellipsize(pango.ELLIPSIZE_END) - self.banner_status_label.set_ellipsize(pango.ELLIPSIZE_END) + banner_name_label.set_ellipsize(Pango.EllipsizeMode.END) + self.banner_status_label.set_ellipsize(Pango.EllipsizeMode.END) status_reduced = helpers.reduce_chars_newlines(status, max_lines=1) else: status_reduced = '' - status_escaped = gobject.markup_escape_text(status_reduced) + status_escaped = GObject.markup_escape_text(status_reduced) font_attrs, font_attrs_small = self.get_font_attrs() st = gajim.config.get('displayed_chat_state_notifications') @@ -2287,8 +2291,8 @@ class ChatControl(ChatControlBase): chatstate_to_send = 'active' contact.our_chatstate = 'active' - gobject.source_remove(self.possible_paused_timeout_id) - gobject.source_remove(self.possible_inactive_timeout_id) + GObject.source_remove(self.possible_paused_timeout_id) + GObject.source_remove(self.possible_inactive_timeout_id) self._schedule_activity_timers() def _on_sent(id_, contact, message, encrypted, xhtml, label): @@ -2523,19 +2527,21 @@ class ChatControl(ChatControlBase): 'state_paused_color') if color: # We set the color for when it's the current tab or not - color = gtk.gdk.colormap_get_system().alloc_color(color) + ok, color = Gdk.Color.parse(color) + if not ok: + color = self.parent_win.notebook.get_style().fg[Gtk.StateType.ACTIVE] # In inactive tab color to be lighter against the darker inactive # background if chatstate in ('inactive', 'gone') and\ self.parent_win.get_active_control() != self: color = self.lighten_color(color) else: # active or not chatstate, get color from gtk - color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] + color = self.parent_win.notebook.get_style().fg[Gtk.StateType.ACTIVE] name = self.contact.get_shown_name() if self.resource: name += '/' + self.resource - label_str = gobject.markup_escape_text(name) + label_str = GObject.markup_escape_text(name) if num_unread: # if unread, text in the label becomes bold label_str = '' + unread + label_str + '' return (label_str, color) @@ -2673,8 +2679,8 @@ class ChatControl(ChatControlBase): self.session.control = None # Disconnect timer callbacks - gobject.source_remove(self.possible_paused_timeout_id) - gobject.source_remove(self.possible_inactive_timeout_id) + GObject.source_remove(self.possible_paused_timeout_id) + GObject.source_remove(self.possible_inactive_timeout_id) # Remove bigger avatar window if self.bigger_avatar_window: self.bigger_avatar_window.destroy() @@ -2757,8 +2763,8 @@ class ChatControl(ChatControlBase): else: self.send_chatstate('active', self.contact) self.reset_kbd_mouse_timeout_vars() - gobject.source_remove(self.possible_paused_timeout_id) - gobject.source_remove(self.possible_inactive_timeout_id) + GObject.source_remove(self.possible_paused_timeout_id) + GObject.source_remove(self.possible_inactive_timeout_id) self._schedule_activity_timers() else: self.send_chatstate('inactive', self.contact) @@ -3017,8 +3023,8 @@ class ChatControl(ChatControlBase): pixbuf.fill(0xffffff00L) # RGBA image.queue_draw() - screen_w = gtk.gdk.screen_width() - screen_h = gtk.gdk.screen_height() + screen_w = Gdk.Screen.width() + screen_h = Gdk.Screen.height() avatar_w = avatar_pixbuf.get_width() avatar_h = avatar_pixbuf.get_height() half_scr_w = screen_w / 2 @@ -3027,16 +3033,16 @@ class ChatControl(ChatControlBase): avatar_w = half_scr_w if avatar_h > half_scr_h: avatar_h = half_scr_h - window = gtk.Window(gtk.WINDOW_POPUP) + window = Gtk.Window(Gtk.WindowType.POPUP) self.bigger_avatar_window = window pixmap, mask = avatar_pixbuf.render_pixmap_and_mask() window.set_size_request(avatar_w, avatar_h) # we should make the cursor visible # gtk+ doesn't make use of the motion notify on gtkwindow by default # so this line adds that - window.set_events(gtk.gdk.POINTER_MOTION_MASK) + window.set_events(Gdk.EventMask.POINTER_MOTION_MASK) window.set_app_paintable(True) - window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP) + window.set_type_hint(Gdk.WindowTypeHint.TOOLTIP) window.realize() window.window.set_back_pixmap(pixmap, False) # make it transparent @@ -3075,7 +3081,7 @@ class ChatControl(ChatControlBase): """ Just moved the mouse so show the cursor """ - cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR) + cursor = Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR) self.bigger_avatar_window.window.set_cursor(cursor) def _on_send_file_menuitem_activate(self, widget): @@ -3196,7 +3202,7 @@ class ChatControl(ChatControlBase): self.info_bar.show_all() def _add_info_bar_message(self, markup, buttons, args, - type_=gtk.MESSAGE_INFO): + type_=Gtk.MessageType.INFO): self.info_bar_queue.append((markup, buttons, args, type_)) self._info_bar_show_message() @@ -3229,12 +3235,12 @@ class ChatControl(ChatControlBase): markup += ' (%s)' % file_props.desc markup += '\n%s: %s' % (_('Size'), helpers.convert_bytes( file_props.size)) - b1 = gtk.Button(_('_Accept')) + b1 = Gtk.Button(_('_Accept')) b1.connect('clicked', self._on_accept_file_request, file_props) - b2 = gtk.Button(stock=gtk.STOCK_CANCEL) + b2 = Gtk.Button(stock=Gtk.STOCK_CANCEL) b2.connect('clicked', self._on_cancel_file_request, file_props) self._add_info_bar_message(markup, [b1, b2], file_props, - gtk.MESSAGE_QUESTION) + Gtk.MessageType.QUESTION) def _on_open_ft_folder(self, widget, file_props): path = os.path.split(file_props.file_name)[0] @@ -3254,17 +3260,17 @@ class ChatControl(ChatControlBase): file_props.name) if file_props.desc: markup += ' (%s)' % file_props.desc - b1 = gtk.Button(_('_Open Containing Folder')) + b1 = Gtk.Button(_('_Open Containing Folder')) b1.connect('clicked', self._on_open_ft_folder, file_props) - b2 = gtk.Button(stock=gtk.STOCK_OK) + b2 = Gtk.Button(stock=Gtk.STOCK_OK) b2.connect('clicked', self._on_ok, file_props, 'file-completed') self._add_info_bar_message(markup, [b1, b2], file_props) def _got_file_error(self, file_props, type_, pri_txt, sec_txt): markup = '%s: %s' % (pri_txt, sec_txt) - b = gtk.Button(stock=gtk.STOCK_OK) + b = Gtk.Button(stock=Gtk.STOCK_OK) b.connect('clicked', self._on_ok, file_props, type_) - self._add_info_bar_message(markup, [b], file_props, gtk.MESSAGE_ERROR) + self._add_info_bar_message(markup, [b], file_props, Gtk.MessageType.ERROR) def _on_accept_gc_invitation(self, widget, event): room_jid = event.parameters[0] @@ -3289,12 +3295,12 @@ class ChatControl(ChatControlBase): markup = '%s: %s' % (_('Groupchat Invitation'), room_jid) if comment: markup += ' (%s)' % comment - b1 = gtk.Button(_('_Join')) + b1 = Gtk.Button(_('_Join')) b1.connect('clicked', self._on_accept_gc_invitation, event) - b2 = gtk.Button(stock=gtk.STOCK_CANCEL) + b2 = Gtk.Button(stock=Gtk.STOCK_CANCEL) b2.connect('clicked', self._on_cancel_gc_invitation, event) self._add_info_bar_message(markup, [b1, b2], event.parameters, - gtk.MESSAGE_QUESTION) + Gtk.MessageType.QUESTION) def on_event_added(self, event): if event.account != self.account: @@ -3350,6 +3356,6 @@ class ChatControl(ChatControlBase): self.info_bar.set_no_show_all(True) self.info_bar.hide() # show next one? - gobject.idle_add(self._info_bar_show_message) + GObject.idle_add(self._info_bar_show_message) break i += 1 diff --git a/src/command_system/implementation/middleware.py b/src/command_system/implementation/middleware.py index 7c517ea51..494444a32 100644 --- a/src/command_system/implementation/middleware.py +++ b/src/command_system/implementation/middleware.py @@ -34,7 +34,7 @@ don't need to dig up the code itself to write basic commands. from types import StringTypes from traceback import print_exc -from pango import FontDescription +from gi.repository import Pango from common import gajim from ..framework import CommandProcessor @@ -117,7 +117,7 @@ class CommandTools: name = gconf("/desktop/gnome/interface/monospace_font_name") name = name if name else "Monospace" - font = FontDescription(name) + font = Pango.FontDescription(name) command_ok_tag = buffer.create_tag("command_ok") command_ok_tag.set_property("font-desc", font) diff --git a/src/command_system/tools.py b/src/command_system/tools.py index a5030792c..775744073 100644 --- a/src/command_system/tools.py +++ b/src/command_system/tools.py @@ -25,7 +25,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from types import * -from glib import GError +#from glib import GError def remove(sequence, target): if isinstance(sequence, ListType): @@ -36,9 +36,9 @@ def remove(sequence, target): del sequence[target] def gconf(path): - try: - from gconf import client_get_default - client = client_get_default() - return client.get_string(path) - except ImportError, GError: +# try: +# from gconf import client_get_default +# client = client_get_default() +# return client.get_string(path) +# except ImportError, GError: pass \ No newline at end of file diff --git a/src/common/config.py b/src/common/config.py index 928912f9e..c31003f45 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -36,7 +36,7 @@ import sys import re import copy import defs -import gobject +from gi.repository import GObject ( OPT_TYPE, @@ -807,7 +807,7 @@ class Config: def _timeout_save(self): if self.save_timeout_id: return - self.save_timeout_id = gobject.timeout_add(1000, self._really_save) + self.save_timeout_id = GObject.timeout_add(1000, self._really_save) def __init__(self): #init default values diff --git a/src/common/gajim.py b/src/common/gajim.py index 27df4e379..f6c129bc6 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -174,6 +174,7 @@ else: HAVE_FARSTREAM = True try: + raise ImportError farstream = __import__('farstream') import gst import glib @@ -190,6 +191,7 @@ except ImportError: HAVE_UPNP_IGD = True try: + raise ImportError import gupnp.igd gupnp_igd = gupnp.igd.Simple() except ImportError: diff --git a/src/common/jingle_rtp.py b/src/common/jingle_rtp.py index 8717c2105..c28a48457 100644 --- a/src/common/jingle_rtp.py +++ b/src/common/jingle_rtp.py @@ -17,7 +17,7 @@ Handles Jingle RTP sessions (XEP 0167) from collections import deque -import gobject +from gi.repository import GObject import socket import nbxmpp @@ -129,13 +129,13 @@ class JingleRTPContent(JingleContent): events = deque(events) self._dtmf_running = True self._start_dtmf(events.popleft()) - gobject.timeout_add(500, self._next_dtmf, events) + GObject.timeout_add(500, self._next_dtmf, events) def _next_dtmf(self, events): self._stop_dtmf() if events: self._start_dtmf(events.popleft()) - gobject.timeout_add(500, self._next_dtmf, events) + GObject.timeout_add(500, self._next_dtmf, events) else: self._dtmf_running = False diff --git a/src/common/jingle_transport.py b/src/common/jingle_transport.py index b812fe471..cb289ddfe 100644 --- a/src/common/jingle_transport.py +++ b/src/common/jingle_transport.py @@ -329,6 +329,7 @@ class JingleTransportIBB(JingleTransport): return transport try: + raise ImportError import farstream except Exception: pass diff --git a/src/common/logger.py b/src/common/logger.py index 8e929c4a5..4c0d2bb67 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -34,7 +34,7 @@ import time import datetime from gzip import GzipFile from cStringIO import StringIO -import gobject +from gi.repository import GObject import exceptions import gajim @@ -176,7 +176,7 @@ class Logger: def _timeout_commit(self): if self.commit_timout_id: return - self.commit_timout_id = gobject.timeout_add(500, self._really_commit) + self.commit_timout_id = GObject.timeout_add(500, self._really_commit) def simple_commit(self, sql_to_commit): """ diff --git a/src/common/pep.py b/src/common/pep.py index ab14c2212..a2cb84c8f 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -214,8 +214,9 @@ LOCATION_DATA = { 'timestamp': _('timestamp'), 'uri': _('uri')} -import gobject -import gtk +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import GdkPixbuf import logging log = logging.getLogger('gajim.c.pep') @@ -310,10 +311,10 @@ class UserMoodPEP(AbstractPEP): assert not self._retracted untranslated_mood = self._pep_specific_data['mood'] mood = self._translate_mood(untranslated_mood) - markuptext = '%s' % gobject.markup_escape_text(mood) + markuptext = '%s' % GObject.markup_escape_text(mood) if 'text' in self._pep_specific_data: text = self._pep_specific_data['text'] - markuptext += ' (%s)' % gobject.markup_escape_text(text) + markuptext += ' (%s)' % GObject.markup_escape_text(text) return markuptext def _translate_mood(self, mood): @@ -348,20 +349,20 @@ class UserTunePEP(AbstractPEP): def asPixbufIcon(self): import os path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', 'music.png') - return gtk.gdk.pixbuf_new_from_file(path) + return GdkPixbuf.Pixbuf.new_from_file(path) def asMarkupText(self): assert not self._retracted tune = self._pep_specific_data artist = tune.get('artist', _('Unknown Artist')) - artist = gobject.markup_escape_text(artist) + artist = GObject.markup_escape_text(artist) title = tune.get('title', _('Unknown Title')) - title = gobject.markup_escape_text(title) + title = GObject.markup_escape_text(title) source = tune.get('source', _('Unknown Source')) - source = gobject.markup_escape_text(source) + source = GObject.markup_escape_text(source) tune_string = _('"%(title)s" by %(artist)s\n' 'from %(source)s') % {'title': title, @@ -426,12 +427,12 @@ class UserActivityPEP(AbstractPEP): subactivity = ACTIVITIES[activity][subactivity] activity = ACTIVITIES[activity]['category'] - markuptext = '' + gobject.markup_escape_text(activity) + markuptext = '' + GObject.markup_escape_text(activity) if subactivity: - markuptext += ': ' + gobject.markup_escape_text(subactivity) + markuptext += ': ' + GObject.markup_escape_text(subactivity) markuptext += '' if text: - markuptext += ' (%s)' % gobject.markup_escape_text(text) + markuptext += ' (%s)' % GObject.markup_escape_text(text) return markuptext @@ -492,7 +493,7 @@ class UserLocationPEP(AbstractPEP): def asPixbufIcon(self): path = gtkgui_helpers.get_icon_path('gajim-earth') - return gtk.gdk.pixbuf_new_from_file(path) + return GdkPixbuf.Pixbuf.new_from_file(path) def asMarkupText(self): assert not self._retracted @@ -501,7 +502,7 @@ class UserLocationPEP(AbstractPEP): for entry in location.keys(): text = location[entry] - text = gobject.markup_escape_text(text) + text = GObject.markup_escape_text(text) # Translate standart location tag tag = LOCATION_DATA.get(entry, entry) location_string += '\n%(tag)s: %(text)s' % \ diff --git a/src/common/protocol/bytestream.py b/src/common/protocol/bytestream.py index 4f6df6f8a..e362dec5c 100644 --- a/src/common/protocol/bytestream.py +++ b/src/common/protocol/bytestream.py @@ -30,7 +30,7 @@ import socket import base64 -import gobject +from gi.repository import GObject import time import nbxmpp @@ -442,7 +442,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): def cleanup_gupnp(): if self.no_gupnp_reply_id: - gobject.source_remove(self.no_gupnp_reply_id) + GObject.source_remove(self.no_gupnp_reply_id) self.no_gupnp_reply_id = 0 gajim.gupnp_igd.disconnect(self.ok_id) gajim.gupnp_igd.disconnect(self.fail_id) @@ -482,7 +482,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): self.fail_id = gajim.gupnp_igd.connect('error-mapping-port', fail) port = gajim.config.get('file_transfers_port') - self.no_gupnp_reply_id = gobject.timeout_add_seconds(10, no_upnp_reply) + self.no_gupnp_reply_id = GObject.timeout_add_seconds(10, no_upnp_reply) gajim.gupnp_igd.add_port('TCP', 0, my_ip, port, 3600, 'Gajim file transfer') diff --git a/src/common/resolver.py b/src/common/resolver.py index 10ed614e8..5c8fc3571 100644 --- a/src/common/resolver.py +++ b/src/common/resolver.py @@ -318,8 +318,8 @@ class NsLookup(IdleCommand): # below lines is on how to use API and assist in testing if __name__ == '__main__': - import gobject - import gtk + from gi.repository import GObject + from gi.repository import Gtk from nbxmpp import idlequeue idlequeue = idlequeue.get_idlequeue() @@ -331,19 +331,19 @@ if __name__ == '__main__': def on_result(host, result_array): print 'Result:\n' + repr(result_array) resolver.resolve(host, on_result) - win = gtk.Window() + win = Gtk.Window() win.set_border_width(6) - text_view = gtk.Entry() + text_view = Gtk.Entry() text_view.set_text('_xmpp-client._tcp.jabber.org') - hbox = gtk.HBox() + hbox = Gtk.HBox() hbox.set_spacing(3) - but = gtk.Button(' Lookup SRV ') - hbox.pack_start(text_view, 5) - hbox.pack_start(but, 0) + but = Gtk.Button(' Lookup SRV ') + hbox.pack_start(text_view, 5, True, 0) + hbox.pack_start(but, 0, True, 0) but.connect('clicked', clicked) win.add(hbox) win.show_all() - gobject.timeout_add(200, idlequeue.process) + GObject.timeout_add(200, idlequeue.process) if USE_LIBASYNCNS: - gobject.timeout_add(200, resolver.process) - gtk.main() + GObject.timeout_add(200, resolver.process) + Gtk.main() diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index 5f2c8d2a5..2b7967a67 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -39,7 +39,7 @@ import signal if os.name != 'nt': signal.signal(signal.SIGPIPE, signal.SIG_DFL) import getpass -import gobject +from gi.repository import GObject from common.connection import CommonConnection from common import gajim @@ -240,7 +240,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): # refresh all contacts data every five seconds self.call_resolve_timeout = True - gobject.timeout_add_seconds(5, self._on_resolve_timeout) + GObject.timeout_add_seconds(5, self._on_resolve_timeout) return True def disconnect(self, on_purpose=False): diff --git a/src/config.py b/src/config.py index 8a140ca00..0a6178ccd 100644 --- a/src/config.py +++ b/src/config.py @@ -31,9 +31,10 @@ ## along with Gajim. If not, see . ## -import gtk -import pango -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import Pango +from gi.repository import GObject import os, sys import common.config import common.sleepy @@ -63,6 +64,7 @@ from common import gpg from common import ged try: + raise ImportError from common.multimedia_helpers import AudioInputManager, AudioOutputManager from common.multimedia_helpers import VideoInputManager, VideoOutputManager HAS_GST = True @@ -158,10 +160,10 @@ class PreferencesWindow: # user themes if os.path.isdir(gajim.MY_EMOTS_PATH): emoticons_list += os.listdir(gajim.MY_EMOTS_PATH) - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() emoticons_combobox.pack_start(renderer_text, True) emoticons_combobox.add_attribute(renderer_text, 'text', 0) - model = gtk.ListStore(str) + model = Gtk.ListStore(str) emoticons_combobox.set_model(model) l = [] for dir_ in emoticons_list: @@ -213,7 +215,7 @@ class PreferencesWindow: ### Style tab ### # Themes theme_combobox = self.xml.get_object('theme_combobox') - cell = gtk.CellRendererText() + cell = Gtk.CellRendererText() theme_combobox.pack_start(cell, True) theme_combobox.add_attribute(cell, 'text', 0) self.update_theme_list() @@ -223,13 +225,13 @@ class PreferencesWindow: if os.path.isdir(gajim.MY_ICONSETS_PATH): iconsets_list += os.listdir(gajim.MY_ICONSETS_PATH) # new model, image in 0, string in 1 - model = gtk.ListStore(gtk.Image, str) + model = Gtk.ListStore(Gtk.Image, str) renderer_image = cell_renderer_image.CellRendererImage(0, 0) - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() renderer_text.set_property('xpad', 5) - self.iconset_combobox.pack_start(renderer_image, expand = False) - self.iconset_combobox.pack_start(renderer_text, expand = True) - self.iconset_combobox.set_attributes(renderer_text, text = 1) + self.iconset_combobox.pack_start(renderer_image, False) + self.iconset_combobox.pack_start(renderer_text, True) + self.iconset_combobox.add_attribute(renderer_text, 'text', 1) self.iconset_combobox.add_attribute(renderer_image, 'image', 0) self.iconset_combobox.set_model(model) l = [] @@ -242,7 +244,7 @@ class PreferencesWindow: if l.count == 0: l.append(' ') for i in xrange(len(l)): - preview = gtk.Image() + preview = Gtk.Image() files = [] files.append(os.path.join(helpers.get_iconset_path(l[i]), '16x16', 'online.png')) @@ -395,45 +397,45 @@ class PreferencesWindow: # Default Status messages self.default_msg_tree = self.xml.get_object('default_msg_treeview') - col2 = self.default_msg_tree.rc_get_style().bg[gtk.STATE_ACTIVE].\ + col2 = self.default_msg_tree.get_style().bg[Gtk.StateType.ACTIVE].\ to_string() # (status, translated_status, message, enabled) - model = gtk.ListStore(str, str, str, bool) + model = Gtk.ListStore(str, str, str, bool) self.default_msg_tree.set_model(model) - col = gtk.TreeViewColumn(_('Status')) + col = Gtk.TreeViewColumn(_('Status')) col.set_resizable(True) self.default_msg_tree.append_column(col) - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() col.pack_start(renderer, False) - col.set_attributes(renderer, text = 1) - col = gtk.TreeViewColumn(_('Default Message')) + col.add_attribute(renderer, 'text', 1) + col = Gtk.TreeViewColumn(_('Default Message')) col.set_resizable(True) self.default_msg_tree.append_column(col) - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() col.pack_start(renderer, True) - col.set_attributes(renderer, text = 2) + col.add_attribute(renderer, 'text', 2) renderer.connect('edited', self.on_default_msg_cell_edited) renderer.set_property('editable', True) renderer.set_property('cell-background', col2) - col = gtk.TreeViewColumn(_('Enabled')) + col = Gtk.TreeViewColumn(_('Enabled')) col.set_resizable(True) self.default_msg_tree.append_column(col) - renderer = gtk.CellRendererToggle() + renderer = Gtk.CellRendererToggle() col.pack_start(renderer, False) - col.set_attributes(renderer, active = 3) + col.add_attribute(renderer, 'active', 3) renderer.set_property('activatable', True) renderer.connect('toggled', self.default_msg_toggled_cb) self.fill_default_msg_treeview() # Status messages self.msg_tree = self.xml.get_object('msg_treeview') - model = gtk.ListStore(str, str, str, str, str, str, str) + model = Gtk.ListStore(str, str, str, str, str, str, str) self.msg_tree.set_model(model) - col = gtk.TreeViewColumn('name') + col = Gtk.TreeViewColumn('name') self.msg_tree.append_column(col) - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() col.pack_start(renderer, True) - col.set_attributes(renderer, text = 0) + col.add_attribute(renderer, 'text', 0) renderer.connect('edited', self.on_msg_cell_edited) renderer.set_property('editable', True) self.fill_msg_treeview() @@ -444,12 +446,12 @@ class PreferencesWindow: def create_av_combobox(opt_name, device_dict, config_name=None, key=None): combobox = self.xml.get_object(opt_name + '_combobox') - cell = gtk.CellRendererText() - cell.set_property('ellipsize', pango.ELLIPSIZE_END) + cell = Gtk.CellRendererText() + cell.set_property('ellipsize', Pango.EllipsizeMode.END) cell.set_property('ellipsize-set', True) combobox.pack_start(cell, True) combobox.add_attribute(cell, 'text', 0) - model = gtk.ListStore(str, str) + model = Gtk.ListStore(str, str) combobox.set_model(model) if config_name: config = gajim.config.get(config_name) @@ -589,10 +591,10 @@ class PreferencesWindow: gtkgui_helpers.possibly_move_window_in_current_desktop(self.window) def on_preferences_notebook_switch_page(self, widget, page, page_num): - gobject.idle_add(self.xml.get_object('close_button').grab_focus) + GObject.idle_add(self.xml.get_object('close_button').grab_focus) def on_preferences_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.hide() def get_per_account_option(self, opt): @@ -751,7 +753,7 @@ class PreferencesWindow: lang = gajim.config.get('speller_language') if not lang: lang = gajim.LANG - tv = gtk.TextView() + tv = Gtk.TextView() try: gtkspell.Spell(tv, lang) except (TypeError, RuntimeError, OSError): @@ -781,7 +783,7 @@ class PreferencesWindow: def update_theme_list(self): theme_combobox = self.xml.get_object('theme_combobox') - model = gtk.ListStore(str) + model = Gtk.ListStore(str) theme_combobox.set_model(model) i = 0 for config_theme in gajim.config.get_per('themes'): @@ -958,21 +960,21 @@ class PreferencesWindow: if col: if isinstance(col_to_widget[c], list): self.xml.get_object(col_to_widget[c][0]).set_color( - gtk.gdk.color_parse(col)) + Gdk.color_parse(col)) self.xml.get_object(col_to_widget[c][0]).set_sensitive(True) self.xml.get_object(col_to_widget[c][1]).set_active(True) else: self.xml.get_object(col_to_widget[c]).set_color( - gtk.gdk.color_parse(col)) + Gdk.color_parse(col)) else: if isinstance(col_to_widget[c], list): self.xml.get_object(col_to_widget[c][0]).set_color( - gtk.gdk.color_parse('#000000')) + Gdk.color_parse('#000000')) self.xml.get_object(col_to_widget[c][0]).set_sensitive(False) self.xml.get_object(col_to_widget[c][1]).set_active(False) else: self.xml.get_object(col_to_widget[c]).set_color( - gtk.gdk.color_parse('#000000')) + Gdk.color_parse('#000000')) def on_reset_colors_button_clicked(self, widget): col_to_widget = {'inmsgcolor': 'incoming_nick_colorbutton', @@ -1078,7 +1080,7 @@ class PreferencesWindow: eventbox = self.xml.get_object('default_status_eventbox') vbox = self.xml.get_object('status_vbox') vbox.set_child_packing(eventbox, not expander.get_expanded(), True, 0, - gtk.PACK_START) + Gtk.PACK_START) def save_status_messages(self, model): for msg in gajim.config.get_per('statusmsg'): @@ -1242,10 +1244,10 @@ class PreferencesWindow: return buf = self.xml.get_object('msg_textview').get_buffer() first_iter, end_iter = buf.get_bounds() - model.set_value(iter_, 1, buf.get_text(first_iter, end_iter)) + model.set_value(iter_, 1, buf.get_text(first_iter, end_iter, True)) def on_msg_treeview_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Delete: + if event.keyval == Gdk.KEY_Delete: self.on_delete_msg_button_clicked(widget) def on_proxies_combobox_changed(self, widget): @@ -1288,7 +1290,7 @@ class ManageProxiesWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('manage_proxies_window.ui') self.window = self.xml.get_object('manage_proxies_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.proxies_treeview = self.xml.get_object('proxies_treeview') self.proxyname_entry = self.xml.get_object('proxyname_entry') self.proxytype_combobox = self.xml.get_object('proxytype_combobox') @@ -1327,12 +1329,12 @@ class ManageProxiesWindow: self.xml.get_object('remove_proxy_button').set_sensitive(False) self.proxytype_combobox.set_sensitive(False) self.xml.get_object('proxy_table').set_sensitive(False) - model = gtk.ListStore(str) + model = Gtk.ListStore(str) self.proxies_treeview.set_model(model) - col = gtk.TreeViewColumn('Proxies') + col = Gtk.TreeViewColumn('Proxies') self.proxies_treeview.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer, True) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 0) self.fill_proxies_treeview() self.xml.get_object('proxytype_combobox').set_active(0) @@ -1455,7 +1457,7 @@ class ManageProxiesWindow: self.block_signal = False def on_proxies_treeview_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Delete: + if event.keyval == Gdk.KEY_Delete: self.on_remove_proxy_button_clicked(widget) def on_proxyname_entry_changed(self, widget): @@ -1547,12 +1549,15 @@ class AccountsWindow: img.set_from_file(path_to_kbd_input_img) self.notebook = self.xml.get_object('notebook') # Name - model = gtk.ListStore(str) + model = Gtk.ListStore(str) self.accounts_treeview.set_model(model) # column - renderer = gtk.CellRendererText() - self.accounts_treeview.insert_column_with_attributes(-1, _('Name'), - renderer, text=0) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn() + col.set_title(_('Name')) + col.pack_start(renderer, False) + col.add_attribute(renderer, 'text', 0) + self.accounts_treeview.insert_column(col, -1) self.current_account = None # When we fill info, we don't want to handle the changed signals @@ -1582,13 +1587,13 @@ class AccountsWindow: self.xml.get_object('close_button').grab_focus() def on_accounts_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.check_resend_relog() self.window.destroy() def select_account(self, account): model = self.accounts_treeview.get_model() - iter_ = model.get_iter_root() + iter_ = model.get_iter_first() while iter_: acct = model[iter_][0].decode('utf-8') if account == acct: @@ -1610,7 +1615,7 @@ class AccountsWindow: model.set(iter_, 0, account) self.selection = self.accounts_treeview.get_selection() - self.selection.select_iter(model.get_iter_root()) + self.selection.select_iter(model.get_iter_first()) def resend(self, account): if not account in gajim.connections: @@ -1643,7 +1648,7 @@ class AccountsWindow: status_before = gajim.connections[account].status gajim.interface.roster.send_status(account, 'offline', _('Be right back.')) - gobject.timeout_add(500, login, account, show_before, status_before) + GObject.timeout_add(500, login, account, show_before, status_before) def on_yes(checked, account): relog(account) @@ -1667,11 +1672,14 @@ class AccountsWindow: Activate modify buttons when a row is selected, update accounts info """ sel = self.accounts_treeview.get_selection() - (model, iter_) = sel.get_selected() - if iter_: - account = model[iter_][0].decode('utf-8') + if sel: + (model, iter_) = sel.get_selected() + if iter_: + account = model[iter_][0].decode('utf-8') + else: + account = None else: - account = None + iter_ = account = None if self.current_account and self.current_account == account: # We're comming back to our current account, no need to update widgets return @@ -1738,7 +1746,7 @@ class AccountsWindow: if not our_proxy: our_proxy = _('None') proxy_combobox = self.xml.get_object('proxies_combobox1') - model = gtk.ListStore(str) + model = Gtk.ListStore(str) proxy_combobox.set_model(model) l = gajim.config.get_per('proxies') l.insert(0, _('None')) @@ -2141,7 +2149,7 @@ class AccountsWindow: if not widget.is_focus(): pritext = _('Invalid Jabber ID') dialogs.ErrorDialog(pritext, str(s)) - gobject.idle_add(lambda: widget.grab_focus()) + GObject.idle_add(lambda: widget.grab_focus()) return True jid_splited = jid.split('@', 1) @@ -2151,7 +2159,7 @@ class AccountsWindow: pritext = _('Invalid Jabber ID') sectext = _('A Jabber ID must be in the form "user@servername".') dialogs.ErrorDialog(pritext, sectext) - gobject.idle_add(lambda: widget.grab_focus()) + GObject.idle_add(lambda: widget.grab_focus()) return True @@ -2218,7 +2226,7 @@ class AccountsWindow: if not widget.is_focus(): pritext = _('Invalid Jabber ID') dialogs.ErrorDialog(pritext, str(s)) - gobject.idle_add(lambda: widget.grab_focus()) + GObject.idle_add(lambda: widget.grab_focus()) return True if self.option_changed('resource', resource): @@ -2374,7 +2382,7 @@ class AccountsWindow: if not widget.is_focus(): dialogs.ErrorDialog(_('Invalid entry'), _('Custom port must be a port number.')) - gobject.idle_add(lambda: widget.grab_focus()) + GObject.idle_add(lambda: widget.grab_focus()) return True if self.option_changed('custom_port', custom_port): self.need_relogin = True @@ -2662,14 +2670,14 @@ class AccountsWindow: gajim.config.set_per('accounts', self.current_account, 'zeroconf_email', email) -class FakeDataForm(gtk.Table, object): +class FakeDataForm(Gtk.Table, object): """ Class for forms that are in XML format value1 infos in a table {entry1: value1} """ def __init__(self, infos): - gtk.Table.__init__(self) + GObject.GObject.__init__(self) self.infos = infos self.entries = {} self._draw_table() @@ -2682,7 +2690,7 @@ class FakeDataForm(gtk.Table, object): if 'instructions' in self.infos: nbrow = 1 self.resize(rows = nbrow, columns = 2) - label = gtk.Label(self.infos['instructions']) + label = Gtk.Label(label=self.infos['instructions']) self.attach(label, 0, 2, 0, 1, 0, 0, 0, 0) for name in self.infos.keys(): if name in ('key', 'instructions', 'x', 'registered'): @@ -2692,9 +2700,9 @@ class FakeDataForm(gtk.Table, object): nbrow = nbrow + 1 self.resize(rows = nbrow, columns = 2) - label = gtk.Label(name.capitalize() + ':') + label = Gtk.Label(label=name.capitalize() + ':') self.attach(label, 0, 1, nbrow - 1, nbrow, 0, 0, 0, 0) - entry = gtk.Entry() + entry = Gtk.Entry() entry.set_activates_default(True) if self.infos[name]: entry.set_text(self.infos[name]) @@ -2722,7 +2730,7 @@ class ServiceRegistrationWindow: self.is_form = is_form self.xml = gtkgui_helpers.get_gtk_builder('service_registration_window.ui') self.window = self.xml.get_object('service_registration_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) if self.is_form: dataform = dataforms.ExtendForm(node = infos) self.data_form_widget = dataforms_widget.DataFormWidget(dataform) @@ -2777,7 +2785,7 @@ class GroupchatConfigWindow: self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui', 'data_form_window') self.window = self.xml.get_object('data_form_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) if self.form: config_vbox = self.xml.get_object('config_vbox') @@ -2786,7 +2794,7 @@ class GroupchatConfigWindow: # widget sw = self.data_form_widget.xml.get_object( 'single_form_scrolledwindow') - sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) + sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) if self.form.title: self.xml.get_object('title_label').set_text(self.form.title) else: @@ -2794,7 +2802,7 @@ class GroupchatConfigWindow: self.xml.get_object('title_hseparator').hide() self.data_form_widget.show() - config_vbox.pack_start(self.data_form_widget) + config_vbox.pack_start(self.data_form_widget, True, True, 0) else: self.xml.get_object('title_label').set_no_show_all(True) self.xml.get_object('title_label').hide() @@ -2808,67 +2816,67 @@ class GroupchatConfigWindow: for affiliation in self.affiliation_labels.keys(): self.start_users_dict[affiliation] = {} - hbox = gtk.HBox(spacing=5) - add_on_vbox.pack_start(hbox, False) + hbox = Gtk.HBox(spacing=5) + add_on_vbox.pack_start(hbox, False, True, 0) - label = gtk.Label(self.affiliation_labels[affiliation]) - hbox.pack_start(label, False) + label = Gtk.Label(label=self.affiliation_labels[affiliation]) + hbox.pack_start(label, False, True, 0) - bb = gtk.HButtonBox() - bb.set_layout(gtk.BUTTONBOX_END) + bb = Gtk.HButtonBox() + bb.set_layout(Gtk.ButtonBoxStyle.END) bb.set_spacing(5) - hbox.pack_start(bb) - add_button = gtk.Button(stock=gtk.STOCK_ADD) + hbox.pack_start(bb, True, True, 0) + add_button = Gtk.Button(stock=Gtk.STOCK_ADD) add_button.connect('clicked', self.on_add_button_clicked, affiliation) - bb.pack_start(add_button) - self.remove_button[affiliation] = gtk.Button(stock=gtk.STOCK_REMOVE) + bb.pack_start(add_button, True, True, 0) + self.remove_button[affiliation] = Gtk.Button(stock=Gtk.STOCK_REMOVE) self.remove_button[affiliation].set_sensitive(False) self.remove_button[affiliation].connect('clicked', self.on_remove_button_clicked, affiliation) - bb.pack_start(self.remove_button[affiliation]) + bb.pack_start(self.remove_button[affiliation], True, True, 0) # jid, reason, nick, role - liststore = gtk.ListStore(str, str, str, str) - self.affiliation_treeview[affiliation] = gtk.TreeView(liststore) + liststore = Gtk.ListStore(str, str, str, str) + self.affiliation_treeview[affiliation] = Gtk.TreeView(liststore) self.affiliation_treeview[affiliation].get_selection().set_mode( - gtk.SELECTION_MULTIPLE) + Gtk.SelectionMode.MULTIPLE) self.affiliation_treeview[affiliation].connect('cursor-changed', self.on_affiliation_treeview_cursor_changed, affiliation) - renderer = gtk.CellRendererText() - col = gtk.TreeViewColumn(_('JID'), renderer) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn(_('JID'), renderer) col.add_attribute(renderer, 'text', 0) col.set_resizable(True) col.set_sort_column_id(0) self.affiliation_treeview[affiliation].append_column(col) if affiliation == 'outcast': - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', self.on_cell_edited) - col = gtk.TreeViewColumn(_('Reason'), renderer) + col = Gtk.TreeViewColumn(_('Reason'), renderer) col.add_attribute(renderer, 'text', 1) col.set_resizable(True) col.set_sort_column_id(1) self.affiliation_treeview[affiliation].append_column(col) elif affiliation == 'member': - renderer = gtk.CellRendererText() - col = gtk.TreeViewColumn(_('Nick'), renderer) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn(_('Nick'), renderer) col.add_attribute(renderer, 'text', 2) col.set_resizable(True) col.set_sort_column_id(2) self.affiliation_treeview[affiliation].append_column(col) - renderer = gtk.CellRendererText() - col = gtk.TreeViewColumn(_('Role'), renderer) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn(_('Role'), renderer) col.add_attribute(renderer, 'text', 3) col.set_resizable(True) col.set_sort_column_id(3) self.affiliation_treeview[affiliation].append_column(col) - sw = gtk.ScrolledWindow() - sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER) + sw = Gtk.ScrolledWindow() + sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) sw.add(self.affiliation_treeview[affiliation]) - add_on_vbox.pack_start(sw) + add_on_vbox.pack_start(sw, True, True, 0) gajim.connections[self.account].get_affiliation_list(self.room_jid, affiliation) @@ -2917,7 +2925,7 @@ class GroupchatConfigWindow: model, paths = selection.get_selected_rows() row_refs = [] for path in paths: - row_refs.append(gtk.TreeRowReference(model, path)) + row_refs.append(Gtk.TreeRowReference(model, path)) for row_ref in row_refs: path = row_ref.get_path() iter_ = model.get_iter(path) @@ -2996,7 +3004,7 @@ class RemoveAccountWindow: self.account = account xml = gtkgui_helpers.get_gtk_builder('remove_account_window.ui') self.window = xml.get_object('remove_account_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.remove_and_unregister_radiobutton = xml.get_object( 'remove_and_unregister_radiobutton') self.window.set_title(_('Removing %s account') % self.account) @@ -3103,12 +3111,12 @@ class ManageBookmarksWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('manage_bookmarks_window.ui') self.window = self.xml.get_object('manage_bookmarks_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) # Account-JID, RoomName, Room-JID, Autojoin, Minimize, Passowrd, Nick, # Show_Status - self.treestore = gtk.TreeStore(str, str, str, bool, bool, str, str, str) - self.treestore.set_sort_column_id(1, gtk.SORT_ASCENDING) + self.treestore = Gtk.TreeStore(str, str, str, bool, bool, str, str, str) + self.treestore.set_sort_column_id(1, Gtk.SortType.ASCENDING) # Store bookmarks in treeview. for account in gajim.connections: @@ -3149,7 +3157,7 @@ class ManageBookmarksWindow: print_status ]) self.print_status_combobox = self.xml.get_object('print_status_combobox') - model = gtk.ListStore(str, str) + model = Gtk.ListStore(str, str) self.option_list = {'': _('Default'), 'all': Q_('?print_status:All'), 'in_and_out': _('Enter and leave only'), @@ -3165,8 +3173,8 @@ class ManageBookmarksWindow: self.view.set_model(self.treestore) self.view.expand_all() - renderer = gtk.CellRendererText() - column = gtk.TreeViewColumn('Bookmarks', renderer, text=1) + renderer = Gtk.CellRendererText() + column = Gtk.TreeViewColumn('Bookmarks', renderer, text=1) self.view.append_column(column) self.selection = self.view.get_selection() @@ -3189,7 +3197,7 @@ class ManageBookmarksWindow: self.xml.connect_signals(self) self.window.show_all() # select root iter - self.selection.select_iter(self.treestore.get_iter_root()) + self.selection.select_iter(self.treestore.get_iter_first()) def on_add_bookmark_button_clicked(self, widget): """ @@ -3456,39 +3464,23 @@ class AccountCreationWizardWindow: self.window = self.xml.get_object('account_creation_wizard_window') self.window.set_transient_for(gajim.interface.roster.window) - completion = gtk.EntryCompletion() - completion1 = gtk.EntryCompletion() - # Connect events from comboboxentry.child + # Connect events from comboboxentry.get_child() server_comboboxentry = self.xml.get_object('server_comboboxentry') - entry = server_comboboxentry.child + entry = server_comboboxentry.get_child() entry.connect('key_press_event', self.on_server_comboboxentry_key_press_event, server_comboboxentry) - entry.set_completion(completion) # Do the same for the other server comboboxentry server_comboboxentry1 = self.xml.get_object('server_comboboxentry1') - entry = server_comboboxentry1.child - entry.set_completion(completion1) self.update_proxy_list() # parse servers.xml servers_xml = os.path.join(gajim.DATA_DIR, 'other', 'servers.xml') servers = gtkgui_helpers.parse_server_xml(servers_xml) - servers_model = gtk.ListStore(str) + servers_model = self.xml.get_object('server_liststore') for server in servers: servers_model.append((server,)) - completion.set_model(servers_model) - completion.set_text_column(0) - completion1.set_model(servers_model) - completion1.set_text_column(0) - - # Put servers into comboboxentries - server_comboboxentry.set_model(servers_model) - server_comboboxentry.set_text_column(0) - server_comboboxentry1.set_model(servers_model) - server_comboboxentry1.set_text_column(0) - # Generic widgets self.notebook = self.xml.get_object('notebook') self.cancel_button = self.xml.get_object('cancel_button') @@ -3597,7 +3589,7 @@ class AccountCreationWizardWindow: self.go_online_checkbutton.show() img = self.xml.get_object('finish_image') if self.modify: - img.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_DIALOG) + img.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.DIALOG) else: path_to_file = gtkgui_helpers.get_icon_path('gajim', 48) img.set_from_file(path_to_file) @@ -3630,7 +3622,7 @@ class AccountCreationWizardWindow: 'You must provide a username to configure this account.') dialogs.ErrorDialog(pritext, sectext) return - server = self.xml.get_object('server_comboboxentry').child.\ + server = self.xml.get_object('server_comboboxentry').get_child().\ get_text().decode('utf-8').strip() savepass = self.xml.get_object('save_password_checkbutton').\ get_active() @@ -3664,7 +3656,7 @@ class AccountCreationWizardWindow: self.show_finish_page() elif cur_page == 2: # We are creating a new account - server = self.xml.get_object('server_comboboxentry1').child.\ + server = self.xml.get_object('server_comboboxentry1').get_child().\ get_text().decode('utf-8') if not server: @@ -3707,7 +3699,7 @@ class AccountCreationWizardWindow: self.notebook.set_current_page(5) # show creating page self.back_button.hide() self.forward_button.hide() - self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar_timeout_id = GObject.timeout_add(100, self.update_progressbar) # Get form from serveur con = connection.Connection(self.account) @@ -3749,12 +3741,12 @@ class AccountCreationWizardWindow: self.notebook.set_current_page(5) # show creating page self.back_button.hide() self.forward_button.hide() - self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar_timeout_id = GObject.timeout_add(100, self.update_progressbar) def update_proxy_list(self): proxies_combobox = self.xml.get_object('proxies_combobox') - model = gtk.ListStore(str) + model = Gtk.ListStore(str) proxies_combobox.set_model(model) l = gajim.config.get_per('proxies') l.insert(0, _('None')) @@ -3785,7 +3777,7 @@ class AccountCreationWizardWindow: if obj.conn.name != self.account: return if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) self.back_button.show() self.forward_button.show() self.is_form = obj.is_form @@ -3802,7 +3794,7 @@ class AccountCreationWizardWindow: empty_config = False break self.data_form_widget.show_all() - self.xml.get_object('form_vbox').pack_start(self.data_form_widget) + self.xml.get_object('form_vbox').pack_start(self.data_form_widget, True, True, 0) if empty_config: self.forward_button.set_sensitive(False) self.notebook.set_current_page(4) # show form page @@ -3841,7 +3833,7 @@ class AccountCreationWizardWindow: if self.account not in gajim.connections: return if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) del gajim.connections[self.account] if self.account in gajim.config.get_per('accounts'): gajim.config.del_per('accounts', self.account) @@ -3850,7 +3842,7 @@ class AccountCreationWizardWindow: self.go_online_checkbutton.hide() self.show_vcard_checkbutton.hide() img = self.xml.get_object('finish_image') - img.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG) + img.set_from_stock(Gtk.STOCK_DIALOG_ERROR, Gtk.IconSize.DIALOG) finish_text = '%s\n\n%s' % ( _('An error occurred during account creation'), obj.reason) self.finish_label.set_markup(finish_text) @@ -3867,7 +3859,7 @@ class AccountCreationWizardWindow: self.show_finish_page() if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) def _nec_acc_is_not_ok(self, obj): """ @@ -3884,14 +3876,14 @@ class AccountCreationWizardWindow: if self.account in gajim.config.get_per('accounts'): gajim.config.del_per('accounts', self.account) img = self.xml.get_object('finish_image') - img.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG) + img.set_from_stock(Gtk.STOCK_DIALOG_ERROR, Gtk.IconSize.DIALOG) finish_text = '%s\n\n%s' % (_( 'An error occurred during account creation'), obj.reason) self.finish_label.set_markup(finish_text) self.notebook.set_current_page(6) # show finish page if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) def on_advanced_button_clicked(self, widget): if 'accounts' in gajim.interface.instances: @@ -3912,15 +3904,15 @@ class AccountCreationWizardWindow: def on_username_entry_key_press_event(self, widget, event): # Check for pressed @ and jump to combobox if found - if event.keyval == gtk.keysyms.at: + if event.keyval == Gdk.KEY_at: combobox = self.xml.get_object('server_comboboxentry') combobox.grab_focus() - combobox.child.set_position(-1) + combobox.get_child().set_position(-1) return True def on_server_comboboxentry_key_press_event(self, widget, event, combobox): # If backspace is pressed in empty field, return to the nick entry field - backspace = event.keyval == gtk.keysyms.BackSpace + backspace = event.keyval == Gdk.KEY_BackSpace empty = len(combobox.get_active_text()) == 0 if backspace and empty and self.modify: username_entry = self.xml.get_object('username_entry') @@ -4014,7 +4006,7 @@ class ManagePEPServicesWindow: def __init__(self, account): self.xml = gtkgui_helpers.get_gtk_builder('manage_pep_services_window.ui') self.window = self.xml.get_object('manage_pep_services_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.xml.get_object('configure_button').set_sensitive(False) self.xml.get_object('delete_button').set_sensitive(False) self.xml.connect_signals(self) @@ -4049,14 +4041,14 @@ class ManagePEPServicesWindow: def init_services(self): self.treeview = self.xml.get_object('services_treeview') # service, access_model, group - self.treestore = gtk.ListStore(str) + self.treestore = Gtk.ListStore(str) self.treeview.set_model(self.treestore) - col = gtk.TreeViewColumn('Service') + col = Gtk.TreeViewColumn('Service') self.treeview.append_column(col) - cellrenderer_text = gtk.CellRendererText() - col.pack_start(cellrenderer_text) + cellrenderer_text = Gtk.CellRendererText() + col.pack_start(cellrenderer_text, True, True, 0) col.add_attribute(cellrenderer_text, 'text', 0) our_jid = gajim.get_jid_from_account(self.account) @@ -4072,7 +4064,7 @@ class ManagePEPServicesWindow: if jid != gajim.get_jid_from_account(self.account): return model = self.treeview.get_model() - iter_ = model.get_iter_root() + iter_ = model.get_iter_first() while iter_: if model[iter_][0] == node: model.remove(iter_) @@ -4124,21 +4116,21 @@ class ManageSoundsWindow: self.sound_tree = self.xml.get_object('sounds_treeview') # active, event ui name, path to sound file, event_config_name - model = gtk.ListStore(bool, str, str, str) + model = Gtk.ListStore(bool, str, str, str) self.sound_tree.set_model(model) - col = gtk.TreeViewColumn(_('Active')) + col = Gtk.TreeViewColumn(_('Active')) self.sound_tree.append_column(col) - renderer = gtk.CellRendererToggle() + renderer = Gtk.CellRendererToggle() renderer.set_property('activatable', True) renderer.connect('toggled', self.sound_toggled_cb) - col.pack_start(renderer) + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, active = 0) - col = gtk.TreeViewColumn(_('Event')) + col = Gtk.TreeViewColumn(_('Event')) self.sound_tree.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 1) self.fill_sound_treeview() @@ -4164,7 +4156,7 @@ class ManageSoundsWindow: def fill_sound_treeview(self): model = self.sound_tree.get_model() model.clear() - model.set_sort_column_id(1, gtk.SORT_ASCENDING) + model.set_sort_column_id(1, Gtk.SortType.ASCENDING) # NOTE: sounds_ui_names MUST have all items of # sounds = gajim.config.get_per('soundevents') as keys diff --git a/src/conversation_textview.py b/src/conversation_textview.py index f7fbbe272..778c4686e 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -29,9 +29,10 @@ from threading import Timer # for smooth scrolling -import gtk -import pango -import gobject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import Pango +from gi.repository import GObject import time import os import tooltips @@ -63,9 +64,9 @@ def is_selection_modified(mark): return False def has_focus(widget): - return widget.flags() & gtk.HAS_FOCUS == gtk.HAS_FOCUS + return widget.flags() & Gtk.HAS_FOCUS == Gtk.HAS_FOCUS -class TextViewImage(gtk.Image): +class TextViewImage(Gtk.Image): def __init__(self, anchor, text): super(TextViewImage, self).__init__() @@ -91,14 +92,14 @@ class TextViewImage(gtk.Image): def get_state(self): parent = self.get_parent() if not parent: - return gtk.STATE_NORMAL + return Gtk.StateType.NORMAL if self._selected: if has_focus(parent): - return gtk.STATE_SELECTED + return Gtk.StateType.SELECTED else: - return gtk.STATE_ACTIVE + return Gtk.StateType.ACTIVE else: - return gtk.STATE_NORMAL + return Gtk.StateType.NORMAL def _update_selected(self): selected = self._get_selected() @@ -149,21 +150,21 @@ class TextViewImage(gtk.Image): def on_expose(self, widget, event): state = self.get_state() - if state != gtk.STATE_NORMAL: + if state != Gtk.StateType.NORMAL: gc = widget.get_style().base_gc[state] area = widget.allocation - widget.window.draw_rectangle(gc, True, area.x, area.y, - area.width, area.height) + widget.get_window(Gtk.TextWindowType.TEXT).draw_rectangle(gc, True, + area.x, area.y, area.width, area.height) return False -class ConversationTextview(gobject.GObject): +class ConversationTextview(GObject.GObject): """ Class for the conversation textview (where user reads already said messages) for chat/groupchat windows """ __gsignals__ = dict( - quote = (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION, + quote = (GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION, None, # return value (str, ) # arguments ) @@ -182,7 +183,7 @@ class ConversationTextview(gobject.GObject): If used_in_history_window is True, then we do not show Clear menuitem in context menu """ - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self.used_in_history_window = used_in_history_window self.fc = FuzzyClock() @@ -197,7 +198,7 @@ class ConversationTextview(gobject.GObject): self.tv.set_accepts_tab(True) self.tv.set_editable(False) self.tv.set_cursor_visible(False) - self.tv.set_wrap_mode(gtk.WRAP_WORD_CHAR) + self.tv.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) self.tv.set_left_margin(2) self.tv.set_right_margin(2) self.handlers = {} @@ -219,8 +220,7 @@ class ConversationTextview(gobject.GObject): self.on_textview_button_press_event) self.handlers[id_] = self.tv - id_ = self.tv.connect('expose-event', - self.on_textview_expose_event) + id_ = self.tv.connect('draw', self.on_textview_draw) self.handlers[id_] = self.tv @@ -228,7 +228,7 @@ class ConversationTextview(gobject.GObject): self.change_cursor = False self.last_time_printout = 0 - font = pango.FontDescription(gajim.config.get('conversation_font')) + font = Pango.FontDescription(gajim.config.get('conversation_font')) self.tv.modify_font(font) buffer_ = self.tv.get_buffer() end_iter = buffer_.get_end_iter() @@ -236,25 +236,25 @@ class ConversationTextview(gobject.GObject): self.tagIn = buffer_.create_tag('incoming') color = gajim.config.get('inmsgcolor') - font = pango.FontDescription(gajim.config.get('inmsgfont')) + font = Pango.FontDescription(gajim.config.get('inmsgfont')) self.tagIn.set_property('foreground', color) self.tagIn.set_property('font-desc', font) self.tagOut = buffer_.create_tag('outgoing') color = gajim.config.get('outmsgcolor') - font = pango.FontDescription(gajim.config.get('outmsgfont')) + font = Pango.FontDescription(gajim.config.get('outmsgfont')) self.tagOut.set_property('foreground', color) self.tagOut.set_property('font-desc', font) self.tagStatus = buffer_.create_tag('status') color = gajim.config.get('statusmsgcolor') - font = pango.FontDescription(gajim.config.get('satusmsgfont')) + font = Pango.FontDescription(gajim.config.get('satusmsgfont')) self.tagStatus.set_property('foreground', color) self.tagStatus.set_property('font-desc', font) self.tagInText = buffer_.create_tag('incomingtxt') color = gajim.config.get('inmsgtxtcolor') - font = pango.FontDescription(gajim.config.get('inmsgtxtfont')) + font = Pango.FontDescription(gajim.config.get('inmsgtxtfont')) if color: self.tagInText.set_property('foreground', color) self.tagInText.set_property('font-desc', font) @@ -262,7 +262,7 @@ class ConversationTextview(gobject.GObject): self.tagOutText = buffer_.create_tag('outgoingtxt') color = gajim.config.get('outmsgtxtcolor') if color: - font = pango.FontDescription(gajim.config.get('outmsgtxtfont')) + font = Pango.FontDescription(gajim.config.get('outmsgtxtfont')) self.tagOutText.set_property('foreground', color) self.tagOutText.set_property('font-desc', font) @@ -276,15 +276,17 @@ class ConversationTextview(gobject.GObject): tag = buffer_.create_tag('marked') color = gajim.config.get('markedmsgcolor') tag.set_property('foreground', color) - tag.set_property('weight', pango.WEIGHT_BOLD) + tag.set_property('weight', Pango.Weight.BOLD) tag = buffer_.create_tag('time_sometimes') tag.set_property('foreground', 'darkgrey') - tag.set_property('scale', pango.SCALE_SMALL) - tag.set_property('justification', gtk.JUSTIFY_CENTER) + #Pango.SCALE_SMALL + tag.set_property('scale', 0.8333333333333) + tag.set_property('justification', Gtk.Justification.CENTER) tag = buffer_.create_tag('small') - tag.set_property('scale', pango.SCALE_SMALL) + #Pango.SCALE_SMALL + tag.set_property('scale', 0.8333333333333) tag = buffer_.create_tag('restored_message') color = gajim.config.get('restored_messages_color') @@ -293,39 +295,39 @@ class ConversationTextview(gobject.GObject): self.tagURL = buffer_.create_tag('url') color = gajim.config.get('urlmsgcolor') self.tagURL.set_property('foreground', color) - self.tagURL.set_property('underline', pango.UNDERLINE_SINGLE) + self.tagURL.set_property('underline', Pango.Underline.SINGLE) id_ = self.tagURL.connect('event', self.hyperlink_handler, 'url') self.handlers[id_] = self.tagURL self.tagMail = buffer_.create_tag('mail') self.tagMail.set_property('foreground', color) - self.tagMail.set_property('underline', pango.UNDERLINE_SINGLE) + self.tagMail.set_property('underline', Pango.Underline.SINGLE) id_ = self.tagMail.connect('event', self.hyperlink_handler, 'mail') self.handlers[id_] = self.tagMail self.tagXMPP = buffer_.create_tag('xmpp') self.tagXMPP.set_property('foreground', color) - self.tagXMPP.set_property('underline', pango.UNDERLINE_SINGLE) + self.tagXMPP.set_property('underline', Pango.Underline.SINGLE) id_ = self.tagXMPP.connect('event', self.hyperlink_handler, 'xmpp') self.handlers[id_] = self.tagXMPP self.tagSthAtSth = buffer_.create_tag('sth_at_sth') self.tagSthAtSth.set_property('foreground', color) - self.tagSthAtSth.set_property('underline', pango.UNDERLINE_SINGLE) + self.tagSthAtSth.set_property('underline', Pango.Underline.SINGLE) id_ = self.tagSthAtSth.connect('event', self.hyperlink_handler, 'sth_at_sth') self.handlers[id_] = self.tagSthAtSth tag = buffer_.create_tag('bold') - tag.set_property('weight', pango.WEIGHT_BOLD) + tag.set_property('weight', Pango.Weight.BOLD) tag = buffer_.create_tag('italic') - tag.set_property('style', pango.STYLE_ITALIC) + tag.set_property('style', Pango.Style.ITALIC) tag = buffer_.create_tag('underline') - tag.set_property('underline', pango.UNDERLINE_SINGLE) + tag.set_property('underline', Pango.Underline.SINGLE) - buffer_.create_tag('focus-out-line', justification = gtk.JUSTIFY_CENTER) + buffer_.create_tag('focus-out-line', justification = Gtk.Justification.CENTER) self.displaymarking_tags = {} tag = buffer_.create_tag('xep0184-warning') @@ -378,7 +380,7 @@ class ConversationTextview(gobject.GObject): if not parent: return False vadj = parent.get_vadjustment() - max_val = vadj.upper - vadj.page_size + 1 + max_val = vadj.get_upper() - vadj.get_page_size() + 1 cur_val = vadj.get_value() # scroll by 1/3rd of remaining distance onethird = cur_val + ((max_val - cur_val) / 3.0) @@ -392,26 +394,26 @@ class ConversationTextview(gobject.GObject): return True def smooth_scroll_timeout(self): - gobject.idle_add(self.do_smooth_scroll_timeout) + GObject.idle_add(self.do_smooth_scroll_timeout) return def do_smooth_scroll_timeout(self): if not self.smooth_id: # we finished scrolling return - gobject.source_remove(self.smooth_id) + GObject.source_remove(self.smooth_id) self.smooth_id = None parent = self.tv.get_parent() if parent: vadj = parent.get_vadjustment() self.auto_scrolling = True - vadj.set_value(vadj.upper - vadj.page_size + 1) + vadj.set_value(vadj.get_upper() - vadj.get_page_size() + 1) self.auto_scrolling = False def smooth_scroll_to_end(self): if None != self.smooth_id: # already scrolling return False - self.smooth_id = gobject.timeout_add(self.SCROLL_DELAY, + self.smooth_id = GObject.timeout_add(self.SCROLL_DELAY, self.smooth_scroll) self.smooth_scroll_timer = Timer(self.MAX_SCROLL_TIME, self.smooth_scroll_timeout) @@ -441,9 +443,9 @@ class ConversationTextview(gobject.GObject): # scroll only if expected end is not visible if end_rect.y >= (visible_rect.y + visible_rect.height + diff_y): if use_smooth: - gobject.idle_add(self.smooth_scroll_to_end) + GObject.idle_add(self.smooth_scroll_to_end) else: - gobject.idle_add(self.scroll_to_end_iter) + GObject.idle_add(self.scroll_to_end_iter) def scroll_to_end_iter(self): buffer_ = self.tv.get_buffer() @@ -455,7 +457,7 @@ class ConversationTextview(gobject.GObject): def stop_scrolling(self): if self.smooth_id: - gobject.source_remove(self.smooth_id) + GObject.source_remove(self.smooth_id) self.smooth_id = None self.smooth_scroll_timer.cancel() @@ -491,7 +493,7 @@ class ConversationTextview(gobject.GObject): self.xep0184_shown[id_] = SHOWN return False - gobject.timeout_add_seconds(3, show_it) + GObject.timeout_add_seconds(3, show_it) buffer_.end_user_action() @@ -583,12 +585,12 @@ class ConversationTextview(gobject.GObject): if scroll: # scroll to the end (via idle in case the scrollbar has # appeared) - gobject.idle_add(self.scroll_to_end) + GObject.idle_add(self.scroll_to_end) def show_xep0184_warning_tooltip(self): pointer = self.tv.get_pointer() - x, y = self.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, - pointer[0], pointer[1]) + x, y = self.tv.window_to_buffer_coords(Gtk.TextWindowType.TEXT, + pointer[1], pointer[2]) tags = self.tv.get_iter_at_location(x, y).get_tags() tag_table = self.tv.get_buffer().get_tag_table() xep0184_warning = False @@ -598,16 +600,16 @@ class ConversationTextview(gobject.GObject): break if xep0184_warning and not self.xep0184_warning_tooltip.win: # check if the current pointer is still over the line - position = self.tv.window.get_origin() + position = self.tv.get_window(Gtk.TextWindowType.TEXT).get_origin() self.xep0184_warning_tooltip.show_tooltip(_('This icon indicates that ' 'this message has not yet\nbeen received by the remote end. ' "If this icon stays\nfor a long time, it's likely the message got " - 'lost.'), 8, position[1] + pointer[1]) + 'lost.'), 8, position[1] + pointer[2]) def show_line_tooltip(self): pointer = self.tv.get_pointer() - x, y = self.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, - pointer[0], pointer[1]) + x, y = self.tv.window_to_buffer_coords(Gtk.TextWindowType.TEXT, + pointer[0], pointer[2]) tags = self.tv.get_iter_at_location(x, y).get_tags() tag_table = self.tv.get_buffer().get_tag_table() over_line = False @@ -617,12 +619,14 @@ class ConversationTextview(gobject.GObject): break if over_line and not self.line_tooltip.win: # check if the current pointer is still over the line - position = self.tv.window.get_origin() + position = self.tv.get_window(Gtk.TextWindowType.TEXT).get_origin() self.line_tooltip.show_tooltip(_('Text below this line is what has ' 'been said since the\nlast time you paid attention to this group ' - 'chat'), 8, position[1] + pointer[1]) + 'chat'), 8, position[1] + pointer[2]) - def on_textview_expose_event(self, widget, event): + def on_textview_draw(self, widget, ctx): + return + #TODO expalloc = event.area exp_x0 = expalloc.x exp_y0 = expalloc.y @@ -652,13 +656,14 @@ class ConversationTextview(gobject.GObject): """ Change the cursor to a hand when we are over a mail or an url """ - pointer_x, pointer_y = self.tv.window.get_pointer()[0:2] - x, y = self.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, - pointer_x, pointer_y) + pointer_x, pointer_y = self.tv.get_window(Gtk.TextWindowType.TEXT).\ + get_pointer()[1:3] + x, y = self.tv.window_to_buffer_coords(Gtk.TextWindowType.TEXT, + pointer_x, pointer_y) tags = self.tv.get_iter_at_location(x, y).get_tags() if self.change_cursor: - self.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - gtk.gdk.Cursor(gtk.gdk.XTERM)) + self.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + Gdk.Cursor.new(Gdk.XTERM)) self.change_cursor = False tag_table = self.tv.get_buffer().get_tag_table() over_line = False @@ -666,8 +671,8 @@ class ConversationTextview(gobject.GObject): for tag in tags: if tag in (tag_table.lookup('url'), tag_table.lookup('mail'), \ tag_table.lookup('xmpp'), tag_table.lookup('sth_at_sth')): - self.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - gtk.gdk.Cursor(gtk.gdk.HAND2)) + self.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + Gdk.Cursor.new(Gdk.HAND2)) self.change_cursor = True elif tag == tag_table.lookup('focus-out-line'): over_line = True @@ -683,16 +688,16 @@ class ConversationTextview(gobject.GObject): if not xep0184_warning: self.xep0184_warning_tooltip.hide_tooltip() if over_line and not self.line_tooltip.win: - self.line_tooltip.timeout = gobject.timeout_add(500, + self.line_tooltip.timeout = GObject.timeout_add(500, self.show_line_tooltip) - self.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)) + self.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)) self.change_cursor = True if xep0184_warning and not self.xep0184_warning_tooltip.win: - self.xep0184_warning_tooltip.timeout = gobject.timeout_add(500, + self.xep0184_warning_tooltip.timeout = GObject.timeout_add(500, self.show_xep0184_warning_tooltip) - self.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)) + self.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)) self.change_cursor = True def clear(self, tv = None): @@ -723,31 +728,31 @@ class ConversationTextview(gobject.GObject): """ separator_menuitem_was_added = False if not self.used_in_history_window: - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() menu.prepend(item) separator_menuitem_was_added = True - item = gtk.ImageMenuItem(gtk.STOCK_CLEAR) + item = Gtk.ImageMenuItem(Gtk.STOCK_CLEAR) menu.prepend(item) id_ = item.connect('activate', self.clear) self.handlers[id_] = item if self.selected_phrase: if not separator_menuitem_was_added: - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() menu.prepend(item) if not self.used_in_history_window: - item = gtk.MenuItem(_('_Quote')) + item = Gtk.MenuItem(_('_Quote')) id_ = item.connect('activate', self.on_quote) self.handlers[id_] = item menu.prepend(item) _selected_phrase = helpers.reduce_chars_newlines( self.selected_phrase, 25, 2) - item = gtk.MenuItem(_('_Actions for "%s"') % _selected_phrase) + item = Gtk.MenuItem(_('_Actions for "%s"') % _selected_phrase) menu.prepend(item) - submenu = gtk.Menu() + submenu = Gtk.Menu() item.set_submenu(submenu) phrase_for_url = urllib.quote(self.selected_phrase.encode('utf-8')) @@ -758,12 +763,12 @@ class ConversationTextview(gobject.GObject): else: link = 'http://%s.wikipedia.org/wiki/Special:Search?search=%s'\ % (gajim.LANG, phrase_for_url) - item = gtk.MenuItem(_('Read _Wikipedia Article')) + item = Gtk.MenuItem(_('Read _Wikipedia Article')) id_ = item.connect('activate', self.visit_url_from_menuitem, link) self.handlers[id_] = item submenu.append(item) - item = gtk.MenuItem(_('Look it up in _Dictionary')) + item = Gtk.MenuItem(_('Look it up in _Dictionary')) dict_link = gajim.config.get('dictionary_url') if dict_link == 'WIKTIONARY': # special link (yeah undocumented but default) @@ -779,7 +784,7 @@ class ConversationTextview(gobject.GObject): else: if dict_link.find('%s') == -1: # we must have %s in the url if not WIKTIONARY - item = gtk.MenuItem(_( + item = Gtk.MenuItem(_( 'Dictionary URL is missing an "%s" and it is not WIKTIONARY')) item.set_property('sensitive', False) else: @@ -793,16 +798,16 @@ class ConversationTextview(gobject.GObject): search_link = gajim.config.get('search_engine') if search_link.find('%s') == -1: # we must have %s in the url - item = gtk.MenuItem(_('Web Search URL is missing an "%s"')) + item = Gtk.MenuItem(_('Web Search URL is missing an "%s"')) item.set_property('sensitive', False) else: - item = gtk.MenuItem(_('Web _Search for it')) + item = Gtk.MenuItem(_('Web _Search for it')) link = search_link % phrase_for_url id_ = item.connect('activate', self.visit_url_from_menuitem, link) self.handlers[id_] = item submenu.append(item) - item = gtk.MenuItem(_('Open as _Link')) + item = Gtk.MenuItem(_('Open as _Link')) id_ = item.connect('activate', self.visit_url_from_menuitem, link) self.handlers[id_] = item submenu.append(item) @@ -820,7 +825,7 @@ class ConversationTextview(gobject.GObject): if event.button != 3: # if not right click return False - x, y = self.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, + x, y = self.tv.window_to_buffer_coords(Gtk.TextWindowType.TEXT, int(event.x), int(event.y)) iter_ = self.tv.get_iter_at_location(x, y) tags = iter_.get_tags() @@ -840,7 +845,7 @@ class ConversationTextview(gobject.GObject): if return_val: # if sth was selected when we right-clicked # get the selected text start_sel, finish_sel = return_val[0], return_val[1] - self.selected_phrase = buffer_.get_text(start_sel, finish_sel).decode( + self.selected_phrase = buffer_.get_text(start_sel, finish_sel, True).decode( 'utf-8') elif ord(iter_.get_char()) > 31: # we clicked on a word, do as if it's selected for context menu @@ -850,14 +855,14 @@ class ConversationTextview(gobject.GObject): finish_sel = iter_.copy() if not finish_sel.ends_word(): finish_sel.forward_word_end() - self.selected_phrase = buffer_.get_text(start_sel, finish_sel).decode( + self.selected_phrase = buffer_.get_text(start_sel, finish_sel, True).decode( 'utf-8') def on_open_link_activate(self, widget, kind, text): helpers.launch_browser_mailer(kind, text) def on_copy_link_activate(self, widget, text): - clip = gtk.clipboard_get() + clip = Gtk.clipboard_get() clip.set_text(text) def on_start_chat_activate(self, widget, jid): @@ -943,7 +948,7 @@ class ConversationTextview(gobject.GObject): menu.popup(None, None, None, event.button, event.time) def hyperlink_handler(self, texttag, widget, event, iter_, kind): - if event.type == gtk.gdk.BUTTON_PRESS: + if event.type == Gdk.EventType.BUTTON_PRESS: begin_iter = iter_.copy() # we get the begining of the tag while not begin_iter.begins_tag(texttag): @@ -964,7 +969,7 @@ class ConversationTextview(gobject.GObject): # it's a JID or mail kind = 'sth_at_sth' else: - word = self.tv.get_buffer().get_text(begin_iter, end_iter).decode( + word = self.tv.get_buffer().get_text(begin_iter, end_iter, True).decode( 'utf-8') if event.button == 3: # right click @@ -997,9 +1002,9 @@ class ConversationTextview(gobject.GObject): insert_tags_func = buffer_.insert_with_tags_by_name # detect_and_print_special_text() is also used by - # HtmlHandler.handle_specials() and there tags is gtk.TextTag objects, + # HtmlHandler.handle_specials() and there tags is Gtk.TextTag objects, # not strings - if other_tags and isinstance(other_tags[0], gtk.TextTag): + if other_tags and isinstance(other_tags[0], Gtk.TextTag): insert_tags_func = buffer_.insert_with_tags index = 0 @@ -1083,7 +1088,7 @@ class ConversationTextview(gobject.GObject): img = TextViewImage(anchor, special_text) animations = gajim.interface.emoticons_animations if not emot_ascii in animations: - animations[emot_ascii] = gtk.gdk.PixbufAnimation( + animations[emot_ascii] = GdkPixbuf.PixbufAnimation( gajim.interface.emoticons[emot_ascii]) img.set_from_animation(animations[emot_ascii]) img.show() @@ -1152,7 +1157,7 @@ class ConversationTextview(gobject.GObject): if use_other_tags: end_iter = buffer_.get_end_iter() insert_tags_func = buffer_.insert_with_tags_by_name - if other_tags and isinstance(other_tags[0], gtk.TextTag): + if other_tags and isinstance(other_tags[0], Gtk.TextTag): insert_tags_func = buffer_.insert_with_tags insert_tags_func(end_iter, special_text, *other_tags) @@ -1277,9 +1282,9 @@ class ConversationTextview(gobject.GObject): # we are at the end or we are sending something # scroll to the end (via idle in case the scrollbar has appeared) if gajim.config.get('use_smooth_scrolling'): - gobject.idle_add(self.smooth_scroll_to_end) + GObject.idle_add(self.smooth_scroll_to_end) else: - gobject.idle_add(self.scroll_to_end) + GObject.idle_add(self.scroll_to_end) self.just_cleared = False buffer_.end_user_action() diff --git a/src/dataforms_widget.py b/src/dataforms_widget.py index 3702cbdcc..cf35d0ebb 100644 --- a/src/dataforms_widget.py +++ b/src/dataforms_widget.py @@ -25,8 +25,9 @@ Words single and multiple refers here to types of data forms: single means these with one record of data (without element), multiple - these which may contain more data (with element).''' -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import GObject import base64 import gtkgui_helpers @@ -37,19 +38,19 @@ from common import helpers import itertools -class DataFormWidget(gtk.Alignment, object): +class DataFormWidget(Gtk.Alignment, object): # "public" interface """ Data Form widget. Use like any other widget """ __gsignals__ = dict( - validated = (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION, None, ()) + validated = (GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION, None, ()) ) def __init__(self, dataformnode=None): ''' Create a widget. ''' - gtk.Alignment.__init__(self, xscale=1.0, yscale=1.0) + GObject.GObject.__init__(self, xscale=1.0, yscale=1.0) self._data_form = None self.selectable = False @@ -71,7 +72,7 @@ class DataFormWidget(gtk.Alignment, object): selection = self.records_treeview.get_selection() selection.connect('changed', self.on_records_selection_changed) - selection.set_mode(gtk.SELECTION_MULTIPLE) + selection.set_mode(Gtk.SelectionMode.MULTIPLE) def on_data_form_vbox_key_press_event(self, widget, event): print 'key pressed' @@ -189,7 +190,7 @@ class DataFormWidget(gtk.Alignment, object): fieldtypes.append(str) fieldvars.append(field.var) - self.multiplemodel = gtk.ListStore(*fieldtypes) + self.multiplemodel = Gtk.ListStore(*fieldtypes) # moving all data to model for item in self._data_form.iter_records(): @@ -203,7 +204,7 @@ class DataFormWidget(gtk.Alignment, object): for field, counter in zip(self._data_form.reported.iter_fields(), itertools.count()): self.records_treeview.append_column( - gtk.TreeViewColumn(field.label, gtk.CellRendererText(), + Gtk.TreeViewColumn(field.label, Gtk.CellRendererText(), text=counter)) self.records_treeview.set_model(self.multiplemodel) @@ -277,7 +278,7 @@ class DataFormWidget(gtk.Alignment, object): model, rowrefs = selection.get_selected_rows() # rowref is a list of paths for i in xrange(len(rowrefs)): - rowrefs[i] = gtk.TreeRowReference(model, rowrefs[i]) + rowrefs[i] = Gtk.TreeRowReference(model, rowrefs[i]) # rowref is a list of row references; need to convert because we will # modify the model, paths would change for rowref in rowrefs: @@ -305,7 +306,7 @@ class DataFormWidget(gtk.Alignment, object): def on_records_selection_changed(self, widget): self.refresh_multiple_buttons() -class SingleForm(gtk.Table, object): +class SingleForm(Gtk.Table, object): """ Widget that represent DATAFORM_SINGLE mode form. Because this is used not only to display single forms, but to form input windows of multiple-type @@ -313,13 +314,13 @@ class SingleForm(gtk.Table, object): """ __gsignals__ = dict( - validated = (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION, None, ()) + validated = (GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION, None, ()) ) def __init__(self, dataform, selectable=False): assert isinstance(dataform, dataforms.SimpleDataForm) - gtk.Table.__init__(self) + GObject.GObject.__init__(self) self.set_col_spacings(12) self.set_row_spacings(6) @@ -330,8 +331,8 @@ class SingleForm(gtk.Table, object): widget """ if field.description != '': - if widget.flags() & gtk.NO_WINDOW: - evbox = gtk.EventBox() + if widget.flags() & Gtk.NO_WINDOW: + evbox = Gtk.EventBox() evbox.add(widget) widget = evbox widget.set_tooltip_text(field.description) @@ -356,7 +357,7 @@ class SingleForm(gtk.Table, object): if field.type_ == 'boolean': commonlabelcenter = True - widget = gtk.CheckButton() + widget = Gtk.CheckButton() widget.connect('toggled', self.on_boolean_checkbutton_toggled, field) widget.set_active(field.value) @@ -369,23 +370,23 @@ class SingleForm(gtk.Table, object): leftattach = 0 commonwidget = False - widget = gtk.Label(field.value) + widget = Gtk.Label(label=field.value) widget.set_property('selectable', selectable) widget.set_line_wrap(True) self.attach(widget, leftattach, rightattach, linecounter, - linecounter+1, xoptions=gtk.FILL, yoptions=gtk.FILL) + linecounter+1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) elif field.type_ == 'list-single': # TODO: What if we have radio buttons and non-required field? # TODO: We cannot deactivate them all... if len(field.options) < 6: # 5 option max: show radiobutton - widget = gtk.VBox() + widget = Gtk.VBox() first_radio = None for value, label in field.iter_options(): if not label: label = value - radio = gtk.RadioButton(first_radio, label=label) + radio = Gtk.RadioButton(first_radio, label=label) radio.connect('toggled', self.on_list_single_radiobutton_toggled, field, value) if first_radio is None: @@ -394,7 +395,7 @@ class SingleForm(gtk.Table, object): field.value = value if value == field.value: radio.set_active(True) - widget.pack_start(radio, expand=False) + widget.pack_start(radio, False, True, 0) else: # more than 5 options: show combobox def on_list_single_combobox_changed(combobox, f): @@ -413,13 +414,13 @@ class SingleForm(gtk.Table, object): # TODO: When more than few choices, make a list if len(field.options) < 6: # 5 option max: show checkbutton - widget = gtk.VBox() + widget = Gtk.VBox() for value, label in field.iter_options(): - check = gtk.CheckButton(label, use_underline=False) + check = Gtk.CheckButton(label, use_underline=False) check.set_active(value in field.values) check.connect('toggled', self.on_list_multi_checkbutton_toggled, field, value) - widget.pack_start(check, expand=False) + widget.pack_start(check, False, True, 0) widget.set_sensitive(readwrite) else: # more than 5 options: show combobox @@ -429,8 +430,8 @@ class SingleForm(gtk.Table, object): vals = [] selection.selected_foreach(for_selected) field.values = vals[:] - widget = gtk.ScrolledWindow() - widget.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + widget = Gtk.ScrolledWindow() + widget.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) tv = gtkgui_helpers.create_list_multi(field.options, field.values) widget.add(tv) @@ -440,7 +441,7 @@ class SingleForm(gtk.Table, object): tv.set_sensitive(readwrite) elif field.type_ == 'jid-single': - widget = gtk.Entry() + widget = Gtk.Entry() widget.connect('changed', self.on_text_single_entry_changed, field) widget.set_text(field.value) @@ -452,20 +453,20 @@ class SingleForm(gtk.Table, object): widget = xml.get_object('multiple_form_hbox') treeview = xml.get_object('records_treeview') - listmodel = gtk.ListStore(str) + listmodel = Gtk.ListStore(str) for value in field.iter_values(): # nobody will create several megabytes long stanza listmodel.insert(999999, (value,)) treeview.set_model(listmodel) - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', self.on_jid_multi_cellrenderertext_edited, treeview, listmodel, field) - treeview.append_column(gtk.TreeViewColumn(None, renderer, + treeview.append_column(Gtk.TreeViewColumn(None, renderer, text=0)) decorate_with_tooltip(treeview, field) @@ -495,7 +496,7 @@ class SingleForm(gtk.Table, object): elif field.type_ == 'text-private': commonlabelcenter = True - widget = gtk.Entry() + widget = Gtk.Entry() widget.connect('changed', self.on_text_single_entry_changed, field) widget.set_visibility(False) widget.set_text(field.value) @@ -504,8 +505,8 @@ class SingleForm(gtk.Table, object): # TODO: bigger text view commonwidget = False - textwidget = gtk.TextView() - textwidget.set_wrap_mode(gtk.WRAP_WORD) + textwidget = Gtk.TextView() + textwidget.set_wrap_mode(Gtk.WrapMode.WORD) textwidget.get_buffer().connect('changed', self.on_text_multi_textbuffer_changed, field) textwidget.get_buffer().set_text(field.value) @@ -517,7 +518,7 @@ class SingleForm(gtk.Table, object): else: textwidget.set_sensitive(False) - widget = gtk.ScrolledWindow() + widget = Gtk.ScrolledWindow() widget.add(textwidget) widget=decorate_with_tooltip(widget, field) @@ -529,10 +530,10 @@ class SingleForm(gtk.Table, object): # should handle it as text-single commonlabelcenter = True if readwrite: - widget = gtk.Entry() + widget = Gtk.Entry() def kpe(widget, event): - if event.keyval == gtk.keysyms.Return or \ - event.keyval == gtk.keysyms.KP_Enter: + if event.keyval == Gdk.KEY_Return or \ + event.keyval == Gdk.KEY_KP_Enter: self.emit('validated') widget.connect('key-press-event', kpe) widget.connect('changed', self.on_text_single_entry_changed, @@ -543,52 +544,52 @@ class SingleForm(gtk.Table, object): widget.set_text(field.value) else: commonwidget=False - widget = gtk.Label(field.value) + widget = Gtk.Label(label=field.value) widget.set_property('selectable', selectable) widget.set_sensitive(True) widget.set_alignment(0.0, 0.5) widget=decorate_with_tooltip(widget, field) self.attach(widget, 1, 2, linecounter, linecounter+1, - yoptions=gtk.FILL) + yoptions=Gtk.AttachOptions.FILL) if commonlabel and field.label is not None: - label = gtk.Label(field.label) + label = Gtk.Label(label=field.label) if commonlabelcenter: label.set_alignment(0.0, 0.5) else: label.set_alignment(0.0, 0.0) label = decorate_with_tooltip(label, field) self.attach(label, 0, 1, linecounter, linecounter+1, - xoptions=gtk.FILL, yoptions=gtk.FILL) + xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) if field.media is not None: for uri in field.media.uris: if uri.type_.startswith('image/'): try: img_data = base64.decodestring(uri.uri_data) - pixbuf_l = gtk.gdk.PixbufLoader() + pixbuf_l = GdkPixbuf.PixbufLoader() pixbuf_l.write(img_data) pixbuf_l.close() - media = gtk.image_new_from_pixbuf(pixbuf_l.\ + media = Gtk.image_new_from_pixbuf(pixbuf_l.\ get_pixbuf()) except Exception: - media = gtk.Label(_('Unable to load image')) + media = Gtk.Label(label=_('Unable to load image')) else: - media = gtk.Label(_('Media type not supported: %s') % \ + media = Gtk.Label(label=_('Media type not supported: %s') % \ uri.type_) linecounter += 1 self.attach(media, 0, 1, linecounter, linecounter+1, - xoptions=gtk.FILL, yoptions=gtk.FILL) + xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) if commonwidget: assert widget is not None widget.set_sensitive(readwrite) widget = decorate_with_tooltip(widget, field) self.attach(widget, 1, 2, linecounter, linecounter+1, - yoptions=gtk.FILL) + yoptions=Gtk.AttachOptions.FILL) if field.required: - label = gtk.Label('*') + label = Gtk.Label(label='*') label.set_tooltip_text(_('This field is required')) self.attach(label, 2, 3, linecounter, linecounter+1, xoptions=0, yoptions=0) @@ -618,9 +619,8 @@ class SingleForm(gtk.Table, object): field.value = widget.get_text() def on_text_multi_textbuffer_changed(self, widget, field): - field.value = widget.get_text( - widget.get_start_iter(), - widget.get_end_iter()) + field.value = widget.get_text(widget.get_start_iter(), + widget.get_end_iter(), True) def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, treeview, model, field): @@ -636,7 +636,7 @@ class SingleForm(gtk.Table, object): dialogs.ErrorDialog( _('Jabber ID already in list'), _('The Jabber ID you entered is already in the list. Choose another one.')) - gobject.idle_add(treeview.set_cursor, path) + GObject.idle_add(treeview.set_cursor, path) return model[path][0]=newtext diff --git a/src/dialogs.py b/src/dialogs.py index 2cf0e66f0..d1213df14 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -29,8 +29,9 @@ ## along with Gajim. If not, see . ## -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import GObject import os import gtkgui_helpers @@ -98,7 +99,7 @@ class EditGroupsDialog: contact.name, contact.groups) def on_edit_groups_dialog_response(self, widget, response_id): - if response_id == gtk.RESPONSE_CLOSE: + if response_id == Gtk.ResponseType.CLOSE: self.dialog.destroy() def remove_group(self, group): @@ -133,7 +134,7 @@ class EditGroupsDialog: return # check if it already exists model = self.treeview.get_model() - iter_ = model.get_iter_root() + iter_ = model.get_iter_first() while iter_: if model.get_value(iter_, 0).decode('utf-8') == group: return @@ -158,7 +159,7 @@ class EditGroupsDialog: self.remove_group(group) def init_list(self): - store = gtk.ListStore(str, bool, bool) + store = Gtk.ListStore(str, bool, bool) self.treeview.set_model(store) for column in self.treeview.get_columns(): # Clear treeview when re-drawing @@ -195,18 +196,18 @@ class EditGroupsDialog: store.set(iter_, 2, False) else: store.set(iter_, 2, True) - column = gtk.TreeViewColumn(_('Group')) + column = Gtk.TreeViewColumn(_('Group')) column.set_expand(True) self.treeview.append_column(column) - renderer = gtk.CellRendererText() - column.pack_start(renderer) + renderer = Gtk.CellRendererText() + column.pack_start(renderer, True, True, 0) column.set_attributes(renderer, text=0) - column = gtk.TreeViewColumn(_('In the group')) + column = Gtk.TreeViewColumn(_('In the group')) column.set_expand(False) self.treeview.append_column(column) - renderer = gtk.CellRendererToggle() - column.pack_start(renderer) + renderer = Gtk.CellRendererToggle() + column.pack_start(renderer, True, True, 0) renderer.set_property('activatable', True) renderer.connect('toggled', self.group_toggled_cb) column.set_attributes(renderer, active=1, inconsistent=2) @@ -234,7 +235,7 @@ class PassphraseDialog: cancelbutton.connect('clicked', self.on_cancelbutton_clicked) self.xml.connect_signals(self) - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.window.show_all() self.check = bool(checkbuttontext) @@ -284,27 +285,27 @@ class ChooseGPGKeyDialog: xml = gtkgui_helpers.get_gtk_builder('choose_gpg_key_dialog.ui') self.window = xml.get_object('choose_gpg_key_dialog') self.window.set_title(title_text) - self.window.set_transient_for(transient_for) + self.set_transient_for(transient_for) self.keys_treeview = xml.get_object('keys_treeview') prompt_label = xml.get_object('prompt_label') prompt_label.set_text(prompt_text) - model = gtk.ListStore(str, str) + model = Gtk.ListStore(str, str) model.set_sort_func(1, self.sort_keys) - model.set_sort_column_id(1, gtk.SORT_ASCENDING) + model.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.keys_treeview.set_model(model) #columns - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() col = self.keys_treeview.insert_column_with_attributes(-1, _('KeyID'), renderer, text=0) col.set_sort_column_id(0) - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() col = self.keys_treeview.insert_column_with_attributes(-1, _('Contact name'), renderer, text=1) col.set_sort_column_id(1) self.keys_treeview.set_search_column(1) self.fill_tree(secret_keys, selected) self.window.connect('response', self.on_dialog_response) - self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) + self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.window.show_all() def sort_keys(self, model, iter1, iter2): @@ -321,7 +322,7 @@ class ChooseGPGKeyDialog: def on_dialog_response(self, dialog, response): selection = self.keys_treeview.get_selection() (model, iter_) = selection.get_selected() - if iter_ and response == gtk.RESPONSE_OK: + if iter_ and response == Gtk.ResponseType.OK: keyID = [ model[iter_][0].decode('utf-8'), model[iter_][1].decode('utf-8') ] else: @@ -350,7 +351,7 @@ class ChangeActivityDialog: self.text = text self.xml = gtkgui_helpers.get_gtk_builder('change_activity_dialog.ui') self.window = self.xml.get_object('change_activity_dialog') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.checkbutton = self.xml.get_object('enable_checkbutton') self.notebook = self.xml.get_object('notebook') @@ -372,14 +373,14 @@ class ChangeActivityDialog: act = category + '_other' if group: - rbtns[act] = gtk.RadioButton(group) + rbtns[act] = Gtk.RadioButton(group) else: - rbtns[act] = group = gtk.RadioButton() + rbtns[act] = group = Gtk.RadioButton() - hbox = gtk.HBox(False, 5) - hbox.pack_start(gtkgui_helpers.load_activity_icon(category), False, + hbox = Gtk.HBox(False, 5) + hbox.pack_start(gtkgui_helpers.load_activity_icon(category, True, True, 0), False, False, 0) - lbl = gtk.Label('' + pep.ACTIVITIES[category]['category'] + '') + lbl = Gtk.Label(label='' + pep.ACTIVITIES[category]['category'] + '') lbl.set_use_markup(True) hbox.pack_start(lbl, False, False, 0) rbtns[act].add(hbox) @@ -399,14 +400,14 @@ class ChangeActivityDialog: act = category + '_' + activity if group: - rbtns[act] = gtk.RadioButton(group) + rbtns[act] = Gtk.RadioButton(group) else: - rbtns[act] = group = gtk.RadioButton() + rbtns[act] = group = Gtk.RadioButton() - hbox = gtk.HBox(False, 5) + hbox = Gtk.HBox(False, 5) hbox.pack_start(gtkgui_helpers.load_activity_icon(category, activity), False, False, 0) - hbox.pack_start(gtk.Label(pep.ACTIVITIES[category][activity]), + hbox.pack_start(Gtk.Label(pep.ACTIVITIES[category][activity], True, True, 0), False, False, 0) rbtns[act].connect('toggled', self.on_rbtn_toggled, [category, activity]) @@ -435,7 +436,7 @@ class ChangeActivityDialog: self.checkbutton.set_active(False) self.xml.connect_signals(self) - self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) + self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.window.show_all() def on_enable_checkbutton_toggled(self, widget): @@ -473,7 +474,7 @@ class ChangeMoodDialog: self.xml = gtkgui_helpers.get_gtk_builder('change_mood_dialog.ui') self.window = self.xml.get_object('change_mood_dialog') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.window.set_title(_('Set Mood')) table = self.xml.get_object('mood_icons_table') @@ -496,10 +497,10 @@ class ChangeMoodDialog: self.MOODS.sort() for mood in self.MOODS: - self.mood_buttons[mood] = gtk.RadioButton(no_mood_button) + self.mood_buttons[mood] = Gtk.RadioButton(no_mood_button) self.mood_buttons[mood].set_mode(False) self.mood_buttons[mood].add(gtkgui_helpers.load_mood_icon(mood)) - self.mood_buttons[mood].set_relief(gtk.RELIEF_NONE) + self.mood_buttons[mood].set_relief(Gtk.ReliefStyle.NONE) self.mood_buttons[mood].set_tooltip_text(pep.MOODS[mood]) self.mood_buttons[mood].connect('clicked', self.on_mood_button_clicked, mood) @@ -523,7 +524,7 @@ class ChangeMoodDialog: self.entry.set_sensitive(False) self.xml.connect_signals(self) - self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) + self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.window.show_all() def on_mood_button_clicked(self, widget, data): @@ -559,7 +560,7 @@ class TimeoutDialog: def run_timeout(self): if self.countdown_left > 0: self.countdown() - gobject.timeout_add_seconds(1, self.countdown) + GObject.timeout_add_seconds(1, self.countdown) def on_timeout(): """ @@ -632,11 +633,11 @@ class ChangeStatusMessageDialog(TimeoutDialog): self.preset_messages_dict[msg_name] = opts sorted_keys_list = helpers.get_sorted_keys(self.preset_messages_dict) - self.message_liststore = gtk.ListStore(str) # msg_name + self.message_liststore = Gtk.ListStore(str) # msg_name self.message_combobox = self.xml.get_object('message_combobox') self.message_combobox.set_model(self.message_liststore) - cellrenderertext = gtk.CellRendererText() - self.message_combobox.pack_start(cellrenderertext, True) + cellrenderertext = Gtk.CellRendererText() + self.message_combobox.pack_start(cellrenderertext, True, True, 0) self.message_combobox.add_attribute(cellrenderertext, 'text', 0) for msg_name in sorted_keys_list: self.message_liststore.append((msg_name,)) @@ -658,7 +659,7 @@ class ChangeStatusMessageDialog(TimeoutDialog): self.xml.connect_signals(self) self.run_timeout() self.dialog.connect('response', self.on_dialog_response) - self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) + self.dialog.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.dialog.show_all() def draw_activity(self): @@ -705,12 +706,12 @@ class ChangeStatusMessageDialog(TimeoutDialog): def on_timeout(self): # Prevent GUI freeze when the combobox menu is opened on close self.message_combobox.popdown() - self.dialog.response(gtk.RESPONSE_OK) + self.dialog.response(Gtk.ResponseType.OK) def on_dialog_response(self, dialog, response): - if response == gtk.RESPONSE_OK: + if response == Gtk.ResponseType.OK: beg, end = self.message_buffer.get_bounds() - message = self.message_buffer.get_text(beg, end).decode('utf-8')\ + message = self.message_buffer.get_text(beg, end, True).decode('utf-8')\ .strip() message = helpers.remove_invalid_xml_chars(message) msg = helpers.to_one_line(message) @@ -751,10 +752,10 @@ class ChangeStatusMessageDialog(TimeoutDialog): def on_change_status_message_dialog_key_press_event(self, widget, event): self.countdown_enabled = False - if event.keyval == gtk.keysyms.Return or \ - event.keyval == gtk.keysyms.KP_Enter: # catch CTRL+ENTER - if (event.state & gtk.gdk.CONTROL_MASK): - self.dialog.response(gtk.RESPONSE_OK) + if event.keyval == Gdk.KEY_Return or \ + event.keyval == Gdk.KEY_KP_Enter: # catch CTRL+ENTER + if (event.get_state() & Gdk.ModifierType.CONTROL_MASK): + self.dialog.response(Gtk.ResponseType.OK) # Stop the event return True @@ -773,7 +774,7 @@ class ChangeStatusMessageDialog(TimeoutDialog): self.countdown_enabled = False start_iter, finish_iter = self.message_buffer.get_bounds() status_message_to_save_as_preset = self.message_buffer.get_text( - start_iter, finish_iter) + start_iter, finish_iter, True) def on_ok(msg_name): msg_text = status_message_to_save_as_preset.decode('utf-8') msg_text_1l = helpers.to_one_line(msg_text) @@ -912,13 +913,13 @@ class AddNewContactWindow: 'prompt': None} self.available_types.append(type_) # Combobox with transport/jabber icons - liststore = gtk.ListStore(str, gtk.gdk.Pixbuf, str) - cell = gtk.CellRendererPixbuf() - self.protocol_combobox.pack_start(cell, False) + liststore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, str) + cell = Gtk.CellRendererPixbuf() + self.protocol_combobox.pack_start(cell, False, True, 0) self.protocol_combobox.add_attribute(cell, 'pixbuf', 1) - cell = gtk.CellRendererText() + cell = Gtk.CellRendererText() cell.set_property('xpad', 5) - self.protocol_combobox.pack_start(cell, True) + self.protocol_combobox.pack_start(cell, True, True, 0) self.protocol_combobox.add_attribute(cell, 'text', 0) self.protocol_combobox.set_model(liststore) uf_type = {'jabber': 'Jabber', 'aim': 'AIM', 'gadu-gadu': 'Gadu Gadu', @@ -944,7 +945,7 @@ class AddNewContactWindow: gajim.connections[account].request_gateway_prompt(service) self.protocol_combobox.set_active(0) self.auto_authorize_checkbutton.show() - liststore = gtk.ListStore(str) + liststore = Gtk.ListStore(str) self.protocol_jid_combobox.set_model(liststore) if jid: type_ = gajim.get_transport_name_from_jid(jid) @@ -995,14 +996,14 @@ class AddNewContactWindow: self.group_comboboxentry.set_active(i) i += 1 - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.window.show_all() if self.account: self.account_label.hide() self.account_hbox.hide() else: - liststore = gtk.ListStore(str, str) + liststore = Gtk.ListStore(str, str) for acct in accounts: liststore.append([acct, acct]) self.account_combobox.set_model(liststore) @@ -1035,7 +1036,7 @@ class AddNewContactWindow: gajim.connections[self.account].request_register_agent_info(jid) def on_add_new_contact_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: # ESCAPE + if event.keyval == Gdk.KEY_Escape: # ESCAPE self.window.destroy() def on_cancel_button_clicked(self, widget): @@ -1107,14 +1108,14 @@ class AddNewContactWindow: message_buffer = self.message_textview.get_buffer() start_iter = message_buffer.get_start_iter() end_iter = message_buffer.get_end_iter() - message = message_buffer.get_text(start_iter, end_iter).decode('utf-8') + message = message_buffer.get_text(start_iter, end_iter, True).decode('utf-8') if self.save_message_checkbutton.get_active(): msg = helpers.to_one_line(message) gajim.config.set_per('accounts', self.account, 'subscription_request_msg', msg) else: message= '' - group = self.group_comboboxentry.child.get_text().decode('utf-8') + group = self.group_comboboxentry.get_child().get_text().decode('utf-8') groups = [] if group: groups = [group] @@ -1261,7 +1262,7 @@ class AboutDialog: """ def __init__(self): - dlg = gtk.AboutDialog() + dlg = Gtk.AboutDialog() dlg.set_transient_for(gajim.interface.roster.window) dlg.set_name('Gajim') dlg.set_version(gajim.version) @@ -1273,8 +1274,8 @@ class AboutDialog: dlg.set_license(text) dlg.set_comments('%s\n%s %s\n%s %s' % (_('A GTK+ Jabber/XMPP client'), - _('GTK+ Version:'), self.tuple2str(gtk.gtk_version), \ - _('PyGTK Version:'), self.tuple2str(gtk.pygtk_version))) + _('GTK+ Version:'), self.tuple2str(Gtk.gtk_version), \ + _('PyGTK Version:'), self.tuple2str(Gtk.pygtk_version))) dlg.set_website('http://gajim.org/') authors_file_path = self.get_path('AUTHORS') @@ -1319,7 +1320,7 @@ class AboutDialog: dlg.set_artists(artists) # connect close button to destroy() function for button in dlg.action_area.get_children(): - if button.get_property('label') == gtk.STOCK_CLOSE: + if button.get_property('label') == Gtk.STOCK_CLOSE: button.connect('clicked', lambda x:dlg.destroy()) dlg.show_all() @@ -1340,11 +1341,11 @@ class AboutDialog: else: return None -class Dialog(gtk.Dialog): +class Dialog(Gtk.Dialog): def __init__(self, parent, title, buttons, default=None, on_response_ok=None, on_response_cancel=None): - gtk.Dialog.__init__(self, title, parent, - gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR) + GObject.GObject.__init__(self, title, parent, + Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.NO_SEPARATOR) self.user_response_ok = on_response_ok self.user_response_cancel = on_response_cancel @@ -1352,8 +1353,8 @@ class Dialog(gtk.Dialog): self.vbox.set_spacing(12) self.set_resizable(False) - possible_responses = {gtk.STOCK_OK: self.on_response_ok, - gtk.STOCK_CANCEL: self.on_response_cancel} + possible_responses = {Gtk.STOCK_OK: self.on_response_ok, + Gtk.STOCK_CANCEL: self.on_response_cancel} for stock, response in buttons: b = self.add_button(stock, response) for response in possible_responses: @@ -1390,21 +1391,21 @@ class Dialog(gtk.Dialog): return index < len(buttons) and buttons[index] or None -class HigDialog(gtk.MessageDialog): +class HigDialog(Gtk.MessageDialog): def __init__(self, parent, type_, buttons, pritext, sectext, on_response_ok=None, on_response_cancel=None, on_response_yes=None, on_response_no=None): self.call_cancel_on_destroy = True - gtk.MessageDialog.__init__(self, parent, - gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, + Gtk.MessageDialog.__init__(self, parent, + Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, type_, buttons, message_format = pritext) self.format_secondary_markup(sectext) buttons = self.action_area.get_children() - self.possible_responses = {gtk.STOCK_OK: on_response_ok, - gtk.STOCK_CANCEL: on_response_cancel, gtk.STOCK_YES: on_response_yes, - gtk.STOCK_NO: on_response_no} + self.possible_responses = {Gtk.STOCK_OK: on_response_ok, + Gtk.STOCK_CANCEL: on_response_cancel, Gtk.STOCK_YES: on_response_yes, + Gtk.STOCK_NO: on_response_no} for b in buttons: for response in self.possible_responses: if b.get_label() == response: @@ -1424,7 +1425,7 @@ class HigDialog(gtk.MessageDialog): def on_dialog_destroy(self, widget): if not self.call_cancel_on_destroy: return - cancel_handler = self.possible_responses[gtk.STOCK_CANCEL] + cancel_handler = self.possible_responses[Gtk.STOCK_CANCEL] if not cancel_handler: return False if isinstance(cancel_handler, tuple): @@ -1440,19 +1441,19 @@ class HigDialog(gtk.MessageDialog): Show dialog """ vb = self.get_children()[0].get_children()[0] # Give focus to top vbox - vb.set_flags(gtk.CAN_FOCUS) +# vb.set_flags(Gtk.CAN_FOCUS) vb.grab_focus() self.show_all() -class FileChooserDialog(gtk.FileChooserDialog): +class FileChooserDialog(Gtk.FileChooserDialog): """ - Non-blocking FileChooser Dialog around gtk.FileChooserDialog + Non-blocking FileChooser Dialog around Gtk.FileChooserDialog """ def __init__(self, title_text, action, buttons, default_response, select_multiple=False, current_folder=None, on_response_ok=None, on_response_cancel=None): - gtk.FileChooserDialog.__init__(self, title=title_text, action=action, + GObject.GObject.__init__(self, title=title_text, action=action, buttons=buttons) self.set_default_response(default_response) @@ -1469,7 +1470,7 @@ class FileChooserDialog(gtk.FileChooserDialog): self.show_all() def on_dialog_response(self, dialog, response): - if response in (gtk.RESPONSE_CANCEL, gtk.RESPONSE_CLOSE): + if response in (Gtk.ResponseType.CANCEL, Gtk.ResponseType.CLOSE): if self.response_cancel: if isinstance(self.response_cancel, tuple): self.response_cancel[0](dialog, *self.response_cancel[1:]) @@ -1477,7 +1478,7 @@ class FileChooserDialog(gtk.FileChooserDialog): self.response_cancel(dialog) else: self.just_destroy(dialog) - elif response == gtk.RESPONSE_OK: + elif response == Gtk.ResponseType.OK: if self.response_ok: if isinstance(self.response_ok, tuple): self.response_ok[0](dialog, *self.response_ok[1:]) @@ -1508,7 +1509,7 @@ class ConfirmationDialog(HigDialog): self.user_response_ok = on_response_ok self.user_response_cancel = on_response_cancel HigDialog.__init__(self, None, - gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext, + Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok, self.on_response_cancel) self.popup() @@ -1543,8 +1544,8 @@ class NonModalConfirmationDialog(HigDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_QUESTION, - gtk.BUTTONS_OK_CANCEL, pritext, sectext, self.on_response_ok, + HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, + Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok, self.on_response_cancel) self.set_modal(False) @@ -1575,8 +1576,8 @@ class WarningDialog(HigDialog): if not transient_for and hasattr(gajim.interface, 'roster') and \ gajim.interface.roster: transient_for = gajim.interface.roster.window - HigDialog.__init__(self, transient_for, gtk.MESSAGE_WARNING, - gtk.BUTTONS_OK, pritext, sectext) + HigDialog.__init__(self, transient_for, Gtk.MessageType.WARNING, + Gtk.ButtonsType.OK, pritext, sectext) self.set_modal(False) self.popup() @@ -1590,7 +1591,7 @@ class InformationDialog(HigDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, + HigDialog.__init__(self, parent, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, pritext, sectext) self.set_modal(False) self.popup() @@ -1606,7 +1607,7 @@ class ErrorDialog(HigDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, + HigDialog.__init__(self, parent, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, pritext, sectext, on_response_ok=on_response_ok, on_response_cancel=on_response_cancel) self.popup() @@ -1617,31 +1618,31 @@ class YesNoDialog(HigDialog): """ def __init__(self, pritext, sectext='', checktext='', text_label=None, - on_response_yes=None, on_response_no=None, type_=gtk.MESSAGE_QUESTION): + on_response_yes=None, on_response_no=None, type_=Gtk.MessageType.QUESTION): self.user_response_yes = on_response_yes self.user_response_no = on_response_no if hasattr(gajim.interface, 'roster') and gajim.interface.roster: parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, type_, gtk.BUTTONS_YES_NO, pritext, + HigDialog.__init__(self, parent, type_, Gtk.ButtonsType.YES_NO, pritext, sectext, on_response_yes=self.on_response_yes, on_response_no=self.on_response_no) if checktext: - self.checkbutton = gtk.CheckButton(checktext) - self.vbox.pack_start(self.checkbutton, expand=False, fill=True) + self.checkbutton = Gtk.CheckButton(checktext) + self.vbox.pack_start(self.checkbutton, False, True, 0) else: self.checkbutton = None if text_label: - label = gtk.Label(text_label) - self.vbox.pack_start(label, expand=False, fill=True) - buff = gtk.TextBuffer() - self.textview = gtk.TextView(buff) - frame = gtk.Frame() - frame.set_shadow_type(gtk.SHADOW_IN) + label = Gtk.Label(label=text_label) + self.vbox.pack_start(label, False, True, 0) + buff = Gtk.TextBuffer() + self.textview = Gtk.TextView(buff) + frame = Gtk.Frame() + frame.set_shadow_type(Gtk.ShadowType.IN) frame.add(self.textview) - self.vbox.pack_start(frame, expand=False, fill=True) + self.vbox.pack_start(frame, False, True, 0) else: self.textview = None self.set_modal(False) @@ -1652,7 +1653,7 @@ class YesNoDialog(HigDialog): if self.textview: buff = self.textview.get_buffer() start, end = buff.get_bounds() - txt = self.textview.get_buffer().get_text(start, end) + txt = self.textview.get_buffer().get_text(start, end, True) if isinstance(self.user_response_yes, tuple): if self.textview: @@ -1674,7 +1675,7 @@ class YesNoDialog(HigDialog): if self.textview: buff = self.textview.get_buffer() start, end = buff.get_bounds() - txt = self.textview.get_buffer().get_text(start, end) + txt = self.textview.get_buffer().get_text(start, end, True) if isinstance(self.user_response_no, tuple): if self.textview: @@ -1711,17 +1712,17 @@ class ConfirmationDialogCheck(ConfirmationDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_QUESTION, - gtk.BUTTONS_OK_CANCEL, pritext, sectext, self.on_response_ok, + HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, + Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok, self.on_response_cancel) - self.set_default_response(gtk.RESPONSE_OK) + self.set_default_response(Gtk.ResponseType.OK) ok_button = self.action_area.get_children()[0] # right to left ok_button.grab_focus() - self.checkbutton = gtk.CheckButton(checktext) - self.vbox.pack_start(self.checkbutton, expand=False, fill=True) + self.checkbutton = Gtk.CheckButton(checktext) + self.vbox.pack_start(self.checkbutton, False, True, 0) self.set_modal(is_modal) self.popup() @@ -1766,27 +1767,27 @@ class ConfirmationDialogDoubleCheck(ConfirmationDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_QUESTION, - gtk.BUTTONS_OK_CANCEL, pritext, sectext, self.on_response_ok, + HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, + Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok, self.on_response_cancel) - self.set_default_response(gtk.RESPONSE_OK) + self.set_default_response(Gtk.ResponseType.OK) ok_button = self.action_area.get_children()[0] # right to left ok_button.grab_focus() if checktext1: - self.checkbutton1 = gtk.CheckButton(checktext1) + self.checkbutton1 = Gtk.CheckButton(checktext1) if tooltip1: self.checkbutton1.set_tooltip_text(tooltip1) - self.vbox.pack_start(self.checkbutton1, expand=False, fill=True) + self.vbox.pack_start(self.checkbutton1, False, True, 0) else: self.checkbutton1 = None if checktext2: - self.checkbutton2 = gtk.CheckButton(checktext2) + self.checkbutton2 = Gtk.CheckButton(checktext2) if tooltip2: self.checkbutton2.set_tooltip_text(tooltip2) - self.vbox.pack_start(self.checkbutton2, expand=False, fill=True) + self.vbox.pack_start(self.checkbutton2, False, True, 0) else: self.checkbutton2 = None @@ -1838,21 +1839,21 @@ class ConfirmationDialogDoubleRadio(ConfirmationDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_QUESTION, - gtk.BUTTONS_OK_CANCEL, pritext, sectext, self.on_response_ok, + HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, + Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok, self.on_response_cancel) - self.set_default_response(gtk.RESPONSE_OK) + self.set_default_response(Gtk.ResponseType.OK) ok_button = self.action_area.get_children()[0] # right to left ok_button.grab_focus() - self.radiobutton1 = gtk.RadioButton(label=radiotext1) - self.vbox.pack_start(self.radiobutton1, expand=False, fill=True) + self.radiobutton1 = Gtk.RadioButton(label=radiotext1) + self.vbox.pack_start(self.radiobutton1, False, True, 0) - self.radiobutton2 = gtk.RadioButton(group=self.radiobutton1, + self.radiobutton2 = Gtk.RadioButton(group=self.radiobutton1, label=radiotext2) - self.vbox.pack_start(self.radiobutton2, expand=False, fill=True) + self.vbox.pack_start(self.radiobutton2, False, True, 0) self.set_modal(is_modal) self.popup() @@ -1899,13 +1900,13 @@ class FTOverwriteConfirmationDialog(ConfirmationDialog): parent = gajim.interface.roster.window else: parent = None - HigDialog.__init__(self, parent, gtk.MESSAGE_QUESTION, - gtk.BUTTONS_CANCEL, pritext, sectext) + HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION, + Gtk.ButtonsType.CANCEL, pritext, sectext) self.on_response = on_response if propose_resume: - b = gtk.Button('', gtk.STOCK_REFRESH) + b = Gtk.Button('', Gtk.STOCK_REFRESH) align = b.get_children()[0] hbox = align.get_children()[0] label = hbox.get_children()[1] @@ -1913,7 +1914,7 @@ class FTOverwriteConfirmationDialog(ConfirmationDialog): label.set_use_underline(True) self.add_action_widget(b, 100) - b = gtk.Button('', gtk.STOCK_SAVE_AS) + b = Gtk.Button('', Gtk.STOCK_SAVE_AS) align = b.get_children()[0] hbox = align.get_children()[0] label = hbox.get_children()[1] @@ -2019,8 +2020,8 @@ class InputDialogCheck(InputDialog): self.input_entry.select_region(0, -1) # select all if checktext: - self.checkbutton = gtk.CheckButton(checktext) - self.vbox.pack_start(self.checkbutton, expand=False, fill=True) + self.checkbutton = Gtk.CheckButton(checktext) + self.vbox.pack_start(self.checkbutton, False, True, 0) self.checkbutton.show() def on_okbutton_clicked(self, widget): @@ -2156,7 +2157,7 @@ class InputTextDialog(CommonInputDialog): def get_text(self): start_iter, end_iter = self.input_buffer.get_bounds() - return self.input_buffer.get_text(start_iter, end_iter).decode('utf-8') + return self.input_buffer.get_text(start_iter, end_iter, True).decode('utf-8') class DoubleInputDialog: """ @@ -2332,10 +2333,10 @@ class JoinGroupchatWindow: account_combobox = self.xml.get_object('account_combobox') account_label.set_no_show_all(False) account_combobox.set_no_show_all(False) - liststore = gtk.ListStore(str) + liststore = Gtk.ListStore(str) account_combobox.set_model(liststore) - cell = gtk.CellRendererText() - account_combobox.pack_start(cell, True) + cell = Gtk.CellRendererText() + account_combobox.pack_start(cell, True, True, 0) account_combobox.add_attribute(cell, 'text', 0) account_combobox.set_active(-1) @@ -2353,7 +2354,7 @@ class JoinGroupchatWindow: self._empty_required_widgets = [] self.window = self.xml.get_object('join_groupchat_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self._room_jid_entry = self.xml.get_object('room_jid_entry') self._nickname_entry = self.xml.get_object('nickname_entry') self._password_entry = self.xml.get_object('password_entry') @@ -2380,10 +2381,10 @@ class JoinGroupchatWindow: server_list.append(gajim.connections[account].muc_jid['jabber']) self.recently_combobox = self.xml.get_object('recently_combobox') - liststore = gtk.ListStore(str) + liststore = Gtk.ListStore(str) self.recently_combobox.set_model(liststore) - cell = gtk.CellRendererText() - self.recently_combobox.pack_start(cell, True) + cell = Gtk.CellRendererText() + self.recently_combobox.pack_start(cell, True, True, 0) self.recently_combobox.add_attribute(cell, 'text', 0) self.recently_groupchat = gajim.config.get('recently_groupchat').split() for g in self.recently_groupchat: @@ -2427,7 +2428,7 @@ class JoinGroupchatWindow: del gajim.interface.instances[self.account]['join_gc'] def on_join_groupchat_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: # ESCAPE + if event.keyval == Gdk.KEY_Escape: # ESCAPE widget.destroy() def on_required_entry_changed(self, widget): @@ -2445,7 +2446,7 @@ class JoinGroupchatWindow: room_jid, server = text.split('@', 1) self._room_jid_entry.set_text(room_jid) if server: - self.server_comboboxentry.child.set_text(server) + self.server_comboboxentry.get_child().set_text(server) self.server_comboboxentry.grab_focus() def on_account_combobox_changed(self, widget): @@ -2457,7 +2458,7 @@ class JoinGroupchatWindow: def _set_room_jid(self, room_jid): room, server = gajim.get_name_and_server_from_jid(room_jid) self._room_jid_entry.set_text(room) - self.server_comboboxentry.child.set_text(server) + self.server_comboboxentry.get_child().set_text(server) def on_recently_combobox_changed(self, widget): model = widget.get_model() @@ -2466,7 +2467,7 @@ class JoinGroupchatWindow: self._set_room_jid(room_jid) def on_browse_rooms_button_clicked(self, widget): - server = self.server_comboboxentry.child.get_text().decode('utf-8') + server = self.server_comboboxentry.get_child().get_text().decode('utf-8') if server in gajim.interface.instances[self.account]['disco']: gajim.interface.instances[self.account]['disco'][server].window.\ present() @@ -2503,7 +2504,7 @@ class JoinGroupchatWindow: 'groupchat.')) return nickname = self._nickname_entry.get_text().decode('utf-8') - server = self.server_comboboxentry.child.get_text().decode('utf-8').\ + server = self.server_comboboxentry.get_child().get_text().decode('utf-8').\ strip() room = self._room_jid_entry.get_text().decode('utf-8').strip() room_jid = room + '@' + server @@ -2567,13 +2568,13 @@ class SynchroniseSelectAccountDialog: self.xml = gtkgui_helpers.get_gtk_builder('synchronise_select_account_dialog.ui') self.dialog = self.xml.get_object('synchronise_select_account_dialog') self.accounts_treeview = self.xml.get_object('accounts_treeview') - model = gtk.ListStore(str, str, bool) + model = Gtk.ListStore(str, str, bool) self.accounts_treeview.set_model(model) # columns - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() self.accounts_treeview.insert_column_with_attributes(-1, _('Name'), renderer, text=0) - renderer = gtk.CellRendererText() + renderer = Gtk.CellRendererText() self.accounts_treeview.insert_column_with_attributes(-1, _('Server'), renderer, text=1) @@ -2582,7 +2583,7 @@ class SynchroniseSelectAccountDialog: self.dialog.show_all() def on_accounts_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.destroy() def init_accounts(self): @@ -2629,15 +2630,15 @@ class SynchroniseSelectContactsDialog: 'synchronise_select_contacts_dialog.ui') self.dialog = self.xml.get_object('synchronise_select_contacts_dialog') self.contacts_treeview = self.xml.get_object('contacts_treeview') - model = gtk.ListStore(bool, str) + model = Gtk.ListStore(bool, str) self.contacts_treeview.set_model(model) # columns - renderer1 = gtk.CellRendererToggle() + renderer1 = Gtk.CellRendererToggle() renderer1.set_property('activatable', True) renderer1.connect('toggled', self.toggled_callback) self.contacts_treeview.insert_column_with_attributes(-1, _('Synchronise'), renderer1, active=0) - renderer2 = gtk.CellRendererText() + renderer2 = Gtk.CellRendererText() self.contacts_treeview.insert_column_with_attributes(-1, _('Name'), renderer2, text=1) @@ -2651,7 +2652,7 @@ class SynchroniseSelectContactsDialog: model[iter_][0] = not cell.get_active() def on_contacts_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.destroy() def init_contacts(self): @@ -2676,7 +2677,7 @@ class SynchroniseSelectContactsDialog: def on_ok_button_clicked(self, widget): model = self.contacts_treeview.get_model() - iter_ = model.get_iter_root() + iter_ = model.get_iter_first() while iter_: if model[iter_][0]: # it is selected @@ -2762,7 +2763,7 @@ class ChangePasswordDialog: self.dialog.show_all() def on_dialog_response(self, dialog, response): - if response != gtk.RESPONSE_OK: + if response != Gtk.ResponseType.OK: dialog.destroy() self.on_response(None) return @@ -2788,7 +2789,7 @@ class PopupNotificationWindow: xml = gtkgui_helpers.get_gtk_builder('popup_notification_window.ui') self.window = xml.get_object('popup_notification_window') - self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP) + self.set_type_hint(Gdk.WindowTypeHint.TOOLTIP) close_button = xml.get_object('close_button') event_type_label = xml.get_object('event_type_label') event_description_label = xml.get_object('event_description_label') @@ -2802,10 +2803,10 @@ class PopupNotificationWindow: event_type_label.set_markup( '%s' % - gobject.markup_escape_text(title)) + GObject.markup_escape_text(title)) # set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ] - self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black')) + self.window.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('black')) # default image if not path_to_image: @@ -2831,11 +2832,11 @@ class PopupNotificationWindow: bg_color = gajim.config.get('notif_status_color') else: # Unknown event! Shouldn't happen but deal with it bg_color = gajim.config.get('notif_other_color') - popup_bg_color = gtk.gdk.color_parse(bg_color) - close_button.modify_bg(gtk.STATE_NORMAL, popup_bg_color) - eventbox.modify_bg(gtk.STATE_NORMAL, popup_bg_color) + popup_bg_color = Gdk.color_parse(bg_color) + close_button.modify_bg(Gtk.StateType.NORMAL, popup_bg_color) + eventbox.modify_bg(Gtk.StateType.NORMAL, popup_bg_color) event_description_label.set_markup('%s' % - gobject.markup_escape_text(text)) + GObject.markup_escape_text(text)) # set the image image.set_from_file(path_to_image) @@ -2845,17 +2846,17 @@ class PopupNotificationWindow: gajim.interface.roster.popups_notification_height += self.window_height pos_x = gajim.config.get('notification_position_x') if pos_x < 0: - pos_x = gtk.gdk.screen_width() - window_width + pos_x + 1 + pos_x = Gdk.Screen.width() - window_width + pos_x + 1 pos_y = gajim.config.get('notification_position_y') if pos_y < 0: - pos_y = gtk.gdk.screen_height() - \ + pos_y = Gdk.Screen.height() - \ gajim.interface.roster.popups_notification_height + pos_y + 1 self.window.move(pos_x, pos_y) xml.connect_signals(self) self.window.show_all() if timeout > 0: - gobject.timeout_add_seconds(timeout, self.on_timeout) + GObject.timeout_add_seconds(timeout, self.on_timeout) def on_close_button_clicked(self, widget): self.adjust_height_and_move_popup_notification_windows() @@ -2880,8 +2881,8 @@ class PopupNotificationWindow: current_index += 1 window_width, window_height = window_instance.window.get_size() gajim.interface.roster.popups_notification_height += window_height - window_instance.window.move(gtk.gdk.screen_width() - window_width, - gtk.gdk.screen_height() - \ + window_instance.window.move(Gdk.Screen.width() - window_width, + Gdk.Screen.height() - \ gajim.interface.roster.popups_notification_height) def on_popup_notification_window_button_press_event(self, widget, event): @@ -2965,7 +2966,7 @@ class SingleMessageWindow: lang = gajim.LANG gtkspell.Spell(self.conversation_textview.tv, lang) gtkspell.Spell(self.message_textview, lang) - except (gobject.GError, TypeError, RuntimeError, OSError): + except (GObject.GError, TypeError, RuntimeError, OSError): AspellDictError(lang) self.prepare_widgets_for(self.action) @@ -3053,7 +3054,7 @@ class SingleMessageWindow: self.cancel_button.hide() self.close_button.show() self.message_tv_buffer.set_text(self.message) - gobject.idle_add(self.set_cursor_to_end) + GObject.idle_add(self.set_cursor_to_end) else: # we write a new message (not from reply) self.close_button.hide() if self.to: # do we already have jid? @@ -3137,7 +3138,7 @@ class SingleMessageWindow: subject = self.subject_entry.get_text().decode('utf-8') begin, end = self.message_tv_buffer.get_bounds() - message = self.message_tv_buffer.get_text(begin, end).decode('utf-8') + message = self.message_tv_buffer.get_text(begin, end, True).decode('utf-8') if '/announce/' in to_whom_jid: gajim.connections[self.account].send_motd(to_whom_jid, subject, @@ -3183,7 +3184,7 @@ class SingleMessageWindow: self.window.destroy() def on_single_message_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: # ESCAPE + if event.keyval == Gdk.KEY_Escape: # ESCAPE self.save_pos() self.window.destroy() @@ -3225,7 +3226,7 @@ class XMLConsoleWindow: self.xml.get_object('enable_checkbutton').set_active(True) self.input_textview.modify_text( - gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) + Gtk.StateType.NORMAL, Gdk.color_parse(color)) if len(gajim.connections) > 1: title = _('XML Console for %s') % self.account @@ -3332,7 +3333,7 @@ class XMLConsoleWindow: buffer.insert_with_tags_by_name(end_iter, stanza.replace('><', '>\n<') \ + '\n\n', type_) if at_the_end: - gobject.idle_add(self.scroll_to_end) + GObject.idle_add(self.scroll_to_end) def _nec_stanza_received(self, obj): if obj.conn.name != self.account: @@ -3352,7 +3353,7 @@ class XMLConsoleWindow: self.account) return begin_iter, end_iter = self.input_tv_buffer.get_bounds() - stanza = self.input_tv_buffer.get_text(begin_iter, end_iter).decode( + stanza = self.input_tv_buffer.get_text(begin_iter, end_iter, True).decode( 'utf-8') if stanza: gajim.connections[self.account].send_stanza(stanza) @@ -3416,10 +3417,10 @@ class RosterItemExchangeWindow: else: self.body_scrolledwindow.hide() # Treeview - model = gtk.ListStore(bool, str, str, str, str) + model = Gtk.ListStore(bool, str, str, str, str) self.items_list_treeview.set_model(model) # columns - renderer1 = gtk.CellRendererToggle() + renderer1 = Gtk.CellRendererToggle() renderer1.set_property('activatable', True) renderer1.connect('toggled', self.toggled_callback) if self.action == 'add': @@ -3430,13 +3431,13 @@ class RosterItemExchangeWindow: title = _('Delete') self.items_list_treeview.insert_column_with_attributes(-1, title, renderer1, active=0) - renderer2 = gtk.CellRendererText() + renderer2 = Gtk.CellRendererText() self.items_list_treeview.insert_column_with_attributes(-1, _('Jabber ID'), renderer2, text=1) - renderer3 = gtk.CellRendererText() + renderer3 = Gtk.CellRendererText() self.items_list_treeview.insert_column_with_attributes(-1, _('Name'), renderer3, text=2) - renderer4 = gtk.CellRendererText() + renderer4 = Gtk.CellRendererText() self.items_list_treeview.insert_column_with_attributes(-1, _('Groups'), renderer4, text=3) @@ -3537,7 +3538,7 @@ class RosterItemExchangeWindow: def on_accept_button_clicked(self, widget): model = self.items_list_treeview.get_model() - iter_ = model.get_iter_root() + iter_ = model.get_iter_first() if self.action == 'add': a = 0 while iter_: @@ -3715,7 +3716,7 @@ class ItemArchivingPreferencesWindow: def launch_progressbar(self): self.progressbar.show() - self.update_progressbar_timeout_id = gobject.timeout_add( + self.update_progressbar_timeout_id = GObject.timeout_add( 100, self.update_progressbar) def response_arrived(self, data): @@ -3763,26 +3764,26 @@ class ArchivingPreferencesWindow: self.method_foo_index[gajim.connections[self.account].\ method_manual]) - model = gtk.ListStore(str, str, str, str) + model = Gtk.ListStore(str, str, str, str) self.item_treeview.set_model(model) - col = gtk.TreeViewColumn('jid') + col = Gtk.TreeViewColumn('jid') self.item_treeview.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer, True) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text=0) - col = gtk.TreeViewColumn('expire') - col.pack_start(renderer, True) + col = Gtk.TreeViewColumn('expire') + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text=1) self.item_treeview.append_column(col) - col = gtk.TreeViewColumn('otr') - col.pack_start(renderer, True) + col = Gtk.TreeViewColumn('otr') + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text=2) self.item_treeview.append_column(col) - col = gtk.TreeViewColumn('save') - col.pack_start(renderer, True) + col = Gtk.TreeViewColumn('save') + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text=3) self.item_treeview.append_column(col) @@ -3809,7 +3810,7 @@ class ArchivingPreferencesWindow: # item1 == item2 ? WTF? return 0 - model.set_sort_column_id(0, gtk.SORT_ASCENDING) + model.set_sort_column_id(0, Gtk.SortType.ASCENDING) model.set_sort_func(0, sort_items) self.remove_button.set_sensitive(False) @@ -4015,7 +4016,7 @@ class PrivacyListWindow: self.privacy_lists_title_label.set_label( _('Privacy List %s') % \ - gobject.markup_escape_text(self.privacy_list_name)) + GObject.markup_escape_text(self.privacy_list_name)) if len(gajim.connections) > 1: title = _('Privacy List for %s') % self.account @@ -4029,10 +4030,10 @@ class PrivacyListWindow: self.list_of_rules_combobox.set_sensitive(False) # set jabber id completion - jids_list_store = gtk.ListStore(gobject.TYPE_STRING) + jids_list_store = Gtk.ListStore(GObject.TYPE_STRING) for jid in gajim.contacts.get_jid_list(self.account): jids_list_store.append([jid]) - jid_entry_completion = gtk.EntryCompletion() + jid_entry_completion = Gtk.EntryCompletion() jid_entry_completion.set_text_column(0) jid_entry_completion.set_model(jids_list_store) jid_entry_completion.set_popup_completion(True) @@ -4490,7 +4491,7 @@ class InvitationReceivedDialog: sectext = sectext.replace('$Contact', contact_text) if comment: # only if not None and not '' - comment = gobject.markup_escape_text(comment) + comment = GObject.markup_escape_text(comment) comment = _('Comment: %s') % comment sectext += '\n\n%s' % comment sectext += '\n\n' + _('Do you want to accept the invitation?') @@ -4525,11 +4526,11 @@ class ProgressDialog: self.progressbar = self.xml.get_object('progressbar') self.dialog.set_title(title_text) self.dialog.set_default_size(450, 250) - self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT) + self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.dialog.show_all() self.xml.connect_signals(self) - self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar_timeout_id = GObject.timeout_add(100, self.update_progressbar) def update_progressbar(self): @@ -4561,20 +4562,20 @@ class ClientCertChooserDialog(FileChooserDialog): FileChooserDialog.__init__(self, title_text=_('Choose Client Cert #PCKS12'), - action=gtk.FILE_CHOOSER_ACTION_OPEN, - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, gtk.RESPONSE_OK), + action=Gtk.FileChooserAction.OPEN, + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_OPEN, Gtk.ResponseType.OK), current_folder='', - default_response=gtk.RESPONSE_OK, + default_response=Gtk.ResponseType.OK, on_response_ok=(on_ok, on_response_ok), on_response_cancel=on_response_cancel) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('All files')) filter_.add_pattern('*') self.add_filter(filter_) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('PKCS12 Files')) filter_.add_pattern('*.p12') self.add_filter(filter_) @@ -4603,20 +4604,20 @@ class SoundChooserDialog(FileChooserDialog): callback(widget, path_to_snd_file) FileChooserDialog.__init__(self, title_text = _('Choose Sound'), - action = gtk.FILE_CHOOSER_ACTION_OPEN, - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, gtk.RESPONSE_OK), - default_response = gtk.RESPONSE_OK, + action = Gtk.FileChooserAction.OPEN, + buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_OPEN, Gtk.ResponseType.OK), + default_response = Gtk.ResponseType.OK, current_folder = gajim.config.get('last_sounds_dir'), on_response_ok = (on_ok, on_response_ok), on_response_cancel = on_response_cancel) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('All files')) filter_.add_pattern('*') self.add_filter(filter_) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('Wav Sounds')) filter_.add_pattern('*.wav') self.add_filter(filter_) @@ -4656,10 +4657,10 @@ class ImageChooserDialog(FileChooserDialog): path = '' FileChooserDialog.__init__(self, title_text = _('Choose Image'), - action = gtk.FILE_CHOOSER_ACTION_OPEN, - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, gtk.RESPONSE_OK), - default_response = gtk.RESPONSE_OK, + action = Gtk.FileChooserAction.OPEN, + buttons = (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_OPEN, Gtk.ResponseType.OK), + default_response = Gtk.ResponseType.OK, current_folder = path, on_response_ok = (on_ok, on_response_ok), on_response_cancel = on_response_cancel) @@ -4667,12 +4668,12 @@ class ImageChooserDialog(FileChooserDialog): if on_response_cancel: self.connect('destroy', on_response_cancel) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('All files')) filter_.add_pattern('*') self.add_filter(filter_) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('Images')) filter_.add_mime_type('image/png') filter_.add_mime_type('image/jpeg') @@ -4687,7 +4688,7 @@ class ImageChooserDialog(FileChooserDialog): self.set_filename(path_to_file) self.set_use_preview_label(False) - self.set_preview_widget(gtk.Image()) + self.set_preview_widget(Gtk.Image()) self.connect('selection-changed', self.update_preview) def update_preview(self, widget): @@ -4698,8 +4699,8 @@ class ImageChooserDialog(FileChooserDialog): widget.get_preview_widget().set_from_file(None) return try: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path_to_file, 100, 100) - except gobject.GError: + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(path_to_file, 100, 100) + except GObject.GError: return widget.get_preview_widget().set_from_pixbuf(pixbuf) @@ -4708,12 +4709,12 @@ class AvatarChooserDialog(ImageChooserDialog): on_response_cancel=None, on_response_clear=None): ImageChooserDialog.__init__(self, path_to_file, on_response_ok, on_response_cancel) - button = gtk.Button(None, gtk.STOCK_CLEAR) + button = Gtk.Button(None, Gtk.STOCK_CLEAR) self.response_clear = on_response_clear if on_response_clear: button.connect('clicked', self.on_clear) button.show_all() - self.action_area.pack_start(button) + self.action_area.pack_start(button, True, True, 0) self.action_area.reorder_child(button, 0) def on_clear(self, widget): @@ -4744,10 +4745,10 @@ class ArchiveChooserDialog(FileChooserDialog): FileChooserDialog.__init__(self, title_text=_('Choose Archive'), - action=gtk.FILE_CHOOSER_ACTION_OPEN, - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, gtk.RESPONSE_OK), - default_response=gtk.RESPONSE_OK, + action=Gtk.FileChooserAction.OPEN, + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_OPEN, Gtk.ResponseType.OK), + default_response=Gtk.ResponseType.OK, current_folder=path, on_response_ok=(on_ok, on_response_ok), on_response_cancel=on_response_cancel) @@ -4755,12 +4756,12 @@ class ArchiveChooserDialog(FileChooserDialog): if on_response_cancel: self.connect('destroy', on_response_cancel) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('All files')) filter_.add_pattern('*') self.add_filter(filter_) - filter_ = gtk.FileFilter() + filter_ = Gtk.FileFilter() filter_.set_name(_('Zip files')) filter_.add_pattern('*.zip') @@ -4843,7 +4844,7 @@ class TransformChatToMUC: self.__dict__[widget_to_add] = self.xml.get_object(widget_to_add) server_list = [] - self.servers = gtk.ListStore(str) + self.servers = Gtk.ListStore(str) self.server_list_comboboxentry.set_model(self.servers) self.server_list_comboboxentry.set_text_column(0) @@ -4868,18 +4869,18 @@ class TransformChatToMUC: # set treeview # name, jid - self.store = gtk.ListStore(gtk.gdk.Pixbuf, str, str) - self.store.set_sort_column_id(1, gtk.SORT_ASCENDING) + self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str) + self.store.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.guests_treeview.set_model(self.store) - renderer1 = gtk.CellRendererText() - renderer2 = gtk.CellRendererPixbuf() - column = gtk.TreeViewColumn('Status', renderer2, pixbuf=0) + renderer1 = Gtk.CellRendererText() + renderer2 = Gtk.CellRendererPixbuf() + column = Gtk.TreeViewColumn('Status', renderer2, pixbuf=0) self.guests_treeview.append_column(column) - column = gtk.TreeViewColumn('Name', renderer1, text=1) + column = Gtk.TreeViewColumn('Name', renderer1, text=1) self.guests_treeview.append_column(column) - self.guests_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + self.guests_treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) # All contacts beside the following can be invited: # transports, zeroconf contacts, minimized groupchats @@ -4929,7 +4930,7 @@ class TransformChatToMUC: self.instances.remove(self) def on_chat_to_muc_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: # ESCAPE + if event.keyval == Gdk.KEY_Escape: # ESCAPE self.window.destroy() def on_invite_button_clicked(self, widget): @@ -4969,8 +4970,8 @@ class TransformChatToMUC: class DataFormWindow(Dialog): def __init__(self, form, on_response_ok): self.df_response_ok = on_response_ok - Dialog.__init__(self, None, 'test', [(gtk.STOCK_CANCEL, - gtk.RESPONSE_REJECT), (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)], + Dialog.__init__(self, None, 'test', [(Gtk.STOCK_CANCEL, + Gtk.ResponseType.REJECT), (Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)], on_response_ok=self.on_ok) self.set_resizable(True) gtkgui_helpers.resize_window(self, 600, 400) @@ -4979,7 +4980,7 @@ class DataFormWindow(Dialog): self.dataform_widget.set_sensitive(True) self.dataform_widget.data_form = self.dataform self.dataform_widget.show_all() - self.vbox.pack_start(self.dataform_widget) + self.vbox.pack_start(self.dataform_widget, True, True, 0) def on_ok(self): form = self.dataform_widget.data_form @@ -5201,7 +5202,7 @@ class VoIPCallReceivedDialog(object): def on_voip_call_received_messagedialog_close(self, dialog): return self.on_voip_call_received_messagedialog_response(dialog, - gtk.RESPONSE_NO) + Gtk.ResponseType.NO) def on_voip_call_received_messagedialog_response(self, dialog, response): # we've got response from user, either stop connecting or accept the call @@ -5210,7 +5211,7 @@ class VoIPCallReceivedDialog(object): if not session: dialog.destroy() return - if response == gtk.RESPONSE_YES: + if response == Gtk.ResponseType.YES: #TODO: Ensure that ctrl.contact.resource == resource jid = gajim.get_jid_without_resource(self.fjid) resource = gajim.get_resource_from_jid(self.fjid) @@ -5231,7 +5232,7 @@ class VoIPCallReceivedDialog(object): session.approve_session() for content in self.content_types: session.approve_content(content) - else: # response==gtk.RESPONSE_NO + else: # response==Gtk.ResponseType.NO if not session.accepted: session.decline_session() else: @@ -5280,11 +5281,11 @@ class CheckFingerprintDialog(YesNoDialog): YesNoDialog.__init__(self, pritext, sectext=sectext, checktext=checktext, on_response_yes=on_response_yes, on_response_no=on_response_no) - b = gtk.Button(_('View cert...')) + b = Gtk.Button(_('View cert...')) b.connect('clicked', self.on_cert_clicked) b.show_all() area = self.get_action_area() - area.pack_start(b) + area.pack_start(b, True, True, 0) def on_cert_clicked(self, button): d = CertificatDialog(self, self.account, self.cert) @@ -5297,11 +5298,11 @@ class SSLErrorDialog(ConfirmationDialogDoubleCheck): ConfirmationDialogDoubleCheck.__init__(self, pritext, sectext, checktext1, checktext2, on_response_ok=on_response_ok, on_response_cancel=on_response_cancel, is_modal=False) - b = gtk.Button(_('View cert...')) + b = Gtk.Button(_('View cert...')) b.connect('clicked', self.on_cert_clicked) b.show_all() area = self.get_action_area() - area.pack_start(b) + area.pack_start(b, True, True, 0) def on_cert_clicked(self, button): d = CertificatDialog(self, self.account, self.cert) diff --git a/src/disco.py b/src/disco.py index a18a7d9ac..2f954707a 100644 --- a/src/disco.py +++ b/src/disco.py @@ -47,9 +47,10 @@ import os import types import weakref -import gobject -import gtk -import pango +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import Pango import dialogs import tooltips @@ -151,7 +152,7 @@ class CacheDictionary: for key in self.cache.keys(): item = self.cache[key] if item.source: - gobject.source_remove(item.source) + GObject.source_remove(item.source) del self.cache[key] def _expire_timeout(self, key): @@ -168,9 +169,9 @@ class CacheDictionary: """ item = self.cache[key] if item.source: - gobject.source_remove(item.source) + GObject.source_remove(item.source) if self.lifetime: - source = gobject.timeout_add_seconds(self.lifetime/1000, self._expire_timeout, key) + source = GObject.timeout_add_seconds(self.lifetime/1000, self._expire_timeout, key) item.source = source def __getitem__(self, key): @@ -187,7 +188,7 @@ class CacheDictionary: def __delitem__(self, key): item = self.cache[key] if item.source: - gobject.source_remove(item.source) + GObject.source_remove(item.source) del self.cache[key] def __contains__(self, key): @@ -549,7 +550,7 @@ _('Without a connection, you can not browse available services')) if address_entry: self.address_comboboxentry = self.xml.get_object( 'address_comboboxentry') - self.address_comboboxentry_entry = self.address_comboboxentry.child + self.address_comboboxentry_entry = self.address_comboboxentry.get_child() self.address_comboboxentry_entry.set_activates_default(True) self.latest_addresses = gajim.config.get( @@ -561,15 +562,15 @@ _('Without a connection, you can not browse available services')) self.latest_addresses = self.latest_addresses[0:10] for j in self.latest_addresses: self.address_comboboxentry.append_text(j) - self.address_comboboxentry.child.set_text(jid) + self.address_comboboxentry.get_child().set_text(jid) else: # Don't show it at all if we didn't ask for it address_table.set_no_show_all(True) address_table.hide() - accel_group = gtk.AccelGroup() - keyval, mod = gtk.accelerator_parse('r') - accel_group.connect_group(keyval, mod, gtk.ACCEL_VISIBLE, + accel_group = Gtk.AccelGroup() + keyval, mod = Gtk.accelerator_parse('r') + accel_group.connect(keyval, mod, Gtk.AccelFlags.VISIBLE, self.accel_group_func) self.window.add_accel_group(accel_group) @@ -590,7 +591,7 @@ _('Without a connection, you can not browse available services')) self.browser.account = value def accel_group_func(self, accel_group, acceleratable, keyval, modifier): - if (modifier & gtk.gdk.CONTROL_MASK) and (keyval == gtk.keysyms.r): + if (modifier & Gdk.ModifierType.CONTROL_MASK) and (keyval == Gdk.KEY_r): self.reload() def _initial_state(self): @@ -612,15 +613,15 @@ _('Without a connection, you can not browse available services')) 'bannerfontattrs') if bannerfont: - font = pango.FontDescription(bannerfont) + font = Pango.FontDescription(bannerfont) else: - font = pango.FontDescription('Normal') + font = Pango.FontDescription('Normal') if bannerfontattrs: # B is attribute set by default if 'B' in bannerfontattrs: - font.set_weight(pango.WEIGHT_HEAVY) + font.set_weight(Pango.Weight.HEAVY) if 'I' in bannerfontattrs: - font.set_style(pango.STYLE_ITALIC) + font.set_style(Pango.Style.ITALIC) font_attrs = 'font_desc="%s"' % font.to_string() font_size = font.get_size() @@ -630,7 +631,7 @@ _('Without a connection, you can not browse available services')) font_attrs = '%s size="large"' % font_attrs markup = '%s' % (font_attrs, text) if text_after: - font.set_weight(pango.WEIGHT_NORMAL) + font.set_weight(Pango.Weight.NORMAL) markup = '%s\n%s' % \ (markup, font.to_string(), text_after) self.banner.set_markup(markup) @@ -644,15 +645,15 @@ _('Without a connection, you can not browse available services')) textcolor = gajim.config.get_per('themes', theme, 'bannertextcolor') self.disconnect_style_event() if bgcolor: - color = gtk.gdk.color_parse(bgcolor) - self.banner_eventbox.modify_bg(gtk.STATE_NORMAL, color) + color = Gdk.color_parse(bgcolor) + self.banner_eventbox.modify_bg(Gtk.StateType.NORMAL, color) default_bg = False else: default_bg = True if textcolor: - color = gtk.gdk.color_parse(textcolor) - self.banner.modify_fg(gtk.STATE_NORMAL, color) + color = Gdk.color_parse(textcolor) + self.banner.modify_fg(Gtk.StateType.NORMAL, color) default_fg = False else: default_fg = True @@ -679,11 +680,11 @@ _('Without a connection, you can not browse available services')) """ self.disconnect_style_event() if opts[1]: - bg_color = widget.style.bg[gtk.STATE_SELECTED] - self.banner_eventbox.modify_bg(gtk.STATE_NORMAL, bg_color) + bg_color = widget.get_style().bg[Gtk.StateType.SELECTED] + self.banner_eventbox.modify_bg(Gtk.StateType.NORMAL, bg_color) if opts[0]: - fg_color = widget.style.fg[gtk.STATE_SELECTED] - self.banner.modify_fg(gtk.STATE_NORMAL, fg_color) + fg_color = widget.get_style().fg[Gtk.StateType.SELECTED] + self.banner.modify_fg(Gtk.StateType.NORMAL, fg_color) self.banner.ensure_style() self.connect_style_event(opts[0], opts[1]) @@ -799,7 +800,7 @@ _('This type of service does not contain any items to browse.')) def on_address_comboboxentry_changed(self, widget): if self.address_comboboxentry.get_active() != -1: # user selected one of the entries so do auto-visit - jid = self.address_comboboxentry.child.get_text().decode('utf-8') + jid = self.address_comboboxentry.get_child().get_text().decode('utf-8') try: jid = helpers.parse_jid(jid) except helpers.InvalidFormat, s: @@ -809,7 +810,7 @@ _('This type of service does not contain any items to browse.')) self.travel(jid, '') def on_go_button_clicked(self, widget): - jid = self.address_comboboxentry.child.get_text().decode('utf-8') + jid = self.address_comboboxentry.get_child().get_text().decode('utf-8') try: jid = helpers.parse_jid(jid) except helpers.InvalidFormat, s: @@ -878,20 +879,20 @@ class AgentBrowser: the JID and node of the item respectively """ # JID, node, name, address - self.model = gtk.ListStore(str, str, str, str) - self.model.set_sort_column_id(3, gtk.SORT_ASCENDING) + self.model = Gtk.ListStore(str, str, str, str) + self.model.set_sort_column_id(3, Gtk.SortType.ASCENDING) self.window.services_treeview.set_model(self.model) # Name column - col = gtk.TreeViewColumn(_('Name')) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + col = Gtk.TreeViewColumn(_('Name')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 2) self.window.services_treeview.insert_column(col, -1) col.set_resizable(True) # Address column - col = gtk.TreeViewColumn(_('JID')) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + col = Gtk.TreeViewColumn(_('JID')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 3) self.window.services_treeview.insert_column(col, -1) col.set_resizable(True) @@ -908,11 +909,11 @@ class AgentBrowser: Add the action buttons to the buttonbox for actions the browser can perform """ - self.browse_button = gtk.Button() - image = gtk.image_new_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON) - label = gtk.Label(_('_Browse')) + self.browse_button = Gtk.Button() + image = Gtk.Image.new_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON) + label = Gtk.Label(label=_('_Browse')) label.set_use_underline(True) - hbox = gtk.HBox() + hbox = Gtk.HBox() hbox.pack_start(image, False, True, 6) hbox.pack_end(label, True, True) self.browse_button.add(hbox) @@ -963,7 +964,7 @@ class AgentBrowser: # or pack_end, so we repack the close button here to make sure it's last close_button = self.window.xml.get_object('close_button') self.window.action_buttonbox.remove(close_button) - self.window.action_buttonbox.pack_end(close_button) + self.window.action_buttonbox.pack_end(close_button, True, True, 0) close_button.show_all() self.update_actions() @@ -1056,7 +1057,7 @@ class AgentBrowser: self.model.clear() self._total_items = self._progress = 0 self.window.progressbar.show() - self._pulse_timeout = gobject.timeout_add(250, self._pulse_timeout_cb) + self._pulse_timeout = GObject.timeout_add(250, self._pulse_timeout_cb) self.cache.get_items(self.jid, self.node, self._agent_items, force=force, args=(force,)) @@ -1074,7 +1075,7 @@ class AgentBrowser: Check if an item is already in the treeview. Return an iter to it if so, None otherwise """ - iter_ = self.model.get_iter_root() + iter_ = self.model.get_iter_first() while iter_: cjid = self.model.get_value(iter_, 0).decode('utf-8') cnode = self.model.get_value(iter_, 1).decode('utf-8') @@ -1091,7 +1092,7 @@ class AgentBrowser: """ self.model.clear() self._total_items = 0 - gobject.source_remove(self._pulse_timeout) + GObject.source_remove(self._pulse_timeout) self.window.progressbar.hide() # The server returned an error if items == 0: @@ -1236,7 +1237,7 @@ class ToplevelAgentBrowser(AgentBrowser): def _show_tooltip(self, state): view = self.window.services_treeview pointer = view.get_pointer() - props = view.get_path_at_pos(pointer[0], pointer[1]) + props = view.get_path_at_pos(pointer[1], pointer[2]) # check if the current pointer is at the same path # as it was before setting the timeout if props and self.tooltip.id == props[0]: @@ -1274,7 +1275,7 @@ class ToplevelAgentBrowser(AgentBrowser): if jid and state > 0 and \ (self.tooltip.timeout == 0 or self.tooltip.id != props[0]): self.tooltip.id = row - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self._show_tooltip, state) def on_treeview_event_hide_tooltip(self, widget, event): @@ -1287,20 +1288,20 @@ class ToplevelAgentBrowser(AgentBrowser): # JID, node, icon, description, state # State means 2 when error, 1 when fetching, 0 when succes. view = self.window.services_treeview - self.model = gtk.TreeStore(str, str, gtk.gdk.Pixbuf, str, int) + self.model = Gtk.TreeStore(str, str, GdkPixbuf.Pixbuf, str, int) self.model.set_sort_func(4, self._treemodel_sort_func) - self.model.set_sort_column_id(4, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(4, Gtk.SortType.ASCENDING) view.set_model(self.model) - col = gtk.TreeViewColumn() + col = Gtk.TreeViewColumn() # Icon Renderer - renderer = gtk.CellRendererPixbuf() + renderer = Gtk.CellRendererPixbuf() renderer.set_property('xpad', 6) - col.pack_start(renderer, expand=False) + col.pack_start(renderer, False, True, 0) col.set_cell_data_func(renderer, self._pixbuf_renderer_data_func) # Text Renderer - renderer = gtk.CellRendererText() - col.pack_start(renderer, expand=True) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_cell_data_func(renderer, self._text_renderer_data_func) renderer.set_property('foreground', 'dark gray') # Save this so we can go along with theme changes @@ -1337,11 +1338,11 @@ class ToplevelAgentBrowser(AgentBrowser): def _add_actions(self): AgentBrowser._add_actions(self) - self.execute_button = gtk.Button() - image = gtk.image_new_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON) - label = gtk.Label(_('_Execute Command')) + self.execute_button = Gtk.Button() + image = Gtk.Image.new_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.BUTTON) + label = Gtk.Label(label=_('_Execute Command')) label.set_use_underline(True) - hbox = gtk.HBox() + hbox = Gtk.HBox() hbox.pack_start(image, False, True, 6) hbox.pack_end(label, True, True) self.execute_button.add(hbox) @@ -1349,17 +1350,17 @@ class ToplevelAgentBrowser(AgentBrowser): self.window.action_buttonbox.add(self.execute_button) self.execute_button.show_all() - self.register_button = gtk.Button(label=_("Re_gister"), + self.register_button = Gtk.Button(label=_("Re_gister"), use_underline=True) self.register_button.connect('clicked', self.on_register_button_clicked) self.window.action_buttonbox.add(self.register_button) self.register_button.show_all() - self.join_button = gtk.Button() - image = gtk.image_new_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON) - label = gtk.Label(_('_Join')) + self.join_button = Gtk.Button() + image = Gtk.Image.new_from_stock(Gtk.STOCK_CONNECT, Gtk.IconSize.BUTTON) + label = Gtk.Label(label=_('_Join')) label.set_use_underline(True) - hbox = gtk.HBox() + hbox = Gtk.HBox() hbox.pack_start(image, False, True, 6) hbox.pack_end(label, True, True) self.join_button.add(hbox) @@ -1367,11 +1368,11 @@ class ToplevelAgentBrowser(AgentBrowser): self.window.action_buttonbox.add(self.join_button) self.join_button.show_all() - self.search_button = gtk.Button() - image = gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON) - label = gtk.Label(_('_Search')) + self.search_button = Gtk.Button() + image = Gtk.Image.new_from_stock(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON) + label = Gtk.Label(label=_('_Search')) label.set_use_underline(True) - hbox = gtk.HBox() + hbox = Gtk.HBox() hbox.pack_start(image, False, True, 6) hbox.pack_end(label, True, True) self.search_button.add(hbox) @@ -1546,7 +1547,7 @@ class ToplevelAgentBrowser(AgentBrowser): # self.expanding = False # return False #self.expanding = True - #gobject.idle_add(expand_all) + #GObject.idle_add(expand_all) self.window.services_treeview.expand_all() def _update_progressbar(self): @@ -1555,7 +1556,7 @@ class ToplevelAgentBrowser(AgentBrowser): """ # Refresh this every update if self._progressbar_sourceid: - gobject.source_remove(self._progressbar_sourceid) + GObject.source_remove(self._progressbar_sourceid) fraction = 0 if self._total_items: @@ -1564,12 +1565,12 @@ class ToplevelAgentBrowser(AgentBrowser): fraction = float(self._progress) / float(self._total_items) if self._progress >= self._total_items: # We show the progressbar for just a bit before hiding it. - id_ = gobject.timeout_add_seconds(2, self._hide_progressbar_cb) + id_ = GObject.timeout_add_seconds(2, self._hide_progressbar_cb) self._progressbar_sourceid = id_ else: self.window.progressbar.show() # Hide the progressbar if we're timing out anyways. (20 secs) - id_ = gobject.timeout_add_seconds(20, self._hide_progressbar_cb) + id_ = GObject.timeout_add_seconds(20, self._hide_progressbar_cb) self._progressbar_sourceid = id_ self.window.progressbar.set_fraction(fraction) @@ -1611,7 +1612,7 @@ class ToplevelAgentBrowser(AgentBrowser): Looks up a category row and returns the iterator to it, or None """ cat = self._friendly_category(cat, type_)[0] - iter_ = self.model.get_iter_root() + iter_ = self.model.get_iter_first() while iter_: if self.model.get_value(iter_, 3).decode('utf-8') == cat: break @@ -1622,7 +1623,7 @@ class ToplevelAgentBrowser(AgentBrowser): def _find_item(self, jid, node): iter_ = None - cat_iter = self.model.get_iter_root() + cat_iter = self.model.get_iter_first() while cat_iter and not iter_: iter_ = self.model.iter_children(cat_iter) while iter_: @@ -1661,7 +1662,7 @@ class ToplevelAgentBrowser(AgentBrowser): if not cat: cat = self._create_category(*cat_args) self.model.append(cat, (jid, node, pix, descr, 1)) - gobject.idle_add(self._expand_all) + GObject.idle_add(self._expand_all) # Grab info on the service self.cache.get_info(jid, node, self._agent_info, force=force) self._update_progressbar() @@ -1736,39 +1737,39 @@ class MucBrowser(AgentBrowser): # JID, node, name, users_int, users_str, description, fetched # This is rather long, I'd rather not use a data_func here though. # Users is a string, because want to be able to leave it empty. - self.model = gtk.ListStore(str, str, str, int, str, str, bool) - self.model.set_sort_column_id(2, gtk.SORT_ASCENDING) + self.model = Gtk.ListStore(str, str, str, int, str, str, bool) + self.model.set_sort_column_id(2, Gtk.SortType.ASCENDING) self.window.services_treeview.set_model(self.model) # Name column - col = gtk.TreeViewColumn(_('Name')) - col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) + col = Gtk.TreeViewColumn(_('Name')) + col.set_sizing(Gtk.TreeViewColumnSizing.FIXED) col.set_fixed_width(100) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 2) col.set_sort_column_id(2) self.window.services_treeview.insert_column(col, -1) col.set_resizable(True) # Users column - col = gtk.TreeViewColumn(_('Users')) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + col = Gtk.TreeViewColumn(_('Users')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 4) col.set_sort_column_id(3) self.window.services_treeview.insert_column(col, -1) col.set_resizable(True) # Description column - col = gtk.TreeViewColumn(_('Description')) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + col = Gtk.TreeViewColumn(_('Description')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 5) col.set_sort_column_id(4) self.window.services_treeview.insert_column(col, -1) col.set_resizable(True) # Id column - col = gtk.TreeViewColumn(_('Id')) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + col = Gtk.TreeViewColumn(_('Id')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 0) col.set_sort_column_id(0) self.window.services_treeview.insert_column(col, -1) @@ -1796,11 +1797,11 @@ class MucBrowser(AgentBrowser): AgentBrowser._clean_treemodel(self) def _add_actions(self): - self.bookmark_button = gtk.Button(label=_('_Bookmark'), use_underline=True) + self.bookmark_button = Gtk.Button(label=_('_Bookmark'), use_underline=True) self.bookmark_button.connect('clicked', self.on_bookmark_button_clicked) self.window.action_buttonbox.add(self.bookmark_button) self.bookmark_button.show_all() - self.join_button = gtk.Button(label=_('_Join'), use_underline=True) + self.join_button = Gtk.Button(label=_('_Join'), use_underline=True) self.join_button.connect('clicked', self.on_join_button_clicked) self.window.action_buttonbox.add(self.join_button) self.join_button.show_all() @@ -1896,9 +1897,9 @@ class MucBrowser(AgentBrowser): # We're already fetching return view = self.window.services_treeview - if not view.flags() & gtk.REALIZED: + if not view.get_realized(): # Prevent a silly warning, try again in a bit. - self._fetch_source = gobject.timeout_add(100, self._start_info_query) + self._fetch_source = GObject.timeout_add(100, self._start_info_query) return # We have to do this in a pygtk <2.8 compatible way :/ #start, end = self.window.services_treeview.get_visible_range() @@ -1965,7 +1966,7 @@ class MucBrowser(AgentBrowser): def _add_item(self, jid, node, parent_node, item, force): self.model.append((jid, node, item.get('name', ''), -1, '', '', False)) if not self._fetch_source: - self._fetch_source = gobject.idle_add(self._start_info_query) + self._fetch_source = GObject.idle_add(self._start_info_query) def _update_info(self, iter_, jid, node, identities, features, data): name = identities[0].get('name', '') @@ -2033,34 +2034,34 @@ class DiscussionGroupsBrowser(AgentBrowser): Create treemodel for the window """ # JID, node, name (with description) - pango markup, dont have info?, subscribed? - self.model = gtk.TreeStore(str, str, str, bool, bool) + self.model = Gtk.TreeStore(str, str, str, bool, bool) # sort by name - self.model.set_sort_column_id(2, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(2, Gtk.SortType.ASCENDING) self.window.services_treeview.set_model(self.model) # Name column # Pango markup for name and description, description printed with # font - renderer = gtk.CellRendererText() - col = gtk.TreeViewColumn(_('Name')) - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn(_('Name')) + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, markup=2) col.set_resizable(True) self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.set_headers_visible(True) # Subscription state - renderer = gtk.CellRendererToggle() - col = gtk.TreeViewColumn(_('Subscribed')) - col.pack_start(renderer) + renderer = Gtk.CellRendererToggle() + col = Gtk.TreeViewColumn(_('Subscribed')) + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, inconsistent=3, active=4) col.set_resizable(False) self.window.services_treeview.insert_column(col, -1) # Node Column - renderer = gtk.CellRendererText() - col = gtk.TreeViewColumn(_('Node')) - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn(_('Node')) + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, markup=1) col.set_resizable(True) self.window.services_treeview.insert_column(col, -1) @@ -2095,7 +2096,7 @@ class DiscussionGroupsBrowser(AgentBrowser): dunno = True subscribed = False - name = gobject.markup_escape_text(name) + name = GObject.markup_escape_text(name) name = '%s' % name if parent_node: @@ -2126,19 +2127,19 @@ class DiscussionGroupsBrowser(AgentBrowser): return self.found_iter def _add_actions(self): - self.post_button = gtk.Button(label=_('New post'), use_underline=True) + self.post_button = Gtk.Button(label=_('New post'), use_underline=True) self.post_button.set_sensitive(False) self.post_button.connect('clicked', self.on_post_button_clicked) self.window.action_buttonbox.add(self.post_button) self.post_button.show_all() - self.subscribe_button = gtk.Button(label=_('_Subscribe'), use_underline=True) + self.subscribe_button = Gtk.Button(label=_('_Subscribe'), use_underline=True) self.subscribe_button.set_sensitive(False) self.subscribe_button.connect('clicked', self.on_subscribe_button_clicked) self.window.action_buttonbox.add(self.subscribe_button) self.subscribe_button.show_all() - self.unsubscribe_button = gtk.Button(label=_('_Unsubscribe'), use_underline=True) + self.unsubscribe_button = Gtk.Button(label=_('_Unsubscribe'), use_underline=True) self.unsubscribe_button.set_sensitive(False) self.unsubscribe_button.connect('clicked', self.on_unsubscribe_button_clicked) self.window.action_buttonbox.add(self.unsubscribe_button) diff --git a/src/features_window.py b/src/features_window.py index 0894cca61..b222d4ab6 100644 --- a/src/features_window.py +++ b/src/features_window.py @@ -25,7 +25,7 @@ import os import sys -import gtk +from gi.repository import Gtk import gtkgui_helpers from common import gajim @@ -41,7 +41,7 @@ class FeaturesWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui') self.window = self.xml.get_object('features_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) treeview = self.xml.get_object('features_treeview') self.desc_label = self.xml.get_object('feature_desc_label') @@ -114,20 +114,20 @@ class FeaturesWindow: } # name, supported - self.model = gtk.ListStore(str, bool) + self.model = Gtk.ListStore(str, bool) treeview.set_model(self.model) - col = gtk.TreeViewColumn(Q_('?features:Available')) + col = Gtk.TreeViewColumn(Q_('?features:Available')) treeview.append_column(col) - cell = gtk.CellRendererToggle() + cell = Gtk.CellRendererToggle() cell.set_property('radio', True) - col.pack_start(cell) + col.pack_start(cell, True, True, 0) col.set_attributes(cell, active = 1) - col = gtk.TreeViewColumn(_('Feature')) + col = Gtk.TreeViewColumn(_('Feature')) treeview.append_column(col) - cell = gtk.CellRendererText() - col.pack_start(cell, expand = True) + cell = Gtk.CellRendererText() + col.pack_start(cell, True, True, 0) col.add_attribute(cell, 'text', 0) # Fill model @@ -136,7 +136,7 @@ class FeaturesWindow: rep = func() self.model.append([feature, rep]) - self.model.set_sort_column_id(0, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING) self.xml.connect_signals(self) self.window.show_all() diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 40edc2d26..a92a01ad8 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -21,9 +21,10 @@ ## along with Gajim. If not, see . ## -import gtk -import gobject -import pango +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import GObject +from gi.repository import Pango import os import time @@ -66,52 +67,52 @@ class FileTransfersWindow: shall_notify = gajim.config.get('notify_on_file_complete') self.notify_ft_checkbox.set_active(shall_notify ) - self.model = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, str, int, + self.model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str, int, int, str) self.tree.set_model(self.model) - col = gtk.TreeViewColumn() + col = Gtk.TreeViewColumn() - render_pixbuf = gtk.CellRendererPixbuf() + render_pixbuf = Gtk.CellRendererPixbuf() - col.pack_start(render_pixbuf, expand=True) + col.pack_start(render_pixbuf, True) render_pixbuf.set_property('xpad', 3) render_pixbuf.set_property('ypad', 3) render_pixbuf.set_property('yalign', .0) col.add_attribute(render_pixbuf, 'pixbuf', 0) self.tree.append_column(col) - col = gtk.TreeViewColumn(_('File')) - renderer = gtk.CellRendererText() - col.pack_start(renderer, expand=False) + col = Gtk.TreeViewColumn(_('File')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, False) col.add_attribute(renderer, 'markup', C_LABELS) renderer.set_property('yalign', 0.) - renderer = gtk.CellRendererText() - col.pack_start(renderer, expand=True) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True) col.add_attribute(renderer, 'markup', C_FILE) renderer.set_property('xalign', 0.) renderer.set_property('yalign', 0.) - renderer.set_property('ellipsize', pango.ELLIPSIZE_END) + renderer.set_property('ellipsize', Pango.EllipsizeMode.END) col.set_resizable(True) col.set_expand(True) self.tree.append_column(col) - col = gtk.TreeViewColumn(_('Time')) - renderer = gtk.CellRendererText() - col.pack_start(renderer, expand=False) + col = Gtk.TreeViewColumn(_('Time')) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, False) col.add_attribute(renderer, 'markup', C_TIME) renderer.set_property('yalign', 0.5) renderer.set_property('xalign', 0.5) - renderer = gtk.CellRendererText() - renderer.set_property('ellipsize', pango.ELLIPSIZE_END) + renderer = Gtk.CellRendererText() + renderer.set_property('ellipsize', Pango.EllipsizeMode.END) col.set_resizable(True) col.set_expand(False) self.tree.append_column(col) - col = gtk.TreeViewColumn(_('Progress')) - renderer = gtk.CellRendererProgress() + col = Gtk.TreeViewColumn(_('Progress')) + renderer = Gtk.CellRendererProgress() renderer.set_property('yalign', 0.5) renderer.set_property('xalign', 0.5) - col.pack_start(renderer, expand=False) + col.pack_start(renderer, False) col.add_attribute(renderer, 'text', C_PROGRESS) col.add_attribute(renderer, 'value', C_PERCENT) col.add_attribute(renderer, 'pulse', C_PULSE) @@ -121,18 +122,18 @@ class FileTransfersWindow: self.images = {} self.icons = { - 'upload': gtk.STOCK_GO_UP, - 'download': gtk.STOCK_GO_DOWN, - 'stop': gtk.STOCK_STOP, - 'waiting': gtk.STOCK_REFRESH, - 'pause': gtk.STOCK_MEDIA_PAUSE, - 'continue': gtk.STOCK_MEDIA_PLAY, - 'ok': gtk.STOCK_APPLY, - 'computing': gtk.STOCK_EXECUTE, - 'hash_error': gtk.STOCK_STOP, + 'upload': Gtk.STOCK_GO_UP, + 'download': Gtk.STOCK_GO_DOWN, + 'stop': Gtk.STOCK_STOP, + 'waiting': Gtk.STOCK_REFRESH, + 'pause': Gtk.STOCK_MEDIA_PAUSE, + 'continue': Gtk.STOCK_MEDIA_PLAY, + 'ok': Gtk.STOCK_APPLY, + 'computing': Gtk.STOCK_EXECUTE, + 'hash_error': Gtk.STOCK_STOP, } - self.tree.get_selection().set_mode(gtk.SELECTION_SINGLE) + self.tree.get_selection().set_mode(Gtk.SelectionMode.SINGLE) self.tree.get_selection().connect('changed', self.selection_changed) self.tooltip = tooltips.FileTransfersTooltip() self.file_transfers_menu = self.xml.get_object('file_transfers_menu') @@ -182,7 +183,7 @@ class FileTransfersWindow: (file_path, file_name) = os.path.split(file_props.file_name) else: file_name = file_props.name - sectext = '\t' + _('Filename: %s') % gobject.markup_escape_text( + sectext = '\t' + _('Filename: %s') % GObject.markup_escape_text( file_name) sectext += '\n\t' + _('Size: %s') % \ helpers.convert_bytes(file_props.size) @@ -207,13 +208,13 @@ class FileTransfersWindow: sectext += recipient if file_props.type_ == 'r': sectext += '\n\t' + _('Saved in: %s') % file_path - dialog = dialogs.HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, + dialog = dialogs.HigDialog(None, Gtk.MessageType.INFO, Gtk.ButtonsType.NONE, _('File transfer completed'), sectext) if file_props.type_ == 'r': - button = gtk.Button(_('_Open Containing Folder')) + button = Gtk.Button(_('_Open Containing Folder')) button.connect('clicked', on_open, file_props) - dialog.action_area.pack_start(button) - ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) + dialog.action_area.pack_start(button, True, True, 0) + ok_button = dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK) def on_ok(widget): dialog.destroy() ok_button.connect('clicked', on_ok) @@ -239,7 +240,7 @@ class FileTransfersWindow: file_name = os.path.basename(file_props.file_name) else: file_name = file_props.name - sectext = '\t' + _('Filename: %s') % gobject.markup_escape_text( + sectext = '\t' + _('Filename: %s') % GObject.markup_escape_text( file_name) sectext += '\n\t' + _('Recipient: %s') % jid if error_msg: @@ -283,12 +284,12 @@ class FileTransfersWindow: _('The file %(file)s has been fully received, but it seems to be ' 'wrongly received.\nDo you want to reload it?') % \ {'file': file_name}, on_response_yes=(on_yes, jid, file_props, - account), type_=gtk.MESSAGE_ERROR) + account), type_=Gtk.MessageType.ERROR) def show_file_send_request(self, account, contact): - win = gtk.ScrolledWindow() - win.set_shadow_type(gtk.SHADOW_IN) - win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) + win = Gtk.ScrolledWindow() + win.set_shadow_type(Gtk.ShadowType.IN) + win.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) from message_textview import MessageTextView desc_entry = MessageTextView() @@ -301,7 +302,7 @@ class FileTransfersWindow: files_path_list) text_buffer = desc_entry.get_buffer() desc = text_buffer.get_text(text_buffer.get_start_iter(), - text_buffer.get_end_iter()) + text_buffer.get_end_iter(), True) for file_path in files_path_list: if self.send_file(account, contact, file_path, desc) \ and file_dir is None: @@ -311,22 +312,22 @@ class FileTransfersWindow: dialog.destroy() dialog = dialogs.FileChooserDialog(_('Choose File to Send...'), - gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), - gtk.RESPONSE_OK, + Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL), + Gtk.ResponseType.OK, True, # select multiple true as we can select many files to send gajim.config.get('last_send_dir'), on_response_ok=on_ok, on_response_cancel=lambda e:dialog.destroy() ) - btn = gtk.Button(_('_Send')) + btn = Gtk.Button(_('_Send')) btn.set_property('can-default', True) # FIXME: add send icon to this button (JUMP_TO) - dialog.add_action_widget(btn, gtk.RESPONSE_OK) - dialog.set_default_response(gtk.RESPONSE_OK) + dialog.add_action_widget(btn, Gtk.ResponseType.OK) + dialog.set_default_response(Gtk.ResponseType.OK) - desc_hbox = gtk.HBox(False, 5) - desc_hbox.pack_start(gtk.Label(_('Description: ')), False, False, 0) + desc_hbox = Gtk.HBox(False, 5) + desc_hbox.pack_start(Gtk.Label(_('Description: ', True, True, 0)), False, False, 0) desc_hbox.pack_start(win, True, True, 0) dialog.vbox.pack_start(desc_hbox, False, False, 0) @@ -383,7 +384,7 @@ class FileTransfersWindow: if os.path.exists(file_path): # check if we have write permissions if not os.access(file_path, os.W_OK): - file_name = gobject.markup_escape_text(os.path.basename( + file_name = GObject.markup_escape_text(os.path.basename( file_path)) dialogs.ErrorDialog( _('Cannot overwrite existing file "%s"' % file_name), @@ -428,10 +429,10 @@ class FileTransfersWindow: dialog2 = dialogs.FileChooserDialog( title_text=_('Save File as...'), - action=gtk.FILE_CHOOSER_ACTION_SAVE, - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_SAVE, gtk.RESPONSE_OK), - default_response=gtk.RESPONSE_OK, + action=Gtk.FileChooserAction.SAVE, + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_SAVE, Gtk.ResponseType.OK), + default_response=Gtk.ResponseType.OK, current_folder=gajim.config.get('last_save_dir'), on_response_ok=(on_ok, account, contact, file_props), on_response_cancel=(on_cancel, account, contact, file_props)) @@ -447,7 +448,7 @@ class FileTransfersWindow: """ if not file_props or not file_props.name: return - sec_text = '\t' + _('File: %s') % gobject.markup_escape_text( + sec_text = '\t' + _('File: %s') % GObject.markup_escape_text( file_props.name) if file_props.size: sec_text += '\n\t' + _('Size: %s') % \ @@ -474,7 +475,7 @@ class FileTransfersWindow: def get_icon(self, ident): return self.images.setdefault(ident, - self.window.render_icon(self.icons[ident], gtk.ICON_SIZE_MENU)) + self.window.render_icon(self.icons[ident], Gtk.IconSize.MENU)) def set_status(self,file_props, status): """ @@ -494,7 +495,7 @@ class FileTransfersWindow: text += helpers.convert_bytes(received_size) + '/' + \ helpers.convert_bytes(full_size) self.model.set(iter_, C_PROGRESS, text) - self.model.set(iter_, C_PULSE, gobject.constants.G_MAXINT) + self.model.set(iter_, C_PULSE, GObject.constants.G_MAXINT) elif status == 'computing': self.model.set(iter_, C_PULSE, 1) text = _('Checking file...') + '\n' @@ -505,11 +506,11 @@ class FileTransfersWindow: self.model.set(iter_, C_PROGRESS, text) def pulse(): p = self.model.get(iter_, C_PULSE)[0] - if p == gobject.constants.G_MAXINT: + if p == GObject.constants.G_MAXINT: return False self.model.set(iter_, C_PULSE, p + 1) return True - gobject.timeout_add(100, pulse) + GObject.timeout_add(100, pulse) elif status == 'hash_error': text = _('File error') + '\n' received_size = int(file_props.received_len) @@ -517,7 +518,7 @@ class FileTransfersWindow: text += helpers.convert_bytes(received_size) + '/' + \ helpers.convert_bytes(full_size) self.model.set(iter_, C_PROGRESS, text) - self.model.set(iter_, C_PULSE, gobject.constants.G_MAXINT) + self.model.set(iter_, C_PULSE, GObject.constants.G_MAXINT) self.model.set(iter_, C_IMAGE, self.get_icon(status)) path = self.model.get_path(iter_) self.select_func(path) @@ -674,7 +675,7 @@ class FileTransfersWindow: Return iter to the row, which holds file transfer, identified by the session id """ - iter_ = self.model.get_iter_root() + iter_ = self.model.get_iter_first() while iter_: if typ + sid == self.model[iter_][C_SID].decode('utf-8'): return iter_ @@ -737,7 +738,7 @@ class FileTransfersWindow: file_name = os.path.split(file_props.file_name)[1] else: file_name = file_props.name - text_props = gobject.markup_escape_text(file_name) + '\n' + text_props = GObject.markup_escape_text(file_name) + '\n' text_props += contact.get_shown_name() self.model.set(iter_, 1, text_labels, 2, text_props, C_PULSE, -1, C_SID, file_props.type_ + file_props.sid) @@ -756,7 +757,7 @@ class FileTransfersWindow: def on_transfers_list_motion_notify_event(self, widget, event): pointer = self.tree.get_pointer() props = widget.get_path_at_pos(int(event.x), int(event.y)) - self.height_diff = pointer[1] - int(event.y) + self.height_diff = pointer[2] - int(event.y) if self.tooltip.timeout > 0: if not props or self.tooltip.id != props[0]: self.tooltip.hide_tooltip() @@ -773,7 +774,7 @@ class FileTransfersWindow: if file_props is not None: if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: self.tooltip.id = row - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, widget) def on_transfers_list_leave_notify_event(self, widget=None, event=None): @@ -782,7 +783,7 @@ class FileTransfersWindow: elif self.height_diff is 0: return pointer = self.tree.get_pointer() - props = self.tree.get_path_at_pos(pointer[0], pointer[1] - self.height_diff) + props = self.tree.get_path_at_pos(pointer[1], pointer[2] - self.height_diff) if self.tooltip.timeout > 0: if not props or self.tooltip.id == props[0]: self.tooltip.hide_tooltip() @@ -893,8 +894,8 @@ class FileTransfersWindow: if status: label = _('Pause') self.pause_button.set_label(label) - self.pause_button.set_image(gtk.image_new_from_stock( - gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU)) + self.pause_button.set_image(Gtk.Image.new_from_stock( + Gtk.STOCK_MEDIA_PAUSE, Gtk.IconSize.MENU)) self.pause_menuitem.set_sensitive(True) self.pause_menuitem.set_no_show_all(False) @@ -904,8 +905,8 @@ class FileTransfersWindow: else: label = _('_Continue') self.pause_button.set_label(label) - self.pause_button.set_image(gtk.image_new_from_stock( - gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU)) + self.pause_button.set_image(Gtk.Image.new_from_stock( + Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.MENU)) self.pause_menuitem.hide() self.pause_menuitem.set_no_show_all(True) self.continue_menuitem.set_sensitive(True) @@ -951,8 +952,8 @@ class FileTransfersWindow: self.tooltip.hide_tooltip() return pointer = self.tree.get_pointer() - props = self.tree.get_path_at_pos(pointer[0], - pointer[1] - self.height_diff) + props = self.tree.get_path_at_pos(pointer[1], + pointer[2] - self.height_diff) # check if the current pointer is at the same path # as it was before setting the timeout if props and self.tooltip.id == props[0]: @@ -1006,7 +1007,7 @@ class FileTransfersWindow: path = self.model.get_path(iter_) self.tree.get_selection().select_path(path) - if event.keyval == gtk.keysyms.Menu: + if event.keyval == Gdk.KEY_Menu: self.show_context_menu(event, iter_) return True @@ -1073,5 +1074,5 @@ class FileTransfersWindow: self.set_all_insensitive() def on_file_transfers_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: # ESCAPE + if event.keyval == Gdk.KEY_Escape: # ESCAPE self.window.hide() diff --git a/src/gajim.py b/src/gajim.py index 894d7186e..43b5e6539 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -68,12 +68,12 @@ except ImportError: print 'Gajim needs python-nbxmpp to run. Quiting...' sys.exit() -from common import demandimport -demandimport.enable() -demandimport.ignore += ['gobject._gobject', 'libasyncns', 'i18n', - 'logging.NullHandler', 'dbus.service', 'OpenSSL.SSL', 'OpenSSL.crypto', - 'common.sleepy', 'DLFCN', 'dl', 'xml.sax', 'xml.sax.handler', 'ic', - 'Crypto.PublicKey', 'IPython'] +#from common import demandimport +#demandimport.enable() +#demandimport.ignore += ['GObject._gobject', 'libasyncns', 'i18n', +# 'logging.NullHandler', 'dbus.service', 'OpenSSL.SSL', 'OpenSSL.crypto', +# 'common.sleepy', 'DLFCN', 'dl', 'xml.sax', 'xml.sax.handler', 'ic', +# 'Crypto.PublicKey', 'IPython'] if os.name == 'nt': import locale @@ -111,6 +111,12 @@ import logging # gajim.gui or gajim.gtk more appropriate ? log = logging.getLogger('gajim.gajim') +#import gi +#gi.require_version('Gtk', '3.0') +#gi.require_version('Gdk', '2.0') +#gi.require_version('GObject', '2.0') +#gi.require_version('Pango', '1.0') + import getopt from common import i18n @@ -190,9 +196,10 @@ if os.name == 'nt': # PyGTK2.10+ only throws a warning warnings.filterwarnings('error', module='gtk') try: - import gobject - gobject.set_prgname('gajim') - import gtk + from gi.repository import GObject + GObject.set_prgname('gajim') + from gi.repository import Gtk + from gi.repository import Gdk except Warning, msg2: if str(msg2) == 'could not open display': print >> sys.stderr, _('Gajim needs X server to run. Quiting...') @@ -237,12 +244,14 @@ else: elif sysname in ('FreeBSD', 'OpenBSD', 'NetBSD'): libc.setproctitle('gajim') - if gtk.pygtk_version < (2, 22, 0): - pritext = _('Gajim needs PyGTK 2.22 or above') - sectext = _('Gajim needs PyGTK 2.22 or above to run. Quiting...') - elif gtk.gtk_version < (2, 22, 0): - pritext = _('Gajim needs GTK 2.22 or above') - sectext = _('Gajim needs GTK 2.22 or above to run. Quiting...') +# if Gtk.pygtk_version < (2, 22, 0): +# pritext = _('Gajim needs PyGTK 2.22 or above') +# sectext = _('Gajim needs PyGTK 2.22 or above to run. Quiting...') +# elif Gtk.gtk_version < (2, 22, 0): +# if (Gtk.get_major_version(), Gtk.get_minor_version(), +# Gtk.get_micro_version()) < (2, 22, 0): +# pritext = _('Gajim needs GTK 2.22 or above') +# sectext = _('Gajim needs GTK 2.22 or above to run. Quiting...') from common import check_paths @@ -257,9 +266,9 @@ else: 'http://sourceforge.net/project/showfiles.php?group_id=78018' if pritext: - dlg = gtk.MessageDialog(None, - gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, - gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message_format = pritext) + dlg = Gtk.MessageDialog(None, + Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, + Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, message_format = pritext) dlg.format_secondary_text(sectext) dlg.run() @@ -385,12 +394,12 @@ if pid_alive(): print("Gajim is already running, bringing the roster to front...") sys.exit(0) pix = gtkgui_helpers.get_icon_pixmap('gajim', 48) - gtk.window_set_default_icon(pix) # set the icon to all newly opened wind + Gtk.window_set_default_icon(pix) # set the icon to all newly opened wind pritext = _('Gajim is already running') sectext = _('Another instance of Gajim seems to be running\nRun anyway?') dialog = dialogs.YesNoDialog(pritext, sectext) dialog.popup() - if dialog.run() != gtk.RESPONSE_YES: + if dialog.run() != Gtk.ResponseType.YES: sys.exit(3) dialog.destroy() # run anyway, delete pid and useless global vars @@ -440,31 +449,31 @@ if __name__ == '__main__': log.info("Encodings: d:%s, fs:%s, p:%s", sys.getdefaultencoding(), \ sys.getfilesystemencoding(), locale.getpreferredencoding()) - if os.name != 'nt': - # Session Management support - try: - import gnome.ui - raise ImportError - except ImportError: - pass - else: - def die_cb(dummy): - gajim.interface.roster.quit_gtkgui_interface() - gnome.program_init('gajim', gajim.version) - cli = gnome.ui.master_client() - cli.connect('die', die_cb) + #if os.name != 'nt': + ## Session Management support + #try: + #import gnome.ui + #raise ImportError + #except ImportError: + #pass + #else: + #def die_cb(dummy): + #gajim.interface.roster.quit_gtkgui_interface() + #gnome.program_init('gajim', gajim.version) + #cli = gnome.ui.master_client() + #cli.connect('die', die_cb) - path_to_gajim_script = gtkgui_helpers.get_abspath_for_script( - 'gajim') + #path_to_gajim_script = gtkgui_helpers.get_abspath_for_script( + #'gajim') - if path_to_gajim_script: - argv = [path_to_gajim_script] - try: - cli.set_restart_command(argv) - except TypeError: - # Fedora systems have a broken gnome-python wrapper for this - # function. - cli.set_restart_command(len(argv), argv) + #if path_to_gajim_script: + #argv = [path_to_gajim_script] + #try: + #cli.set_restart_command(argv) + #except TypeError: + ## Fedora systems have a broken gnome-python wrapper for this + ## function. + #cli.set_restart_command(len(argv), argv) check_paths.check_and_possibly_create_paths() @@ -475,10 +484,10 @@ if __name__ == '__main__': if os.name != 'nt': # This makes Gajim unusable under windows, and threads are used only # for GPG, so not under windows - gtk.gdk.threads_init() - gtk.gdk.threads_enter() - gtk.main() + Gdk.threads_init() + Gdk.threads_enter() + Gtk.main() if os.name != 'nt': - gtk.gdk.threads_leave() + Gdk.threads_leave() except KeyboardInterrupt: print >> sys.stderr, 'KeyboardInterrupt' diff --git a/src/gajim_themes_window.py b/src/gajim_themes_window.py index 0a8c64213..29023acfa 100644 --- a/src/gajim_themes_window.py +++ b/src/gajim_themes_window.py @@ -22,8 +22,8 @@ ## along with Gajim. If not, see . ## -import gtk -import pango +from gi.repository import Gtk +from gi.repository import Pango import dialogs import gtkgui_helpers @@ -34,7 +34,7 @@ class GajimThemesWindow: def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('gajim_themes_window.ui') self.window = self.xml.get_object('gajim_themes_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) self.options = ['account', 'group', 'contact', 'banner'] self.options_combobox = self.xml.get_object('options_combobox') @@ -54,12 +54,12 @@ class GajimThemesWindow: 'muc_msg', 'muc_directed_msg'): self.colorbuttons[chatstate] = self.xml.get_object(chatstate + \ '_colorbutton') - model = gtk.ListStore(str) + model = Gtk.ListStore(str) self.themes_tree.set_model(model) - col = gtk.TreeViewColumn(_('Theme')) + col = Gtk.TreeViewColumn(_('Theme')) self.themes_tree.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer, True) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = 0) renderer.connect('edited', self.on_theme_cell_edited) renderer.set_property('editable', True) @@ -125,7 +125,7 @@ class GajimThemesWindow: def select_active_theme(self): model = self.themes_tree.get_model() - iter_ = model.get_iter_root() + iter_ = model.get_iter_first() active_theme = gajim.config.get('roster_theme').replace('_', ' ') while iter_: theme = model[iter_][0] @@ -198,7 +198,7 @@ class GajimThemesWindow: textcolor = gajim.config.get_per('themes', theme, option + 'textcolor') if textcolor: state = True - self.text_colorbutton.set_color(gtk.gdk.color_parse(textcolor)) + self.text_colorbutton.set_color(Gdk.color_parse(textcolor)) else: state = False self.textcolor_checkbutton.set_active(state) @@ -206,7 +206,7 @@ class GajimThemesWindow: bgcolor = gajim.config.get_per('themes', theme, option + 'bgcolor') if bgcolor: state = True - self.background_colorbutton.set_color(gtk.gdk.color_parse( + self.background_colorbutton.set_color(Gdk.color_parse( bgcolor)) else: state = False @@ -231,7 +231,7 @@ class GajimThemesWindow: 'muc_msg', 'muc_directed_msg'): color = gajim.config.get_per('themes', theme, 'state_' + chatstate + \ '_color') - self.colorbuttons[chatstate].set_color(gtk.gdk.color_parse(color)) + self.colorbuttons[chatstate].set_color(Gdk.color_parse(color)) def on_textcolor_checkbutton_toggled(self, widget): state = widget.get_active() @@ -328,11 +328,11 @@ class GajimThemesWindow: """ Return a FontDescription from togglebuttons states """ - fd = pango.FontDescription() + fd = Pango.FontDescription() if self.bold_togglebutton.get_active(): - fd.set_weight(pango.WEIGHT_BOLD) + fd.set_weight(Pango.Weight.BOLD) if self.italic_togglebutton.get_active(): - fd.set_style(pango.STYLE_ITALIC) + fd.set_style(Pango.Style.ITALIC) return fd def _set_font_widgets(self, font_attrs): @@ -365,10 +365,10 @@ class GajimThemesWindow: Get tuple of font properties: weight, style """ font_props = [False, False, False] - font_description = pango.FontDescription(font_name) - if font_description.get_weight() != pango.WEIGHT_NORMAL: + font_description = Pango.FontDescription(font_name) + if font_description.get_weight() != Pango.Weight.NORMAL: font_props[0] = True - if font_description.get_style() != pango.STYLE_ITALIC: + if font_description.get_style() != Pango.Style.ITALIC: font_props[1] = True return font_props diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 9e431f8d3..fd705214b 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -30,9 +30,10 @@ import os import time import locale -import gtk -import pango -import gobject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import Pango +from gi.repository import GObject import gtkgui_helpers import gui_menu_builder import message_control @@ -72,10 +73,10 @@ def set_renderer_color(treeview, renderer, set_background=True): Set style for group row, using PRELIGHT system color """ if set_background: - bgcolor = treeview.style.bg[gtk.STATE_PRELIGHT] + bgcolor = treeview.get_style().bg[Gtk.StateType.PRELIGHT] renderer.set_property('cell-background-gdk', bgcolor) else: - fgcolor = treeview.style.fg[gtk.STATE_PRELIGHT] + fgcolor = treeview.get_style().fg[Gtk.StateType.PRELIGHT] renderer.set_property('foreground-gdk', fgcolor) def tree_cell_data_func(column, renderer, model, iter_, tv=None): @@ -84,7 +85,7 @@ def tree_cell_data_func(column, renderer, model, iter_, tv=None): theme = gajim.config.get('roster_theme') # allocate space for avatar only if needed parent_iter = model.iter_parent(iter_) - if isinstance(renderer, gtk.CellRendererPixbuf): + if isinstance(renderer, Gtk.CellRendererPixbuf): avatar_position = gajim.config.get('avatar_position_in_roster') if avatar_position == 'right': renderer.set_property('xalign', 1) # align pixbuf to the right @@ -103,7 +104,7 @@ def tree_cell_data_func(column, renderer, model, iter_, tv=None): renderer.set_property('cell-background', bgcolor) else: renderer.set_property('cell-background', None) - if isinstance(renderer, gtk.CellRendererText): + if isinstance(renderer, Gtk.CellRendererText): # foreground property is only with CellRendererText color = gajim.config.get_per('themes', theme, 'contacttextcolor') if color: @@ -118,7 +119,7 @@ def tree_cell_data_func(column, renderer, model, iter_, tv=None): renderer.set_property('cell-background', bgcolor) else: set_renderer_color(tv, renderer) - if isinstance(renderer, gtk.CellRendererText): + if isinstance(renderer, Gtk.CellRendererText): # foreground property is only with CellRendererText color = gajim.config.get_per('themes', theme, 'grouptextcolor') if color: @@ -327,7 +328,7 @@ class GroupchatControl(ChatControlBase): if gtkgui_helpers.gtk_icon_theme.has_icon('bookmark-new'): img = self.xml.get_object('image7') - img.set_from_icon_name('bookmark-new', gtk.ICON_SIZE_MENU) + img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU) widget.set_sensitive( gajim.connections[self.account].private_storage_supported or \ (gajim.connections[self.account].pubsub_supported and \ @@ -425,13 +426,13 @@ class GroupchatControl(ChatControlBase): self.hpaned.set_position(hpaned_position) #status_image, shown_nick, type, nickname, avatar - self.columns = [gtk.Image, str, str, str, gtk.gdk.Pixbuf] - self.model = gtk.TreeStore(*self.columns) + self.columns = [Gtk.Image, str, str, str, GdkPixbuf.Pixbuf] + self.model = Gtk.TreeStore(*self.columns) self.model.set_sort_func(C_NICK, self.tree_compare_iters) - self.model.set_sort_column_id(C_NICK, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(C_NICK, Gtk.SortType.ASCENDING) # columns - column = gtk.TreeViewColumn() + column = Gtk.TreeViewColumn() # list of renderers with attributes / properties in the form: # (name, renderer_object, expand?, attribute_name, attribute_value, # cell_data_func, func_arg) @@ -441,9 +442,9 @@ class GroupchatControl(ChatControlBase): self.renderers_propertys = {} renderer_image = cell_renderer_image.CellRendererImage(0, 0) self.renderers_propertys[renderer_image] = ('width', 26) - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() self.renderers_propertys[renderer_text] = ('ellipsize', - pango.ELLIPSIZE_END) + Pango.EllipsizeMode.END) self.renderers_list += ( # status img @@ -454,7 +455,7 @@ class GroupchatControl(ChatControlBase): 'markup', C_TEXT, tree_cell_data_func, self.list_treeview)) # avatar img - avater_renderer = ('avatar', gtk.CellRendererPixbuf(), + avater_renderer = ('avatar', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_AVATAR, tree_cell_data_func, self.list_treeview) @@ -467,9 +468,9 @@ class GroupchatControl(ChatControlBase): self.list_treeview.append_column(column) # workaround to avoid gtk arrows to be shown - column = gtk.TreeViewColumn() # 2nd COLUMN - renderer = gtk.CellRendererPixbuf() - column.pack_start(renderer, expand=False) + column = Gtk.TreeViewColumn() # 2nd COLUMN + renderer = Gtk.CellRendererPixbuf() + column.pack_start(renderer, False, True, 0) self.list_treeview.append_column(column) column.set_visible(False) self.list_treeview.set_expander_column(column) @@ -507,7 +508,7 @@ class GroupchatControl(ChatControlBase): def fill_column(self, col): for rend in self.renderers_list: - col.pack_start(rend[1], expand=rend[2]) + col.pack_start(rend[1], rend[2], True, 0) col.add_attribute(rend[1], rend[3], rend[4]) col.set_cell_data_func(rend[1], rend[5], rend[6]) # set renderers propertys @@ -562,17 +563,17 @@ class GroupchatControl(ChatControlBase): and the ability to insert a nick """ ChatControlBase.on_msg_textview_populate_popup(self, textview, menu) - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() menu.prepend(item) - item = gtk.MenuItem(_('Insert Nickname')) + item = Gtk.MenuItem(_('Insert Nickname')) menu.prepend(item) - submenu = gtk.Menu() + submenu = Gtk.Menu() item.set_submenu(submenu) for nick in sorted(gajim.contacts.get_nick_list(self.account, self.room_jid)): - item = gtk.MenuItem(nick, use_underline=False) + item = Gtk.MenuItem(nick, use_underline=False) submenu.append(item) id_ = item.connect('activate', self.append_nick_in_msg_textview, nick) @@ -587,7 +588,7 @@ class GroupchatControl(ChatControlBase): self.resize_from_another_muc = False # Reset the flag when everything will be redrawn, and in particular when # on_treeview_size_allocate will have been called. - gobject.idle_add(reset_flag) + GObject.idle_add(reset_flag) def on_hpaned_notify(self, pane, gparamspec): """ @@ -616,7 +617,7 @@ class GroupchatControl(ChatControlBase): """ Iterate over all contact rows in the tree model """ - role_iter = self.model.get_iter_root() + role_iter = self.model.get_iter_first() while role_iter: contact_iter = self.model.iter_children(role_iter) while contact_iter: @@ -668,13 +669,13 @@ class GroupchatControl(ChatControlBase): if chatstate == 'active' or (current_tab and has_focus): self.attention_flag = False # get active color from gtk - color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] + color = self.parent_win.notebook.get_style().fg[Gtk.StateType.ACTIVE] elif chatstate == 'newmsg' and (not has_focus or not current_tab) \ and not self.attention_flag: color_name = gajim.config.get_per('themes', theme, 'state_muc_msg_color') if color_name: - color = gtk.gdk.colormap_get_system().alloc_color(color_name) + color = Gdk.colormap_get_system().alloc_color(color_name) if self.is_continued: # if this is a continued conversation @@ -726,14 +727,14 @@ class GroupchatControl(ChatControlBase): image = 'muc_inactive' if '32' in images and image in images['32']: muc_icon = images['32'][image] - if muc_icon.get_storage_type() != gtk.IMAGE_EMPTY: + if muc_icon.get_storage_type() != Gtk.ImageType.EMPTY: pix = muc_icon.get_pixbuf() banner_status_img.set_from_pixbuf(pix) return # we need to scale 16x16 to 32x32 muc_icon = images['16'][image] pix = muc_icon.get_pixbuf() - scaled_pix = pix.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR) + scaled_pix = pix.scale_simple(32, 32, GdkPixbuf.InterpType.BILINEAR) banner_status_img.set_from_pixbuf(scaled_pix) def get_continued_conversation_name(self): @@ -758,8 +759,8 @@ class GroupchatControl(ChatControlBase): Draw the text in the fat line at the top of the window that houses the room jid, subject """ - self.name_label.set_ellipsize(pango.ELLIPSIZE_END) - self.banner_status_label.set_ellipsize(pango.ELLIPSIZE_END) + self.name_label.set_ellipsize(Pango.EllipsizeMode.END) + self.banner_status_label.set_ellipsize(Pango.EllipsizeMode.END) font_attrs, font_attrs_small = self.get_font_attrs() if self.is_continued: name = self.get_continued_conversation_name() @@ -770,7 +771,7 @@ class GroupchatControl(ChatControlBase): if self.subject: subject = helpers.reduce_chars_newlines(self.subject, max_lines=2) - subject = gobject.markup_escape_text(subject) + subject = GObject.markup_escape_text(subject) subject_text = self.urlfinder.sub(self.make_href, subject) subject_text = '%s' % (font_attrs_small, subject_text) @@ -807,8 +808,8 @@ class GroupchatControl(ChatControlBase): request_voice_separator = xml.get_object('request_voice_separator') if gtkgui_helpers.gtk_icon_theme.has_icon('bookmark-new'): - img = gtk.Image() - img.set_from_icon_name('bookmark-new', gtk.ICON_SIZE_MENU) + img = Gtk.Image() + img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU) bookmark_room_menuitem.set_image(img) if hide_buttonbar_items: @@ -831,15 +832,15 @@ class GroupchatControl(ChatControlBase): bookmark_separator.hide() break - ag = gtk.accel_groups_from_object(self.parent_win.window)[0] - change_nick_menuitem.add_accelerator('activate', ag, gtk.keysyms.n, - gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK, gtk.ACCEL_VISIBLE) + ag = Gtk.accel_groups_from_object(self.parent_win.window)[0] + change_nick_menuitem.add_accelerator('activate', ag, Gdk.KEY_n, + Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK, Gtk.AccelFlags.VISIBLE) change_subject_menuitem.add_accelerator('activate', ag, - gtk.keysyms.t, gtk.gdk.MOD1_MASK, gtk.ACCEL_VISIBLE) - bookmark_room_menuitem.add_accelerator('activate', ag, gtk.keysyms.b, - gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) - history_menuitem.add_accelerator('activate', ag, gtk.keysyms.h, - gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) + Gdk.KEY_t, Gdk.ModifierType.MOD1_MASK, Gtk.AccelFlags.VISIBLE) + bookmark_room_menuitem.add_accelerator('activate', ag, Gdk.KEY_b, + Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) + history_menuitem.add_accelerator('activate', ag, Gdk.KEY_h, + Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) if self.contact.jid in gajim.config.get_per('accounts', self.account, 'minimized_gc').split(' '): @@ -914,15 +915,15 @@ class GroupchatControl(ChatControlBase): def destroy_menu(self, menu, change_nick_menuitem, change_subject_menuitem, bookmark_room_menuitem, history_menuitem): # destroy accelerators - ag = gtk.accel_groups_from_object(self.parent_win.window)[0] - change_nick_menuitem.remove_accelerator(ag, gtk.keysyms.n, - gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK) - change_subject_menuitem.remove_accelerator(ag, gtk.keysyms.t, - gtk.gdk.MOD1_MASK) - bookmark_room_menuitem.remove_accelerator(ag, gtk.keysyms.b, - gtk.gdk.CONTROL_MASK) - history_menuitem.remove_accelerator(ag, gtk.keysyms.h, - gtk.gdk.CONTROL_MASK) + ag = Gtk.accel_groups_from_object(self.parent_win.window)[0] + change_nick_menuitem.remove_accelerator(ag, Gdk.KEY_n, + Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK) + change_subject_menuitem.remove_accelerator(ag, Gdk.KEY_t, + Gdk.ModifierType.MOD1_MASK) + bookmark_room_menuitem.remove_accelerator(ag, Gdk.KEY_b, + Gdk.ModifierType.CONTROL_MASK) + history_menuitem.remove_accelerator(ag, Gdk.KEY_h, + Gdk.ModifierType.CONTROL_MASK) # destroy menu menu.destroy() @@ -966,15 +967,15 @@ class GroupchatControl(ChatControlBase): self.form_widget.connect('validated', on_send_dataform_clicked) self.form_widget.show_all() vbox = self.xml.get_object('gc_textviews_vbox') - vbox.pack_start(self.form_widget, expand=False, fill=False) + vbox.pack_start(self.form_widget, False, True, 0) - valid_button = gtk.Button(stock=gtk.STOCK_OK) + valid_button = Gtk.Button(stock=Gtk.STOCK_OK) valid_button.connect('clicked', on_send_dataform_clicked) - self.btn_box = gtk.HButtonBox() - self.btn_box.set_layout(gtk.BUTTONBOX_END) - self.btn_box.pack_start(valid_button) + self.btn_box = Gtk.HButtonBox() + self.btn_box.set_layout(Gtk.ButtonBoxStyle.END) + self.btn_box.pack_start(valid_button, True, True, 0) self.btn_box.show_all() - vbox.pack_start(self.btn_box, expand=False, fill=False) + vbox.pack_start(self.btn_box, False, False, 0) if self.parent_win: self.parent_win.redraw_tab(self, 'attention') else: @@ -1037,7 +1038,7 @@ class GroupchatControl(ChatControlBase): gajim.interface.roster.draw_contact(self.room_jid, self.account) def get_contact_iter(self, nick): - role_iter = self.model.get_iter_root() + role_iter = self.model.get_iter_first() while role_iter: user_iter = self.model.iter_children(role_iter) while user_iter: @@ -1303,7 +1304,7 @@ class GroupchatControl(ChatControlBase): def got_connected(self): # Make autorejoin stop. if self.autorejoin: - gobject.source_remove(self.autorejoin) + GObject.source_remove(self.autorejoin) self.autorejoin = None gajim.gc_connected[self.account][self.room_jid] = True @@ -1349,7 +1350,7 @@ class GroupchatControl(ChatControlBase): if self.autorejoin is None and gajim.account_is_connected(self.account): ar_to = gajim.config.get('muc_autorejoin_timeout') if ar_to: - self.autorejoin = gobject.timeout_add_seconds(ar_to, + self.autorejoin = GObject.timeout_add_seconds(ar_to, self.rejoin) def rejoin(self): @@ -1403,7 +1404,7 @@ class GroupchatControl(ChatControlBase): else: image = state_images[gc_contact.show] - name = gobject.markup_escape_text(gc_contact.name) + name = GObject.markup_escape_text(gc_contact.name) # Strike name if blocked fjid = self.room_jid + '/' + nick @@ -1422,14 +1423,14 @@ class GroupchatControl(ChatControlBase): colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue) name += ('\n' - '%s') % (colorstring, gobject.markup_escape_text( + '%s') % (colorstring, GObject.markup_escape_text( status)) - if image.get_storage_type() == gtk.IMAGE_PIXBUF and \ + if image.get_storage_type() == Gtk.ImageType.PIXBUF and \ gc_contact.affiliation != 'none' and gajim.config.get( 'show_affiliation_in_groupchat'): pixbuf1 = image.get_pixbuf().copy() - pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 4, 4) + pixbuf2 = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, True, 8, 4, 4) if gc_contact.affiliation == 'owner': pixbuf2.fill(0xff0000ff) # Red elif gc_contact.affiliation == 'admin': @@ -1438,8 +1439,8 @@ class GroupchatControl(ChatControlBase): pixbuf2.fill(0x00ff00ff) # Green pixbuf2.composite(pixbuf1, 12, 12, pixbuf2.get_property('width'), pixbuf2.get_property('height'), 0, 0, 1.0, 1.0, - gtk.gdk.INTERP_HYPER, 127) - image = gtk.image_new_from_pixbuf(pixbuf1) + GdkPixbuf.InterpType.HYPER, 127) + image = Gtk.image_new_from_pixbuf(pixbuf1) self.model[iter_][C_IMG] = image self.model[iter_][C_TEXT] = name @@ -1829,7 +1830,7 @@ class GroupchatControl(ChatControlBase): return iter_ def get_role_iter(self, role): - role_iter = self.model.get_iter_root() + role_iter = self.model.get_iter_first() while role_iter: role_name = self.model[role_iter][C_NICK].decode('utf-8') if role == role_name: @@ -2150,7 +2151,7 @@ class GroupchatControl(ChatControlBase): # Textview is not sensitive, don't handle keypress return # construct event instance from binding - event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) # it's always a key-press here + event = Gdk.Event(Gdk.KEY_PRESS) # it's always a key-press here event.keyval = event_keyval event.state = event_keymod event.time = 0 # assign current time @@ -2158,7 +2159,7 @@ class GroupchatControl(ChatControlBase): message_buffer = widget.get_buffer() start_iter, end_iter = message_buffer.get_bounds() - if event.keyval == gtk.keysyms.Tab: # TAB + if event.keyval == Gdk.KEY_Tab: # TAB cursor_position = message_buffer.get_insert() end_iter = message_buffer.get_iter_at_mark(cursor_position) text = message_buffer.get_text(start_iter, end_iter, False).decode( @@ -2271,7 +2272,7 @@ class GroupchatControl(ChatControlBase): self.last_key_tabs = False def on_list_treeview_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: selection = widget.get_selection() iter_ = selection.get_selected()[1] if iter_: @@ -2438,7 +2439,7 @@ class GroupchatControl(ChatControlBase): item = xml.get_object('send_file_menuitem') # add a special img for send file menuitem path_to_upload_img = gtkgui_helpers.get_icon_path('gajim-upload') - img = gtk.Image() + img = Gtk.Image() img.set_from_file(path_to_upload_img) item.set_image(img) @@ -2515,7 +2516,7 @@ class GroupchatControl(ChatControlBase): return True elif event.button == 1: # left click - if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK: + if gajim.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK: self.on_row_activated(widget, path) return True else: @@ -2529,7 +2530,7 @@ class GroupchatControl(ChatControlBase): widget.collapse_row(path) else: widget.expand_row(path, False) - elif event.state & gtk.gdk.SHIFT_MASK: + elif event.get_state() & Gdk.ModifierType.SHIFT_MASK: self.append_nick_in_msg_textview(self.msg_textview, nick) self.msg_textview.grab_focus() return True @@ -2570,7 +2571,7 @@ class GroupchatControl(ChatControlBase): if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: self.tooltip.id = row nick = self.model[iter_][C_NICK].decode('utf-8') - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, gajim.contacts.get_gc_contact( account, self.room_jid, nick)) @@ -2585,7 +2586,7 @@ class GroupchatControl(ChatControlBase): # control has been destroyed since tooltip was requested return pointer = self.list_treeview.get_pointer() - props = self.list_treeview.get_path_at_pos(pointer[0], pointer[1]) + props = self.list_treeview.get_path_at_pos(pointer[1], pointer[2]) # check if the current pointer is at the same path # as it was before setting the timeout if props and self.tooltip.id == props[0]: diff --git a/src/groups.py b/src/groups.py index 0b44088f2..1b3809966 100644 --- a/src/groups.py +++ b/src/groups.py @@ -64,7 +64,7 @@ class GroupsPostWindow: item.addChild('title', {}, [self.subject_entry.get_text()]) buf = self.contents_textview.get_buffer() - item.addChild('content', {}, [buf.get_text(buf.get_start_iter(), buf.get_end_iter())]) + item.addChild('content', {}, [buf.get_text(buf.get_start_iter(), buf.get_end_iter(), True)]) # publish it to node gajim.connections[self.account].send_pb_publish(self.servicejid, self.groupid, item, '0') diff --git a/src/gtkexcepthook.py b/src/gtkexcepthook.py index 5a9bb3476..eb334270b 100644 --- a/src/gtkexcepthook.py +++ b/src/gtkexcepthook.py @@ -25,8 +25,8 @@ import os import traceback import threading -import gtk -import pango +from gi.repository import Gtk +from gi.repository import Pango from common import i18n # installs _() function import dialogs @@ -42,7 +42,7 @@ def _info(type_, value, tb): _excepthook_save(type_, value, tb) return - dialog = dialogs.HigDialog(None, gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, + dialog = dialogs.HigDialog(None, Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE, _('A programming error has been detected'), _('It probably is not fatal, but should be reported ' 'to the developers nonetheless.')) @@ -50,20 +50,20 @@ def _info(type_, value, tb): dialog.set_modal(False) #FIXME: add icon to this button RESPONSE_REPORT_BUG = 42 - dialog.add_buttons(gtk.STOCK_CLOSE, gtk.BUTTONS_CLOSE, + dialog.add_buttons(Gtk.STOCK_CLOSE, Gtk.ButtonsType.CLOSE, _('_Report Bug'), RESPONSE_REPORT_BUG) report_button = dialog.action_area.get_children()[0] # right to left report_button.grab_focus() # Details - textview = gtk.TextView() + textview = Gtk.TextView() textview.set_editable(False) - textview.modify_font(pango.FontDescription('Monospace')) - sw = gtk.ScrolledWindow() - sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + textview.modify_font(Pango.FontDescription('Monospace')) + sw = Gtk.ScrolledWindow() + sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) sw.add(textview) - frame = gtk.Frame() - frame.set_shadow_type(gtk.SHADOW_IN) + frame = Gtk.Frame() + frame.set_shadow_type(Gtk.ShadowType.IN) frame.add(sw) frame.set_border_width(6) textbuffer = textview.get_buffer() @@ -71,15 +71,15 @@ def _info(type_, value, tb): traceback.print_exception(type_, value, tb, None, trace) textbuffer.set_text(trace.getvalue()) textview.set_size_request( - gtk.gdk.screen_width() / 3, - gtk.gdk.screen_height() / 4) - expander = gtk.Expander(_('Details')) + Gdk.Screen.width() / 3, + Gdk.Screen.height() / 4) + expander = Gtk.Expander(_('Details')) expander.add(frame) dialog.vbox.add(expander) dialog.set_resizable(True) # on expand the details the dialog remains centered on screen - dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS) + dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS) def on_dialog_response(dialog, response): if response == RESPONSE_REPORT_BUG: diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 7583e6daf..7e4c96e26 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -28,10 +28,12 @@ ## import xml.sax.saxutils -import gtk +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GdkPixbuf import glib -import gobject -import pango +from gi.repository import GObject +from gi.repository import Pango import os import sys @@ -41,13 +43,13 @@ log = logging.getLogger('gajim.gtkgui_helpers') from common import i18n from common import gajim -gtk_icon_theme = gtk.icon_theme_get_default() +gtk_icon_theme = Gtk.IconTheme.get_default() gtk_icon_theme.append_search_path(gajim.ICONS_DIR) def get_icon_pixmap(icon_name, size=16): try: return gtk_icon_theme.load_icon(icon_name, size, 0) - except gobject.GError, e: + except GObject.GError, e: log.error('Unable to load icon %s: %s' % (icon_name, str(e))) def get_icon_path(icon_name, size=16): @@ -58,7 +60,7 @@ def get_icon_path(icon_name, size=16): return "" else: return icon_info.get_filename() - except gobject.GError, e: + except GObject.GError, e: log.error("Unable to find icon %s: %s" % (icon_name, str(e))) import vcard @@ -76,11 +78,11 @@ if os.name == 'nt': from common import helpers -screen_w = gtk.gdk.screen_width() -screen_h = gtk.gdk.screen_height() +screen_w = Gdk.Screen.width() +screen_h = Gdk.Screen.height() def add_image_to_menuitem(menuitem, icon_name): - img = gtk.Image() + img = Gtk.Image() path_img = get_icon_path(icon_name) img.set_from_file(path_img) menuitem.set_image(img) @@ -91,7 +93,7 @@ def add_image_to_button(button, icon_name): GUI_DIR = os.path.join(gajim.DATA_DIR, 'gui') def get_gtk_builder(file_name, widget=None): file_path = os.path.join(GUI_DIR, file_name) - builder = gtk.Builder() + builder = Gtk.Builder() builder.set_translation_domain(i18n.APP) if widget: builder.add_objects_from_file(file_path, [widget]) @@ -104,15 +106,15 @@ def get_completion_liststore(entry): Create a completion model for entry widget completion list consists of (Pixbuf, Text) rows """ - completion = gtk.EntryCompletion() - liststore = gtk.ListStore(gtk.gdk.Pixbuf, str) + completion = Gtk.EntryCompletion() + liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str) - render_pixbuf = gtk.CellRendererPixbuf() - completion.pack_start(render_pixbuf, expand = False) + render_pixbuf = Gtk.CellRendererPixbuf() + completion.pack_start(render_pixbuf, False, True, 0) completion.add_attribute(render_pixbuf, 'pixbuf', 0) - render_text = gtk.CellRendererText() - completion.pack_start(render_text, expand = True) + render_text = Gtk.CellRendererText() + completion.pack_start(render_text, True, True, 0) completion.add_attribute(render_text, 'text', 1) completion.set_property('text_column', 1) completion.set_model(liststore) @@ -138,7 +140,7 @@ def popup_emoticons_under_button(menu, button, parent_win): ## should we pop down or up? if (y + button.allocation.height + menu_height - < gtk.gdk.screen_height()): + < Gdk.Screen.height()): # now move the menu below the button y += button.allocation.height else: @@ -156,14 +158,14 @@ def get_theme_font_for_option(theme, option): Return string description of the font, stored in theme preferences """ font_name = gajim.config.get_per('themes', theme, option) - font_desc = pango.FontDescription() + font_desc = Pango.FontDescription() font_prop_str = gajim.config.get_per('themes', theme, option + 'attrs') if font_prop_str: if font_prop_str.find('B') != -1: - font_desc.set_weight(pango.WEIGHT_BOLD) + font_desc.set_weight(Pango.Weight.BOLD) if font_prop_str.find('I') != -1: - font_desc.set_style(pango.STYLE_ITALIC) - fd = pango.FontDescription(font_name) + font_desc.set_style(Pango.Style.ITALIC) + fd = Pango.FontDescription(font_name) fd.merge(font_desc, True) return fd.to_string() @@ -188,7 +190,7 @@ def get_default_font(): if xdg_config_home == '': xdg_config_home = os.path.expanduser('~/.config') # default xfce_config_file = os.path.join(xdg_config_home, - 'xfce4/mcs_settings/gtk.xml') + 'xfce4/mcs_settings/Gtk.xml') kde_config_file = os.path.expanduser('~/.kde/share/config/kdeglobals') @@ -406,15 +408,15 @@ def get_abspath_for_script(scriptname, want_type = False): def get_pixbuf_from_data(file_data, want_type = False): """ - Get image data and returns gtk.gdk.Pixbuf if want_type is True it also + Get image data and returns GdkPixbuf.Pixbuf if want_type is True it also returns 'jpeg', 'png' etc """ - pixbufloader = gtk.gdk.PixbufLoader() + pixbufloader = GdkPixbuf.PixbufLoader() try: pixbufloader.write(file_data) pixbufloader.close() pixbuf = pixbufloader.get_pixbuf() - except gobject.GError: # 'unknown image format' + except GObject.GError: # 'unknown image format' pixbufloader.close() pixbuf = None if want_type: @@ -429,9 +431,9 @@ def get_pixbuf_from_data(file_data, want_type = False): return pixbuf def get_invisible_cursor(): - pixmap = gtk.gdk.Pixmap(None, 1, 1, 1) - color = gtk.gdk.Color() - cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0) + pixmap = Gdk.Pixmap(None, 1, 1, 1) + color = Gdk.Color() + cursor = Gdk.Cursor.new(pixmap, pixmap, color, color, 0, 0) return cursor def get_current_desktop(window): @@ -457,10 +459,16 @@ def possibly_move_window_in_current_desktop(window): NOTE: Window is a GDK window. """ + #TODO: property_get doesn't work: + #prop_atom = Gdk.Atom.intern('_NET_CURRENT_DESKTOP', False) + #type_atom = Gdk.Atom.intern("CARDINAL", False) + #w = Gdk.Screen.get_default().get_root_window() + #Gdk.property_get(w, prop_atom, type_atom, 0, 9999, False) + return False if os.name == 'nt': return False - root_window = gtk.gdk.screen_get_default().get_root_window() + root_window = Gdk.Screen.get_default().get_root_window() # current user's vd current_virtual_desktop_no = get_current_desktop(root_window) @@ -514,20 +522,20 @@ def get_fade_color(treeview, selected, focused): Get a gdk color that is between foreground and background in 0.3 0.7 respectively colors of the cell for the given treeview """ - style = treeview.style + style = treeview.get_style() if selected: if focused: # is the window focused? - state = gtk.STATE_SELECTED + state = Gtk.StateType.SELECTED else: # is it not? NOTE: many gtk themes change bg on this - state = gtk.STATE_ACTIVE + state = Gtk.StateType.ACTIVE else: - state = gtk.STATE_NORMAL + state = Gtk.StateType.NORMAL bg = style.base[state] fg = style.text[state] p = 0.3 # background q = 0.7 # foreground # p + q should do 1.0 - return gtk.gdk.Color(int(bg.red*p + fg.red*q), + return Gdk.Color(int(bg.red*p + fg.red*q), int(bg.green*p + fg.green*q), int(bg.blue*p + fg.blue*q)) @@ -557,7 +565,7 @@ def get_scaled_pixbuf(pixbuf, kind): else: h = height w = int(h * ratio) - scaled_buf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_HYPER) + scaled_buf = pixbuf.scale_simple(w, h, GdkPixbuf.InterpType.HYPER) return scaled_buf def get_avatar_pixbuf_from_cache(fjid, use_local=True): @@ -743,9 +751,9 @@ Description=xmpp gajim.config.set('check_if_gajim_is_default', False) try: - import gconf + from gi.repository import GConf # in try because daemon may not be there - client = gconf.client_get_default() + client = GConf.Client.get_default() except Exception: return @@ -786,7 +794,7 @@ def get_state_image_from_file_path_show(file_path, show): files = [] files.append(os.path.join(file_path, state_file + '.png')) files.append(os.path.join(file_path, state_file + '.gif')) - image = gtk.Image() + image = Gtk.Image() image.set_from_pixbuf(None) for file_ in files: if os.path.exists(file_): @@ -799,7 +807,7 @@ def get_possible_button_event(event): """ Mouse or keyboard caused the event? """ - if event.type == gtk.gdk.KEY_PRESS: + if event.type == Gdk.KEY_PRESS: return 0 # no event.button so pass 0 # BUTTON_PRESS event, so pass event.button return event.button @@ -870,9 +878,9 @@ def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''): dialog.destroy() dialog = dialogs.FileChooserDialog(title_text=_('Save Image as...'), - action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL, - gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK), - default_response=gtk.RESPONSE_OK, + action=Gtk.FileChooserAction.SAVE, buttons=(Gtk.STOCK_CANCEL, + Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK), + default_response=Gtk.ResponseType.OK, current_folder=gajim.config.get('last_save_dir'), on_response_ok=on_ok, on_response_cancel=on_cancel) @@ -881,16 +889,16 @@ def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''): on_cancel(widget)) def on_bm_header_changed_state(widget, event): - widget.set_state(gtk.STATE_NORMAL) #do not allow selected_state + widget.set_state(Gtk.StateType.NORMAL) #do not allow selected_state def create_combobox(value_list, selected_value = None): """ Value_list is [(label1, value1)] """ - liststore = gtk.ListStore(str, str) - combobox = gtk.ComboBox(liststore) - cell = gtk.CellRendererText() - combobox.pack_start(cell, True) + liststore = Gtk.ListStore(str, str) + combobox = Gtk.ComboBox(liststore) + cell = Gtk.CellRendererText() + combobox.pack_start(cell, True, True, 0) combobox.add_attribute(cell, 'text', 0) i = -1 for value in value_list: @@ -906,14 +914,14 @@ def create_list_multi(value_list, selected_values=None): """ Value_list is [(label1, value1)] """ - liststore = gtk.ListStore(str, str) - treeview = gtk.TreeView(liststore) - treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + liststore = Gtk.ListStore(str, str) + treeview = Gtk.TreeView(liststore) + treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) treeview.set_headers_visible(False) - col = gtk.TreeViewColumn() + col = Gtk.TreeViewColumn() treeview.append_column(col) - cell = gtk.CellRendererText() - col.pack_start(cell, True) + cell = Gtk.CellRendererText() + col.pack_start(cell, True, True, 0) col.set_attributes(cell, text=0) for value in value_list: iter = liststore.append(value) @@ -982,7 +990,7 @@ def load_icons_meta(): if not os.path.isfile(path_opened): path_opened = os.path.join(path, 'opened.png') if os.path.isfile(path_opened): - pixo = gtk.gdk.pixbuf_new_from_file(path_opened) + pixo = GdkPixbuf.Pixbuf.new_from_file(path_opened) else: pixo = None # Same thing for closed @@ -990,7 +998,7 @@ def load_icons_meta(): if not os.path.isfile(path_closed): path_closed = os.path.join(path, 'closed.png') if os.path.isfile(path_closed): - pixc = gtk.gdk.pixbuf_new_from_file(path_closed) + pixc = GdkPixbuf.Pixbuf.new_from_file(path_closed) else: pixc = None return pixo, pixc @@ -1007,19 +1015,19 @@ def _load_icon_list(icons_list, path, pixbuf2 = None): files = [] files.append(path + icon_file + '.gif') files.append(path + icon_file + '.png') - image = gtk.Image() + image = Gtk.Image() image.show() imgs[icon] = image for file_ in files: # loop seeking for either gif or png if os.path.exists(file_): image.set_from_file(file_) - if pixbuf2 and image.get_storage_type() == gtk.IMAGE_PIXBUF: + if pixbuf2 and image.get_storage_type() == Gtk.ImageType.PIXBUF: # add pixbuf2 on top-left corner of image pixbuf1 = image.get_pixbuf() pixbuf2.composite(pixbuf1, 0, 0, pixbuf2.get_property('width'), pixbuf2.get_property('height'), 0, 0, 1.0, 1.0, - gtk.gdk.INTERP_NEAREST, 255) + GdkPixbuf.InterpType.NEAREST, 255) image.set_from_pixbuf(pixbuf1) break return imgs @@ -1058,21 +1066,21 @@ def make_jabber_state_images(): else: # Resize 32x32 icons to 24x24 for each in gajim.interface.jabber_state_images['32']: - img = gtk.Image() + img = Gtk.Image() pix = gajim.interface.jabber_state_images['32'][each] pix_type = pix.get_storage_type() - if pix_type == gtk.IMAGE_ANIMATION: + if pix_type == Gtk.ImageType.ANIMATION: animation = pix.get_animation() pixbuf = animation.get_static_image() - elif pix_type == gtk.IMAGE_EMPTY: + elif pix_type == Gtk.ImageType.EMPTY: pix = gajim.interface.jabber_state_images['16'][each] pix_16_type = pix.get_storage_type() - if pix_16_type == gtk.IMAGE_ANIMATION: + if pix_16_type == Gtk.ImageType.ANIMATION: animation = pix.get_animation() pixbuf = animation.get_static_image() else: pixbuf = pix.get_pixbuf() - scaled_pix = pixbuf.scale_simple(24, 24, gtk.gdk.INTERP_BILINEAR) + scaled_pix = pixbuf.scale_simple(24, 24, GdkPixbuf.InterpType.BILINEAR) img.set_from_pixbuf(scaled_pix) gajim.interface.jabber_state_images['24'][each] = img @@ -1085,11 +1093,11 @@ def label_set_autowrap(widget): Make labels automatically re-wrap if their containers are resized. Accepts label or container widgets """ - if isinstance (widget, gtk.Container): + if isinstance (widget, Gtk.Container): children = widget.get_children() for i in xrange (len (children)): label_set_autowrap(children[i]) - elif isinstance(widget, gtk.Label): + elif isinstance(widget, Gtk.Label): widget.set_line_wrap(True) widget.connect_after('size-allocate', __label_size_allocate) @@ -1101,13 +1109,13 @@ def __label_size_allocate(widget, allocation): lw_old, lh_old = layout.get_size() # fixed width labels - if lw_old/pango.SCALE == allocation.width: + if lw_old/Pango.SCALE == allocation.width: return - # set wrap width to the pango.Layout of the labels ### + # set wrap width to the Pango.Layout of the labels ### widget.set_alignment(0.0, 0.0) - layout.set_width (allocation.width * pango.SCALE) + layout.set_width (allocation.width * Pango.SCALE) lh = layout.get_size()[1] if lh_old != lh: - widget.set_size_request (-1, lh / pango.SCALE) + widget.set_size_request (-1, lh / Pango.SCALE) diff --git a/src/gui_interface.py b/src/gui_interface.py index b16c178e8..403c95693 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -41,8 +41,9 @@ import time import math from subprocess import Popen -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import GObject from common import i18n from common import gajim @@ -228,7 +229,7 @@ class Interface: # we stop blocking notifications of any kind # this prevents from getting the roster items as 'just signed in' # contacts. 30 seconds should be enough time - gobject.timeout_add_seconds(30, + GObject.timeout_add_seconds(30, self.unblock_signed_in_notifications, account) if account in self.show_vcard_when_connect and obj.show not in ( @@ -369,7 +370,7 @@ class Interface: # popup notifications for 30s account_jid = account + '/' + jid gajim.block_signed_in_notifications[account_jid] = True - gobject.timeout_add_seconds(30, + GObject.timeout_add_seconds(30, self.unblock_signed_in_notifications, account_jid) highest = gajim.contacts.get_contact_with_highest_priority(account, jid) @@ -964,13 +965,13 @@ class Interface: # then the file is not corrupt jid = unicode(file_props.sender) if file_props.hash_ == hash_: - gobject.idle_add(self.popup_ft_result, account, jid, file_props) - gobject.idle_add(ft_win.set_status, file_props, 'ok') + GObject.idle_add(self.popup_ft_result, account, jid, file_props) + GObject.idle_add(ft_win.set_status, file_props, 'ok') else: # wrong hash, we need to get the file again! file_props.error = -10 - gobject.idle_add(self.popup_ft_result, account, jid, file_props) - gobject.idle_add(ft_win.set_status, file_props, 'hash_error') + GObject.idle_add(self.popup_ft_result, account, jid, file_props) + GObject.idle_add(ft_win.set_status, file_props, 'hash_error') # End jingle session if session: session.end_session() @@ -1109,7 +1110,7 @@ class Interface: if gajim.config.get('ask_offline_status_on_connection'): # Ask offline status in 1 minute so w'are sure we got all online # presences - gobject.timeout_add_seconds(60, self.ask_offline_status, account) + GObject.timeout_add_seconds(60, self.ask_offline_status, account) if state != common.sleepy.STATE_UNKNOWN and connected in (2, 3): # we go online or free for chat, so we activate auto status gajim.sleeper_state[account] = 'online' @@ -1757,7 +1758,7 @@ class Interface: self.roster.draw_contact(jid, account) if w: w.set_active_tab(ctrl) - w.window.window.focus(gtk.get_current_event_time()) + w.window.window.focus(Gtk.get_current_event_time()) # Using isinstance here because we want to catch all derived types if isinstance(ctrl, ChatControlBase): tv = ctrl.conv_textview @@ -1770,13 +1771,13 @@ class Interface: def image_is_ok(self, image): if not os.path.exists(image): return False - img = gtk.Image() + img = Gtk.Image() try: img.set_from_file(image) except Exception: return False t = img.get_storage_type() - if t != gtk.IMAGE_PIXBUF and t != gtk.IMAGE_ANIMATION: + if t != Gtk.ImageType.PIXBUF and t != Gtk.ImageType.ANIMATION: return False return True @@ -1874,7 +1875,6 @@ class Interface: emoticons_pattern_postmatch = '' emoticon_length = 0 for emoticon in keys: # travel thru emoticons list - emoticon = emoticon.decode('utf-8') emoticon_escaped = re.escape(emoticon) # espace regexp metachars # | means or in regexp emoticons_pattern += emoticon_escaped + '|' @@ -1917,7 +1917,7 @@ class Interface: button, parent_win) def prepare_emoticons_menu(self): - menu = gtk.Menu() + menu = Gtk.Menu() def emoticon_clicked(w, str_): if self.emoticon_menuitem_clicked: self.emoticon_menuitem_clicked(str_) @@ -1932,12 +1932,14 @@ class Interface: # Calculate the side lenght of the popup to make it a square size = int(round(math.sqrt(len(self.emoticons_images)))) for image in self.emoticons_images: - item = gtk.MenuItem() - img = gtk.Image() - if isinstance(image[1], gtk.gdk.PixbufAnimation): + item = Gtk.MenuItem() + img = Gtk.Image() + if isinstance(image[1], GdkPixbuf.PixbufAnimation): img.set_from_animation(image[1]) else: img.set_from_pixbuf(image[1]) + c = item.get_child() + item.remove(c) item.add(img) item.connect('activate', emoticon_clicked, image[0]) # add tooltip with ascii @@ -1972,9 +1974,9 @@ class Interface: # and :-) if not emot_file in self.emoticons.values(): if emot_file.endswith('.gif'): - pix = gtk.gdk.PixbufAnimation(emot_file) + pix = GdkPixbuf.PixbufAnimation.new_from_file(emot_file) else: - pix = gtk.gdk.pixbuf_new_from_file_at_size(emot_file, + pix = GdkPixbuf.Pixbuf.new_from_file_at_size(emot_file, 16, 16) self.emoticons_images.append((emot, pix)) self.emoticons[emot.upper()] = emot_file @@ -2187,7 +2189,7 @@ class Interface: # For JEP-0172 if added_to_roster: ctrl.user_nick = gajim.nicks[account] - gobject.idle_add(mw.window.grab_focus) + GObject.idle_add(mw.window.grab_focus) return ctrl @@ -2307,11 +2309,11 @@ class Interface: return format_rgb (*gdkcolor_to_rgb (gdkcolor)) # get style colors and create string for dvipng - dummy = gtk.Invisible() + dummy = Gtk.Invisible() dummy.ensure_style() style = dummy.get_style() - bg_str = format_gdkcolor(style.base[gtk.STATE_NORMAL]) - fg_str = format_gdkcolor(style.text[gtk.STATE_NORMAL]) + bg_str = format_gdkcolor(style.base[Gtk.StateType.NORMAL]) + fg_str = format_gdkcolor(style.text[Gtk.StateType.NORMAL]) return (bg_str, fg_str) def get_fg_color(self, fmt='hex'): @@ -2323,9 +2325,9 @@ class Interface: return str(c) # get foreground style color and create string - dummy = gtk.Invisible() + dummy = Gtk.Invisible() dummy.ensure_style() - return format_gdkcolor(dummy.get_style().text[gtk.STATE_NORMAL]) + return format_gdkcolor(dummy.get_style().text[Gtk.StateType.NORMAL]) def read_sleepy(self): """ @@ -2435,9 +2437,9 @@ class Interface: # Otherwise, an exception will stop our loop timeout, in_seconds = gajim.idlequeue.PROCESS_TIMEOUT if in_seconds: - gobject.timeout_add_seconds(timeout, self.process_connections) + GObject.timeout_add_seconds(timeout, self.process_connections) else: - gobject.timeout_add(timeout, self.process_connections) + GObject.timeout_add(timeout, self.process_connections) raise return True # renew timeout (loop for ever) @@ -2608,21 +2610,21 @@ class Interface: except ImportError: print 'ipython_view not found' return - import pango + from gi.repository import Pango if os.name == 'nt': font = 'Lucida Console 9' else: font = 'Luxi Mono 10' - window = gtk.Window() + window = Gtk.Window() window.set_size_request(750, 550) window.set_resizable(True) - sw = gtk.ScrolledWindow() - sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + sw = Gtk.ScrolledWindow() + sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) view = IPythonView() - view.modify_font(pango.FontDescription(font)) - view.set_wrap_mode(gtk.WRAP_CHAR) + view.modify_font(Pango.FontDescription(font)) + view.set_wrap_mode(Gtk.WrapMode.CHAR) sw.add(view) window.add(sw) window.show_all() @@ -2650,18 +2652,18 @@ class Interface: # get instances for windows/dialogs that will show_all()/hide() self.instances['file_transfers'] = dialogs.FileTransfersWindow() - gobject.timeout_add(100, self.autoconnect) + GObject.timeout_add(100, self.autoconnect) timeout, in_seconds = gajim.idlequeue.PROCESS_TIMEOUT if in_seconds: - gobject.timeout_add_seconds(timeout, self.process_connections) + GObject.timeout_add_seconds(timeout, self.process_connections) else: - gobject.timeout_add(timeout, self.process_connections) - gobject.timeout_add_seconds(gajim.config.get( + GObject.timeout_add(timeout, self.process_connections) + GObject.timeout_add_seconds(gajim.config.get( 'check_idle_every_foo_seconds'), self.read_sleepy) # when using libasyncns we need to process resolver in regular intervals if resolver.USE_LIBASYNCNS: - gobject.timeout_add(200, gajim.resolver.process) + GObject.timeout_add(200, gajim.resolver.process) def remote_init(): if gajim.config.get('remote_control'): @@ -2670,7 +2672,7 @@ class Interface: self.remote_ctrl = remote_control.Remote() except Exception: pass - gobject.timeout_add_seconds(5, remote_init) + GObject.timeout_add_seconds(5, remote_init) def __init__(self): gajim.interface = self @@ -2730,8 +2732,8 @@ class Interface: break # Is gnome configured to activate row on single click ? try: - import gconf - client = gconf.client_get_default() + from gi.repository import GConf + client = GConf.Client.get_default() click_policy = client.get_string( '/apps/nautilus/preferences/click_policy') if click_policy == 'single': @@ -2814,9 +2816,9 @@ class Interface: gajim.connections[account] = Connection(account) # gtk hooks - gtk.about_dialog_set_email_hook(self.on_launch_browser_mailer, 'mail') - gtk.about_dialog_set_url_hook(self.on_launch_browser_mailer, 'url') - gtk.link_button_set_uri_hook(self.on_launch_browser_mailer, 'url') +# Gtk.about_dialog_set_email_hook(self.on_launch_browser_mailer, 'mail') +# Gtk.about_dialog_set_url_hook(self.on_launch_browser_mailer, 'url') +# Gtk.link_button_set_uri_hook(self.on_launch_browser_mailer, 'url') self.instances = {} @@ -2928,7 +2930,7 @@ class Interface: pixs.append(pix) if pixs: # set the icon to all windows - gtk.window_set_default_icon_list(*pixs) + Gtk.Window.set_default_icon_list(pixs) self.init_emoticons() self.make_regexps() @@ -2941,7 +2943,7 @@ class Interface: lang = gajim.config.get('speller_language') if not lang: lang = gajim.LANG - tv = gtk.TextView() + tv = Gtk.TextView() try: import gtkspell spell = gtkspell.Spell(tv, lang) @@ -2998,7 +3000,7 @@ class PassphraseRequest: self.passphrase = passphrase self.completed = True if passphrase is not None: - gobject.timeout_add_seconds(30, + GObject.timeout_add_seconds(30, gajim.interface.forget_gpg_passphrase, self.keyid) for (account, cb) in self.callbacks: self.run_callback(account, cb) @@ -3050,7 +3052,7 @@ class ThreadInterface: def thread_function(func, func_args, callback, callback_args): output = func(*func_args) if callback: - gobject.idle_add(callback, output, *callback_args) + GObject.idle_add(callback, output, *callback_args) Thread(target=thread_function, args=(func, func_args, callback, callback_args)).start() diff --git a/src/gui_menu_builder.py b/src/gui_menu_builder.py index 7d9d3a8e9..e968c513c 100644 --- a/src/gui_menu_builder.py +++ b/src/gui_menu_builder.py @@ -18,7 +18,7 @@ ## along with Gajim. If not, see . ## -import gtk +from gi.repository import Gtk import os import gtkgui_helpers import message_control @@ -35,7 +35,7 @@ def build_resources_submenu(contacts, account, action, room_jid=None, action self.on_invite_to_room """ roster = gajim.interface.roster - sub_menu = gtk.Menu() + sub_menu = Gtk.Menu() iconset = gajim.config.get('iconset') if not iconset: @@ -44,7 +44,7 @@ def build_resources_submenu(contacts, account, action, room_jid=None, for c in contacts: # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - item = gtk.ImageMenuItem('%s (%s)' % (c.resource, str(c.priority))) + item = Gtk.ImageMenuItem('%s (%s)' % (c.resource, str(c.priority))) icon_name = helpers.get_icon_name_to_show(c, account) icon = state_images[icon_name] item.set_image(icon) @@ -89,10 +89,10 @@ def build_invite_submenu(invite_menuitem, list_, ignore_rooms=[]): # they are not all from the same transport invite_menuitem.set_sensitive(False) return - invite_to_submenu = gtk.Menu() + invite_to_submenu = Gtk.Menu() invite_menuitem.set_submenu(invite_to_submenu) - invite_to_new_room_menuitem = gtk.ImageMenuItem(_('_New Group Chat')) - icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU) + invite_to_new_room_menuitem = Gtk.ImageMenuItem(_('_New Group Chat')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU) invite_to_new_room_menuitem.set_image(icon) if len(contact_list) > 1: # several resources invite_to_new_room_menuitem.set_submenu(build_resources_submenu( @@ -136,10 +136,10 @@ def build_invite_submenu(invite_menuitem, list_, ignore_rooms=[]): contacts_transport == gajim.get_transport_name_from_jid(room_jid): rooms.append((room_jid, acct)) if len(rooms): - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator invite_to_submenu.append(item) for (room_jid, account) in rooms: - menuitem = gtk.MenuItem(room_jid.split('@')[0]) + menuitem = Gtk.MenuItem(room_jid.split('@')[0]) if len(contact_list) > 1: # several resources menuitem.set_submenu(build_resources_submenu( contact_list, account, roster.on_invite_to_room, room_jid, @@ -207,7 +207,7 @@ control=None, gc_contact=None, is_anonymous=True): # add a special img for send file menuitem path_to_upload_img = gtkgui_helpers.get_icon_path('gajim-upload') - img = gtk.Image() + img = Gtk.Image() img.set_from_file(path_to_upload_img) send_file_menuitem.set_image(img) @@ -373,7 +373,7 @@ control=None, gc_contact=None, is_anonymous=True): send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon( gajim.interface.status_sent_to_users[account][jid])) else: - icon = gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NETWORK, Gtk.IconSize.MENU) send_custom_status_menuitem.set_image(icon) muc_icon = gtkgui_helpers.load_icon('muc_active') @@ -393,14 +393,14 @@ control=None, gc_contact=None, is_anonymous=True): invite_menuitem.set_sensitive(False) # One or several resource, we do the same for send_custom_status - status_menuitems = gtk.Menu() + status_menuitems = Gtk.Menu() send_custom_status_menuitem.set_submenu(status_menuitems) iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) + status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s)) status_menuitem.connect('activate', roster.on_send_custom_status, [(contact, account)], s) icon = state_images[s] diff --git a/src/history_manager.py b/src/history_manager.py index b1d007826..4b9292590 100644 --- a/src/history_manager.py +++ b/src/history_manager.py @@ -49,8 +49,8 @@ if os.name == 'nt': import sys import signal -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject import time import locale @@ -110,7 +110,7 @@ class HistoryManager: def __init__(self): pix = gtkgui_helpers.get_icon_pixmap('gajim') # set the icon to all newly opened windows - gtk.window_set_default_icon(pix) + Gtk.window_set_default_icon(pix) if not os.path.exists(LOG_DB_PATH): dialogs.ErrorDialog(_('Cannot find history logs database'), @@ -148,12 +148,12 @@ class HistoryManager: xml.connect_signals(self) def _init_jids_listview(self): - self.jids_liststore = gtk.ListStore(str, str) # jid, jid_id + self.jids_liststore = Gtk.ListStore(str, str) # jid, jid_id self.jids_listview.set_model(self.jids_liststore) - self.jids_listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + self.jids_listview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) - renderer_text = gtk.CellRendererText() # holds jid - col = gtk.TreeViewColumn(_('Jabber ID'), renderer_text, text=0) + renderer_text = Gtk.CellRendererText() # holds jid + col = Gtk.TreeViewColumn(_('Jabber ID'), renderer_text, text=0) self.jids_listview.append_column(col) self.jids_listview.get_selection().connect('changed', @@ -161,19 +161,19 @@ class HistoryManager: def _init_logs_listview(self): # log_line_id(HIDDEN), jid_id(HIDDEN), time, message, subject, nickname - self.logs_liststore = gtk.ListStore(str, str, str, str, str, str) + self.logs_liststore = Gtk.ListStore(str, str, str, str, str, str) self.logs_listview.set_model(self.logs_liststore) - self.logs_listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + self.logs_listview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) - renderer_text = gtk.CellRendererText() # holds time - col = gtk.TreeViewColumn(_('Date'), renderer_text, text=C_UNIXTIME) + renderer_text = Gtk.CellRendererText() # holds time + col = Gtk.TreeViewColumn(_('Date'), renderer_text, text=C_UNIXTIME) # user can click this header and sort col.set_sort_column_id(C_UNIXTIME) col.set_resizable(True) self.logs_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds nickname - col = gtk.TreeViewColumn(_('Nickname'), renderer_text, text=C_NICKNAME) + renderer_text = Gtk.CellRendererText() # holds nickname + col = Gtk.TreeViewColumn(_('Nickname'), renderer_text, text=C_NICKNAME) # user can click this header and sort col.set_sort_column_id(C_NICKNAME) col.set_resizable(True) @@ -181,16 +181,16 @@ class HistoryManager: self.nickname_col_for_logs = col self.logs_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds message - col = gtk.TreeViewColumn(_('Message'), renderer_text, markup=C_MESSAGE) + renderer_text = Gtk.CellRendererText() # holds message + col = Gtk.TreeViewColumn(_('Message'), renderer_text, markup=C_MESSAGE) # user can click this header and sort col.set_sort_column_id(C_MESSAGE) col.set_resizable(True) self.message_col_for_logs = col self.logs_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds subject - col = gtk.TreeViewColumn(_('Subject'), renderer_text, text=C_SUBJECT) + renderer_text = Gtk.CellRendererText() # holds subject + col = Gtk.TreeViewColumn(_('Subject'), renderer_text, text=C_SUBJECT) col.set_sort_column_id(C_SUBJECT) # user can click this header and sort col.set_resizable(True) col.set_visible(False) @@ -199,37 +199,37 @@ class HistoryManager: def _init_search_results_listview(self): # log_line_id (HIDDEN), jid, time, message, subject, nickname - self.search_results_liststore = gtk.ListStore(str, str, str, str, str, + self.search_results_liststore = Gtk.ListStore(str, str, str, str, str, str) self.search_results_listview.set_model(self.search_results_liststore) - renderer_text = gtk.CellRendererText() # holds JID (who said this) - col = gtk.TreeViewColumn(_('JID'), renderer_text, text=1) + renderer_text = Gtk.CellRendererText() # holds JID (who said this) + col = Gtk.TreeViewColumn(_('JID'), renderer_text, text=1) col.set_sort_column_id(1) # user can click this header and sort col.set_resizable(True) self.search_results_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds time - col = gtk.TreeViewColumn(_('Date'), renderer_text, text=C_UNIXTIME) + renderer_text = Gtk.CellRendererText() # holds time + col = Gtk.TreeViewColumn(_('Date'), renderer_text, text=C_UNIXTIME) # user can click this header and sort col.set_sort_column_id(C_UNIXTIME) col.set_resizable(True) self.search_results_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds message - col = gtk.TreeViewColumn(_('Message'), renderer_text, text=C_MESSAGE) + renderer_text = Gtk.CellRendererText() # holds message + col = Gtk.TreeViewColumn(_('Message'), renderer_text, text=C_MESSAGE) col.set_sort_column_id(C_MESSAGE) # user can click this header and sort col.set_resizable(True) self.search_results_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds subject - col = gtk.TreeViewColumn(_('Subject'), renderer_text, text=C_SUBJECT) + renderer_text = Gtk.CellRendererText() # holds subject + col = Gtk.TreeViewColumn(_('Subject'), renderer_text, text=C_SUBJECT) col.set_sort_column_id(C_SUBJECT) # user can click this header and sort col.set_resizable(True) self.search_results_listview.append_column(col) - renderer_text = gtk.CellRendererText() # holds nickname - col = gtk.TreeViewColumn(_('Nickname'), renderer_text, text=C_NICKNAME) + renderer_text = Gtk.CellRendererText() # holds nickname + col = Gtk.TreeViewColumn(_('Nickname'), renderer_text, text=C_NICKNAME) # user can click this header and sort col.set_sort_column_id(C_NICKNAME) col.set_resizable(True) @@ -237,16 +237,16 @@ class HistoryManager: def on_history_manager_window_delete_event(self, widget, event): if not self.AT_LEAST_ONE_DELETION_DONE: - gtk.main_quit() + Gtk.main_quit() return def on_yes(clicked): self.cur.execute('VACUUM') self.con.commit() - gtk.main_quit() + Gtk.main_quit() def on_no(): - gtk.main_quit() + Gtk.main_quit() dialog = dialogs.YesNoDialog( _('Do you want to clean up the database? ' @@ -285,7 +285,7 @@ class HistoryManager: list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) - list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) + list_of_rowrefs.append(Gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: # FILL THE STORE, for all rows selected path = rowref.get_path() @@ -413,7 +413,7 @@ class HistoryManager: if color: message_ += ' foreground="%s"' % color message_ += '>%s' % \ - gobject.markup_escape_text(message) + GObject.markup_escape_text(message) self.logs_liststore.append((log_line_id, jid_id, time_, message_, subject, nickname)) @@ -451,7 +451,7 @@ class HistoryManager: def on_logs_listview_key_press_event(self, widget, event): liststore, list_of_paths = self.logs_listview.get_selection()\ .get_selected_rows() - if event.keyval == gtk.keysyms.Delete: + if event.keyval == Gdk.KEY_Delete: self._delete_logs(liststore, list_of_paths) def on_listview_button_press_event(self, widget, event): @@ -479,7 +479,7 @@ class HistoryManager: dlg.props.do_overwrite_confirmation = True response = dlg.run() - if response == gtk.RESPONSE_OK: # user want us to export ;) + if response == Gtk.ResponseType.OK: # user want us to export ;) liststore, list_of_paths = self.jids_listview.get_selection()\ .get_selected_rows() path_to_file = dlg.get_filename() @@ -489,7 +489,7 @@ class HistoryManager: dlg.destroy() def on_delete_menuitem_activate(self, widget, listview): - widget_name = gtk.Buildable.get_name(listview) + widget_name = Gtk.Buildable.get_name(listview) liststore, list_of_paths = listview.get_selection().get_selected_rows() if widget_name == 'jids_listview': self._delete_jid_logs(liststore, list_of_paths) @@ -501,7 +501,7 @@ class HistoryManager: def on_jids_listview_key_press_event(self, widget, event): liststore, list_of_paths = self.jids_listview.get_selection()\ .get_selected_rows() - if event.keyval == gtk.keysyms.Delete: + if event.keyval == Gdk.KEY_Delete: self._delete_jid_logs(liststore, list_of_paths) def _export_jids_logs_to_file(self, liststore, list_of_paths, path_to_file): @@ -511,7 +511,7 @@ class HistoryManager: list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) - list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) + list_of_rowrefs.append(Gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: path = rowref.get_path() @@ -563,7 +563,7 @@ class HistoryManager: # delete all rows from db that match jid_id list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) - list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) + list_of_rowrefs.append(Gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: path = rowref.get_path() @@ -612,7 +612,7 @@ class HistoryManager: # delete rows from db that match log_line_id list_of_rowrefs = [] for path in list_of_paths: # make them treerowrefs (it's needed) - list_of_rowrefs.append(gtk.TreeRowReference(liststore, path)) + list_of_rowrefs.append(Gtk.TreeRowReference(liststore, path)) for rowref in list_of_rowrefs: path = rowref.get_path() @@ -660,7 +660,7 @@ class HistoryManager: # as this is what db returns so I don't have to fight with types jid_id = self._get_jid_id(jid) - iter_ = self.jids_liststore.get_iter_root() + iter_ = self.jids_liststore.get_iter_first() while iter_: # self.jids_liststore[iter_][1] holds jid_ids if self.jids_liststore[iter_][1] == jid_id: @@ -673,7 +673,7 @@ class HistoryManager: path = self.jids_liststore.get_path(iter_) self.jids_listview.set_cursor(path) - iter_ = self.logs_liststore.get_iter_root() + iter_ = self.logs_liststore.get_iter_first() while iter_: # self.logs_liststore[iter_][0] holds lon_line_ids if self.logs_liststore[iter_][0] == log_line_id: @@ -686,4 +686,4 @@ class HistoryManager: if __name__ == '__main__': signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application HistoryManager() - gtk.main() + Gtk.main() diff --git a/src/history_window.py b/src/history_window.py index c458c65af..a774b83b0 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -25,8 +25,8 @@ ## along with Gajim. If not, see . ## -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject import time import calendar @@ -78,7 +78,7 @@ class HistoryWindow: self.on_log_history_checkbutton_toggled) self.query_entry = xml.get_object('query_entry') self.query_combobox = xml.get_object('query_combobox') - self.jid_entry = self.query_combobox.child + self.jid_entry = self.query_combobox.get_child() self.jid_entry.connect('activate', self.on_jid_entry_activate) self.query_combobox.set_active(0) self.results_treeview = xml.get_object('results_treeview') @@ -86,28 +86,28 @@ class HistoryWindow: self.search_in_date = xml.get_object('search_in_date') # contact_name, date, message, time - model = gtk.ListStore(str, str, str, str, str) + model = Gtk.ListStore(str, str, str, str, str) self.results_treeview.set_model(model) - col = gtk.TreeViewColumn(_('Name')) + col = Gtk.TreeViewColumn(_('Name')) self.results_treeview.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = C_CONTACT_NAME) col.set_sort_column_id(C_CONTACT_NAME) # user can click this header and sort col.set_resizable(True) - col = gtk.TreeViewColumn(_('Date')) + col = Gtk.TreeViewColumn(_('Date')) self.results_treeview.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = C_UNIXTIME) col.set_sort_column_id(C_UNIXTIME) # user can click this header and sort col.set_resizable(True) - col = gtk.TreeViewColumn(_('Message')) + col = Gtk.TreeViewColumn(_('Message')) self.results_treeview.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer) + renderer = Gtk.CellRendererText() + col.pack_start(renderer, True, True, 0) col.set_attributes(renderer, text = C_MESSAGE) col.set_resizable(True) @@ -118,7 +118,7 @@ class HistoryWindow: self.jids_to_search = [] # This will load history too - gobject.idle_add(self._fill_completion_dict().next) + GObject.idle_add(self._fill_completion_dict().next) if jid: self.jid_entry.set_text(jid) @@ -231,7 +231,7 @@ class HistoryWindow: del gajim.interface.instances['logs'] def on_history_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.save_state() self.window.destroy() @@ -605,7 +605,7 @@ class HistoryWindow: timestamp_str = gajim.config.get('time_stamp') timestamp_str = helpers.from_one_line(timestamp_str) tim = time.strftime(timestamp_str, local_time) - result = start_iter.forward_search(tim, gtk.TEXT_SEARCH_VISIBLE_ONLY, + result = start_iter.forward_search(tim, Gtk.TextSearchFlags.VISIBLE_ONLY, None) if result is not None: match_start_iter, match_end_iter = result @@ -641,7 +641,7 @@ class HistoryWindow: self.jid_entry.set_text(jid) if account and account not in self.accounts_seen_online: # Update dict to not only show bare jid - gobject.idle_add(self._fill_completion_dict().next) + GObject.idle_add(self._fill_completion_dict().next) else: # Only in that case because it's called by self._fill_completion_dict() # otherwise diff --git a/src/htmltextview.py b/src/htmltextview.py index 981dc5531..3b31e6da9 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -26,7 +26,7 @@ ## """ -A gtk.TextView-based renderer for XHTML-IM, as described in: +A Gtk.TextView-based renderer for XHTML-IM, as described in: http://xmpp.org/extensions/xep-0071.html Starting with the version posted by Gustavo Carneiro, @@ -35,9 +35,11 @@ with the markup that docutils generate, and also more modular. """ -import gobject -import pango -import gtk +from gi.repository import GObject +from gi.repository import Pango +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GdkPixbuf import xml.sax, xml.sax.handler import re from cStringIO import StringIO @@ -64,8 +66,8 @@ whitespace_rx = re.compile('\\s+') allwhitespace_rx = re.compile('^\\s*$') # pixels = points * display_resolution -display_resolution = 0.3514598*(gtk.gdk.screen_height() / - float(gtk.gdk.screen_height_mm())) +display_resolution = 0.3514598*(Gdk.Screen.height() / + float(Gdk.Screen.height_mm())) # embryo of CSS classes classes = { @@ -194,9 +196,9 @@ for name in BLOCK_HEAD: def _parse_css_color(color): if color.startswith('rgb(') and color.endswith(')'): r, g, b = [int(c)*257 for c in color[4:-1].split(',')] - return gtk.gdk.Color(r, g, b) + return Gdk.Color(r, g, b) else: - return gtk.gdk.color_parse(color) + return Gdk.color_parse(color) def style_iter(style): return ([x.strip() for x in item.split(':', 1)] for item in style.split(';')\ @@ -219,7 +221,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): self.text = '' self.starting=True self.preserve = False - self.styles = [] # a gtk.TextTag or None, for each span level + self.styles = [] # a Gtk.TextTag or None, for each span level self.list_counters = [] # stack (top at head) of list # counters, or None for unordered list @@ -258,7 +260,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): frac = val/100 if font_relative: attrs = self._get_current_attributes() - font_size = attrs.font.get_size() / pango.SCALE + font_size = attrs.font.get_size() / Pango.SCALE callback(frac*display_resolution*font_size, *args) elif block_relative: # CSS says 'Percentage values: refer to width of the closest @@ -285,14 +287,14 @@ class HtmlHandler(xml.sax.handler.ContentHandler): elif value.endswith('em'): # ems, the width of the element's font attrs = self._get_current_attributes() - font_size = attrs.font.get_size() / pango.SCALE + font_size = attrs.font.get_size() / Pango.SCALE callback(get_val()*display_resolution*font_size, *args) elif value.endswith('ex'): # x-height, ~ the height of the letter 'x' # FIXME: figure out how to calculate this correctly # for now 'em' size is used as approximation attrs = self._get_current_attributes() - font_size = attrs.font.get_size() / pango.SCALE + font_size = attrs.font.get_size() / Pango.SCALE callback(get_val()*display_resolution*font_size, *args) elif value.endswith('px'): # pixels @@ -321,13 +323,13 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def _parse_style_font_size(self, tag, value): try: scale = { - 'xx-small': pango.SCALE_XX_SMALL, - 'x-small': pango.SCALE_X_SMALL, - 'small': pango.SCALE_SMALL, - 'medium': pango.SCALE_MEDIUM, - 'large': pango.SCALE_LARGE, - 'x-large': pango.SCALE_X_LARGE, - 'xx-large': pango.SCALE_XX_LARGE, + 'xx-small': Pango.SCALE_XX_SMALL, + 'x-small': Pango.SCALE_X_SMALL, + 'small': Pango.SCALE_SMALL, + 'medium': Pango.SCALE_MEDIUM, + 'large': Pango.SCALE_LARGE, + 'x-large': Pango.SCALE_X_LARGE, + 'xx-large': Pango.SCALE_XX_LARGE, } [value] except KeyError: pass @@ -336,10 +338,10 @@ class HtmlHandler(xml.sax.handler.ContentHandler): tag.set_property('scale', scale / attrs.font_scale) return if value == 'smaller': - tag.set_property('scale', pango.SCALE_SMALL) + tag.set_property('scale', Pango.SCALE_SMALL) return if value == 'larger': - tag.set_property('scale', pango.SCALE_LARGE) + tag.set_property('scale', Pango.SCALE_LARGE) return # font relative (5 ~ 4pt, 110 ~ 72pt) self._parse_length(value, True, False, 5, 110,self.__parse_font_size_cb, @@ -348,9 +350,9 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def _parse_style_font_style(self, tag, value): try: style = { - 'normal': pango.STYLE_NORMAL, - 'italic': pango.STYLE_ITALIC, - 'oblique': pango.STYLE_OBLIQUE, + 'normal': Pango.Style.NORMAL, + 'italic': Pango.Style.ITALIC, + 'oblique': Pango.Style.OBLIQUE, } [value] except KeyError: log.warning('unknown font-style %s' % value) @@ -378,17 +380,17 @@ class HtmlHandler(xml.sax.handler.ContentHandler): # TODO: missing 'bolder' and 'lighter' try: weight = { - '100': pango.WEIGHT_ULTRALIGHT, - '200': pango.WEIGHT_ULTRALIGHT, - '300': pango.WEIGHT_LIGHT, - '400': pango.WEIGHT_NORMAL, - '500': pango.WEIGHT_NORMAL, - '600': pango.WEIGHT_BOLD, - '700': pango.WEIGHT_BOLD, - '800': pango.WEIGHT_ULTRABOLD, - '900': pango.WEIGHT_HEAVY, - 'normal': pango.WEIGHT_NORMAL, - 'bold': pango.WEIGHT_BOLD, + '100': Pango.Weight.ULTRALIGHT, + '200': Pango.Weight.ULTRALIGHT, + '300': Pango.Weight.LIGHT, + '400': Pango.Weight.NORMAL, + '500': Pango.Weight.NORMAL, + '600': Pango.Weight.BOLD, + '700': Pango.Weight.BOLD, + '800': Pango.Weight.ULTRABOLD, + '900': Pango.Weight.HEAVY, + 'normal': Pango.Weight.NORMAL, + 'bold': Pango.Weight.BOLD, } [value] except KeyError: log.warning('unknown font-style %s' % value) @@ -401,10 +403,10 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def _parse_style_text_align(self, tag, value): try: align = { - 'left': gtk.JUSTIFY_LEFT, - 'right': gtk.JUSTIFY_RIGHT, - 'center': gtk.JUSTIFY_CENTER, - 'justify': gtk.JUSTIFY_FILL, + 'left': Gtk.Justification.LEFT, + 'right': Gtk.Justification.RIGHT, + 'center': Gtk.Justification.CENTER, + 'justify': Gtk.Justification.FILL, } [value] except KeyError: log.warning('Invalid text-align:%s requested' % value) @@ -414,12 +416,12 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def _parse_style_text_decoration(self, tag, value): values = value.split(' ') if 'none' in values: - tag.set_property('underline', pango.UNDERLINE_NONE) + tag.set_property('underline', Pango.Underline.NONE) tag.set_property('strikethrough', False) if 'underline' in values: - tag.set_property('underline', pango.UNDERLINE_SINGLE) + tag.set_property('underline', Pango.Underline.SINGLE) else: - tag.set_property('underline', pango.UNDERLINE_NONE) + tag.set_property('underline', Pango.Underline.NONE) if 'line-through' in values: tag.set_property('strikethrough', True) else: @@ -431,11 +433,11 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def _parse_style_white_space(self, tag, value): if value == 'pre': - tag.set_property('wrap_mode', gtk.WRAP_NONE) + tag.set_property('wrap_mode', Gtk.WrapMode.NONE) elif value == 'normal': - tag.set_property('wrap_mode', gtk.WRAP_WORD) + tag.set_property('wrap_mode', Gtk.WrapMode.WORD) elif value == 'nowrap': - tag.set_property('wrap_mode', gtk.WRAP_NONE) + tag.set_property('wrap_mode', Gtk.WrapMode.NONE) def __length_tag_cb(self, value, tag, propname): try: @@ -483,7 +485,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): tag.type_ = type_ # to be used by the URL handler tag.connect('event', self.textview.hyperlink_handler, 'url') tag.set_property('foreground', gajim.config.get('urlmsgcolor')) - tag.set_property('underline', pango.UNDERLINE_SINGLE) + tag.set_property('underline', Pango.Underline.SINGLE) tag.is_anchor = True if title: tag.title = title @@ -525,7 +527,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): # Caveat: GdkPixbuf is known not to be safe to load # images from network... this program is now potentially # hackable ;) - loader = gtk.gdk.PixbufLoader() + loader = GdkPixbuf.PixbufLoader() dims = [0, 0] def height_cb(length): dims[1] = length @@ -548,7 +550,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): """ FIXME: Floats should be relative to the whole textview, and resize with it. This needs new pifbufs for every resize, - gtk.gdk.Pixbuf.scale_simple or similar. + GdkPixbuf.Pixbuf.scale_simple or similar. """ if isinstance(dims[0], float): dims[0] = int(dims[0]*w) @@ -647,7 +649,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): self._insert_text(text.strip('\n')) def _anchor_event(self, tag, textview, event, iter_, href, type_): - if event.type == gtk.gdk.BUTTON_PRESS: + if event.type == Gdk.EventType.BUTTON_PRESS: self.textview.emit('url-clicked', href, type_) return True return False @@ -792,11 +794,11 @@ class HtmlHandler(xml.sax.handler.ContentHandler): self._jump_line() self._end_span() -class HtmlTextView(gtk.TextView): +class HtmlTextView(Gtk.TextView): def __init__(self): - gobject.GObject.__init__(self) - self.set_wrap_mode(gtk.WRAP_CHAR) + GObject.GObject.__init__(self) + self.set_wrap_mode(Gtk.WrapMode.CHAR) self.set_editable(False) self._changed_cursor = False self.connect('destroy', self.__destroy_event) @@ -808,7 +810,8 @@ class HtmlTextView(gtk.TextView): self.connect('copy-clipboard', self.on_html_text_view_copy_clipboard) self.id_ = self.connect('button-release-event', self.on_left_mouse_button_release) - self.get_buffer().create_tag('eol', scale = pango.SCALE_XX_SMALL) + #Pango.SCALE_XX_SMALL) + self.get_buffer().create_tag('eol', scale=0.5787037037037) self.tooltip = tooltips.BaseTooltip() self.config = gajim.config self.interface = gajim.interface @@ -820,15 +823,15 @@ class HtmlTextView(gtk.TextView): def __leave_event(self, widget, event): if self._changed_cursor: - window = widget.get_window(gtk.TEXT_WINDOW_TEXT) - window.set_cursor(gtk.gdk.Cursor(gtk.gdk.XTERM)) + window = widget.get_window(Gtk.TextWindowType.TEXT) + window.set_cursor(Gdk.Cursor.new(Gdk.XTERM)) self._changed_cursor = False def show_tooltip(self, tag): if not self.tooltip.win: # check if the current pointer is still over the line - x, y, _ = self.window.get_pointer() - x, y = self.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y) + x, y = self.get_window(Gtk.TextWindowType.TEXT).get_pointer()[1:3] + x, y = self.window_to_buffer_coords(Gtk.TextWindowType.TEXT, x, y) tags = self.get_iter_at_location(x, y).get_tags() is_over_anchor = False for tag_ in tags: @@ -840,12 +843,12 @@ class HtmlTextView(gtk.TextView): text = getattr(tag, 'title', False) if text: pointer = self.get_pointer() - position = self.window.get_origin() - self.tooltip.show_tooltip(text, 8, position[1] + pointer[1]) + position = self.get_window(Gtk.TextWindowType.TEXT).get_origin() + self.tooltip.show_tooltip(text, 8, position[1] + pointer[2]) def __motion_notify_event(self, widget, event): - x, y, _ = widget.window.get_pointer() - x, y = widget.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y) + x, y = widget.get_window(Gtk.TextWindowType.TEXT).get_pointer()[1:3] + x, y = widget.window_to_buffer_coords(Gtk.TextWindowType.TEXT, x, y) tags = widget.get_iter_at_location(x, y).get_tags() anchor_tags = [tag for tag in tags if getattr(tag, 'is_anchor', False)] if self.tooltip.timeout != 0: @@ -853,14 +856,14 @@ class HtmlTextView(gtk.TextView): if not anchor_tags: self.tooltip.hide_tooltip() if not self._changed_cursor and anchor_tags: - window = widget.get_window(gtk.TEXT_WINDOW_TEXT) - window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2)) + window = widget.get_window(Gtk.TextWindowType.TEXT) + window.set_cursor(Gdk.Cursor.new(Gdk.HAND2)) self._changed_cursor = True - self.tooltip.timeout = gobject.timeout_add(500, self.show_tooltip, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, anchor_tags[0]) elif self._changed_cursor and not anchor_tags: - window = widget.get_window(gtk.TEXT_WINDOW_TEXT) - window.set_cursor(gtk.gdk.Cursor(gtk.gdk.XTERM)) + window = widget.get_window(Gtk.TextWindowType.TEXT) + window.set_cursor(Gdk.Cursor.new(Gdk.XTERM)) self._changed_cursor = False return False @@ -879,17 +882,17 @@ class HtmlTextView(gtk.TextView): # buffer_.insert(eob, '\n') def on_html_text_view_copy_clipboard(self, unused_data): - clipboard = self.get_clipboard(gtk.gdk.SELECTION_CLIPBOARD) + clipboard = self.get_clipboard(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(self.get_selected_text()) self.emit_stop_by_name('copy-clipboard') def on_html_text_view_realized(self, unused_data): self.get_buffer().remove_selection_clipboard(self.get_clipboard( - gtk.gdk.SELECTION_PRIMARY)) + Gdk.SELECTION_PRIMARY)) def on_html_text_view_unrealized(self, unused_data): self.get_buffer().add_selection_clipboard(self.get_clipboard( - gtk.gdk.SELECTION_PRIMARY)) + Gdk.SELECTION_PRIMARY)) def on_left_mouse_button_release(self, widget, event): if event.button != 1: @@ -899,7 +902,7 @@ class HtmlTextView(gtk.TextView): if bounds: # textview can be hidden while we add a new line in it. if self.has_screen(): - clipboard = self.get_clipboard(gtk.gdk.SELECTION_PRIMARY) + clipboard = self.get_clipboard(Gdk.SELECTION_PRIMARY) clipboard.set_text(self.get_selected_text()) def get_selected_text(self): @@ -944,7 +947,7 @@ if __name__ == '__main__': path = gtkgui_helpers.get_icon_path('gajim-muc_separator') # use this for hr - htmlview.tv.focus_out_line_pixbuf = gtk.gdk.pixbuf_new_from_file(path) + htmlview.tv.focus_out_line_pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) tooltip = tooltips.BaseTooltip() @@ -953,20 +956,21 @@ if __name__ == '__main__': Change the cursor to a hand when we are over a mail or an url """ global change_cursor - pointer_x, pointer_y = htmlview.tv.window.get_pointer()[0:2] - x, y = htmlview.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, + pointer_x, pointer_y = htmlview.tv.get_window(Gtk.TextWindowType.TEXT).\ + get_pointer()[1:3] + x, y = htmlview.tv.window_to_buffer_coords(Gtk.TextWindowType.TEXT, pointer_x, pointer_y) tags = htmlview.tv.get_iter_at_location(x, y).get_tags() if change_cursor: - htmlview.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - gtk.gdk.Cursor(gtk.gdk.XTERM)) + htmlview.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + Gdk.Cursor.new(Gdk.XTERM)) change_cursor = None tag_table = htmlview.tv.get_buffer().get_tag_table() for tag in tags: try: if tag.is_anchor: - htmlview.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - gtk.gdk.Cursor(gtk.gdk.HAND2)) + htmlview.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + Gdk.Cursor.new(Gdk.HAND2)) change_cursor = tag elif tag == tag_table.lookup('focus-out-line'): over_line = True @@ -978,16 +982,16 @@ if __name__ == '__main__': # if not over_line: # line_tooltip.hide_tooltip() #if over_line and not line_tooltip.win: - # line_tooltip.timeout = gobject.timeout_add(500, + # line_tooltip.timeout = GObject.timeout_add(500, # show_line_tooltip) - # htmlview.tv.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( - # gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)) + # htmlview.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor( + # Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)) # change_cursor = tag htmlview.tv.connect('motion_notify_event', on_textview_motion_notify_event) def handler(texttag, widget, event, iter_, kind): - if event.type == gtk.gdk.BUTTON_PRESS: + if event.type == Gdk.EventType.BUTTON_PRESS: pass htmlview.tv.hyperlink_handler = htmlview.hyperlink_handler @@ -1108,19 +1112,19 @@ hhx4dbgYKAAA7' alt='Larry'/> ''') htmlview.tv.show() - sw = gtk.ScrolledWindow() - sw.set_property('hscrollbar-policy', gtk.POLICY_AUTOMATIC) - sw.set_property('vscrollbar-policy', gtk.POLICY_AUTOMATIC) + sw = Gtk.ScrolledWindow() + sw.set_property('hscrollbar-policy', Gtk.PolicyType.AUTOMATIC) + sw.set_property('vscrollbar-policy', Gtk.PolicyType.AUTOMATIC) sw.set_property('border-width', 0) sw.add(htmlview.tv) sw.show() - frame = gtk.Frame() - frame.set_shadow_type(gtk.SHADOW_IN) + frame = Gtk.Frame() + frame.set_shadow_type(Gtk.ShadowType.IN) frame.show() frame.add(sw) - w = gtk.Window() + w = Gtk.Window() w.add(frame) w.set_default_size(400, 300) w.show_all() - w.connect('destroy', lambda w: gtk.main_quit()) - gtk.main() + w.connect('destroy', lambda w: Gtk.main_quit()) + Gtk.main() diff --git a/src/ipython_view.py b/src/ipython_view.py index c26a0bbf9..e816c7805 100644 --- a/src/ipython_view.py +++ b/src/ipython_view.py @@ -42,11 +42,12 @@ available under the terms of the BSD which accompanies this distribution, and is available at U{http://www.opensource.org/licenses/bsd-license.php} """ -import gtk, gobject +from gi.repository import Gtk +from gi.repository import GObject import re import sys import os -import pango +from gi.repository import Pango from StringIO import StringIO try: @@ -128,7 +129,7 @@ class IterableIPShell: # Workaround for updating namespace with sys.modules # self.__update_namespace() - + def __update_namespace(self): ''' Update self.IP namespace for autocompletion with sys.modules @@ -187,7 +188,7 @@ class IterableIPShell: Generate prompt depending on is_continuation value @param is_continuation - @type is_continuation: boolean + @type is_continuation: boolean @return: The prompt string representation @rtype: string @@ -316,7 +317,7 @@ class IterableIPShell: output.close() input_.close() -class ConsoleView(gtk.TextView): +class ConsoleView(Gtk.TextView): """ Specialized text view for console-like workflow @@ -324,13 +325,13 @@ class ConsoleView(gtk.TextView): @type ANSI_COLORS: dictionary @ivar text_buffer: Widget's text buffer. - @type text_buffer: gtk.TextBuffer + @type text_buffer: Gtk.TextBuffer @ivar color_pat: Regex of terminal color pattern @type color_pat: _sre.SRE_Pattern @ivar mark: Scroll mark for automatic scrolling on input. - @type mark: gtk.TextMark + @type mark: Gtk.TextMark @ivar line_start: Start of command line mark. - @type line_start: gtk.TextMark + @type line_start: Gtk.TextMark """ ANSI_COLORS = {'0;30': 'Black', '0;31': 'Red', @@ -346,8 +347,8 @@ class ConsoleView(gtk.TextView): """ Initialize console view """ - gtk.TextView.__init__(self) - self.modify_font(pango.FontDescription('Mono')) + GObject.GObject.__init__(self) + self.modify_font(Pango.FontDescription('Mono')) self.set_cursor_visible(True) self.text_buffer = self.get_buffer() self.mark = self.text_buffer.create_mark('scroll_mark', @@ -366,7 +367,7 @@ class ConsoleView(gtk.TextView): self.connect('key-press-event', self.onKeyPress) def write(self, text, editable=False): - gobject.idle_add(self._write, text, editable) + GObject.idle_add(self._write, text, editable) def _write(self, text, editable=False): """ @@ -400,7 +401,7 @@ class ConsoleView(gtk.TextView): def showPrompt(self, prompt): - gobject.idle_add(self._showPrompt, prompt) + GObject.idle_add(self._showPrompt, prompt) def _showPrompt(self, prompt): """ @@ -414,7 +415,7 @@ class ConsoleView(gtk.TextView): self.text_buffer.get_end_iter()) def changeLine(self, text): - gobject.idle_add(self._changeLine, text) + GObject.idle_add(self._changeLine, text) def _changeLine(self, text): """ @@ -441,7 +442,7 @@ class ConsoleView(gtk.TextView): return rv def showReturned(self, text): - gobject.idle_add(self._showReturned, text) + GObject.idle_add(self._showReturned, text) def _showReturned(self, text): """ @@ -470,9 +471,9 @@ class ConsoleView(gtk.TextView): line @param widget: Widget that key press accored in. - @type widget: gtk.Widget + @type widget: Gtk.Widget @param event: Event object - @type event: gtk.gdk.Event + @type event: Gdk.Event @return: Return True if event should not trickle. @rtype: boolean @@ -482,14 +483,14 @@ class ConsoleView(gtk.TextView): selection_mark = self.text_buffer.get_selection_bound() selection_iter = self.text_buffer.get_iter_at_mark(selection_mark) start_iter = self.text_buffer.get_iter_at_mark(self.line_start) - if event.keyval == gtk.keysyms.Home: - if event.state == 0: + if event.keyval == Gdk.KEY_Home: + if event.get_state() == 0: self.text_buffer.place_cursor(start_iter) return True - elif event.state == gtk.gdk.SHIFT_MASK: + elif event.get_state() == Gdk.ModifierType.SHIFT_MASK: self.text_buffer.move_mark(insert_mark, start_iter) return True - elif event.keyval == gtk.keysyms.Left: + elif event.keyval == Gdk.KEY_Left: insert_iter.backward_cursor_position() if not insert_iter.editable(True): return True @@ -555,27 +556,27 @@ class IPythonView(ConsoleView, IterableIPShell): autocompletions, etc @param widget: Widget that key press occured in. - @type widget: gtk.Widget + @type widget: Gtk.Widget @param event: Event object. - @type event: gtk.gdk.Event + @type event: Gdk.Event @return: True if event should not trickle. @rtype: boolean """ - if event.state & gtk.gdk.CONTROL_MASK and event.keyval == 99: + if event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == 99: self.interrupt = True self._processLine() return True - elif event.keyval == gtk.keysyms.Return: + elif event.keyval == Gdk.KEY_Return: self._processLine() return True - elif event.keyval == gtk.keysyms.Up: + elif event.keyval == Gdk.KEY_Up: self.changeLine(self.historyBack()) return True - elif event.keyval == gtk.keysyms.Down: + elif event.keyval == Gdk.KEY_Down: self.changeLine(self.historyForward()) return True - elif event.keyval == gtk.keysyms.Tab: + elif event.keyval == Gdk.KEY_Tab: if not self.getCurrentLine().strip(): return False completed, possibilities = self.complete(self.getCurrentLine()) diff --git a/src/message_control.py b/src/message_control.py index 4c58c5a92..f063fb333 100644 --- a/src/message_control.py +++ b/src/message_control.py @@ -42,7 +42,7 @@ TYPE_PM = 'pm' class MessageControl(object): """ - An abstract base widget that can embed in the gtk.Notebook of a + An abstract base widget that can embed in the Gtk.Notebook of a MessageWindow """ @@ -156,7 +156,7 @@ class MessageControl(object): Derivded classes MUST implement this. """ - # Return a markup'd label and optional gtk.Color in a tupple like: + # Return a markup'd label and optional Gtk.Color in a tupple like: # return (label_str, None) pass diff --git a/src/message_textview.py b/src/message_textview.py index 6bc4a4c7d..9700032bd 100644 --- a/src/message_textview.py +++ b/src/message_textview.py @@ -23,35 +23,36 @@ import gc -import gtk -import gobject -import pango +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject +from gi.repository import Pango import gtkgui_helpers from common import gajim -class MessageTextView(gtk.TextView): +class MessageTextView(Gtk.TextView): """ Class for the message textview (where user writes new messages) for chat/groupchat windows """ UNDO_LIMIT = 20 __gsignals__ = dict( - mykeypress = (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION, + mykeypress = (GObject.SignalFlags.RUN_LAST | GObject.SignalFlags.ACTION, None, # return value - (int, gtk.gdk.ModifierType ) # arguments + (int, Gdk.ModifierType ) # arguments ) ) def __init__(self): - gtk.TextView.__init__(self) + GObject.GObject.__init__(self) # set properties self.set_border_width(1) self.set_accepts_tab(True) self.set_editable(True) self.set_cursor_visible(True) - self.set_wrap_mode(gtk.WRAP_WORD_CHAR) + self.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) self.set_left_margin(2) self.set_right_margin(2) self.set_pixels_above_lines(2) @@ -69,15 +70,15 @@ class MessageTextView(gtk.TextView): self.fonts_tags = [] self.other_tags = {} self.other_tags['bold'] = _buffer.create_tag('bold') - self.other_tags['bold'].set_property('weight', pango.WEIGHT_BOLD) + self.other_tags['bold'].set_property('weight', Pango.Weight.BOLD) self.begin_tags['bold'] = '' self.end_tags['bold'] = '' self.other_tags['italic'] = _buffer.create_tag('italic') - self.other_tags['italic'].set_property('style', pango.STYLE_ITALIC) + self.other_tags['italic'].set_property('style', Pango.Style.ITALIC) self.begin_tags['italic'] = '' self.end_tags['italic'] = '' self.other_tags['underline'] = _buffer.create_tag('underline') - self.other_tags['underline'].set_property('underline', pango.UNDERLINE_SINGLE) + self.other_tags['underline'].set_property('underline', Pango.Underline.SINGLE) self.begin_tags['underline'] = '' self.end_tags['underline'] = '' self.other_tags['strike'] = _buffer.create_tag('strike') @@ -176,10 +177,10 @@ class MessageTextView(gtk.TextView): _buffer = self.get_buffer() font = font.get_font_name() - font_desc = pango.FontDescription(font) + font_desc = Pango.FontDescription(font) family = font_desc.get_family() size = font_desc.get_size() - size = size / pango.SCALE + size = size / Pango.SCALE weight = font_desc.get_weight() style = font_desc.get_style() @@ -202,12 +203,12 @@ class MessageTextView(gtk.TextView): _buffer.apply_tag_by_name(tag_name, start, finish) - if weight == pango.WEIGHT_BOLD: + if weight == Pango.Weight.BOLD: _buffer.apply_tag_by_name('bold', start, finish) else: _buffer.remove_tag_by_name('bold', start, finish) - if style == pango.STYLE_ITALIC: + if style == Pango.Style.ITALIC: _buffer.apply_tag_by_name('italic', start, finish) else: _buffer.remove_tag_by_name('italic', start, finish) @@ -217,7 +218,7 @@ class MessageTextView(gtk.TextView): old = _buffer.get_start_iter() tags = {} tags['bold'] = False - iter = _buffer.get_start_iter() + iter_ = _buffer.get_start_iter() old = _buffer.get_start_iter() text = '' modified = False @@ -229,31 +230,31 @@ class MessageTextView(gtk.TextView): text = text.replace('\n', '
') return text - for tag in iter.get_toggled_tags(True): + for tag in iter_.get_toggled_tags(True): tag_name = tag.get_property('name') if tag_name not in self.begin_tags: continue text += self.begin_tags[tag_name] modified = True - while (iter.forward_to_tag_toggle(None) and not iter.is_end()): - text += xhtml_special(_buffer.get_text(old, iter)) + while (iter_.forward_to_tag_toggle(None) and not iter_.is_end()): + text += xhtml_special(_buffer.get_text(old, iter_, True)) old.forward_to_tag_toggle(None) new_tags, old_tags, end_tags = [], [], [] - for tag in iter.get_toggled_tags(True): + for tag in iter_.get_toggled_tags(True): tag_name = tag.get_property('name') if tag_name not in self.begin_tags: continue new_tags.append(tag_name) modified = True - for tag in iter.get_tags(): + for tag in iter_.get_tags(): tag_name = tag.get_property('name') if tag_name not in self.begin_tags or tag_name not in self.end_tags: continue if tag_name not in new_tags: old_tags.append(tag_name) - for tag in iter.get_toggled_tags(False): + for tag in iter_.get_toggled_tags(False): tag_name = tag.get_property('name') if tag_name not in self.end_tags: continue @@ -268,8 +269,8 @@ class MessageTextView(gtk.TextView): for tag in old_tags: text += self.begin_tags[tag] - text += xhtml_special(_buffer.get_text(old, _buffer.get_end_iter())) - for tag in iter.get_toggled_tags(False): + text += xhtml_special(_buffer.get_text(old, _buffer.get_end_iter(), True)) + for tag in iter_.get_toggled_tags(False): tag_name = tag.get_property('name') if tag_name not in self.end_tags: continue @@ -281,7 +282,7 @@ class MessageTextView(gtk.TextView): return None def destroy(self): - gobject.idle_add(gc.collect) + GObject.idle_add(gc.collect) def clear(self, widget = None): """ @@ -322,62 +323,62 @@ class MessageTextView(gtk.TextView): # and we also return True there to stop the default action from running # CTRL + SHIFT + TAB -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.ISO_Left_Tab, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.ISO_Left_Tab, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_ISO_Left_Tab, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_ISO_Left_Tab, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) -# CTRL + TAB -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Tab, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.Tab, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +## CTRL + TAB +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Tab, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_Tab, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) -# TAB -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Tab, - 0, 'mykeypress', int, gtk.keysyms.Tab, gtk.gdk.ModifierType, 0) +## TAB +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Tab, + #0, 'mykeypress', int, Gdk.KEY_Tab, Gdk.ModifierType, 0) -# CTRL + UP -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Up, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.Up, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +## CTRL + UP +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Up, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_Up, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) -# CTRL + DOWN -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Down, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.Down, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +## CTRL + DOWN +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Down, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_Down, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) -# CTRL + SHIFT + UP -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Up, - gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK, 'mykeypress', int, - gtk.keysyms.Up, gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK | - gtk.gdk.SHIFT_MASK) +## CTRL + SHIFT + UP +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Up, + #Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK, 'mykeypress', int, + #Gdk.KEY_Up, Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK | + #Gdk.ModifierType.SHIFT_MASK) -# CTRL + SHIFT + DOWN -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Down, - gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK, 'mykeypress', int, - gtk.keysyms.Down, gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK | - gtk.gdk.SHIFT_MASK) +## CTRL + SHIFT + DOWN +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Down, + #Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK, 'mykeypress', int, + #Gdk.KEY_Down, Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK | + #Gdk.ModifierType.SHIFT_MASK) -# ENTER -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Return, - 0, 'mykeypress', int, gtk.keysyms.Return, - gtk.gdk.ModifierType, 0) +## ENTER +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Return, + #0, 'mykeypress', int, Gdk.KEY_Return, + #Gdk.ModifierType, 0) -# Ctrl + Enter -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.Return, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.Return, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +## Ctrl + Enter +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_Return, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_Return, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) -# Keypad Enter -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.KP_Enter, - 0, 'mykeypress', int, gtk.keysyms.KP_Enter, - gtk.gdk.ModifierType, 0) +## Keypad Enter +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_KP_Enter, + #0, 'mykeypress', int, Gdk.KEY_KP_Enter, + #Gdk.ModifierType, 0) -# Ctrl + Keypad Enter -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.KP_Enter, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.KP_Enter, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +## Ctrl + Keypad Enter +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_KP_Enter, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_KP_Enter, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) -# Ctrl + z -gtk.binding_entry_add_signal(MessageTextView, gtk.keysyms.z, - gtk.gdk.CONTROL_MASK, 'mykeypress', int, gtk.keysyms.z, - gtk.gdk.ModifierType, gtk.gdk.CONTROL_MASK) +## Ctrl + z +#Gtk.binding_entry_add_signal(MessageTextView, Gdk.KEY_z, + #Gdk.ModifierType.CONTROL_MASK, 'mykeypress', int, Gdk.KEY_z, + #Gdk.ModifierType, Gdk.ModifierType.CONTROL_MASK) diff --git a/src/message_window.py b/src/message_window.py index 2167ae456..f47b09db4 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -27,8 +27,9 @@ ## along with Gajim. If not, see . ## -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject import time import common @@ -106,16 +107,16 @@ class MessageWindow(object): 'w', 'Page_Up', 'Page_Down', 'Right', 'Left', 'd', 'c', 'm', 't', 'Escape'] + \ [''+str(i) for i in xrange(10)] - accel_group = gtk.AccelGroup() + accel_group = Gtk.AccelGroup() for key in keys: - keyval, mod = gtk.accelerator_parse(key) - accel_group.connect_group(keyval, mod, gtk.ACCEL_VISIBLE, + keyval, mod = Gtk.accelerator_parse(key) + accel_group.connect(keyval, mod, Gtk.AccelFlags.VISIBLE, self.accel_group_func) self.window.add_accel_group(accel_group) # gtk+ doesn't make use of the motion notify on gtkwindow by default # so this line adds that - self.window.add_events(gtk.gdk.POINTER_MOTION_MASK) + self.window.add_events(Gdk.EventMask.POINTER_MOTION_MASK) id_ = self.notebook.connect('switch-page', self._on_notebook_switch_page) @@ -127,13 +128,13 @@ class MessageWindow(object): # Tab customizations pref_pos = gajim.config.get('tabs_position') if pref_pos == 'bottom': - nb_pos = gtk.POS_BOTTOM + nb_pos = Gtk.PositionType.BOTTOM elif pref_pos == 'left': - nb_pos = gtk.POS_LEFT + nb_pos = Gtk.PositionType.LEFT elif pref_pos == 'right': - nb_pos = gtk.POS_RIGHT + nb_pos = Gtk.PositionType.RIGHT else: - nb_pos = gtk.POS_TOP + nb_pos = Gtk.PositionType.TOP self.notebook.set_tab_pos(nb_pos) window_mode = gajim.interface.msg_win_mgr.mode if gajim.config.get('tabs_always_visible') or \ @@ -275,17 +276,17 @@ class MessageWindow(object): scrolled = True self.notebook.set_show_tabs(True) if scrolled: - gobject.idle_add(conv_textview.scroll_to_end_iter) + GObject.idle_add(conv_textview.scroll_to_end_iter) # Add notebook page and connect up to the tab's close button xml = gtkgui_helpers.get_gtk_builder('message_window.ui', 'chat_tab_ebox') tab_label_box = xml.get_object('chat_tab_ebox') widget = xml.get_object('tab_close_button') - #this reduces the size of the button - style = gtk.RcStyle() - style.xthickness = 0 - style.ythickness = 0 - widget.modify_style(style) + # this reduces the size of the button +# style = Gtk.RcStyle() +# style.xthickness = 0 +# style.ythickness = 0 +# widget.modify_style(style) id_ = widget.connect('clicked', self._on_close_button_clicked, control) control.handlers[id_] = widget @@ -305,7 +306,7 @@ class MessageWindow(object): # NOTE: we do not call set_control_active(True) since we don't know # whether the tab is the active one. self.show_title() - gobject.timeout_add(500, control.msg_textview.grab_focus) + GObject.timeout_add(500, control.msg_textview.grab_focus) def on_tab_eventbox_button_press_event(self, widget, event, child): if event.button == 3: # right click @@ -317,27 +318,27 @@ class MessageWindow(object): self.remove_tab(ctrl, self.CLOSE_TAB_MIDDLE_CLICK) else: ctrl = self._widget_to_control(child) - gobject.idle_add(ctrl.msg_textview.grab_focus) + GObject.idle_add(ctrl.msg_textview.grab_focus) def _on_message_textview_mykeypress_event(self, widget, event_keyval, event_keymod): # NOTE: handles mykeypress which is custom signal; see message_textview.py # construct event instance from binding - event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) # it's always a key-press here + event = Gdk.Event(Gdk.KEY_PRESS) # it's always a key-press here event.keyval = event_keyval event.state = event_keymod event.time = 0 # assign current time - if event.state & gtk.gdk.CONTROL_MASK: + if event.get_state() & Gdk.ModifierType.CONTROL_MASK: # Tab switch bindings - if event.keyval == gtk.keysyms.Tab: # CTRL + TAB + if event.keyval == Gdk.KEY_Tab: # CTRL + TAB self.move_to_next_unread_tab(True) - elif event.keyval == gtk.keysyms.ISO_Left_Tab: # CTRL + SHIFT + TAB + elif event.keyval == Gdk.KEY_ISO_Left_Tab: # CTRL + SHIFT + TAB self.move_to_next_unread_tab(False) - elif event.keyval == gtk.keysyms.Page_Down: # CTRL + PAGE DOWN + elif event.keyval == Gdk.KEY_Page_Down: # CTRL + PAGE DOWN self.notebook.emit('key_press_event', event) - elif event.keyval == gtk.keysyms.Page_Up: # CTRL + PAGE UP + elif event.keyval == Gdk.KEY_Page_Up: # CTRL + PAGE UP self.notebook.emit('key_press_event', event) def accel_group_func(self, accel_group, acceleratable, keyval, modifier): @@ -348,76 +349,76 @@ class MessageWindow(object): return # CTRL mask - if modifier & gtk.gdk.CONTROL_MASK: - if keyval == gtk.keysyms.h: # CTRL + h - if gtk.settings_get_default().get_property( + if modifier & Gdk.ModifierType.CONTROL_MASK: + if keyval == Gdk.KEY_h: # CTRL + h + if Gtk.Settings.get_default().get_property( 'gtk-key-theme-name') != 'Emacs': control._on_history_menuitem_activate() return True elif control.type_id == message_control.TYPE_CHAT and \ - keyval == gtk.keysyms.f: # CTRL + f + keyval == Gdk.KEY_f: # CTRL + f # CTRL + f moves cursor one char forward when user uses Emacs # theme - if not gtk.settings_get_default().get_property( + if not Gtk.Settings.get_default().get_property( 'gtk-key-theme-name') == 'Emacs': control._on_send_file_menuitem_activate(None) return True elif control.type_id == message_control.TYPE_CHAT and \ - keyval == gtk.keysyms.g: # CTRL + g + keyval == Gdk.KEY_g: # CTRL + g control._on_convert_to_gc_menuitem_activate(None) return True elif control.type_id in (message_control.TYPE_CHAT, - message_control.TYPE_PM) and keyval == gtk.keysyms.i: # CTRL + i + message_control.TYPE_PM) and keyval == Gdk.KEY_i: # CTRL + i control._on_contact_information_menuitem_activate(None) return True - elif keyval == gtk.keysyms.l or keyval == gtk.keysyms.L: # CTRL + l|L + elif keyval == Gdk.KEY_l or keyval == Gdk.KEY_L: # CTRL + l|L control.conv_textview.clear() return True - elif keyval == gtk.keysyms.u: # CTRL + u: emacs style clear line + elif keyval == Gdk.KEY_u: # CTRL + u: emacs style clear line control.clear(control.msg_textview) return True elif control.type_id == message_control.TYPE_GC and \ - keyval == gtk.keysyms.b: # CTRL + b + keyval == Gdk.KEY_b: # CTRL + b control._on_bookmark_room_menuitem_activate(None) return True # Tab switch bindings - elif keyval == gtk.keysyms.F4: # CTRL + F4 + elif keyval == Gdk.KEY_F4: # CTRL + F4 self.remove_tab(control, self.CLOSE_CTRL_KEY) return True - elif keyval == gtk.keysyms.w: # CTRL + w + elif keyval == Gdk.KEY_w: # CTRL + w # CTRL + w removes latest word before sursor when User uses emacs # theme - if not gtk.settings_get_default().get_property( + if not Gtk.Settings.get_default().get_property( 'gtk-key-theme-name') == 'Emacs': self.remove_tab(control, self.CLOSE_CTRL_KEY) return True - elif keyval in (gtk.keysyms.Page_Up, gtk.keysyms.Page_Down): + elif keyval in (Gdk.KEY_Page_Up, Gdk.KEY_Page_Down): # CTRL + PageUp | PageDown # Create event and send it to notebook - event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) + event = Gdk.Event(Gdk.KEY_PRESS) event.window = self.window.window event.time = int(time.time()) - event.state = gtk.gdk.CONTROL_MASK + event.state = Gdk.ModifierType.CONTROL_MASK event.keyval = int(keyval) self.notebook.emit('key_press_event', event) return True - if modifier & gtk.gdk.SHIFT_MASK: + if modifier & Gdk.ModifierType.SHIFT_MASK: # CTRL + SHIFT if control.type_id == message_control.TYPE_GC and \ - keyval == gtk.keysyms.n: # CTRL + SHIFT + n + keyval == Gdk.KEY_n: # CTRL + SHIFT + n control._on_change_nick_menuitem_activate(None) return True # MOD1 (ALT) mask - elif modifier & gtk.gdk.MOD1_MASK: + elif modifier & Gdk.ModifierType.MOD1_MASK: # Tab switch bindings - if keyval == gtk.keysyms.Right: # ALT + RIGHT + if keyval == Gdk.KEY_Right: # ALT + RIGHT new = self.notebook.get_current_page() + 1 if new >= self.notebook.get_n_pages(): new = 0 self.notebook.set_current_page(new) return True - elif keyval == gtk.keysyms.Left: # ALT + LEFT + elif keyval == Gdk.KEY_Left: # ALT + LEFT new = self.notebook.get_current_page() - 1 if new < 0: new = self.notebook.get_n_pages() - 1 @@ -426,23 +427,23 @@ class MessageWindow(object): elif chr(keyval) in st: # ALT + 1,2,3.. self.notebook.set_current_page(st.index(chr(keyval))) return True - elif keyval == gtk.keysyms.c: # ALT + C toggles chat buttons + elif keyval == Gdk.KEY_c: # ALT + C toggles chat buttons control.chat_buttons_set_visible(not control.hide_chat_buttons) return True - elif keyval == gtk.keysyms.m: # ALT + M show emoticons menu + elif keyval == Gdk.KEY_m: # ALT + M show emoticons menu control.show_emoticons_menu() return True - elif keyval == gtk.keysyms.d: # ALT + D show actions menu - if gtk.settings_get_default().get_property( + elif keyval == Gdk.KEY_d: # ALT + D show actions menu + if Gtk.Settings.get_default().get_property( 'gtk-key-theme-name') != 'Emacs': control.on_actions_button_clicked(control.actions_button) return True elif control.type_id == message_control.TYPE_GC and \ - keyval == gtk.keysyms.t: # ALT + t + keyval == Gdk.KEY_t: # ALT + t control._on_change_subject_menuitem_activate(None) return True # Close tab bindings - elif keyval == gtk.keysyms.Escape and \ + elif keyval == Gdk.KEY_Escape and \ gajim.config.get('escape_key_closes'): # Escape self.remove_tab(control, self.CLOSE_ESC) return True @@ -545,7 +546,7 @@ class MessageWindow(object): ctrl_page = self.notebook.page_num(ctrl.widget) self.notebook.set_current_page(ctrl_page) self.window.present() - gobject.idle_add(ctrl.msg_textview.grab_focus) + GObject.idle_add(ctrl.msg_textview.grab_focus) def remove_tab(self, ctrl, method, reason = None, force = False): """ @@ -638,12 +639,12 @@ class MessageWindow(object): (tab_label_str, tab_label_color) = ctrl.get_tab_label(chatstate) nick_label.set_markup(tab_label_str) if tab_label_color: - nick_label.modify_fg(gtk.STATE_NORMAL, tab_label_color) - nick_label.modify_fg(gtk.STATE_ACTIVE, tab_label_color) + nick_label.modify_fg(Gtk.StateType.NORMAL, tab_label_color) + nick_label.modify_fg(Gtk.StateType.ACTIVE, tab_label_color) tab_img = ctrl.get_tab_image() if tab_img: - if tab_img.get_storage_type() == gtk.IMAGE_ANIMATION: + if tab_img.get_storage_type() == Gtk.ImageType.ANIMATION: status_img.set_from_animation(tab_img.get_animation()) else: status_img.set_from_pixbuf(tab_img.get_pixbuf()) @@ -810,37 +811,37 @@ class MessageWindow(object): def _on_notebook_key_press(self, widget, event): # when tab itself is selected, # make sure <- and -> are allowed for navigating between tabs - if event.keyval in (gtk.keysyms.Left, gtk.keysyms.Right): + if event.keyval in (Gdk.KEY_Left, Gdk.KEY_Right): return False control = self.get_active_control() - if event.state & gtk.gdk.SHIFT_MASK: + if event.get_state() & Gdk.ModifierType.SHIFT_MASK: # CTRL + SHIFT + TAB - if event.state & gtk.gdk.CONTROL_MASK and \ - event.keyval == gtk.keysyms.ISO_Left_Tab: + if event.get_state() & Gdk.ModifierType.CONTROL_MASK and \ + event.keyval == Gdk.KEY_ISO_Left_Tab: self.move_to_next_unread_tab(False) return True # SHIFT + PAGE_[UP|DOWN]: send to conv_textview - elif event.keyval in (gtk.keysyms.Page_Down, gtk.keysyms.Page_Up): + elif event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up): control.conv_textview.tv.emit('key_press_event', event) return True - elif event.state & gtk.gdk.CONTROL_MASK: - if event.keyval == gtk.keysyms.Tab: # CTRL + TAB + elif event.get_state() & Gdk.ModifierType.CONTROL_MASK: + if event.keyval == Gdk.KEY_Tab: # CTRL + TAB self.move_to_next_unread_tab(True) return True # Ctrl+PageUP / DOWN has to be handled by notebook - elif event.keyval == gtk.keysyms.Page_Down: + elif event.keyval == Gdk.KEY_Page_Down: self.move_to_next_unread_tab(True) return True - elif event.keyval == gtk.keysyms.Page_Up: + elif event.keyval == Gdk.KEY_Page_Up: self.move_to_next_unread_tab(False) return True - if event.keyval in (gtk.keysyms.Shift_L, gtk.keysyms.Shift_R, - gtk.keysyms.Control_L, gtk.keysyms.Control_R, gtk.keysyms.Caps_Lock, - gtk.keysyms.Shift_Lock, gtk.keysyms.Meta_L, gtk.keysyms.Meta_R, - gtk.keysyms.Alt_L, gtk.keysyms.Alt_R, gtk.keysyms.Super_L, - gtk.keysyms.Super_R, gtk.keysyms.Hyper_L, gtk.keysyms.Hyper_R): + if event.keyval in (Gdk.KEY_Shift_L, Gdk.KEY_Shift_R, + Gdk.KEY_Control_L, Gdk.KEY_Control_R, Gdk.KEY_Caps_Lock, + Gdk.KEY_Shift_Lock, Gdk.KEY_Meta_L, Gdk.KEY_Meta_R, + Gdk.KEY_Alt_L, Gdk.KEY_Alt_R, Gdk.KEY_Super_L, + Gdk.KEY_Super_R, Gdk.KEY_Hyper_L, Gdk.KEY_Hyper_R): return True if isinstance(control, ChatControlBase): @@ -855,8 +856,8 @@ class MessageWindow(object): """ page_num = -1 to_right = False - horiz = self.notebook.get_tab_pos() == gtk.POS_TOP or \ - self.notebook.get_tab_pos() == gtk.POS_BOTTOM + horiz = self.notebook.get_tab_pos() == Gtk.PositionType.TOP or \ + self.notebook.get_tab_pos() == Gtk.PositionType.BOTTOM for i in xrange(self.notebook.get_n_pages()): page = self.notebook.get_nth_page(i) tab = self.notebook.get_tab_label(page) @@ -892,13 +893,13 @@ class MessageWindow(object): return page_num ################################################################################ -class MessageWindowMgr(gobject.GObject): +class MessageWindowMgr(GObject.GObject): """ A manager and factory for MessageWindow objects """ __gsignals__ = { - 'window-delete': (gobject.SIGNAL_RUN_LAST, None, (object,)), + 'window-delete': (GObject.SignalFlags.RUN_LAST, None, (object,)), } # These constants map to common.config.opt_one_window_types indices @@ -923,7 +924,7 @@ class MessageWindowMgr(gobject.GObject): ONE_MSG_WINDOW_PERACCT: The key is the account name ONE_MSG_WINDOW_PERTYPE: The key is a message type constant """ - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self._windows = {} # Map the mode to a int constant for frequent compares @@ -984,7 +985,10 @@ class MessageWindowMgr(gobject.GObject): parent_size = win.window.get_size() # Need to add the size of the now visible paned handle, otherwise # the saved width of the message window decreases by this amount - handle_size = win.parent_paned.style_get_property('handle-size') + s = GObject.Value() + s.init(GObject.TYPE_INT) + win.parent_paned.style_get_property('handle-size', s) + handle_size = s.get_int() size = (parent_size[0] + size[0] + handle_size, size[1]) elif self.mode == self.ONE_MSG_WINDOW_PERACCT: size = (gajim.config.get_per('accounts', acct, 'msgwin-width'), @@ -1195,7 +1199,7 @@ class MessageWindowMgr(gobject.GObject): size_height_key = type_ + '-msgwin-height' elif self.mode == self.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER: # Ignore any hpaned width - width = msg_win.notebook.allocation.width + width = msg_win.notebook.get_allocation().width if acct: gajim.config.set_per('accounts', acct, size_width_key, width) @@ -1206,8 +1210,8 @@ class MessageWindowMgr(gobject.GObject): gajim.config.set_per('accounts', acct, pos_y_key, y) else: - win_maximized = msg_win.window.window.get_state() == \ - gtk.gdk.WINDOW_STATE_MAXIMIZED + win_maximized = msg_win.window.get_window().get_state() == \ + Gdk.WindowState.MAXIMIZED gajim.config.set(max_win_key, win_maximized) width += width_adjust gajim.config.set(size_width_key, width) diff --git a/src/music_track_listener.py b/src/music_track_listener.py index c0910d7e3..30ee57ce3 100644 --- a/src/music_track_listener.py +++ b/src/music_track_listener.py @@ -23,7 +23,7 @@ ## along with Gajim. If not, see . ## -import gobject +from gi.repository import GObject if __name__ == '__main__': # install _() func before importing dbus_support from common import i18n @@ -36,9 +36,9 @@ class MusicTrackInfo(object): __slots__ = ['title', 'album', 'artist', 'duration', 'track_number', 'paused'] -class MusicTrackListener(gobject.GObject): +class MusicTrackListener(GObject.GObject): __gsignals__ = { - 'music-track-changed': (gobject.SIGNAL_RUN_LAST, None, (object,)), + 'music-track-changed': (GObject.SignalFlags.RUN_LAST, None, (object,)), } _instance = None @@ -300,4 +300,4 @@ if __name__ == '__main__': print 'Now not playing anything' else: print 'Now playing: "%s" by %s' % (track.title, track.artist) - gobject.MainLoop().run() + GObject.MainLoop().run() diff --git a/src/negotiation.py b/src/negotiation.py index a8287a3a0..e002cf74f 100644 --- a/src/negotiation.py +++ b/src/negotiation.py @@ -49,7 +49,7 @@ class FeatureNegotiationWindow: dataform = dataforms.ExtendForm(node = self.form) self.data_form_widget = dataforms_widget.DataFormWidget(dataform) self.data_form_widget.show() - config_vbox.pack_start(self.data_form_widget) + config_vbox.pack_start(self.data_form_widget, True, True, 0) self.xml.connect_signals(self) self.window.show_all() diff --git a/src/notify.py b/src/notify.py index 78b31f6a7..f2b8d5b11 100644 --- a/src/notify.py +++ b/src/notify.py @@ -30,9 +30,9 @@ import os import time from dialogs import PopupNotificationWindow -import gobject +from gi.repository import GObject import gtkgui_helpers -import gtk +from gi.repository import Gtk from common import gajim from common import helpers @@ -45,8 +45,8 @@ if dbus_support.supported: USER_HAS_PYNOTIFY = True # user has pynotify module try: - import pynotify - pynotify.init('Gajim Notification') + from gi.repository import Notify + Notify.init('Gajim Notification') except ImportError: USER_HAS_PYNOTIFY = False @@ -89,7 +89,7 @@ text=None, timeout=-1): if gajim.config.get('use_notif_daemon') and dbus_support.supported: try: DesktopNotification(event_type, jid, account, msg_type, - path_to_image, title, gobject.markup_escape_text(text), timeout) + path_to_image, title, GObject.markup_escape_text(text), timeout) return # sucessfully did D-Bus Notification procedure! except dbus.DBusException, e: # Connection to D-Bus failed @@ -103,17 +103,17 @@ text=None, timeout=-1): if not text and event_type == 'new_message': # empty text for new_message means do_preview = False # -> default value for text - _text = gobject.markup_escape_text( + _text = GObject.markup_escape_text( gajim.get_name_from_jid(account, jid)) else: - _text = gobject.markup_escape_text(text) + _text = GObject.markup_escape_text(text) if not title: _title = '' else: _title = title - notification = pynotify.Notification(_title, _text) + notification = Notify.Notification(_title, _text) notification.set_timeout(timeout*1000) notification.set_category(event_type) @@ -122,14 +122,14 @@ text=None, timeout=-1): notification.set_data('account', account) notification.set_data('msg_type', msg_type) notification.set_property('icon-name', path_to_image) - if 'actions' in pynotify.get_server_caps(): + if 'actions' in Notify.get_server_caps(): notification.add_action('default', 'Default Action', on_pynotify_notification_clicked) try: notification.show() return - except gobject.GError, e: + except GObject.GError, e: # Connection to notification-daemon failed, see #2893 gajim.log.debug(str(e)) diff --git a/src/plugins/gui.py b/src/plugins/gui.py index 1029662ce..96a5baa04 100644 --- a/src/plugins/gui.py +++ b/src/plugins/gui.py @@ -26,8 +26,11 @@ GUI classes related to plug-in management. __all__ = ['PluginsWindow'] -import pango -import gtk, gobject, os +from gi.repository import Pango +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import GObject +import os import gtkgui_helpers from dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog @@ -53,7 +56,7 @@ class PluginsWindow(object): '''Initialize Plugins window''' self.xml = gtkgui_helpers.get_gtk_builder('plugins_window.ui') self.window = self.xml.get_object('plugins_window') - self.window.set_transient_for(gajim.interface.roster.window) + self.set_transient_for(gajim.interface.roster.window) widgets_to_extract = ('plugins_notebook', 'plugin_name_label', 'plugin_version_label', 'plugin_authors_label', @@ -64,45 +67,45 @@ class PluginsWindow(object): for widget_name in widgets_to_extract: setattr(self, widget_name, self.xml.get_object(widget_name)) - attr_list = pango.AttrList() - attr_list.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)) + attr_list = Pango.AttrList() + attr_list.insert(Pango.AttrWeight(Pango.Weight.BOLD, 0, -1)) self.plugin_name_label.set_attributes(attr_list) - self.installed_plugins_model = gtk.ListStore(gobject.TYPE_PYOBJECT, - gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN, - gtk.gdk.Pixbuf) + self.installed_plugins_model = Gtk.ListStore(GObject.TYPE_PYOBJECT, + GObject.TYPE_STRING, GObject.TYPE_BOOLEAN, GObject.TYPE_BOOLEAN, + GdkPixbuf.Pixbuf) self.installed_plugins_treeview.set_model(self.installed_plugins_model) self.installed_plugins_treeview.set_rules_hint(True) - renderer = gtk.CellRendererText() - col = gtk.TreeViewColumn(_('Plugin'))#, renderer, text=NAME) - cell = gtk.CellRendererPixbuf() - col.pack_start(cell, False) + renderer = Gtk.CellRendererText() + col = Gtk.TreeViewColumn(_('Plugin'))#, renderer, text=NAME) + cell = Gtk.CellRendererPixbuf() + col.pack_start(cell, False, True, 0) col.add_attribute(cell, 'pixbuf', ICON) - col.pack_start(renderer, True) + col.pack_start(renderer, True, True, 0) col.add_attribute(renderer, 'text', NAME) self.installed_plugins_treeview.append_column(col) - renderer = gtk.CellRendererToggle() + renderer = Gtk.CellRendererToggle() renderer.connect('toggled', self.installed_plugins_toggled_cb) - col = gtk.TreeViewColumn(_('Active'), renderer, active=ACTIVE, + col = Gtk.TreeViewColumn(_('Active'), renderer, active=ACTIVE, activatable=ACTIVATABLE) self.installed_plugins_treeview.append_column(col) - icon = gtk.Image() - self.def_icon = icon.render_icon(gtk.STOCK_PREFERENCES, - gtk.ICON_SIZE_MENU) + icon = Gtk.Image() + self.def_icon = icon.render_icon(Gtk.STOCK_PREFERENCES, + Gtk.IconSize.MENU) # connect signal for selection change selection = self.installed_plugins_treeview.get_selection() selection.connect('changed', self.installed_plugins_treeview_selection_changed) - selection.set_mode(gtk.SELECTION_SINGLE) + selection.set_mode(Gtk.SelectionMode.SINGLE) self._clear_installed_plugin_info() self.fill_installed_plugins_model() - selection.select_iter(self.installed_plugins_model.get_iter_root()) + selection.select_iter(self.installed_plugins_model.get_iter_first()) self.xml.connect_signals(self) @@ -114,7 +117,7 @@ class PluginsWindow(object): def on_plugins_notebook_switch_page(self, widget, page, page_num): - gobject.idle_add(self.xml.get_object('close_button').grab_focus) + GObject.idle_add(self.xml.get_object('close_button').grab_focus) @log_calls('PluginsWindow') def installed_plugins_treeview_selection_changed(self, treeview_selection): @@ -133,7 +136,7 @@ class PluginsWindow(object): self.plugin_version_label.set_text(plugin.version) self.plugin_authors_label.set_text(plugin.authors) label = self.plugin_homepage_linkbutton.get_children()[0] - label.set_ellipsize(pango.ELLIPSIZE_END) + label.set_ellipsize(Pango.EllipsizeMode.END) self.plugin_homepage_linkbutton.set_uri(plugin.homepage) self.plugin_homepage_linkbutton.set_label(plugin.homepage) self.plugin_homepage_linkbutton.set_property('sensitive', True) @@ -170,7 +173,7 @@ class PluginsWindow(object): def fill_installed_plugins_model(self): pm = gajim.plugin_manager self.installed_plugins_model.clear() - self.installed_plugins_model.set_sort_column_id(1, gtk.SORT_ASCENDING) + self.installed_plugins_model.set_sort_column_id(1, Gtk.SortType.ASCENDING) for plugin in pm.plugins: icon = self.get_plugin_icon(plugin) @@ -182,7 +185,7 @@ class PluginsWindow(object): plugin.__path__)[1]) + '.png' icon = self.def_icon if os.path.isfile(icon_file): - icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_file, 16, 16) + icon = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file, 16, 16) return icon @log_calls('PluginsWindow') @@ -299,16 +302,16 @@ class PluginsWindow(object): self.dialog = ArchiveChooserDialog(on_response_ok=_try_install) -class GajimPluginConfigDialog(gtk.Dialog): +class GajimPluginConfigDialog(Gtk.Dialog): @log_calls('GajimPluginConfigDialog') def __init__(self, plugin, **kwargs): - gtk.Dialog.__init__(self, '%s %s'%(plugin.name, _('Configuration')), + Gtk.Dialog.__init__(self, '%s %s'%(plugin.name, _('Configuration')), **kwargs) self.plugin = plugin - self.add_button('gtk-close', gtk.RESPONSE_CLOSE) + self.add_button('gtk-close', Gtk.ResponseType.CLOSE) - self.child.set_spacing(3) + self.get_child().set_spacing(3) self.init() diff --git a/src/profile_window.py b/src/profile_window.py index 5c506e941..8b13d4198 100644 --- a/src/profile_window.py +++ b/src/profile_window.py @@ -22,8 +22,9 @@ # THIS FILE IS FOR **OUR** PROFILE (when we edit our INFO) -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GdkPixbuf +from gi.repository import GObject import base64 import mimetypes import os @@ -45,7 +46,7 @@ class ProfileWindow: def __init__(self, account, transient_for=None): self.xml = gtkgui_helpers.get_gtk_builder('profile_window.ui') self.window = self.xml.get_object('profile_window') - self.window.set_transient_for(transient_for) + self.set_transient_for(transient_for) self.progressbar = self.xml.get_object('progressbar') self.statusbar = self.xml.get_object('statusbar') self.context_id = self.statusbar.get_context_id('profile') @@ -58,12 +59,12 @@ class ProfileWindow: self.avatar_encoded = None self.message_id = self.statusbar.push(self.context_id, _('Retrieving profile...')) - self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar_timeout_id = GObject.timeout_add(100, self.update_progressbar) self.remove_statusbar_timeout_id = None # Create Image for avatar button - image = gtk.Image() + image = Gtk.Image() self.xml.get_object('PHOTO_button').set_image(image) self.xml.connect_signals(self) gajim.ged.register_event_handler('vcard-published', ged.GUI1, @@ -76,7 +77,7 @@ class ProfileWindow: self.xml.get_object('ok_button').grab_focus() def on_information_notebook_switch_page(self, widget, page, page_num): - gobject.idle_add(self.xml.get_object('ok_button').grab_focus) + GObject.idle_add(self.xml.get_object('ok_button').grab_focus) def update_progressbar(self): self.progressbar.pulse() @@ -88,9 +89,9 @@ class ProfileWindow: def on_profile_window_destroy(self, widget): if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) if self.remove_statusbar_timeout_id is not None: - gobject.source_remove(self.remove_statusbar_timeout_id) + GObject.source_remove(self.remove_statusbar_timeout_id) gajim.ged.remove_event_handler('vcard-published', ged.GUI1, self._nec_vcard_published) gajim.ged.remove_event_handler('vcard-not-published', ged.GUI1, @@ -102,7 +103,7 @@ class ProfileWindow: self.dialog.destroy() def on_profile_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.destroy() def on_clear_button_clicked(self, widget): @@ -132,12 +133,12 @@ class ProfileWindow: msg = _('File does not exist') if not invalid_file and filesize > 16384: # 16 kb try: - pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_file) + pixbuf = GdkPixbuf.Pixbuf.new_from_file(path_to_file) # get the image at 'notification size' # and hope that user did not specify in ACE crazy size scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'tooltip') - except gobject.GError, msg: # unknown format + except GObject.GError, msg: # unknown format # msg should be string, not object instance msg = str(msg) invalid_file = True @@ -198,7 +199,7 @@ class ProfileWindow: If right-clicked, show popup """ if event.button == 3 and self.avatar_encoded: # right click - menu = gtk.Menu() + menu = Gtk.Menu() # Try to get pixbuf pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(self.jid, @@ -206,13 +207,13 @@ class ProfileWindow: if pixbuf not in (None, 'ask'): nick = gajim.config.get_per('accounts', self.account, 'name') - menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) + menuitem = Gtk.ImageMenuItem(Gtk.STOCK_SAVE_AS) menuitem.connect('activate', gtkgui_helpers.on_avatar_save_as_menuitem_activate, self.jid, nick) menu.append(menuitem) # show clear - menuitem = gtk.ImageMenuItem(gtk.STOCK_CLEAR) + menuitem = Gtk.ImageMenuItem(Gtk.STOCK_CLEAR) menuitem.connect('activate', self.on_clear_button_clicked) menu.append(menuitem) menu.connect('selection-done', lambda w:w.destroy()) @@ -233,7 +234,7 @@ class ProfileWindow: pritext = _('Wrong date format') dialogs.ErrorDialog(pritext, _('Format of the date must be ' 'YYYY-MM-DD')) - gobject.idle_add(lambda: widget.grab_focus()) + GObject.idle_add(lambda: widget.grab_focus()) return True def set_value(self, entry_name, value): @@ -290,9 +291,9 @@ class ProfileWindow: self.statusbar.remove_message(self.context_id, self.message_id) self.message_id = self.statusbar.push(self.context_id, _('Information received')) - self.remove_statusbar_timeout_id = gobject.timeout_add_seconds(3, + self.remove_statusbar_timeout_id = GObject.timeout_add_seconds(3, self.remove_statusbar, self.message_id) - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) self.progressbar.hide() self.progressbar.set_fraction(0) self.update_progressbar_timeout_id = None @@ -350,7 +351,7 @@ class ProfileWindow: buff = self.xml.get_object('DESC_textview').get_buffer() start_iter = buff.get_start_iter() end_iter = buff.get_end_iter() - txt = buff.get_text(start_iter, end_iter, 0) + txt = buff.get_text(start_iter, end_iter, False) if txt != '': vcard_['DESC'] = txt.decode('utf-8') @@ -382,14 +383,14 @@ class ProfileWindow: self.message_id = self.statusbar.push(self.context_id, _('Sending profile...')) self.progressbar.show() - self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar_timeout_id = GObject.timeout_add(100, self.update_progressbar) def _nec_vcard_published(self, obj): if obj.conn.name != self.account: return if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) self.update_progressbar_timeout_id = None self.window.destroy() @@ -400,10 +401,10 @@ class ProfileWindow: self.statusbar.remove_message(self.context_id, self.message_id) self.message_id = self.statusbar.push(self.context_id, _('Information NOT published')) - self.remove_statusbar_timeout_id = gobject.timeout_add_seconds(3, + self.remove_statusbar_timeout_id = GObject.timeout_add_seconds(3, self.remove_statusbar, self.message_id) if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) self.progressbar.set_fraction(0) self.update_progressbar_timeout_id = None dialogs.InformationDialog(_('vCard publication failed'), diff --git a/src/remote_control.py b/src/remote_control.py index ac34db3e5..5216201bb 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -26,8 +26,8 @@ ## along with Gajim. If not, see . ## -import gobject -import gtk +from gi.repository import GObject +from gi.repository import Gtk import os import base64 import mimetypes @@ -535,7 +535,7 @@ class SignalObject(dbus.service.Object): win = gajim.interface.msg_win_mgr.get_window(jid, connected_account).window if win.get_property('visible'): - win.window.focus(gtk.get_current_event_time()) + win.window.focus(Gtk.get_current_event_time()) return DBUS_BOOLEAN(True) return DBUS_BOOLEAN(False) @@ -553,7 +553,7 @@ class SignalObject(dbus.service.Object): if account not in gajim.connections: return DBUS_BOOLEAN(False) status = gajim.SHOW_LIST[gajim.connections[account].connected] - gobject.idle_add(gajim.interface.roster.send_status, account, + GObject.idle_add(gajim.interface.roster.send_status, account, status, message) else: # account not specified, so change the status of all accounts @@ -567,7 +567,7 @@ class SignalObject(dbus.service.Object): if acc not in gajim.connections: continue status_ = gajim.SHOW_LIST[gajim.connections[acc].connected] - gobject.idle_add(gajim.interface.roster.send_status, acc, + GObject.idle_add(gajim.interface.roster.send_status, acc, status_, message) return DBUS_BOOLEAN(False) @@ -581,7 +581,7 @@ class SignalObject(dbus.service.Object): gajim.config.set_per('accounts', account, 'priority', prio) show = gajim.SHOW_LIST[gajim.connections[account].connected] status = gajim.connections[account].status - gobject.idle_add(gajim.connections[account].change_status, show, + GObject.idle_add(gajim.connections[account].change_status, show, status) else: # account not specified, so change prio of all accounts @@ -594,7 +594,7 @@ class SignalObject(dbus.service.Object): gajim.config.set_per('accounts', acc, 'priority', prio) show = gajim.SHOW_LIST[gajim.connections[acc].connected] status = gajim.connections[acc].status - gobject.idle_add(gajim.connections[acc].change_status, show, + GObject.idle_add(gajim.connections[acc].change_status, show, status) @dbus.service.method(INTERFACE, in_signature='', out_signature='') @@ -687,12 +687,12 @@ class SignalObject(dbus.service.Object): """ win = gajim.interface.roster.window if win.get_property('visible'): - gobject.idle_add(win.hide) + GObject.idle_add(win.hide) else: win.present() # preserve the 'steal focus preservation' if self._is_first(): - win.window.focus(gtk.get_current_event_time()) + win.window.focus(Gtk.get_current_event_time()) else: win.window.focus(long(time())) @@ -705,7 +705,7 @@ class SignalObject(dbus.service.Object): win.present() # preserve the 'steal focus preservation' if self._is_first(): - win.window.focus(gtk.get_current_event_time()) + win.window.focus(Gtk.get_current_event_time()) else: win.window.focus(long(time())) @@ -717,7 +717,7 @@ class SignalObject(dbus.service.Object): win = gajim.ipython_window if win: if win.window.is_visible(): - gobject.idle_add(win.hide) + GObject.idle_add(win.hide) else: win.show_all() win.present() diff --git a/src/roster_window.py b/src/roster_window.py index d901ce0f8..8e6565472 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -32,9 +32,11 @@ ## along with Gajim. If not, see . ## -import gtk -import pango -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GdkPixbuf +from gi.repository import Pango +from gi.repository import GObject import os import sys import time @@ -95,7 +97,7 @@ class RosterWindow: def _get_account_iter(self, name, model=None): """ - Return the gtk.TreeIter of the given account or None if not found + Return the Gtk.TreeIter of the given account or None if not found Keyword arguments: name -- the account name @@ -113,14 +115,17 @@ class RosterWindow: if model == self.model or it is None: return it try: - return self.modelfilter.convert_child_iter_to_iter(it) + (ok, it) = self.modelfilter.convert_child_iter_to_iter(it) + if ok: + return it + return None except RuntimeError: return None def _get_group_iter(self, name, account, model=None): """ - Return the gtk.TreeIter of the given group or None if not found + Return the Gtk.TreeIter of the given group or None if not found Keyword arguments: name -- the group name @@ -142,14 +147,17 @@ class RosterWindow: if model == self.model or it is None: return it try: - return self.modelfilter.convert_child_iter_to_iter(it) + (ok, it) = self.modelfilter.convert_child_iter_to_iter(it) + if ok: + return it + return None except RuntimeError: return None def _get_self_contact_iter(self, account, model=None): """ - Return the gtk.TreeIter of SelfContact or None if not found + Return the Gtk.TreeIter of SelfContact or None if not found Keyword arguments: account -- the account of SelfContact @@ -164,7 +172,7 @@ class RosterWindow: def _get_contact_iter(self, jid, account, contact=None, model=None): """ - Return a list of gtk.TreeIter of the given contact + Return a list of Gtk.TreeIter of the given contact Keyword arguments: jid -- the jid without resource @@ -201,19 +209,21 @@ class RosterWindow: its2 = [] for it in its: try: - its2.append(self.modelfilter.convert_child_iter_to_iter(it)) + (ok, it) = self.modelfilter.convert_child_iter_to_iter(it) + if ok: + its2.append(it) except RuntimeError: pass return its2 - def _iter_is_separator(self, model, titer): + def _iter_is_separator(self, model, titer, dummy): """ Return True if the given iter is a separator Keyword arguments: model -- the data model - iter -- the gtk.TreeIter to test + iter -- the Gtk.TreeIter to test """ if model[titer][0] == 'SEPARATOR': return True @@ -248,12 +258,12 @@ class RosterWindow: if gajim.account_is_securely_connected(account): # the only way to create a pixbuf from stock tls_pixbuf = self.window.render_icon( - gtk.STOCK_DIALOG_AUTHENTICATION, - gtk.ICON_SIZE_MENU) + Gtk.STOCK_DIALOG_AUTHENTICATION, + Gtk.IconSize.MENU) it = self.model.append(None, [ gajim.interface.jabber_state_images['16'][show], - gobject.markup_escape_text(account), 'account', our_jid, + GObject.markup_escape_text(account), 'account', our_jid, account, None, None, None, None, None, tls_pixbuf] + [None] * self.nb_ext_renderers) self._iters[account]['account'] = it @@ -309,7 +319,7 @@ class RosterWindow: iter_parent = self._get_account_iter(account, self.model) iter_group = self.model.append(iter_parent, [gajim.interface.jabber_state_images['16']['closed'], - gobject.markup_escape_text(group), 'group', group, account, None, + GObject.markup_escape_text(group), 'group', group, account, None, None, None, None, None, None] + [None] * self.nb_ext_renderers) self.draw_group(group, account) self._iters[account_group]['groups'][group] = iter_group @@ -1022,10 +1032,10 @@ class RosterWindow: self.regroup and num_of_secured and num_of_secured == num_of_accounts: # the only way to create a pixbuf from stock tls_pixbuf = self.window.render_icon( - gtk.STOCK_DIALOG_AUTHENTICATION, gtk.ICON_SIZE_MENU) + Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU) self.model[child_iter][C_PADLOCK_PIXBUF] = tls_pixbuf else: - self.model[child_iter][C_PADLOCK_PIXBUF] = None + self.model[child_iter][C_PADLOCK_PIXBUF] = "" if self.regroup: account_name = _('Merged accounts') @@ -1052,27 +1062,27 @@ class RosterWindow: self.model[child_iter][C_MOOD_PIXBUF] = pep_dict['mood'].\ asPixbufIcon() else: - self.model[child_iter][C_MOOD_PIXBUF] = None + self.model[child_iter][C_MOOD_PIXBUF] = "" if gajim.config.get('show_activity_in_roster') and 'activity' in \ pep_dict: self.model[child_iter][C_ACTIVITY_PIXBUF] = pep_dict['activity'].\ asPixbufIcon() else: - self.model[child_iter][C_ACTIVITY_PIXBUF] = None + self.model[child_iter][C_ACTIVITY_PIXBUF] = "" if gajim.config.get('show_tunes_in_roster') and 'tune' in pep_dict: self.model[child_iter][C_TUNE_PIXBUF] = pep_dict['tune'].\ asPixbufIcon() else: - self.model[child_iter][C_TUNE_PIXBUF] = None + self.model[child_iter][C_TUNE_PIXBUF] = "" if gajim.config.get('show_location_in_roster') and 'location' in \ pep_dict: self.model[child_iter][C_LOCATION_PIXBUF] = pep_dict['location'].\ asPixbufIcon() else: - self.model[child_iter][C_LOCATION_PIXBUF] = None + self.model[child_iter][C_LOCATION_PIXBUF] = "" def _really_draw_accounts(self): for acct in self.accounts_to_draw: @@ -1085,7 +1095,7 @@ class RosterWindow: return self.accounts_to_draw.append(account) if len(self.accounts_to_draw) == 1: - gobject.timeout_add(200, self._really_draw_accounts) + GObject.timeout_add(200, self._really_draw_accounts) def _really_draw_group(self, group, account): child_iter = self._get_group_iter(group, account, model=self.model) @@ -1097,7 +1107,7 @@ class RosterWindow: accounts = [] else: accounts = [account] - text = gobject.markup_escape_text(group) + text = GObject.markup_escape_text(group) if helpers.group_is_blocked(account, group): text = '%s' % text if gajim.config.get('show_contacts_number'): @@ -1121,7 +1131,7 @@ class RosterWindow: return self.groups_to_draw[ag] = {'group': group, 'account': account} if len(self.groups_to_draw) == 1: - gobject.timeout_add(200, self._really_draw_groups) + GObject.timeout_add(200, self._really_draw_groups) def draw_parent_contact(self, jid, account): child_iters = self._get_contact_iter(jid, account, model=self.model) @@ -1155,7 +1165,7 @@ class RosterWindow: if not child_iters: return False - name = gobject.markup_escape_text(contact.get_shown_name()) + name = GObject.markup_escape_text(contact.get_shown_name()) # gets number of unread gc marked messages if jid in gajim.interface.minimized_controls[account] and \ @@ -1208,7 +1218,7 @@ class RosterWindow: color.blue) name += '\n%s' % (colorstring, - gobject.markup_escape_text(status)) + GObject.markup_escape_text(status)) icon_name = helpers.get_icon_name_to_show(contact, account) # look if another resource has awaiting events @@ -1329,7 +1339,7 @@ class RosterWindow: if pep_type in contact.pep: pixbuf = contact.pep[pep_type].asPixbufIcon() else: - pixbuf = None + pixbuf = "" for child_iter in iters: self.model[child_iter][model_column] = pixbuf @@ -1340,7 +1350,7 @@ class RosterWindow: jid = self.model[iters[0]][C_JID].decode('utf-8') pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid) if pixbuf in (None, 'ask'): - scaled_pixbuf = None + scaled_pixbuf = "" else: scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster') for child_iter in iters: @@ -1401,13 +1411,13 @@ class RosterWindow: yield False task = _draw_all_contacts(jids, account) - gobject.idle_add(task.next) + GObject.idle_add(task.next) def _before_fill(self): self.tree.freeze_child_notify() self.tree.set_model(None) # disable sorting - self.model.set_sort_column_id(-2, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(-2, Gtk.SortType.ASCENDING) self.starting = True self.starting_filtering = True @@ -1424,7 +1434,7 @@ class RosterWindow: self.draw_group(group, account) self.draw_account(account) - self.model.set_sort_column_id(1, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.tree.set_model(self.modelfilter) self.tree.thaw_child_notify() self.starting_filtering = False @@ -1435,10 +1445,10 @@ class RosterWindow: Create new empty model and draw roster """ self.modelfilter = None - self.model = gtk.TreeStore(*self.columns) + self.model = Gtk.TreeStore(*self.columns) self.model.set_sort_func(1, self._compareIters) - self.model.set_sort_column_id(1, gtk.SORT_ASCENDING) + self.model.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.modelfilter = self.model.filter_new() self.modelfilter.set_visible_func(self._visible_func) self.modelfilter.connect('row-has-child-toggled', @@ -1581,7 +1591,7 @@ class RosterWindow: return False return True - def _visible_func(self, model, titer): + def _visible_func(self, model, titer, dummy): """ Determine whether iter should be visible in the treeview """ @@ -2034,7 +2044,7 @@ class RosterWindow: rect = self.tree.get_cell_area(props[0], props[1]) # position of the treeview on the screen - position = self.tree.window.get_origin() + position = self.tree.get_window().get_origin() self.tooltip.show_tooltip(contact, rect.height, position[1] + \ rect.y) else: @@ -2426,15 +2436,15 @@ class RosterWindow: # in case show_roster_on_start is False and roster is never shown # window.window is None - if self.window.window is not None: + if self.window.get_window() is not None: if gajim.config.get('save-roster-position'): - x, y = self.window.window.get_root_origin() + x, y = self.window.get_window().get_root_origin() gajim.config.set('roster_x-position', x) gajim.config.set('roster_y-position', y) width, height = self.window.get_size() # For the width use the size of the vbox containing the tree and # status combo, this will cancel out any hpaned width - width = self.xml.get_object('roster_vbox2').allocation.width + width = self.xml.get_object('roster_vbox2').get_allocation().width gajim.config.set('roster_width', width) gajim.config.set('roster_height', height) if not self.xml.get_object('roster_vbox2').get_property('visible'): @@ -2461,7 +2471,7 @@ class RosterWindow: When we quit the gtk interface - exit gtk """ self.prepare_quit() - gtk.main_quit() + Gtk.main_quit() def on_quit_request(self, widget=None): """ @@ -2562,11 +2572,11 @@ class RosterWindow: if jid in jid_list or jid == gajim.get_jid_from_account(account): if not gajim.jid_is_transport(jid) and len(obj.contact_list) == 1: if obj.old_show == 0 and obj.new_show > 1: - gobject.timeout_add_seconds(5, self.remove_newly_added, jid, + GObject.timeout_add_seconds(5, self.remove_newly_added, jid, account) elif obj.old_show > 1 and obj.new_show == 0 and \ obj.conn.connected > 1: - gobject.timeout_add_seconds(5, self.remove_to_be_removed, + GObject.timeout_add_seconds(5, self.remove_to_be_removed, jid, account) if obj.need_redraw: @@ -2589,7 +2599,7 @@ class RosterWindow: if obj.popup: ctrl = gajim.interface.msg_win_mgr.search_control(jid, account) if ctrl: - gobject.idle_add(ctrl.parent_win.set_active_tab, ctrl) + GObject.idle_add(ctrl.parent_win.set_active_tab, ctrl) else: ctrl = gajim.interface.new_chat(obj.contact, account) if len(gajim.events.get_events(account, obj.jid)): @@ -2629,7 +2639,7 @@ class RosterWindow: account) gajim.config.set_per('accounts', account, 'opened_chat_controls', '') - gobject.idle_add(self.refilter_shown_roster_items) + GObject.idle_add(self.refilter_shown_roster_items) def _nec_anonymous_auth(self, obj): """ @@ -2859,7 +2869,7 @@ class RosterWindow: # no connected contacts, show the ofline one connected_contacts = contacts self.tooltip.account = account - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, connected_contacts) elif model[titer][C_TYPE] == 'groupchat': if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: @@ -2868,7 +2878,7 @@ class RosterWindow: self.tooltip.id = row contact = gajim.contacts.get_contacts(account, jid) self.tooltip.account = account - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, contact) elif model[titer][C_TYPE] == 'account': # we're on an account entry in the roster @@ -2877,7 +2887,7 @@ class RosterWindow: if account == 'all': self.tooltip.id = row self.tooltip.account = None - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, []) return jid = gajim.get_jid_from_account(account) @@ -2931,7 +2941,7 @@ class RosterWindow: contacts.append(contact) self.tooltip.id = row self.tooltip.account = None - self.tooltip.timeout = gobject.timeout_add(500, + self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip, contacts) def on_agent_logging(self, widget, jid, state, account): @@ -3158,7 +3168,7 @@ class RosterWindow: old_text = jid title = _('Rename Group') message = _('Enter a new name for group %s') % \ - gobject.markup_escape_text(jid) + GObject.markup_escape_text(jid) def on_renamed(new_text, account, row_type, jid, old_text): if 'rename' in gajim.interface.instances: @@ -3264,12 +3274,12 @@ class RosterWindow: dialogs.ErrorDialog(_('Could not load image'), msg) return try: - pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_file) + pixbuf = GdkPixbuf.Pixbuf.new_from_file(path_to_file) if filesize > 16384: # 16 kb # get the image at 'tooltip size' # and hope that user did not specify in ACE crazy size pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'tooltip') - except gobject.GError, msg: # unknown format + except GObject.GError, msg: # unknown format # msg should be string, not object instance msg = str(msg) dialogs.ErrorDialog(_('Could not load image'), msg) @@ -3405,7 +3415,7 @@ class RosterWindow: if gc_control: mw = gajim.interface.msg_win_mgr.get_window(jid, account) mw.set_active_tab(gc_control) - mw.window.window.focus(gtk.get_current_event_time()) + mw.window.window.focus(Gtk.get_current_event_time()) return ctrl = gajim.interface.minimized_controls[account][jid] mw = gajim.interface.msg_win_mgr.get_window(jid, account) @@ -3415,7 +3425,7 @@ class RosterWindow: ctrl.parent_win = mw mw.new_tab(ctrl) mw.set_active_tab(ctrl) - mw.window.window.focus(gtk.get_current_event_time()) + mw.window.window.focus(Gtk.get_current_event_time()) self.remove_groupchat(jid, account) def on_edit_account(self, widget, account): @@ -3458,12 +3468,12 @@ class RosterWindow: When a key is pressed in the treeviews """ self.tooltip.hide_tooltip() - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: if self.rfilter_enabled: self.disable_rfilter() else: self.tree.get_selection().unselect_all() - elif event.keyval == gtk.keysyms.F2: + elif event.keyval == Gdk.KEY_F2: treeselection = self.tree.get_selection() model, list_of_paths = treeselection.get_selected_rows() if len(list_of_paths) != 1: @@ -3475,7 +3485,7 @@ class RosterWindow: account = model[path][C_ACCOUNT].decode('utf-8') self.on_rename(widget, type_, jid, account) - elif event.keyval == gtk.keysyms.Delete: + elif event.keyval == Gdk.KEY_Delete: treeselection = self.tree.get_selection() model, list_of_paths = treeselection.get_selected_rows() if not len(list_of_paths): @@ -3499,17 +3509,17 @@ class RosterWindow: elif type_ == 'agent': self.on_remove_agent(widget, list_) - elif not (event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.MOD1_MASK)) and\ - gtk.gdk.keyval_to_unicode(event.keyval): + elif not (event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)) and\ + Gdk.keyval_to_unicode(event.keyval): # if we got unicode symbol without ctrl / alt - num = gtk.gdk.keyval_to_unicode(event.keyval) + num = Gdk.keyval_to_unicode(event.keyval) self.enable_rfilter(unichr(num)) - elif event.state & gtk.gdk.CONTROL_MASK and event.state & gtk.gdk.SHIFT_MASK and event.keyval == gtk.keysyms.U: + elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.get_state() & Gdk.ModifierType.SHIFT_MASK and event.keyval == Gdk.KEY_U: self.enable_rfilter('') self.rfilter_entry.emit('key_press_event', event) - elif event.keyval == gtk.keysyms.Left: + elif event.keyval == Gdk.KEY_Left: treeselection = self.tree.get_selection() model, list_of_paths = treeselection.get_selected_rows() if len(list_of_paths) != 1: @@ -3522,7 +3532,7 @@ class RosterWindow: elif len(path) > 1: self.tree.set_cursor(path[:-1]) return True - elif event.keyval == gtk.keysyms.Right: + elif event.keyval == Gdk.KEY_Right: treeselection = self.tree.get_selection() model, list_of_paths = treeselection.get_selected_rows() if len(list_of_paths) != 1: @@ -3540,8 +3550,8 @@ class RosterWindow: return False if event.button == 1: # Left click - if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK and \ - not event.state & gtk.gdk.CONTROL_MASK: + if gajim.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ + not event.get_state() & Gdk.ModifierType.CONTROL_MASK: # Check if button has been pressed on the same row if self.clicked_path == path: self.on_row_activated(widget, path) @@ -3549,8 +3559,8 @@ class RosterWindow: def accel_group_func(self, accel_group, acceleratable, keyval, modifier): # CTRL mask - if modifier & gtk.gdk.CONTROL_MASK: - if keyval == gtk.keysyms.s: # CTRL + s + if modifier & Gdk.ModifierType.CONTROL_MASK: + if keyval == Gdk.KEY_s: # CTRL + s model = self.status_combobox.get_model() accounts = gajim.connections.keys() status = model[self.previous_status_combobox_active][2].decode( @@ -3633,8 +3643,8 @@ class RosterWindow: x_min = gajim.config.get('roster_avatar_width') else: x_min = 0 - if gajim.single_click and not event.state & gtk.gdk.SHIFT_MASK and \ - not event.state & gtk.gdk.CONTROL_MASK: + if gajim.single_click and not event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ + not event.get_state() & Gdk.ModifierType.CONTROL_MASK: # Don't handle double click if we press icon of a metacontact titer = model.get_iter(path) if x > x_min and x < x_min + 27 and type_ == 'contact' and \ @@ -4058,7 +4068,7 @@ class RosterWindow: self.draw_contact(jid, account, selected=True, focus=False) def on_roster_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: if self.rfilter_enabled: self.disable_rfilter() return @@ -4074,8 +4084,8 @@ class RosterWindow: 'allow_hide_roster')): self.tooltip.hide_tooltip() self.window.hide() - elif event.state & gtk.gdk.CONTROL_MASK and event.keyval == \ - gtk.keysyms.i: + elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \ + Gdk.KEY_i: treeselection = self.tree.get_selection() model, list_of_paths = treeselection.get_selected_rows() for path in list_of_paths: @@ -4086,8 +4096,8 @@ class RosterWindow: contact = gajim.contacts.get_first_contact_from_jid(account, jid) self.on_info(widget, contact, account) - elif event.state & gtk.gdk.CONTROL_MASK and event.keyval == \ - gtk.keysyms.h: + elif event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == \ + Gdk.KEY_h: treeselection = self.tree.get_selection() model, list_of_paths = treeselection.get_selected_rows() if len(list_of_paths) != 1: @@ -4102,7 +4112,7 @@ class RosterWindow: self.on_history(widget, contact, account) def on_roster_window_popup_menu(self, widget): - event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) + event = Gdk.Event(Gdk.KEY_PRESS) self.show_treeview_menu(event) def on_row_activated(self, widget, path): @@ -4319,7 +4329,7 @@ class RosterWindow: if self.filtering: # Prevent endless loops jid = model[titer][C_JID].decode('utf-8') - gobject.idle_add(self.draw_contact, jid, account) + GObject.idle_add(self.draw_contact, jid, account) elif type_ == 'group': group = model[titer][C_JID].decode('utf-8') self._adjust_group_expand_collapse_state(group, account) @@ -4341,7 +4351,7 @@ class RosterWindow: # if len(self._last_selected_contact): # # update unselected rows # for (jid, account) in self._last_selected_contact: -# gobject.idle_add(self.draw_contact, jid, +# GObject.idle_add(self.draw_contact, jid, # account) # self._last_selected_contact = [] # if len(list_of_paths) == 0: @@ -4354,7 +4364,7 @@ class RosterWindow: # jid = row[C_JID].decode('utf-8') # account = row[C_ACCOUNT].decode('utf-8') # self._last_selected_contact.append((jid, account)) -# gobject.idle_add(self.draw_contact, jid, account, True) +# GObject.idle_add(self.draw_contact, jid, account, True) def on_service_disco_menuitem_activate(self, widget, account): server_jid = gajim.config.get_per('accounts', account, 'hostname') @@ -4435,16 +4445,16 @@ class RosterWindow: self.disable_rfilter() def on_rfilter_entry_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.disable_rfilter() - elif event.keyval == gtk.keysyms.Return: + elif event.keyval == Gdk.KEY_Return: self.tree.grab_focus() self.tree.emit('key_press_event', event) self.disable_rfilter() - elif event.keyval in (gtk.keysyms.Up, gtk.keysyms.Down): + elif event.keyval in (Gdk.KEY_Up, Gdk.KEY_Down): self.tree.grab_focus() self.tree.emit('key_press_event', event) - elif event.keyval == gtk.keysyms.BackSpace: + elif event.keyval == Gdk.KEY_BackSpace: if widget.get_text() == '': self.disable_rfilter() @@ -4473,9 +4483,9 @@ class RosterWindow: def on_roster_hpaned_notify(self, pane, gparamspec): """ Keep changing the width of the roster - (when a gtk.Paned widget handle is dragged) + (when a Gtk.Paned widget handle is dragged) """ - if gparamspec.name == 'position': + if gparamspec and gparamspec.name == 'position': roster_width = pane.get_child1().allocation.width gajim.config.set('roster_width', roster_width) @@ -4653,7 +4663,7 @@ class RosterWindow: self.remove_contact_from_groups(c_source.jid, account, [grp_source]) - if context.action in (gtk.gdk.ACTION_MOVE, gtk.gdk.ACTION_COPY): + if context.action in (Gdk.DragAction.MOVE, Gdk.DragAction.COPY): context.finish(True, True, etime) def drag_drop(self, treeview, context, x, y, timestamp): @@ -4681,10 +4691,10 @@ class RosterWindow: data = selection.data path_dest, position = drop_info - if position == gtk.TREE_VIEW_DROP_BEFORE and len(path_dest) == 2 \ + if position == Gtk.TreeViewDropPosition.BEFORE and len(path_dest) == 2 \ and path_dest[1] == 0: # dropped before the first group return - if position == gtk.TREE_VIEW_DROP_BEFORE and len(path_dest) == 2: + if position == Gtk.TreeViewDropPosition.BEFORE and len(path_dest) == 2: # dropped before a group: we drop it in the previous group every # time path_dest = (path_dest[0], path_dest[1]-1) @@ -4851,29 +4861,29 @@ class RosterWindow: drop_in_middle_of_meta = False if type_dest == 'contact': - if position == gtk.TREE_VIEW_DROP_BEFORE and len(path_dest) == 4: + if position == Gtk.TreeViewDropPosition.BEFORE and len(path_dest) == 4: drop_in_middle_of_meta = True - if position == gtk.TREE_VIEW_DROP_AFTER and (len(path_dest) == 4 or\ + if position == Gtk.TreeViewDropPosition.AFTER and (len(path_dest) == 4 or\ self.modelfilter.iter_has_child(iter_dest)): drop_in_middle_of_meta = True # Contact drop on group row or between two contacts that are # not metacontacts - if (type_dest == 'group' or position in (gtk.TREE_VIEW_DROP_BEFORE, - gtk.TREE_VIEW_DROP_AFTER)) and not drop_in_middle_of_meta: + if (type_dest == 'group' or position in (Gtk.TreeViewDropPosition.BEFORE, + Gtk.TreeViewDropPosition.AFTER)) and not drop_in_middle_of_meta: self.on_drop_in_group(None, account_source, c_source, grp_dest, is_big_brother, context, etime, grp_source) return # Contact drop on another contact, make meta contacts - if position == gtk.TREE_VIEW_DROP_INTO_OR_AFTER or \ - position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE or drop_in_middle_of_meta: + if position == Gtk.TreeViewDropPosition.INTO_OR_AFTER or \ + position == Gtk.TreeViewDropPosition.INTO_OR_BEFORE or drop_in_middle_of_meta: c_dest = gajim.contacts.get_contact_with_highest_priority( account_dest, jid_dest) if not c_dest: # c_dest is None if jid_dest doesn't belong to account return - menu = gtk.Menu() - item = gtk.MenuItem(_('Send %s to %s') % (c_source.get_shown_name(), + menu = Gtk.Menu() + item = Gtk.MenuItem(_('Send %s to %s') % (c_source.get_shown_name(), c_dest.get_shown_name())) item.connect('activate', self.on_drop_rosterx, account_source, c_source, account_dest, c_dest, is_big_brother, context, etime) @@ -4884,10 +4894,10 @@ class RosterWindow: source_family = gajim.contacts.get_metacontacts_family( account_source, c_source.jid) if dest_family == source_family: - item = gtk.MenuItem(_('Make %s first contact') % ( + item = Gtk.MenuItem(_('Make %s first contact') % ( c_source.get_shown_name())) else: - item = gtk.MenuItem(_('Make %s and %s metacontacts') % ( + item = Gtk.MenuItem(_('Make %s and %s metacontacts') % ( c_source.get_shown_name(), c_dest.get_shown_name())) item.connect('activate', self.on_drop_in_contact, account_source, @@ -4948,7 +4958,7 @@ class RosterWindow: self.setup_and_draw_roster() # Update the status combobox model = self.status_combobox.get_model() - titer = model.get_iter_root() + titer = model.get_iter_first() while titer: if model[titer][2] != '': # If it's not change status message iter @@ -5049,10 +5059,10 @@ class RosterWindow: Set style for treeview cell, using PRELIGHT system color """ if set_background: - bgcolor = self.tree.style.bg[style] + bgcolor = self.tree.get_style().bg[style] renderer.set_property('cell-background-gdk', bgcolor) else: - fgcolor = self.tree.style.fg[style] + fgcolor = self.tree.get_style().fg[style] renderer.set_property('foreground-gdk', fgcolor) def _iconCellDataFunc(self, column, renderer, model, titer, data=None): @@ -5102,7 +5112,7 @@ class RosterWindow: if color: renderer.set_property('foreground', color) else: - self.set_renderer_color(renderer, gtk.STATE_ACTIVE, False) + self.set_renderer_color(renderer, Gtk.StateType.ACTIVE, False) renderer.set_property('font', gtkgui_helpers.get_theme_font_for_option(theme, 'accountfont')) renderer.set_property('xpad', 0) @@ -5113,7 +5123,7 @@ class RosterWindow: if color: renderer.set_property('foreground', color) else: - self.set_renderer_color(renderer, gtk.STATE_PRELIGHT, False) + self.set_renderer_color(renderer, Gtk.StateType.PRELIGHT, False) renderer.set_property('font', gtkgui_helpers.get_theme_font_for_option(theme, 'groupfont')) parent_iter = model.iter_parent(titer) @@ -5240,7 +5250,7 @@ class RosterWindow: if color: renderer.set_property('cell-background', color) else: - self.set_renderer_color(renderer, gtk.STATE_ACTIVE) + self.set_renderer_color(renderer, Gtk.StateType.ACTIVE) def _set_contact_row_background_color(self, renderer, jid, account): theme = gajim.config.get('roster_theme') @@ -5260,7 +5270,7 @@ class RosterWindow: if color: renderer.set_property('cell-background', color) else: - self.set_renderer_color(renderer, gtk.STATE_PRELIGHT) + self.set_renderer_color(renderer, Gtk.StateType.PRELIGHT) ################################################################################ ### Everything about building menus @@ -5315,14 +5325,14 @@ class RosterWindow: self.profile_avatar_menuitem_handler_id = None # remove the existing submenus - add_new_contact_menuitem.remove_submenu() - service_disco_menuitem.remove_submenu() - join_gc_menuitem.remove_submenu() - single_message_menuitem.remove_submenu() - advanced_menuitem.remove_submenu() - profile_avatar_menuitem.remove_submenu() + add_new_contact_menuitem.set_submenu(None) + service_disco_menuitem.set_submenu(None) + join_gc_menuitem.set_submenu(None) + single_message_menuitem.set_submenu(None) + advanced_menuitem.set_submenu(None) + profile_avatar_menuitem.set_submenu(None) - gc_sub_menu = gtk.Menu() # gc is always a submenu + gc_sub_menu = Gtk.Menu() # gc is always a submenu join_gc_menuitem.set_submenu(gc_sub_menu) connected_accounts = gajim.get_number_of_connected_accounts() @@ -5334,7 +5344,7 @@ class RosterWindow: if connected_accounts > 2 or \ (connected_accounts > 1 and not gajim.zeroconf_is_connected()): # 2 or more "real" (no zeroconf) accounts? make submenus - new_chat_sub_menu = gtk.Menu() + new_chat_sub_menu = Gtk.Menu() for account in accounts_list: if gajim.connections[account].connected <= 1 or \ @@ -5343,8 +5353,8 @@ class RosterWindow: continue # new chat - new_chat_item = gtk.MenuItem(_('using account %s') % account, - False) + new_chat_item = Gtk.MenuItem(_('using account %s') % account, + use_underline=False) new_chat_sub_menu.append(new_chat_item) new_chat_item.connect('activate', self.on_new_chat_menuitem_activate, account) @@ -5386,9 +5396,9 @@ class RosterWindow: break # No other account connected else: # 2 or more 'real' accounts are connected, make submenus - single_message_sub_menu = gtk.Menu() - add_sub_menu = gtk.Menu() - disco_sub_menu = gtk.Menu() + single_message_sub_menu = Gtk.Menu() + add_sub_menu = Gtk.Menu() + disco_sub_menu = Gtk.Menu() for account in accounts_list: if gajim.connections[account].connected <= 1 or \ @@ -5397,8 +5407,8 @@ class RosterWindow: continue # single message - single_message_item = gtk.MenuItem(_('using account %s') % \ - account, False) + single_message_item = Gtk.MenuItem(_('using account %s') % \ + account, use_underline=False) single_message_sub_menu.append(single_message_item) single_message_item.connect('activate', self.on_send_single_message_menuitem_activate, account) @@ -5406,20 +5416,22 @@ class RosterWindow: # join gc if gajim.connections[account].private_storage_supported: connected_accounts_with_private_storage += 1 - gc_item = gtk.MenuItem(_('using account %s') % account, False) + gc_item = Gtk.MenuItem(_('using account %s') % account, + use_underline=False) gc_sub_menu.append(gc_item) - gc_menuitem_menu = gtk.Menu() + gc_menuitem_menu = Gtk.Menu() self.add_bookmarks_list(gc_menuitem_menu, account) gc_item.set_submenu(gc_menuitem_menu) # add - add_item = gtk.MenuItem(_('to %s account') % account, False) + add_item = Gtk.MenuItem(_('to %s account') % account, + use_underline=False) add_sub_menu.append(add_item) add_item.connect('activate', self.on_add_new_contact, account) # disco - disco_item = gtk.MenuItem(_('using %s account') % account, - False) + disco_item = Gtk.MenuItem(_('using %s account') % account, + use_underline=False) disco_sub_menu.append(disco_item) disco_item.connect('activate', self.on_service_disco_menuitem_activate, account) @@ -5454,12 +5466,12 @@ class RosterWindow: item.set_sensitive(False) # Manage GC bookmarks - newitem = gtk.SeparatorMenuItem() # separator + newitem = Gtk.SeparatorMenuItem() # separator gc_sub_menu.append(newitem) - newitem = gtk.ImageMenuItem(_('_Manage Bookmarks...')) - img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, - gtk.ICON_SIZE_MENU) + newitem = Gtk.ImageMenuItem(_('_Manage Bookmarks...')) + img = Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, + Gtk.IconSize.MENU) newitem.set_image(img) newitem.connect('activate', self.on_manage_bookmarks_menuitem_activate) gc_sub_menu.append(newitem) @@ -5474,11 +5486,11 @@ class RosterWindow: connected_accounts_with_vcard.append(account) if len(connected_accounts_with_vcard) > 1: # 2 or more accounts? make submenus - profile_avatar_sub_menu = gtk.Menu() + profile_avatar_sub_menu = Gtk.Menu() for account in connected_accounts_with_vcard: # profile, avatar - profile_avatar_item = gtk.MenuItem(_('of account %s') % account, - False) + profile_avatar_item = Gtk.MenuItem(_('of account %s') % account, + use_underline=False) profile_avatar_sub_menu.append(profile_avatar_item) profile_avatar_item.connect('activate', self.on_profile_avatar_menuitem_activate, account) @@ -5512,14 +5524,14 @@ class RosterWindow: advanced_menuitem.set_submenu(advanced_menuitem_menu) advanced_menuitem_menu.show_all() else: # user has *more* than one account : build advanced submenus - advanced_sub_menu = gtk.Menu() + advanced_sub_menu = Gtk.Menu() accounts = [] # Put accounts in a list to sort them for account in gajim.connections: accounts.append(account) accounts.sort() for account in accounts: - advanced_item = gtk.MenuItem(_('for account %s') % account, - False) + advanced_item = Gtk.MenuItem(_('for account %s') % account, + use_underline=False) advanced_sub_menu.append(advanced_item) advanced_menuitem_menu = \ self.get_and_connect_advanced_menuitem_menu(account) @@ -5559,12 +5571,12 @@ class RosterWindow: execute_command_menuitem = xml.get_object( 'execute_command_menuitem') edit_account_menuitem = xml.get_object('edit_account_menuitem') - sub_menu = gtk.Menu() + sub_menu = Gtk.Menu() status_menuitem.set_submenu(sub_menu) for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): uf_show = helpers.get_uf_show(show, use_mnemonic=True) - item = gtk.ImageMenuItem(uf_show) + item = Gtk.ImageMenuItem(uf_show) icon = state_images[show] item.set_image(icon) sub_menu.append(item) @@ -5575,10 +5587,10 @@ class RosterWindow: else: item.connect('activate', self.change_status, account, show) - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() sub_menu.append(item) - item = gtk.ImageMenuItem(_('_Change Status Message')) + item = Gtk.ImageMenuItem(_('_Change Status Message')) gtkgui_helpers.add_image_to_menuitem(item, 'gajim-kbd_input') sub_menu.append(item) item.connect('activate', self.on_change_status_message_activate, @@ -5586,11 +5598,11 @@ class RosterWindow: if gajim.connections[account].connected < 2: item.set_sensitive(False) - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() sub_menu.append(item) uf_show = helpers.get_uf_show('offline', use_mnemonic=True) - item = gtk.ImageMenuItem(uf_show) + item = Gtk.ImageMenuItem(uf_show) icon = state_images['offline'] item.set_image(icon) sub_menu.append(item) @@ -5598,10 +5610,10 @@ class RosterWindow: pep_menuitem = xml.get_object('pep_menuitem') if gajim.connections[account].pep_supported: - pep_submenu = gtk.Menu() + pep_submenu = Gtk.Menu() pep_menuitem.set_submenu(pep_submenu) def add_item(label, opt_name, func): - item = gtk.CheckMenuItem(label) + item = Gtk.CheckMenuItem(label) pep_submenu.append(item) if not dbus_support.supported: item.set_sensitive(False) @@ -5616,15 +5628,15 @@ class RosterWindow: add_item(_('Publish Location'), 'publish_location', self.on_publish_location_toggled) - pep_config = gtk.ImageMenuItem(_('Configure Services...')) - item = gtk.SeparatorMenuItem() + pep_config = Gtk.ImageMenuItem(_('Configure Services...')) + item = Gtk.SeparatorMenuItem() pep_submenu.append(item) pep_config.set_sensitive(True) pep_submenu.append(pep_config) pep_config.connect('activate', self.on_pep_services_menuitem_activate, account) - img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, - gtk.ICON_SIZE_MENU) + img = Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, + Gtk.IconSize.MENU) pep_config.set_image(img) else: @@ -5655,7 +5667,7 @@ class RosterWindow: start_chat_menuitem.connect('activate', self.on_new_chat_menuitem_activate, account) - gc_sub_menu = gtk.Menu() # gc is always a submenu + gc_sub_menu = Gtk.Menu() # gc is always a submenu join_group_chat_menuitem.set_submenu(gc_sub_menu) self.add_bookmarks_list(gc_sub_menu, account) @@ -5672,21 +5684,21 @@ class RosterWindow: status_menuitem = xml.get_object('status_menuitem') zeroconf_properties_menuitem = xml.get_object( 'zeroconf_properties_menuitem') - sub_menu = gtk.Menu() + sub_menu = Gtk.Menu() status_menuitem.set_submenu(sub_menu) for show in ('online', 'away', 'dnd', 'invisible'): uf_show = helpers.get_uf_show(show, use_mnemonic=True) - item = gtk.ImageMenuItem(uf_show) + item = Gtk.ImageMenuItem(uf_show) icon = state_images[show] item.set_image(icon) sub_menu.append(item) item.connect('activate', self.change_status, account, show) - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() sub_menu.append(item) - item = gtk.ImageMenuItem(_('_Change Status Message')) + item = Gtk.ImageMenuItem(_('_Change Status Message')) gtkgui_helpers.add_image_to_menuitem(item, 'gajim-kbd_input') sub_menu.append(item) item.connect('activate', self.on_change_status_message_activate, @@ -5695,7 +5707,7 @@ class RosterWindow: item.set_sensitive(False) uf_show = helpers.get_uf_show('offline', use_mnemonic=True) - item = gtk.ImageMenuItem(uf_show) + item = Gtk.ImageMenuItem(uf_show) icon = state_images['offline'] item.set_image(icon) sub_menu.append(item) @@ -5716,7 +5728,7 @@ class RosterWindow: if account != 'all': # not in merged mode menu = self.build_account_menu(account) else: - menu = gtk.Menu() + menu = Gtk.Menu() iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') accounts = [] # Put accounts in a list to sort them @@ -5725,7 +5737,7 @@ class RosterWindow: accounts.sort() for account in accounts: state_images = gtkgui_helpers.load_iconset(path) - item = gtk.ImageMenuItem(account) + item = Gtk.ImageMenuItem(account) show = gajim.SHOW_LIST[gajim.connections[account].connected] icon = state_images[show] item.set_image(icon) @@ -5760,32 +5772,32 @@ class RosterWindow: if contact.show not in ('offline', 'error'): list_online.append((contact, account)) list_.append((contact, account)) - menu = gtk.Menu() + menu = Gtk.Menu() # Make special context menu if group is Groupchats if group == _('Groupchats'): - maximize_menuitem = gtk.ImageMenuItem(_('_Maximize All')) - icon = gtk.image_new_from_stock(gtk.STOCK_GOTO_TOP, - gtk.ICON_SIZE_MENU) + maximize_menuitem = Gtk.ImageMenuItem(_('_Maximize All')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_GOTO_TOP, + Gtk.IconSize.MENU) maximize_menuitem.set_image(icon) maximize_menuitem.connect('activate', self.on_all_groupchat_maximized, list_) menu.append(maximize_menuitem) else: # Send Group Message - send_group_message_item = gtk.ImageMenuItem( + send_group_message_item = Gtk.ImageMenuItem( _('Send Group M_essage')) - icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU) send_group_message_item.set_image(icon) - send_group_message_submenu = gtk.Menu() + send_group_message_submenu = Gtk.Menu() send_group_message_item.set_submenu(send_group_message_submenu) menu.append(send_group_message_item) - group_message_to_all_item = gtk.MenuItem(_('To all users')) + group_message_to_all_item = Gtk.MenuItem(_('To all users')) send_group_message_submenu.append(group_message_to_all_item) - group_message_to_all_online_item = gtk.MenuItem( + group_message_to_all_online_item = Gtk.MenuItem( _('To all online users')) send_group_message_submenu.append(group_message_to_all_online_item) @@ -5796,7 +5808,7 @@ class RosterWindow: self.on_send_single_message_menuitem_activate, account, list_) # Invite to - invite_menuitem = gtk.ImageMenuItem(_('In_vite to')) + invite_menuitem = Gtk.ImageMenuItem(_('In_vite to')) muc_icon = gtkgui_helpers.load_icon('muc_active') if muc_icon: invite_menuitem.set_image(muc_icon) @@ -5805,7 +5817,7 @@ class RosterWindow: menu.append(invite_menuitem) # Send Custom Status - send_custom_status_menuitem = gtk.ImageMenuItem( + send_custom_status_menuitem = Gtk.ImageMenuItem( _('Send Cus_tom Status')) # add a special img for this menuitem if helpers.group_is_blocked(account, group): @@ -5813,17 +5825,17 @@ class RosterWindow: 'offline')) send_custom_status_menuitem.set_sensitive(False) else: - icon = gtk.image_new_from_stock(gtk.STOCK_NETWORK, - gtk.ICON_SIZE_MENU) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NETWORK, + Gtk.IconSize.MENU) send_custom_status_menuitem.set_image(icon) - status_menuitems = gtk.Menu() + status_menuitems = Gtk.Menu() send_custom_status_menuitem.set_submenu(status_menuitems) iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) + status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s)) status_menuitem.connect('activate', self.on_send_custom_status, list_, s, group) icon = state_images[s] @@ -5837,11 +5849,11 @@ class RosterWindow: send_group_message_item.set_sensitive(False) if not group in helpers.special_groups: - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) # Rename - rename_item = gtk.ImageMenuItem(_('Re_name')) + rename_item = Gtk.ImageMenuItem(_('Re_name')) # add a special img for rename menuitem gtkgui_helpers.add_image_to_menuitem(rename_item, 'gajim-kbd_input') menu.append(rename_item) @@ -5860,17 +5872,17 @@ class RosterWindow: if is_blocked and gajim.connections[account].\ privacy_rules_supported: - unblock_menuitem = gtk.ImageMenuItem(_('_Unblock')) - icon = gtk.image_new_from_stock(gtk.STOCK_STOP, - gtk.ICON_SIZE_MENU) + unblock_menuitem = Gtk.ImageMenuItem(_('_Unblock')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, + Gtk.IconSize.MENU) unblock_menuitem.set_image(icon) unblock_menuitem.connect('activate', self.on_unblock, list_, group) menu.append(unblock_menuitem) else: - block_menuitem = gtk.ImageMenuItem(_('_Block')) - icon = gtk.image_new_from_stock(gtk.STOCK_STOP, - gtk.ICON_SIZE_MENU) + block_menuitem = Gtk.ImageMenuItem(_('_Block')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, + Gtk.IconSize.MENU) block_menuitem.set_image(icon) block_menuitem.connect('activate', self.on_block, list_, group) menu.append(block_menuitem) @@ -5878,9 +5890,9 @@ class RosterWindow: block_menuitem.set_sensitive(False) # Remove group - remove_item = gtk.ImageMenuItem(_('_Remove')) - icon = gtk.image_new_from_stock(gtk.STOCK_REMOVE, - gtk.ICON_SIZE_MENU) + remove_item = Gtk.ImageMenuItem(_('_Remove')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE, + Gtk.IconSize.MENU) remove_item.set_image(icon) menu.append(remove_item) remove_item.connect('activate', self.on_remove_group_item_activated, @@ -5937,7 +5949,7 @@ class RosterWindow: is_blocked = False list_.append((contact, account)) - menu = gtk.Menu() + menu = Gtk.Menu() account = None for (contact, current_account) in list_: # check that we use the same account for every sender @@ -5946,16 +5958,16 @@ class RosterWindow: break account = current_account if account is not None: - send_group_message_item = gtk.ImageMenuItem( + send_group_message_item = Gtk.ImageMenuItem( _('Send Group M_essage')) - icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU) send_group_message_item.set_image(icon) menu.append(send_group_message_item) send_group_message_item.connect('activate', self.on_send_single_message_menuitem_activate, account, list_) # Invite to Groupchat - invite_item = gtk.ImageMenuItem(_('In_vite to')) + invite_item = Gtk.ImageMenuItem(_('In_vite to')) muc_icon = gtkgui_helpers.load_icon('muc_active') if muc_icon: invite_item.set_image(muc_icon) @@ -5963,38 +5975,38 @@ class RosterWindow: gui_menu_builder.build_invite_submenu(invite_item, list_) menu.append(invite_item) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) # Manage Transport submenu - item = gtk.ImageMenuItem(_('_Manage Contacts')) - icon = gtk.image_new_from_stock(gtk.STOCK_PROPERTIES, - gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('_Manage Contacts')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, + Gtk.IconSize.MENU) item.set_image(icon) - manage_contacts_submenu = gtk.Menu() + manage_contacts_submenu = Gtk.Menu() item.set_submenu(manage_contacts_submenu) menu.append(item) # Edit Groups - edit_groups_item = gtk.ImageMenuItem(_('Edit _Groups')) - icon = gtk.image_new_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU) + edit_groups_item = Gtk.ImageMenuItem(_('Edit _Groups')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_EDIT, Gtk.IconSize.MENU) edit_groups_item.set_image(icon) manage_contacts_submenu.append(edit_groups_item) edit_groups_item.connect('activate', self.on_edit_groups, list_) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator manage_contacts_submenu.append(item) # Block if is_blocked and privacy_rules_supported: - unblock_menuitem = gtk.ImageMenuItem(_('_Unblock')) - icon = gtk.image_new_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + unblock_menuitem = Gtk.ImageMenuItem(_('_Unblock')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU) unblock_menuitem.set_image(icon) unblock_menuitem.connect('activate', self.on_unblock, list_) manage_contacts_submenu.append(unblock_menuitem) else: - block_menuitem = gtk.ImageMenuItem(_('_Block')) - icon = gtk.image_new_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + block_menuitem = Gtk.ImageMenuItem(_('_Block')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU) block_menuitem.set_image(icon) block_menuitem.connect('activate', self.on_block, list_) manage_contacts_submenu.append(block_menuitem) @@ -6003,8 +6015,8 @@ class RosterWindow: block_menuitem.set_sensitive(False) # Remove - remove_item = gtk.ImageMenuItem(_('_Remove')) - icon = gtk.image_new_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU) + remove_item = Gtk.ImageMenuItem(_('_Remove')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE, Gtk.IconSize.MENU) remove_item.set_image(icon) manage_contacts_submenu.append(remove_item) remove_item.connect('activate', self.on_req_usub, list_) @@ -6028,11 +6040,11 @@ class RosterWindow: path = model.get_path(titer) account = model[titer][C_ACCOUNT].decode('utf-8') contact = gajim.contacts.get_contact_with_highest_priority(account, jid) - menu = gtk.Menu() + menu = Gtk.Menu() # Send single message - item = gtk.ImageMenuItem(_('Send Single Message')) - icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('Send Single Message')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.on_send_single_message_menuitem_activate, account, contact) @@ -6043,7 +6055,7 @@ class RosterWindow: blocked = True # Send Custom Status - send_custom_status_menuitem = gtk.ImageMenuItem( + send_custom_status_menuitem = Gtk.ImageMenuItem( _('Send Cus_tom Status')) # add a special img for this menuitem if blocked: @@ -6056,17 +6068,17 @@ class RosterWindow: send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon( gajim.interface.status_sent_to_users[account][jid])) else: - icon = gtk.image_new_from_stock(gtk.STOCK_NETWORK, - gtk.ICON_SIZE_MENU) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NETWORK, + Gtk.IconSize.MENU) send_custom_status_menuitem.set_image(icon) - status_menuitems = gtk.Menu() + status_menuitems = Gtk.Menu() send_custom_status_menuitem.set_submenu(status_menuitems) iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) + status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s)) status_menuitem.connect('activate', self.on_send_custom_status, [(contact, account)], s) icon = state_images[s] @@ -6074,12 +6086,12 @@ class RosterWindow: status_menuitems.append(status_menuitem) menu.append(send_custom_status_menuitem) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) # Execute Command - item = gtk.ImageMenuItem(_('Execute Command...')) - icon = gtk.image_new_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('Execute Command...')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.MENU) item.set_image(icon) menu.append(item) item.connect('activate', self.on_execute_command, contact, account, @@ -6088,18 +6100,18 @@ class RosterWindow: item.set_sensitive(False) # Manage Transport submenu - item = gtk.ImageMenuItem(_('_Manage Transport')) - icon = gtk.image_new_from_stock(gtk.STOCK_PROPERTIES, - gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('_Manage Transport')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, + Gtk.IconSize.MENU) item.set_image(icon) - manage_transport_submenu = gtk.Menu() + manage_transport_submenu = Gtk.Menu() item.set_submenu(manage_transport_submenu) menu.append(item) # Modify Transport - item = gtk.ImageMenuItem(_('_Modify Transport')) - icon = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, - gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('_Modify Transport')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, + Gtk.IconSize.MENU) item.set_image(icon) manage_transport_submenu.append(item) item.connect('activate', self.on_edit_agent, contact, account) @@ -6107,7 +6119,7 @@ class RosterWindow: item.set_sensitive(False) # Rename - item = gtk.ImageMenuItem(_('_Rename')) + item = Gtk.ImageMenuItem(_('_Rename')) # add a special img for rename menuitem gtkgui_helpers.add_image_to_menuitem(item, 'gajim-kbd_input') manage_transport_submenu.append(item) @@ -6115,38 +6127,38 @@ class RosterWindow: if gajim.account_is_disconnected(account): item.set_sensitive(False) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator manage_transport_submenu.append(item) # Block if blocked: - item = gtk.ImageMenuItem(_('_Unblock')) + item = Gtk.ImageMenuItem(_('_Unblock')) item.connect('activate', self.on_unblock, [(contact, account)]) else: - item = gtk.ImageMenuItem(_('_Block')) + item = Gtk.ImageMenuItem(_('_Block')) item.connect('activate', self.on_block, [(contact, account)]) - icon = gtk.image_new_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU) item.set_image(icon) manage_transport_submenu.append(item) if gajim.account_is_disconnected(account): item.set_sensitive(False) # Remove - item = gtk.ImageMenuItem(_('_Remove')) - icon = gtk.image_new_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('_Remove')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE, Gtk.IconSize.MENU) item.set_image(icon) manage_transport_submenu.append(item) item.connect('activate', self.on_remove_agent, [(contact, account)]) if gajim.account_is_disconnected(account): item.set_sensitive(False) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) # Information - information_menuitem = gtk.ImageMenuItem(_('_Information')) - icon = gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_MENU) + information_menuitem = Gtk.ImageMenuItem(_('_Information')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.MENU) information_menuitem.set_image(icon) menu.append(information_menuitem) information_menuitem.connect('activate', self.on_info, contact, account) @@ -6164,39 +6176,39 @@ class RosterWindow: jid = model[titer][C_JID].decode('utf-8') account = model[titer][C_ACCOUNT].decode('utf-8') contact = gajim.contacts.get_contact_with_highest_priority(account, jid) - menu = gtk.Menu() + menu = Gtk.Menu() if jid in gajim.interface.minimized_controls[account]: - maximize_menuitem = gtk.ImageMenuItem(_('_Maximize')) - icon = gtk.image_new_from_stock(gtk.STOCK_GOTO_TOP, - gtk.ICON_SIZE_MENU) + maximize_menuitem = Gtk.ImageMenuItem(_('_Maximize')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_GOTO_TOP, + Gtk.IconSize.MENU) maximize_menuitem.set_image(icon) maximize_menuitem.connect('activate', self.on_groupchat_maximized, \ jid, account) menu.append(maximize_menuitem) if not gajim.gc_connected[account].get(jid, False): - connect_menuitem = gtk.ImageMenuItem(_('_Reconnect')) - connect_icon = gtk.image_new_from_stock(gtk.STOCK_CONNECT, \ - gtk.ICON_SIZE_MENU) + connect_menuitem = Gtk.ImageMenuItem(_('_Reconnect')) + connect_icon = Gtk.Image.new_from_stock(Gtk.STOCK_CONNECT, \ + Gtk.IconSize.MENU) connect_menuitem.set_image(connect_icon) connect_menuitem.connect('activate', self.on_reconnect, jid, account) menu.append(connect_menuitem) - disconnect_menuitem = gtk.ImageMenuItem(_('_Disconnect')) - disconnect_icon = gtk.image_new_from_stock(gtk.STOCK_DISCONNECT, \ - gtk.ICON_SIZE_MENU) + disconnect_menuitem = Gtk.ImageMenuItem(_('_Disconnect')) + disconnect_icon = Gtk.Image.new_from_stock(Gtk.STOCK_DISCONNECT, \ + Gtk.IconSize.MENU) disconnect_menuitem.set_image(disconnect_icon) disconnect_menuitem.connect('activate', self.on_disconnect, jid, account) menu.append(disconnect_menuitem) - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) - history_menuitem = gtk.ImageMenuItem(_('_History')) - history_icon = gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_FILL, \ - gtk.ICON_SIZE_MENU) + history_menuitem = Gtk.ImageMenuItem(_('_History')) + history_icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUSTIFY_FILL, \ + Gtk.IconSize.MENU) history_menuitem.set_image(history_icon) history_menuitem .connect('activate', self.on_history, contact, account) menu.append(history_menuitem) @@ -6268,13 +6280,13 @@ class RosterWindow: """ Add a seperator and History Manager menuitem BELOW for account menuitems """ - item = gtk.SeparatorMenuItem() # separator + item = Gtk.SeparatorMenuItem() # separator menu.append(item) # History manager - item = gtk.ImageMenuItem(_('History Manager')) - icon = gtk.image_new_from_stock(gtk.STOCK_JUSTIFY_FILL, - gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('History Manager')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_JUSTIFY_FILL, + Gtk.IconSize.MENU) item.set_image(icon) menu.append(item) item.connect('activate', self.on_history_manager_menuitem_activate) @@ -6283,8 +6295,8 @@ class RosterWindow: """ Show join new group chat item and bookmarks list for an account """ - item = gtk.ImageMenuItem(_('_Join New Group Chat')) - icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU) + item = Gtk.ImageMenuItem(_('_Join New Group Chat')) + icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.on_join_gc_activate, account) @@ -6292,12 +6304,12 @@ class RosterWindow: # User has at least one bookmark. if gajim.connections[account].bookmarks: - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() gc_sub_menu.append(item) for bookmark in gajim.connections[account].bookmarks: # Do not use underline. - item = gtk.MenuItem(bookmark['name'], False) + item = Gtk.MenuItem(bookmark['name'], use_underline=False) item.connect('activate', self.on_bookmark_menuitem_activate, account, bookmark) gc_sub_menu.append(item) @@ -6307,14 +6319,14 @@ class RosterWindow: # Just handle new_chat_menuitem to have ctrl+N working even if we don't # open the menu new_chat_menuitem = self.xml.get_object('new_chat_menuitem') - ag = gtk.accel_groups_from_object(self.window)[0] + ag = Gtk.accel_groups_from_object(self.window)#[0] if self.new_chat_menuitem_handler_id: new_chat_menuitem.handler_disconnect( self.new_chat_menuitem_handler_id) self.new_chat_menuitem_handler_id = None - new_chat_menuitem.remove_submenu() + new_chat_menuitem.set_submenu(None) connected_accounts = gajim.get_number_of_connected_accounts() if connected_accounts == 1 or (connected_accounts == 2 and \ @@ -6384,7 +6396,7 @@ class RosterWindow: def fill_column(self, col): for rend in self.renderers_list: - col.pack_start(rend[1], expand=rend[2]) + col.pack_start(rend[1], rend[2]) col.add_attribute(rend[1], rend[3], rend[4]) col.set_cell_data_func(rend[1], rend[5], rend[6]) # set renderers propertys @@ -6407,9 +6419,9 @@ class RosterWindow: # [icon, name, type, jid, account, editable, mood_pixbuf, # activity_pixbuf, tune_pixbuf, location_pixbuf, avatar_pixbuf, # padlock_pixbuf] - self.columns = [gtk.Image, str, str, str, str, - gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, - gtk.gdk.Pixbuf, gtk.gdk.Pixbuf] + self.columns = [Gtk.Image, str, str, str, str, + GdkPixbuf.Pixbuf, GdkPixbuf.Pixbuf, GdkPixbuf.Pixbuf, GdkPixbuf.Pixbuf, + GdkPixbuf.Pixbuf, GdkPixbuf.Pixbuf] self.xml = gtkgui_helpers.get_gtk_builder('roster_window.ui') self.window = self.xml.get_object('roster_window') self.hpaned = self.xml.get_object('roster_hpaned') @@ -6421,7 +6433,7 @@ class RosterWindow: self.window.set_property('skip-taskbar-hint', True) self.tree = self.xml.get_object('roster_treeview') sel = self.tree.get_selection() - sel.set_mode(gtk.SELECTION_MULTIPLE) + sel.set_mode(Gtk.SelectionMode.MULTIPLE) # sel.connect('changed', # self.on_treeview_selection_changed) @@ -6476,7 +6488,7 @@ class RosterWindow: self.accounts_to_draw = [] # uf_show, img, show, sensitive - liststore = gtk.ListStore(str, gtk.Image, str, bool) + liststore = Gtk.ListStore(str, Gtk.Image, str, bool) self.status_combobox = self.xml.get_object('status_combobox') cell = cell_renderer_image.CellRendererImage(0, 1) @@ -6489,7 +6501,7 @@ class RosterWindow: # if we want False (so we add it for img_cell too) self.status_combobox.add_attribute(cell, 'sensitive', 3) - cell = gtk.CellRendererText() + cell = Gtk.CellRendererText() cell.set_property('xpad', 5) # padding for status text self.status_combobox.pack_start(cell, True) # text to show is in in first column of liststore @@ -6497,7 +6509,7 @@ class RosterWindow: # if it will be sensitive or not it is in the fourth column self.status_combobox.add_attribute(cell, 'sensitive', 3) - self.status_combobox.set_row_separator_func(self._iter_is_separator) + self.status_combobox.set_row_separator_func(self._iter_is_separator, None) for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): uf_show = helpers.get_uf_show(show) @@ -6507,7 +6519,7 @@ class RosterWindow: liststore.append(['SEPARATOR', None, '', True]) path = gtkgui_helpers.get_icon_path('gajim-kbd_input') - img = gtk.Image() + img = Gtk.Image() img.set_from_file(path) # sensitivity to False because by default we're offline self.status_message_menuitem_iter = liststore.append( @@ -6553,7 +6565,7 @@ class RosterWindow: self.xml.get_object('show_roster_menuitem').set_active(True) # columns - col = gtk.TreeViewColumn() + col = Gtk.TreeViewColumn() # list of renderers with attributes / properties in the form: # (name, renderer_object, expand?, attribute_name, attribute_value, # cell_data_func, func_arg) @@ -6563,12 +6575,12 @@ class RosterWindow: 'activity': C_ACTIVITY_PIXBUF, 'tune': C_TUNE_PIXBUF, 'location': C_LOCATION_PIXBUF} - renderer_text = gtk.CellRendererText() + renderer_text = Gtk.CellRendererText() self.renderers_propertys[renderer_text] = ('ellipsize', - pango.ELLIPSIZE_END) + Pango.EllipsizeMode.END) def add_avatar_renderer(): - self.renderers_list.append(('avatar', gtk.CellRendererPixbuf(), + self.renderers_list.append(('avatar', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_AVATAR_PIXBUF, self._fill_avatar_pixbuf_renderer, None)) @@ -6582,26 +6594,26 @@ class RosterWindow: ('name', renderer_text, True, 'markup', C_NAME, self._nameCellDataFunc, None), - ('mood', gtk.CellRendererPixbuf(), False, + ('mood', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_MOOD_PIXBUF, self._fill_pep_pixbuf_renderer, C_MOOD_PIXBUF), - ('activity', gtk.CellRendererPixbuf(), False, + ('activity', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_ACTIVITY_PIXBUF, self._fill_pep_pixbuf_renderer, C_ACTIVITY_PIXBUF), - ('tune', gtk.CellRendererPixbuf(), False, + ('tune', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_TUNE_PIXBUF, self._fill_pep_pixbuf_renderer, C_TUNE_PIXBUF), - ('location', gtk.CellRendererPixbuf(), False, + ('location', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_LOCATION_PIXBUF, self._fill_pep_pixbuf_renderer, C_LOCATION_PIXBUF)) if gajim.config.get('avatar_position_in_roster') == 'right': add_avatar_renderer() - self.renderers_list.append(('padlock', gtk.CellRendererPixbuf(), False, + self.renderers_list.append(('padlock', Gtk.CellRendererPixbuf(), False, 'pixbuf', C_PADLOCK_PIXBUF, self._fill_padlock_pixbuf_renderer, None)) @@ -6610,9 +6622,9 @@ class RosterWindow: self.tree.append_column(col) # do not show gtk arrows workaround - col = gtk.TreeViewColumn() - render_pixbuf = gtk.CellRendererPixbuf() - col.pack_start(render_pixbuf, expand=False) + col = Gtk.TreeViewColumn() + render_pixbuf = Gtk.CellRendererPixbuf() + col.pack_start(render_pixbuf, False) self.tree.append_column(col) col.set_visible(False) self.tree.set_expander_column(col) @@ -6620,12 +6632,12 @@ class RosterWindow: # signals self.TARGET_TYPE_URI_LIST = 80 TARGETS = [('MY_TREE_MODEL_ROW', - gtk.TARGET_SAME_APP | gtk.TARGET_SAME_WIDGET, 0)] - TARGETS2 = [('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0), + Gtk.TargetFlags.SAME_APP | Gtk.TargetFlags.SAME_WIDGET, 0)] + TARGETS2 = [('MY_TREE_MODEL_ROW', Gtk.TargetFlags.SAME_WIDGET, 0), ('text/uri-list', 0, self.TARGET_TYPE_URI_LIST)] - self.tree.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, TARGETS, - gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY) - self.tree.enable_model_drag_dest(TARGETS2, gtk.gdk.ACTION_DEFAULT) + self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, TARGETS, + Gdk.DragAction.DEFAULT | Gdk.DragAction.MOVE | Gdk.DragAction.COPY) + self.tree.enable_model_drag_dest(TARGETS2, Gdk.DragAction.DEFAULT) self.tree.connect('drag_begin', self.drag_begin) self.tree.connect('drag_end', self.drag_end) self.tree.connect('drag_drop', self.drag_drop) @@ -6662,7 +6674,7 @@ class RosterWindow: config.AccountCreationWizardWindow() # Open wizard only after roster is created, so we can make it # transient for the roster window - gobject.idle_add(_open_wizard) + GObject.idle_add(_open_wizard) if not gajim.ZEROCONF_ACC_NAME in gajim.config.get_per('accounts'): # Create zeroconf in config file from common.zeroconf import connection_zeroconf @@ -6670,19 +6682,19 @@ class RosterWindow: # Setting CTRL+J to be the shortcut for bringing up the dialog to join a # conference. - accel_group = gtk.accel_groups_from_object(self.window)[0] - accel_group.connect_group(gtk.keysyms.j, gtk.gdk.CONTROL_MASK, - gtk.ACCEL_MASK, self.on_ctrl_j) + accel_group = Gtk.accel_groups_from_object(self.window)[0] + accel_group.connect(Gdk.KEY_j, Gdk.ModifierType.CONTROL_MASK, + Gtk.AccelFlags.MASK, self.on_ctrl_j) # Setting CTRL+N to be the shortcut for show Start chat dialog new_chat_menuitem = self.xml.get_object('new_chat_menuitem') new_chat_menuitem.add_accelerator('activate', accel_group, - gtk.keysyms.n, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) + Gdk.KEY_n, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) # Setting CTRL+S to be the shortcut to change status message - accel_group = gtk.AccelGroup() - keyval, mod = gtk.accelerator_parse('s') - accel_group.connect_group(keyval, mod, gtk.ACCEL_VISIBLE, + accel_group = Gtk.AccelGroup() + keyval, mod = Gtk.accelerator_parse('s') + accel_group.connect(keyval, mod, Gtk.AccelFlags.VISIBLE, self.accel_group_func) self.window.add_accel_group(accel_group) diff --git a/src/search_window.py b/src/search_window.py index 1b2f3a02b..b40bcf852 100644 --- a/src/search_window.py +++ b/src/search_window.py @@ -19,8 +19,8 @@ ## along with Gajim. If not, see . ## -import gobject -import gtk +from gi.repository import GObject +from gi.repository import Gtk from common import gajim from common import dataforms @@ -52,7 +52,7 @@ class SearchWindow: self.xml.connect_signals(self) self.window.show_all() self.request_form() - self.pulse_id = gobject.timeout_add(80, self.pulse_callback) + self.pulse_id = GObject.timeout_add(80, self.pulse_callback) self.is_form = None @@ -72,12 +72,12 @@ class SearchWindow: return True def on_search_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.destroy() def on_search_window_destroy(self, widget): if self.pulse_id: - gobject.source_remove(self.pulse_id) + GObject.source_remove(self.pulse_id) del gajim.interface.instances[self.account]['search'][self.jid] gajim.ged.remove_event_handler('search-form-received', ged.GUI1, self._nec_search_form_received) @@ -104,7 +104,7 @@ class SearchWindow: self.progressbar.show() self.label.set_text(_('Waiting for results')) self.label.show() - self.pulse_id = gobject.timeout_add(80, self.pulse_callback) + self.pulse_id = GObject.timeout_add(80, self.pulse_callback) self.search_button.hide() def on_add_contact_button_clicked(self, widget): @@ -128,7 +128,7 @@ class SearchWindow: def _nec_search_form_received(self, obj): if self.pulse_id: - gobject.source_remove(self.pulse_id) + GObject.source_remove(self.pulse_id) self.progressbar.hide() self.label.hide() @@ -151,7 +151,7 @@ class SearchWindow: self.data_form_widget = config.FakeDataForm(obj.data) self.data_form_widget.show_all() - self.search_vbox.pack_start(self.data_form_widget) + self.search_vbox.pack_start(self.data_form_widget, True, True, 0) def on_result_treeview_cursor_changed(self, treeview): if self.jid_column == -1: @@ -168,7 +168,7 @@ class SearchWindow: def _nec_search_result_received(self, obj): if self.pulse_id: - gobject.source_remove(self.pulse_id) + GObject.source_remove(self.pulse_id) self.progressbar.hide() self.label.hide() @@ -178,29 +178,29 @@ class SearchWindow: self.label.show() return # We suppose all items have the same fields - sw = gtk.ScrolledWindow() - sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self.result_treeview = gtk.TreeView() + sw = Gtk.ScrolledWindow() + sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + self.result_treeview = Gtk.TreeView() self.result_treeview.connect('cursor-changed', self.on_result_treeview_cursor_changed) sw.add(self.result_treeview) # Create model fieldtypes = [str]*len(obj.data[0]) - model = gtk.ListStore(*fieldtypes) + model = Gtk.ListStore(*fieldtypes) # Copy data to model for item in obj.data: model.append(item.values()) # Create columns counter = 0 for field in obj.data[0].keys(): - self.result_treeview.append_column(gtk.TreeViewColumn(field, - gtk.CellRendererText(), text=counter)) + self.result_treeview.append_column(Gtk.TreeViewColumn(field, + Gtk.CellRendererText(), text=counter)) if field == 'jid': self.jid_column = counter counter += 1 self.result_treeview.set_model(model) sw.show_all() - self.search_vbox.pack_start(sw) + self.search_vbox.pack_start(sw, True, True, 0) if self.jid_column > -1: self.add_contact_button.show() self.information_button.show() @@ -223,7 +223,7 @@ class SearchWindow: self.result_treeview = self.data_form_widget.records_treeview selection = self.result_treeview.get_selection() - selection.set_mode(gtk.SELECTION_SINGLE) + selection.set_mode(Gtk.SelectionMode.SINGLE) self.result_treeview.connect('cursor-changed', self.on_result_treeview_cursor_changed) @@ -233,7 +233,7 @@ class SearchWindow: self.jid_column = counter break counter += 1 - self.search_vbox.pack_start(self.data_form_widget) + self.search_vbox.pack_start(self.data_form_widget, True, True, 0) self.data_form_widget.show() if self.jid_column > -1: self.add_contact_button.show() diff --git a/src/statusicon.py b/src/statusicon.py index 6548843d7..6ce82586f 100644 --- a/src/statusicon.py +++ b/src/statusicon.py @@ -24,8 +24,8 @@ ## import sys -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject import os import dialogs @@ -86,7 +86,7 @@ class StatusIcon: def show_icon(self): if not self.status_icon: - self.status_icon = gtk.StatusIcon() + self.status_icon = Gtk.StatusIcon() self.statusicon_size = '16' self.status_icon.set_property('has-tooltip', True) self.status_icon.connect('activate', self.on_status_icon_left_clicked) @@ -135,11 +135,11 @@ class StatusIcon: Apart from image, we also update tooltip text here """ def really_set_img(): - if image.get_storage_type() == gtk.IMAGE_PIXBUF: + if image.get_storage_type() == Gtk.ImageType.PIXBUF: self.status_icon.set_from_pixbuf(image.get_pixbuf()) # FIXME: oops they forgot to support GIF animation? # or they were lazy to get it to work under Windows! WTF! - elif image.get_storage_type() == gtk.IMAGE_ANIMATION: + elif image.get_storage_type() == Gtk.ImageType.ANIMATION: self.status_icon.set_from_pixbuf( image.get_animation().get_static_image()) # self.status_icon.set_from_animation(image.get_animation()) @@ -150,16 +150,16 @@ class StatusIcon: self.status_icon.set_visible(True) if gajim.events.get_nb_systray_events(): self.status_icon.set_visible(True) - if gajim.config.get('trayicon_blink'): - self.status_icon.set_blinking(True) - else: - image = gtkgui_helpers.load_icon('event') - really_set_img() - return +# if gajim.config.get('trayicon_blink'): +# self.status_icon.set_blinking(True) +# else: + image = gtkgui_helpers.load_icon('event') + really_set_img() + return else: if gajim.config.get('trayicon') == 'on_event': self.status_icon.set_visible(False) - self.status_icon.set_blinking(False) +# self.status_icon.set_blinking(False) image = gajim.interface.jabber_state_images[self.statusicon_size][ self.status] @@ -213,11 +213,11 @@ class StatusIcon: chat_with_menuitem.disconnect(self.new_chat_handler_id) self.new_chat_handler_id = None - sub_menu = gtk.Menu() + sub_menu = Gtk.Menu() self.popup_menus.append(sub_menu) status_menuitem.set_submenu(sub_menu) - gc_sub_menu = gtk.Menu() # gc is always a submenu + gc_sub_menu = Gtk.Menu() # gc is always a submenu join_gc_menuitem.set_submenu(gc_sub_menu) # We need our own set of status icons, let's make 'em! @@ -230,15 +230,15 @@ class StatusIcon: for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): uf_show = helpers.get_uf_show(show, use_mnemonic = True) - item = gtk.ImageMenuItem(uf_show) + item = Gtk.ImageMenuItem(uf_show) item.set_image(state_images[show]) sub_menu.append(item) item.connect('activate', self.on_show_menuitem_activate, show) - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() sub_menu.append(item) - item = gtk.ImageMenuItem(_('_Change Status Message...')) + item = Gtk.ImageMenuItem(_('_Change Status Message...')) gtkgui_helpers.add_image_to_menuitem(item, 'gajim-kbd_input') sub_menu.append(item) item.connect('activate', self.on_change_status_message_activate) @@ -249,11 +249,11 @@ class StatusIcon: connected_accounts_with_private_storage = 0 - item = gtk.SeparatorMenuItem() + item = Gtk.SeparatorMenuItem() sub_menu.append(item) uf_show = helpers.get_uf_show('offline', use_mnemonic = True) - item = gtk.ImageMenuItem(uf_show) + item = Gtk.ImageMenuItem(uf_show) item.set_image(state_images['offline']) sub_menu.append(item) item.connect('activate', self.on_show_menuitem_activate, 'offline') @@ -267,14 +267,14 @@ class StatusIcon: accounts_list = sorted(gajim.contacts.get_accounts()) # items that get shown whether an account is zeroconf or not if connected_accounts > 1: # 2 or more connections? make submenus - account_menu_for_chat_with = gtk.Menu() + account_menu_for_chat_with = Gtk.Menu() chat_with_menuitem.set_submenu(account_menu_for_chat_with) self.popup_menus.append(account_menu_for_chat_with) for account in accounts_list: if gajim.account_is_connected(account): # for chat_with - item = gtk.MenuItem(_('using account %s') % account) + item = Gtk.MenuItem(_('using account %s') % account) account_menu_for_chat_with.append(item) item.connect('activate', self.on_new_chat, account) @@ -299,7 +299,7 @@ class StatusIcon: connected_accounts_with_private_storage += 1 # for single message - single_message_menuitem.remove_submenu() + single_message_menuitemset_submenu(None) self.single_message_handler_id = single_message_menuitem.\ connect('activate', self.on_single_message_menuitem_activate, account) @@ -309,7 +309,7 @@ class StatusIcon: break # No other account connected else: # 2 or more 'real' accounts are connected, make submenus - account_menu_for_single_message = gtk.Menu() + account_menu_for_single_message = Gtk.Menu() single_message_menuitem.set_submenu( account_menu_for_single_message) self.popup_menus.append(account_menu_for_single_message) @@ -321,24 +321,25 @@ class StatusIcon: if gajim.connections[account].private_storage_supported: connected_accounts_with_private_storage += 1 # for single message - item = gtk.MenuItem(_('using account %s') % account) + item = Gtk.MenuItem(_('using account %s') % account) item.connect('activate', self.on_single_message_menuitem_activate, account) account_menu_for_single_message.append(item) # join gc - gc_item = gtk.MenuItem(_('using account %s') % account, False) + gc_item = Gtk.MenuItem(_('using account %s') % account, + use_underline=False) gc_sub_menu.append(gc_item) - gc_menuitem_menu = gtk.Menu() + gc_menuitem_menu = Gtk.Menu() gajim.interface.roster.add_bookmarks_list(gc_menuitem_menu, account) gc_item.set_submenu(gc_menuitem_menu) gc_sub_menu.show_all() - newitem = gtk.SeparatorMenuItem() # separator + newitem = Gtk.SeparatorMenuItem() # separator gc_sub_menu.append(newitem) - newitem = gtk.ImageMenuItem(_('_Manage Bookmarks...')) - img = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) + newitem = Gtk.ImageMenuItem(_('_Manage Bookmarks...')) + img = Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU) newitem.set_image(img) newitem.connect('activate', gajim.interface.roster.on_manage_bookmarks_menuitem_activate) @@ -362,8 +363,8 @@ class StatusIcon: if os.name == 'nt': if self.added_hide_menuitem is False: - self.systray_context_menu.prepend(gtk.SeparatorMenuItem()) - item = gtk.MenuItem(_('Hide this menu')) + self.systray_context_menu.prepend(Gtk.SeparatorMenuItem()) + item = Gtk.MenuItem(_('Hide this menu')) self.systray_context_menu.prepend(item) self.added_hide_menuitem = True @@ -423,7 +424,7 @@ class StatusIcon: gajim.config.get('roster_y-position')) if not gajim.config.get('roster_window_skip_taskbar'): win.set_property('skip-taskbar-hint', False) - win.present_with_time(gtk.get_current_event_time()) + win.present_with_time(Gtk.get_current_event_time()) else: self.handle_first_event() @@ -452,7 +453,7 @@ class StatusIcon: def on_clicked(self, widget, event): self.on_tray_leave_notify_event(widget, None) - if event.type_ != gtk.gdk.BUTTON_PRESS: + if event.type_ != Gdk.EventType.BUTTON_PRESS: return if event.button == 1: # Left click self.on_left_click() diff --git a/src/tooltips.py b/src/tooltips.py index 0acc2abd5..386a6d4bb 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -28,8 +28,9 @@ ## along with Gajim. If not, see . ## -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject import os import time import locale @@ -78,20 +79,20 @@ class BaseTooltip: implementation: show data as value of a label """ self.create_window() - self.win.add(gtk.Label(data)) + self.win.add(Gtk.Label(label=data)) def create_window(self): """ Create a popup window each time tooltip is requested """ - self.win = gtk.Window(gtk.WINDOW_POPUP) + self.win = Gtk.Window(Gtk.WindowType.POPUP) self.win.set_title('tooltip') self.win.set_border_width(3) self.win.set_resizable(False) self.win.set_name('gtk-tooltips') - self.win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP) + self.win.set_type_hint(Gdk.WindowTypeHint.TOOLTIP) - self.win.set_events(gtk.gdk.POINTER_MOTION_MASK) + self.win.set_events(Gdk.EventMask.POINTER_MOTION_MASK) self.win.connect_after('expose_event', self.expose) self.win.connect('size-request', self.on_size_request) self.win.connect('motion-notify-event', self.motion_notify_event) @@ -135,7 +136,7 @@ class BaseTooltip: def expose(self, widget, event): style = self.win.get_style() size = self.win.get_size() - style.paint_shadow(self.win.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT, + style.paint_shadow(self.win.window, Gtk.StateType.NORMAL, Gtk.ShadowType.OUT, None, self.win, 'tooltip', 0, 0, size[0], size[1]) return True @@ -165,7 +166,7 @@ class BaseTooltip: def hide_tooltip(self): if self.timeout > 0: - gobject.source_remove(self.timeout) + GObject.source_remove(self.timeout) self.timeout = 0 if self.win: self.win.destroy() @@ -231,12 +232,12 @@ class StatusTable: self.spacer_label = ' ' def create_table(self): - self.table = gtk.Table(4, 1) + self.table = Gtk.Table(4, 1) self.table.set_property('column-spacing', 2) def add_text_row(self, text, col_inc = 0): self.current_row += 1 - self.text_label = gtk.Label() + self.text_label = Gtk.Label() self.text_label.set_line_wrap(True) self.text_label.set_alignment(0, 0) self.text_label.set_selectable(False) @@ -254,8 +255,8 @@ class StatusTable: status = unicode(status, encoding='utf-8') # reduce to 100 chars, 1 line status = helpers.reduce_chars_newlines(status, 100, 1) - str_status = gobject.markup_escape_text(str_status) - status = gobject.markup_escape_text(status) + str_status = GObject.markup_escape_text(str_status) + status = GObject.markup_escape_text(status) str_status += ' - ' + status + '' return str_status @@ -269,29 +270,29 @@ class StatusTable: files = [] files.append(os.path.join(file_path, state_file + '.png')) files.append(os.path.join(file_path, state_file + '.gif')) - image = gtk.Image() + image = Gtk.Image() image.set_from_pixbuf(None) for f in files: if os.path.exists(f): image.set_from_file(f) break - spacer = gtk.Label(self.spacer_label) + spacer = Gtk.Label(label=self.spacer_label) image.set_alignment(1, 0.5) if indent: self.table.attach(spacer, 1, 2, self.current_row, self.current_row + 1, 0, 0, 0, 0) self.table.attach(image, 2, 3, self.current_row, - self.current_row + 1, gtk.FILL, gtk.FILL, 2, 0) - status_label = gtk.Label() + self.current_row + 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 2, 0) + status_label = Gtk.Label() status_label.set_markup(str_status) status_label.set_alignment(0, 0) status_label.set_line_wrap(True) self.table.attach(status_label, 3, 4, self.current_row, - self.current_row + 1, gtk.FILL | gtk.EXPAND, 0, 0, 0) + self.current_row + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0) if show_lock: - lock_image = gtk.Image() - lock_image.set_from_stock(gtk.STOCK_DIALOG_AUTHENTICATION, - gtk.ICON_SIZE_MENU) + lock_image = Gtk.Image() + lock_image.set_from_stock(Gtk.STOCK_DIALOG_AUTHENTICATION, + Gtk.IconSize.MENU) self.table.attach(lock_image, 4, 5, self.current_row, self.current_row + 1, 0, 0, 0, 0) @@ -316,7 +317,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable): if isinstance(message, str): message = unicode(message, encoding = 'utf-8') message = helpers.reduce_chars_newlines(message, 100, 1) - message = gobject.markup_escape_text(message) + message = GObject.markup_escape_text(message) if acct['name'] in gajim.con_types and \ gajim.con_types[acct['name']] in ('tls', 'ssl'): show_lock = True @@ -324,11 +325,11 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable): show_lock = False if message: self.add_status_row(file_path, acct['show'], - gobject.markup_escape_text(acct['name']) + \ + GObject.markup_escape_text(acct['name']) + \ ' - ' + message, show_lock=show_lock, indent=False) else: self.add_status_row(file_path, acct['show'], - gobject.markup_escape_text(acct['name']) + GObject.markup_escape_text(acct['name']) , show_lock=show_lock, indent=False) for line in acct['event_lines']: self.add_text_row(' ' + line, 1) @@ -340,7 +341,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable): accounts = helpers.get_notification_icon_tooltip_dict() self.table.resize(2, 1) self.fill_table_with_accounts(accounts) - self.hbox = gtk.HBox() + self.hbox = Gtk.HBox() self.table.set_property('column-spacing', 1) self.hbox.add(self.table) @@ -353,11 +354,11 @@ class GCTooltip(BaseTooltip): def __init__(self): self.account = None - self.text_label = gtk.Label() + self.text_label = Gtk.Label() self.text_label.set_line_wrap(True) self.text_label.set_alignment(0, 0) self.text_label.set_selectable(False) - self.avatar_image = gtk.Image() + self.avatar_image = Gtk.Image() BaseTooltip.__init__(self) @@ -365,14 +366,14 @@ class GCTooltip(BaseTooltip): if not contact: return self.create_window() - vcard_table = gtk.Table(3, 1) + vcard_table = Gtk.Table(3, 1) vcard_table.set_property('column-spacing', 2) vcard_table.set_homogeneous(False) vcard_current_row = 1 properties = [] nick_markup = '' + \ - gobject.markup_escape_text(contact.get_shown_name()) \ + GObject.markup_escape_text(contact.get_shown_name()) \ + '' properties.append((nick_markup, None)) @@ -382,7 +383,7 @@ class GCTooltip(BaseTooltip): # escape markup entities status = helpers.reduce_chars_newlines(status, 300, 5) status = '' +\ - gobject.markup_escape_text(status) + '' + GObject.markup_escape_text(status) + '' properties.append((status, None)) show = helpers.get_uf_show(contact.show) @@ -394,7 +395,7 @@ class GCTooltip(BaseTooltip): if hasattr(contact, 'resource') and contact.resource.strip(): properties.append((_('Resource: '), - gobject.markup_escape_text(contact.resource))) + GObject.markup_escape_text(contact.resource))) if contact.affiliation != 'none': uf_affiliation = helpers.get_uf_affiliation(contact.affiliation) @@ -419,31 +420,31 @@ class GCTooltip(BaseTooltip): while properties: property_ = properties.pop(0) vcard_current_row += 1 - vertical_fill = gtk.FILL + vertical_fill = Gtk.AttachOptions.FILL if not properties: - vertical_fill |= gtk.EXPAND - label = gtk.Label() + vertical_fill |= Gtk.AttachOptions.EXPAND + label = Gtk.Label() label.set_alignment(0, 0) if property_[1]: label.set_markup(property_[0]) vcard_table.attach(label, 1, 2, vcard_current_row, - vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0) - label = gtk.Label() + vcard_current_row + 1, Gtk.AttachOptions.FILL, vertical_fill, 0, 0) + label = Gtk.Label() label.set_alignment(0, 0) label.set_markup(property_[1]) label.set_line_wrap(True) vcard_table.attach(label, 2, 3, vcard_current_row, - vcard_current_row + 1, gtk.EXPAND | gtk.FILL, + vcard_current_row + 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, vertical_fill, 0, 0) else: label.set_markup(property_[0]) label.set_line_wrap(True) vcard_table.attach(label, 1, 3, vcard_current_row, - vcard_current_row + 1, gtk.FILL, vertical_fill, 0) + vcard_current_row + 1, Gtk.AttachOptions.FILL, vertical_fill, 0) self.avatar_image.set_alignment(0, 0) vcard_table.attach(self.avatar_image, 3, 4, 2, vcard_current_row + 1, - gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3) + Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 3, 3) gajim.plugin_manager.gui_extension_point('gc_tooltip_populate', self, contact, vcard_table) self.win.add(vcard_table) @@ -455,11 +456,11 @@ class RosterTooltip(NotificationAreaTooltip): def __init__(self): self.account = None - self.image = gtk.Image() + self.image = Gtk.Image() self.image.set_alignment(0, 0) # padding is independent of the total length and better than alignment self.image.set_padding(1, 2) - self.avatar_image = gtk.Image() + self.avatar_image = Gtk.Image() NotificationAreaTooltip.__init__(self) def populate(self, contacts): @@ -491,19 +492,19 @@ class RosterTooltip(NotificationAreaTooltip): table_size = 4 else: self.avatar_image.set_from_pixbuf(None) - vcard_table = gtk.Table(1,table_size) + vcard_table = Gtk.Table(1,table_size) vcard_table.set_property('column-spacing', 2) vcard_table.set_homogeneous(False) vcard_current_row = 1 properties = [] name_markup = u'' + \ - gobject.markup_escape_text(prim_contact.get_shown_name())\ + GObject.markup_escape_text(prim_contact.get_shown_name())\ + '' if gajim.config.get('mergeaccounts'): name_markup += u" (%s)" % ( gajim.config.get('tooltip_account_name_color'), - gobject.markup_escape_text(prim_contact.account.name)) + GObject.markup_escape_text(prim_contact.account.name)) if self.account and helpers.jid_is_blocked(self.account, prim_contact.jid): @@ -604,7 +605,7 @@ class RosterTooltip(NotificationAreaTooltip): # status is wrapped status = helpers.reduce_chars_newlines(status, 300, 5) # escape markup entities. - status = gobject.markup_escape_text(status) + status = GObject.markup_escape_text(status) properties.append(('%s' % status, None)) properties.append((show, None)) @@ -615,14 +616,14 @@ class RosterTooltip(NotificationAreaTooltip): # contact has only one ressource if num_resources == 1 and contact.resource: properties.append((_('Resource: '), - gobject.markup_escape_text(contact.resource) +\ + GObject.markup_escape_text(contact.resource) +\ ' (' + unicode(contact.priority) + ')')) if self.account and prim_contact.sub and prim_contact.sub != 'both' and\ prim_contact.jid not in gajim.gc_connected[self.account]: # ('both' is the normal sub so we don't show it) properties.append(( _('Subscription: '), - gobject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub)))) + GObject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub)))) if prim_contact.keyID: keyID = None @@ -632,7 +633,7 @@ class RosterTooltip(NotificationAreaTooltip): keyID = prim_contact.keyID[8:] if keyID: properties.append((_('OpenPGP: '), - gobject.markup_escape_text(keyID))) + GObject.markup_escape_text(keyID))) if contact.last_activity_time: last_active = datetime(*contact.last_activity_time[:6]) @@ -660,21 +661,21 @@ class RosterTooltip(NotificationAreaTooltip): while properties: property_ = properties.pop(0) vcard_current_row += 1 - vertical_fill = gtk.FILL + vertical_fill = Gtk.AttachOptions.FILL if not properties and table_size == 4: - vertical_fill |= gtk.EXPAND - label = gtk.Label() + vertical_fill |= Gtk.AttachOptions.EXPAND + label = Gtk.Label() label.set_alignment(0, 0) if property_[1]: label.set_markup(property_[0]) vcard_table.attach(label, 1, 2, vcard_current_row, - vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0) - label = gtk.Label() + vcard_current_row + 1, Gtk.AttachOptions.FILL, vertical_fill, 0, 0) + label = Gtk.Label() label.set_alignment(0, 0) label.set_markup(property_[1]) label.set_line_wrap(True) vcard_table.attach(label, 2, 3, vcard_current_row, - vcard_current_row + 1, gtk.EXPAND | gtk.FILL, + vcard_current_row + 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, vertical_fill, 0, 0) else: if isinstance(property_[0], (unicode, str)): # FIXME: rm unicode? @@ -683,11 +684,11 @@ class RosterTooltip(NotificationAreaTooltip): else: label = property_[0] vcard_table.attach(label, 1, 3, vcard_current_row, - vcard_current_row + 1, gtk.FILL, vertical_fill, 0) + vcard_current_row + 1, Gtk.AttachOptions.FILL, vertical_fill, 0) self.avatar_image.set_alignment(0, 0) if table_size == 4: vcard_table.attach(self.avatar_image, 3, 4, 2, - vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3) + vcard_current_row + 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 3, 3) gajim.plugin_manager.gui_extension_point('roster_tooltip_populate', self, contacts, vcard_table) @@ -733,7 +734,7 @@ class FileTransfersTooltip(BaseTooltip): BaseTooltip.__init__(self) def populate(self, file_props): - ft_table = gtk.Table(2, 1) + ft_table = Gtk.Table(2, 1) ft_table.set_property('column-spacing', 2) current_row = 1 self.create_window() @@ -744,7 +745,7 @@ class FileTransfersTooltip(BaseTooltip): else: file_name = file_props.name properties.append((_('Name: '), - gobject.markup_escape_text(file_name))) + GObject.markup_escape_text(file_name))) if file_props.type_ == 'r': type_ = _('Download') actor = _('Sender: ') @@ -760,7 +761,7 @@ class FileTransfersTooltip(BaseTooltip): else: name = receiver.split('/')[0] properties.append((_('Type: '), type_)) - properties.append((actor, gobject.markup_escape_text(name))) + properties.append((actor, GObject.markup_escape_text(name))) transfered_len = file_props.received_len if not transfered_len: @@ -788,22 +789,22 @@ class FileTransfersTooltip(BaseTooltip): status = _('Not started') properties.append((_('Status: '), status)) file_desc = file_props.desc - properties.append((_('Description: '), gobject.markup_escape_text( + properties.append((_('Description: '), GObject.markup_escape_text( file_desc))) while properties: property_ = properties.pop(0) current_row += 1 - label = gtk.Label() + label = Gtk.Label() label.set_alignment(0, 0) label.set_markup(property_[0]) ft_table.attach(label, 1, 2, current_row, current_row + 1, - gtk.FILL, gtk.FILL, 0, 0) - label = gtk.Label() + Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 0, 0) + label = Gtk.Label() label.set_alignment(0, 0) label.set_line_wrap(True) label.set_markup(property_[1]) ft_table.attach(label, 2, 3, current_row, current_row + 1, - gtk.EXPAND | gtk.FILL, gtk.FILL, 0, 0) + Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 0, 0) self.win.add(ft_table) @@ -814,7 +815,7 @@ class ServiceDiscoveryTooltip(BaseTooltip): """ def populate(self, status): self.create_window() - label = gtk.Label() + label = Gtk.Label() label.set_line_wrap(True) label.set_alignment(0, 0) label.set_selectable(False) diff --git a/src/vcard.py b/src/vcard.py index f406e66dd..9d9dabe7b 100644 --- a/src/vcard.py +++ b/src/vcard.py @@ -31,8 +31,8 @@ # THIS FILE IS FOR **OTHERS'** PROFILE (when we VIEW their INFO) -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject import base64 import time import locale @@ -123,7 +123,7 @@ class VcardWindow: self.vcard_arrived = False self.os_info_arrived = False self.entity_time_arrived = False - self.update_progressbar_timeout_id = gobject.timeout_add(100, + self.update_progressbar_timeout_id = GObject.timeout_add(100, self.update_progressbar) gajim.ged.register_event_handler('version-result-received', ged.GUI1, @@ -151,11 +151,11 @@ class VcardWindow: def on_vcard_information_window_destroy(self, widget): if self.update_progressbar_timeout_id is not None: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) del gajim.interface.instances[self.account]['infos'][self.contact.jid] buffer_ = self.xml.get_object('textview_annotation').get_buffer() annotation = buffer_.get_text(buffer_.get_start_iter(), - buffer_.get_end_iter()) + buffer_.get_end_iter(), True) connection = gajim.connections[self.account] if annotation != connection.annotations.get(self.contact.jid, ''): connection.annotations[self.contact.jid] = annotation @@ -170,19 +170,19 @@ class VcardWindow: self._nec_vcard_received) def on_vcard_information_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.destroy() def on_information_notebook_switch_page(self, widget, page, page_num): - gobject.idle_add(self.xml.get_object('close_button').grab_focus) + GObject.idle_add(self.xml.get_object('close_button').grab_focus) def on_PHOTO_eventbox_button_press_event(self, widget, event): """ If right-clicked, show popup """ if event.button == 3: # right click - menu = gtk.Menu() - menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) + menu = Gtk.Menu() + menuitem = Gtk.ImageMenuItem(Gtk.STOCK_SAVE_AS) menuitem.connect('activate', gtkgui_helpers.on_avatar_save_as_menuitem_activate, self.contact.jid, self.contact.get_shown_name()) @@ -195,7 +195,7 @@ class VcardWindow: def set_value(self, entry_name, value): try: if value and entry_name == 'URL_label': - widget = gtk.LinkButton(value, value) + widget = Gtk.LinkButton(value, value) widget.set_alignment(0, 0) widget.show() table = self.xml.get_object('personal_info_table') @@ -220,7 +220,7 @@ class VcardWindow: self.xml.get_object('user_avatar_label').show() if not pixbuf: image.set_from_icon_name('stock_person', - gtk.ICON_SIZE_DIALOG) + Gtk.IconSize.DIALOG) continue pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'vcard') image.set_from_pixbuf(pixbuf) @@ -259,7 +259,7 @@ class VcardWindow: def test_remove_progressbar(self): if self.update_progressbar_timeout_id is not None and \ self.vcard_arrived and self.os_info_arrived and self.entity_time_arrived: - gobject.source_remove(self.update_progressbar_timeout_id) + GObject.source_remove(self.update_progressbar_timeout_id) self.progressbar.hide() self.update_progressbar_timeout_id = None @@ -432,10 +432,10 @@ class VcardWindow: else: # Request os info if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) - gobject.idle_add(gajim.connections[self.account].request_os_info, + GObject.idle_add(gajim.connections[self.account].request_os_info, j, r, self.contact.jid) else: - gobject.idle_add(gajim.connections[self.account].request_os_info, + GObject.idle_add(gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) # do not wait for entity_time if contact is not connected or has error @@ -446,10 +446,10 @@ class VcardWindow: else: # Request entity time if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) - gobject.idle_add(gajim.connections[self.account].\ + GObject.idle_add(gajim.connections[self.account].\ request_entity_time, j, r, self.contact.jid) else: - gobject.idle_add(gajim.connections[self.account].\ + GObject.idle_add(gajim.connections[self.account].\ request_entity_time, self.contact.jid, self.contact.resource) self.os_info = {0: {'resource': self.real_resource, 'client': '', @@ -465,10 +465,10 @@ class VcardWindow: uf_resources += '\n' + c.resource + \ _(' resource with priority ') + unicode(c.priority) if c.show not in ('offline', 'error'): - gobject.idle_add( + GObject.idle_add( gajim.connections[self.account].request_os_info, c.jid, c.resource) - gobject.idle_add(gajim.connections[self.account].\ + GObject.idle_add(gajim.connections[self.account].\ request_entity_time, c.jid, c.resource) self.os_info[i] = {'resource': c.resource, 'client': '', 'os': ''} @@ -516,7 +516,7 @@ class ZeroconfVcardWindow: del gajim.interface.instances[self.account]['infos'][self.contact.jid] def on_zeroconf_information_window_key_press_event(self, widget, event): - if event.keyval == gtk.keysyms.Escape: + if event.keyval == Gdk.KEY_Escape: self.window.destroy() def on_PHOTO_eventbox_button_press_event(self, widget, event): @@ -524,8 +524,8 @@ class ZeroconfVcardWindow: If right-clicked, show popup """ if event.button == 3: # right click - menu = gtk.Menu() - menuitem = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) + menu = Gtk.Menu() + menuitem = Gtk.ImageMenuItem(Gtk.STOCK_SAVE_AS) menuitem.connect('activate', gtkgui_helpers.on_avatar_save_as_menuitem_activate, self.contact.jid, self.contact.get_shown_name()) @@ -538,7 +538,7 @@ class ZeroconfVcardWindow: def set_value(self, entry_name, value): try: if value and entry_name == 'URL_label': - widget = gtk.LinkButton(value, value) + widget = Gtk.LinkButton(value, value) widget.set_alignment(0, 0) table = self.xml.get_object('personal_info_table') table.attach(widget, 1, 4, 3, 4, yoptions = 0)