Commit 5293788d authored by nkour's avatar nkour

introducing common/helpers.py where get_uf_status lives [more functions to...

introducing common/helpers.py where get_uf_status lives [more functions to come there in the future]
parent 056ff7bd
## common/helpers.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.
##
def get_uf_status(self, status):
'''returns a userfriendly string for dnd/xa/chat
and capitalize()s the rest'''
if status == 'dnd':
uf_status = 'Busy'
elif status == 'xa':
uf_status = 'Not Available'
elif status == 'chat':
uf_status = 'Free for Chat'
else:
uf_status = status.capitalize()
return uf_status
......@@ -21,11 +21,14 @@ import gtk
import gtk.glade
import gobject
import os
from vcard import Vcard_window
from advanced import Advanced_configuration_window
from gajim import User
from common import gajim
from common import helpers
from common import i18n
from vcard import Vcard_window
from advanced import Advanced_configuration_window
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain (APP, i18n.DIR)
......@@ -180,7 +183,7 @@ class Change_status_message_dialog:
def __init__(self, plugin, status):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP)
self.window = self.xml.get_widget('change_status_message_dialog')
uf_status = plugin.roster.get_uf_status(status)
uf_status = helpers.get_uf_status(status)
self.window.set_title(uf_status + ' Status Message')
message_textview = self.xml.get_widget('message_textview')
......
......@@ -35,6 +35,7 @@ import cell_renderer_image
from gajim import User
from common import gajim
from common import helpers
from common import i18n
_ = i18n._
......@@ -1399,19 +1400,6 @@ class Roster_window:
start = '* '
self.window.set_title(start + 'Gajim')
def get_uf_status(self, status):
'''returns a userfriendly string for dnd/xa/chat
and capitalize()s the rest'''
if status == 'dnd':
uf_status = 'Busy'
elif status == 'xa':
uf_status = 'Not Available'
elif status == 'chat':
uf_status = 'Free for Chat'
else:
uf_status = status.capitalize()
return uf_status
def __init__(self, plugin):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_window', APP)
self.window = self.xml.get_widget('roster_window')
......@@ -1472,7 +1460,7 @@ class Roster_window:
for status in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible',
'offline']:
uf_status = self.get_uf_status(status)
uf_status = helpers.get_uf_status(status)
iter = liststore.append([uf_status, self.jabber_state_images[status], status])
self.status_combobox.show_all()
self.status_combobox.set_model(liststore)
......
......@@ -22,6 +22,7 @@ import gtk.glade
import dialogs
from common import gajim
from common import helpers
from common import i18n
try:
......@@ -181,7 +182,7 @@ class Systray:
if group in user.groups and user.show != 'offline' and \
user.show != 'error':
at_least_one = True
status = self.plugin.roster.get_uf_status(user.show)
status = helpers.get_uf_status(user.show)
s = user.name.replace('_', '__') + ' (' + status + ')'
item = gtk.MenuItem(s)
item.connect('activate', self.start_chat, account,\
......
......@@ -23,11 +23,12 @@ import pango
import gobject
import time
from common import gajim
import dialogs
import history_window
import chat
from common import gajim
from common import helpers
from common import i18n
_ = i18n._
......@@ -170,7 +171,7 @@ class Tabbed_chat_window(chat.Chat):
self.redraw_tab(user.jid)
self.draw_widgets(user)
uf_status = self.plugin.roster.get_uf_status(user.show)
uf_status = helpers.get_uf_status(user.show)
self.print_conversation(_('%s is %s (%s)') % (user.name,
uf_status, user.status), user.jid, 'status')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment