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 @@
-
+
-
-
+
+
+
+
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'/>