Commit 8f71d9f2 authored by Yann Leboulanger's avatar Yann Leboulanger

start porting Gajim to gobject introspection and GTK3

parent cae8faf0
This diff is collapsed.
......@@ -13,7 +13,6 @@
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="scrollable">True</property>
<property name="tab_border">0</property>
</object>
</child>
</object>
......
......@@ -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',
......
......@@ -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
......
......@@ -23,9 +23,9 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
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)
......
......@@ -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'<span foreground="blue" underline="single">%s</span>' % \
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'<small>%s</small>' % \
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'<span foreground="blue" underline="single">%s</span>' % \
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('')
......
......@@ -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
......
This diff is collapsed.
......@@ -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)
......
......@@ -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
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -329,6 +329,7 @@ class JingleTransportIBB(JingleTransport):
return transport
try:
raise ImportError
import farstream
except Exception:
pass
......
......@@ -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):
"""
......
......@@ -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 = '<b>%s</b>' % gobject.markup_escape_text(mood)
markuptext = '<b>%s</b>' % 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 = _('<b>"%(title)s"</b> by <i>%(artist)s</i>\n'
'from <i>%(source)s</i>') % {'title': title,
......@@ -426,12 +427,12 @@ class UserActivityPEP(AbstractPEP):
subactivity = ACTIVITIES[activity][subactivity]
activity = ACTIVITIES[activity]['category']
markuptext = '<b>' + gobject.markup_escape_text(activity)
markuptext = '<b>' + GObject.markup_escape_text(activity)
if subactivity:
markuptext += ': ' + gobject.markup_escape_text(subactivity)
markuptext += ': ' + GObject.markup_escape_text(subactivity)
markuptext += '</b>'
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<b>%(tag)s</b>: %(text)s' % \
......
......@@ -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')
......
......@@ -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()
......@@ -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):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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()
......
This diff is collapsed.
This diff is collapsed.
......@@ -22,8 +22,8 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.