From 5293788dc1a92fec1048d6b3d4f65a2a7c9451ed Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Fri, 20 May 2005 15:58:23 +0000 Subject: [PATCH] introducing common/helpers.py where get_uf_status lives [more functions to come there in the future] --- src/common/helpers.py | 31 +++++++++++++++++++++++++++++++ src/dialogs.py | 11 +++++++---- src/roster_window.py | 16 ++-------------- src/systray.py | 3 ++- src/tabbed_chat_window.py | 5 +++-- 5 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 src/common/helpers.py diff --git a/src/common/helpers.py b/src/common/helpers.py new file mode 100644 index 000000000..40441ea7d --- /dev/null +++ b/src/common/helpers.py @@ -0,0 +1,31 @@ +## common/helpers.py +## +## Gajim Team: +## - Yann Le Boulanger +## - Vincent Hanquez +## - Nikos Kouremenos +## +## 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 diff --git a/src/dialogs.py b/src/dialogs.py index aecec58a2..3bea64190 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -21,11 +21,14 @@ import gtk import gtk.glade import gobject import os -from gajim import User -from common import gajim -from common import i18n + 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 + _ = 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') diff --git a/src/roster_window.py b/src/roster_window.py index 2a02d6481..26f8d38c9 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -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) diff --git a/src/systray.py b/src/systray.py index 2c8642667..b8609935b 100644 --- a/src/systray.py +++ b/src/systray.py @@ -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,\ diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index e8820da2f..8c69d08e0 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -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')