adding setting in advanced/misc for not checking for new version. [this is not an expert setting, and should stay in prefs window]. ALSO fixes/typos all over

This commit is contained in:
Nikos Kouremenos 2005-04-18 14:05:30 +00:00
parent 4e722bd62e
commit 3d7d4c1fff
10 changed files with 214 additions and 135 deletions

View File

@ -0,0 +1,115 @@
## cell_renderer_image.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
import gtk
import gobject
class CellRendererImage(gtk.GenericCellRenderer):
__gproperties__ = {
'image': (gobject.TYPE_OBJECT, 'Image',
'Image', gobject.PARAM_READWRITE),
}
def __init__(self):
self.__gobject_init__()
self.image = None
def do_set_property(self, pspec, value):
setattr(self, pspec.name, value)
def do_get_property(self, pspec):
return getattr(self, pspec.name)
def func(self, model, path, iter, (image, tree)):
if model.get_value(iter, 0) == image:
self.redraw = 1
cell_area = tree.get_cell_area(path, tree.get_column(0))
tree.queue_draw_area(cell_area.x, cell_area.y, cell_area.width, \
cell_area.height)
def animation_timeout(self, tree, image):
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
self.redraw = 0
image.get_data('iter').advance()
model = tree.get_model()
model.foreach(self.func, (image, tree))
if self.redraw:
gobject.timeout_add(image.get_data('iter').get_delay_time(), \
self.animation_timeout, tree, image)
else:
image.set_data('iter', None)
def on_render(self, window, widget, background_area,cell_area, \
expose_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 not self.image.get_data('iter'):
animation = self.image.get_animation()
self.image.set_data('iter', animation.get_iter())
gobject.timeout_add(self.image.get_data('iter').get_delay_time(), \
self.animation_timeout, widget, self.image)
pix = self.image.get_data('iter').get_pixbuf()
elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF:
pix = self.image.get_pixbuf()
else:
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+2, draw_rect.width, draw_rect.height, \
gtk.gdk.RGB_DITHER_NONE, 0, 0)
def on_get_size(self, widget, cell_area):
if not self.image:
return 0, 0, 0, 0
if self.image.get_storage_type() == gtk.IMAGE_ANIMATION:
animation = self.image.get_animation()
pix = animation.get_iter().get_pixbuf()
elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF:
pix = self.image.get_pixbuf()
else:
return 0, 0, 0, 0
pixbuf_width = pix.get_width()
pixbuf_height = pix.get_height()
calc_width = self.get_property('xpad') * 2 + pixbuf_width
calc_height = self.get_property('ypad') * 2 + pixbuf_height
x_offset = 0
y_offset = 0
if cell_area and pixbuf_width > 0 and pixbuf_height > 0:
x_offset = self.get_property('xalign') * (cell_area.width - \
calc_width - self.get_property('xpad'))
y_offset = self.get_property('yalign') * (cell_area.height - \
calc_height - self.get_property('ypad'))
return x_offset, y_offset, calc_width, calc_height
gobject.type_register(CellRendererImage)

View File

@ -1,3 +1,22 @@
## common/check_for_new_version.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
import gtk
import gtk.glade
@ -9,7 +28,7 @@ APP = i18n.APP
gtk.glade.bindtextdomain(APP, i18n.DIR)
gtk.glade.textdomain(APP)
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
GTKGUI_GLADE='gtkgui.glade'
class Check_for_new_version_dialog:
def __init__(self, plugin):

View File

@ -18,7 +18,7 @@
##
import re
import sre
import copy
OPT_TYPE = 0
@ -87,6 +87,7 @@ class Config:
'before_nickname': [ opt_str, '<' ],
'after_nickname': [ opt_str, '>' ],
'do_not_send_os_info': [ opt_bool, False ],
'do_not_check_for_new_version': [ opt_bool, False ],
'usegpg': [ opt_bool, False ],
'lognotusr': [ opt_bool, True ],
'lognotsep': [ opt_bool, True ],
@ -236,7 +237,7 @@ class Config:
elif type[0] == 'string':
return self.is_valid_string(val)
else:
return re.match(type[1], val)
return sre.match(type[1], val)
def set(self, optname, value):
if not self.__options.has_key(optname):

View File

@ -3,6 +3,7 @@
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <kourem@gmail.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
@ -20,7 +21,7 @@ import logging
import common.config
import common.logger
version = "0.7"
version = '0.7'
config = common.config.Config()
connections = {}
log = logging.getLogger('Gajim')

View File

@ -22,17 +22,19 @@ import gtk.glade
import gobject
import os
import common.sleepy
import dialogs
import gtkgui
from common import gajim
from common import connection
from common import i18n
from common import cell_renderer_image
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain (APP, i18n.DIR)
gtk.glade.textdomain (APP)
import dialogs
import gtkgui
GTKGUI_GLADE='gtkgui.glade'
@ -495,6 +497,12 @@ class Preferences_window:
gajim.config.set('do_not_send_os_info', False)
self.plugin.save_config()
def on_do_not_check_for_new_version_checkbutton_toggled(self, widget):
if widget.get_active():
gajim.config.set('do_not_check_for_new_version', True)
else:
gajim.config.set('do_not_check_for_new_version', False)
self.plugin.save_config()
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)
@ -883,6 +891,12 @@ class Preferences_window:
# don't send os info
st = gajim.config.get('do_not_send_os_info')
self.xml.get_widget('do_not_send_os_info_checkbutton').set_active(st)
# don't check for new version
st = gajim.config.get('do_not_check_for_new_version')
btn = self.xml.get_widget('do_not_check_for_new_version_checkbutton')
btn.set_active(st)
self.xml.signal_autoconnect(self)
self.sound_tree.get_model().connect('row-changed', \
@ -1485,7 +1499,7 @@ class Add_remove_emoticons_window:
col = gtk.TreeViewColumn(_('Image'))
self.emot_tree.append_column(col)
renderer = gtkgui.CellRendererImage()
renderer = cell_renderer_image.CellRendererImage()
col.pack_start(renderer, expand = False)
col.add_attribute(renderer, 'image', 2)

View File

@ -1,4 +1,4 @@
## plugins/dialogs.py
## dialogs.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>

View File

@ -29,10 +29,11 @@ import pango
import gobject
import os
import sre
from common import gajim
import signal
import common.sleepy
import common.check_for_new_version
from common import gajim
from common import i18n
i18n.init()
_ = i18n._
@ -48,102 +49,8 @@ try:
except ImportError:
pass
class CellRendererImage(gtk.GenericCellRenderer):
__gproperties__ = {
'image': (gobject.TYPE_OBJECT, 'Image',
'Image', gobject.PARAM_READWRITE),
}
def __init__(self):
self.__gobject_init__()
self.image = None
def do_set_property(self, pspec, value):
setattr(self, pspec.name, value)
def do_get_property(self, pspec):
return getattr(self, pspec.name)
def func(self, model, path, iter, (image, tree)):
if model.get_value(iter, 0) == image:
self.redraw = 1
cell_area = tree.get_cell_area(path, tree.get_column(0))
tree.queue_draw_area(cell_area.x, cell_area.y, cell_area.width, \
cell_area.height)
def animation_timeout(self, tree, image):
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
self.redraw = 0
image.get_data('iter').advance()
model = tree.get_model()
model.foreach(self.func, (image, tree))
if self.redraw:
gobject.timeout_add(image.get_data('iter').get_delay_time(), \
self.animation_timeout, tree, image)
else:
image.set_data('iter', None)
def on_render(self, window, widget, background_area,cell_area, \
expose_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 not self.image.get_data('iter'):
animation = self.image.get_animation()
self.image.set_data('iter', animation.get_iter())
gobject.timeout_add(self.image.get_data('iter').get_delay_time(), \
self.animation_timeout, widget, self.image)
pix = self.image.get_data('iter').get_pixbuf()
elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF:
pix = self.image.get_pixbuf()
else:
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+2, draw_rect.width, draw_rect.height, \
gtk.gdk.RGB_DITHER_NONE, 0, 0)
def on_get_size(self, widget, cell_area):
if not self.image:
return 0, 0, 0, 0
if self.image.get_storage_type() == gtk.IMAGE_ANIMATION:
animation = self.image.get_animation()
pix = animation.get_iter().get_pixbuf()
elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF:
pix = self.image.get_pixbuf()
else:
return 0, 0, 0, 0
pixbuf_width = pix.get_width()
pixbuf_height = pix.get_height()
calc_width = self.get_property('xpad') * 2 + pixbuf_width
calc_height = self.get_property('ypad') * 2 + pixbuf_height
x_offset = 0
y_offset = 0
if cell_area and pixbuf_width > 0 and pixbuf_height > 0:
x_offset = self.get_property('xalign') * (cell_area.width - \
calc_width - self.get_property('xpad'))
y_offset = self.get_property('yalign') * (cell_area.height - \
calc_height - self.get_property('ypad'))
return x_offset, y_offset, calc_width, calc_height
gobject.type_register(CellRendererImage)
class User:
"""Information concerning each users"""
'''Information concerning each users'''
def __init__(self, *args):
if len(args) == 0:
self.jid = ''
@ -177,7 +84,7 @@ import config
GTKGUI_GLADE='gtkgui.glade'
class interface:
class Interface:
def launch_browser_mailer(self, kind, url):
#kind = 'url' or 'mail'
if gajim.config.get('openwith') == 'gnome-open':
@ -207,7 +114,7 @@ class interface:
def play_timeout(self, pid):
pidp, r = os.waitpid(pid, os.WNOHANG)
return 0
return False
def play_sound(self, event):
if not gajim.config.get('sounds_on'):
@ -257,7 +164,7 @@ class interface:
if not resource:
resource = ''
priority = array[4]
if jid.find("@") <= 0:
if jid.find('@') <= 0:
#It must be an agent
ji = jid.replace('@', '')
else:
@ -280,7 +187,7 @@ class interface:
if user1.show in statuss:
old_show = statuss.index(user1.show)
if (resources != [''] and (len(luser) != 1 or
luser[0].show != 'offline')) and not jid.find("@") <= 0:
luser[0].show != 'offline')) and not jid.find('@') <= 0:
old_show = 0
user1 = User(user1.jid, user1.name, user1.groups, user1.show, \
user1.status, user1.sub, user1.ask, user1.resource, \
@ -309,7 +216,7 @@ class interface:
user1.status = array[2]
user1.priority = priority
user1.keyID = keyID
if jid.find("@") <= 0:
if jid.find('@') <= 0:
#It must be an agent
if self.roster.contacts[account].has_key(ji):
#Update existing iter
@ -346,7 +253,7 @@ class interface:
def handle_event_msg(self, account, array):
#('MSG', account, (user, msg, time))
jid = array[0].split('/')[0]
if jid.find("@") <= 0:
if jid.find('@') <= 0:
jid = jid.replace('@', '')
if gajim.config.get('ignore_unknown_contacts') and \
not self.roster.contacts[account].has_key(jid):
@ -370,7 +277,7 @@ class interface:
def handle_event_msgerror(self, account, array):
#('MSGERROR', account, (user, error_code, error_msg, msg, time))
jid = array[0].split('/')[0]
if jid.find("@") <= 0:
if jid.find('@') <= 0:
jid = jid.replace('@', '')
self.roster.on_message(jid, _('error while sending') + \
' \"%s\" ( %s )' % (array[3], array[2]), array[4], account)
@ -523,9 +430,9 @@ class interface:
self.roster.redraw_jid(jid, account)
def read_sleepy(self):
"""Check if we are idle"""
'''Check if we are idle'''
if not self.sleeper.poll():
return 1
return True # renew timeout (loop for ever)
state = self.sleeper.getState()
for account in gajim.connections:
if not self.sleeper_state[account]:
@ -548,10 +455,10 @@ class interface:
#we go extended away
gajim.connections[account].change_status('xa', 'auto away (idle)')
self.sleeper_state[account] = 3
return 1
return True # renew timeout (loop for ever)
def autoconnect(self):
"""auto connect at startup"""
'''auto connect at startup'''
ask_message = 0
for a in gajim.connections:
if gajim.config.get_per('accounts', a, 'autoconnect'):
@ -564,7 +471,7 @@ class interface:
for a in gajim.connections:
if gajim.config.get_per('accounts', a, 'autoconnect'):
self.roster.send_status(a, 'online', message, 1)
return 0
return False
def show_systray(self):
self.systray.show_icon()
@ -681,10 +588,13 @@ class interface:
conn.register_handler('ROSTER_INFO', self.handle_event_roster_info)
def process_connections(self):
for account in gajim.connections:
if gajim.connections[account].connected:
gajim.connections[account].process(0.01)
return True
try:
for account in gajim.connections:
if gajim.connections[account].connected:
gajim.connections[account].process(0.01)
return True # renew timeout (loop for ever)
except KeyboardInterrupt:
sys.exit()
def save_config(self):
parser.read_config()
@ -738,7 +648,8 @@ class interface:
if self.systray_capabilities:
self.show_systray()
common.check_for_new_version.Check_for_new_version_dialog(self)
if not gajim.config.get('do_not_check_for_new_version'):
common.check_for_new_version.Check_for_new_version_dialog(self)
self.init_regexp()
@ -752,10 +663,12 @@ class interface:
self.register_handlers(gajim.connections[account])
gobject.timeout_add(100, self.autoconnect)
gobject.timeout_add(500, self.read_sleepy)
gobject.timeout_add(200, self.process_connections)
gobject.timeout_add(500, self.read_sleepy)
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application
try: # Import Psyco if available
import psyco
psyco.full()
@ -764,5 +677,5 @@ if __name__ == '__main__':
parser.parseCfgFile()
parser.fill_config()
interface()
Interface()
gtk.main()

View File

@ -22,12 +22,11 @@ import gtk.glade
import pango
import gobject
import time
from common import gajim
import dialogs
import chat
from gtkgui import CellRendererImage
from common import gajim
from common import i18n
from common import cell_renderer_image
_ = i18n._
APP = i18n.APP
@ -468,7 +467,7 @@ class Groupchat_window(chat.Chat):
#status_image, nickname, real_jid, status
store = gtk.TreeStore(gtk.Image, str, str, str)
column = gtk.TreeViewColumn('contacts')
renderer_image = CellRendererImage()
renderer_image = cell_renderer_image.CellRendererImage()
renderer_image.set_property('width', 20)
column.pack_start(renderer_image, expand = False)
column.add_attribute(renderer_image, 'image', 0)

View File

@ -5829,7 +5829,7 @@ Custom</property>
<widget class="GtkCheckButton" id="do_not_send_os_info_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Don't send OS Information</property>
<property name="label" translatable="yes">Do not send OS Information</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@ -5846,7 +5846,23 @@ Custom</property>
</child>
<child>
<placeholder/>
<widget class="GtkCheckButton" id="do_not_check_for_new_version_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Do not check for new version at startup</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_do_not_check_for_new_version_checkbutton_toggled" last_modification_time="Mon, 18 Apr 2005 12:41:51 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>

View File

@ -1,4 +1,4 @@
## plugins/gtkgui/roster_window.py
## roster_window.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
@ -25,14 +25,15 @@ import os
import Queue
import common.sleepy
from common import gajim
import tabbed_chat_window
import groupchat_window
import history_window
from gtkgui import CellRendererImage, User
import dialogs
import config
from gtkgui import User
from common import gajim
from common import cell_renderer_image
from common import i18n
_ = i18n._
@ -1359,7 +1360,7 @@ class Roster_window:
gobject.TYPE_STRING)
self.status_combobox = gtk.ComboBox()
self.xml.get_widget('vbox1').pack_end(self.status_combobox, False)
cell = CellRendererImage()
cell = cell_renderer_image.CellRendererImage()
self.status_combobox.pack_start(cell, False)
self.status_combobox.add_attribute(cell, 'image', 1)
cell = gtk.CellRendererText()
@ -1386,7 +1387,7 @@ class Roster_window:
#this col has two cells: first one img, second one text
col = gtk.TreeViewColumn()
render_pixbuf = CellRendererImage()
render_pixbuf = cell_renderer_image.CellRendererImage()
col.pack_start(render_pixbuf, expand = False)
col.add_attribute(render_pixbuf, 'image', 0)
col.set_cell_data_func(render_pixbuf, self.iconCellDataFunc, None)