2
# Copyright (C) 2010 Canonical Ltd
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License version 2 as
6
# published by the Free Software Foundation.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# Copyright (C) 2010 Ken VanDine <ken.vandine@canonical.com>
18
# Error dialog for Gwibber
24
from gettext import lgettext as _
25
if hasattr(gettext, 'bind_textdomain_codeset'):
26
gettext.bind_textdomain_codeset('gwibber','UTF-8')
27
gettext.textdomain('gwibber')
31
class GwibberErrorService:
36
def ShowDialog(self, message=None, title=None, condition="error", service=None, username=None, type=None):
37
"""show_dialog raises a gtk.MessageDialog to the user
38
displaying errors or information.
41
message - a string to present to the user
42
title - OPTIONAL: a string which will set the title of the window
43
condition - a string, must be either "error" or "info"
46
type - auth, network, keyring
49
if type == "keyring": service = "any"
50
# Don't notify for the same error again
51
if self.notified.has_key(service):
52
if self.notified[service] == type:
56
if os.path.exists(os.path.join("bin", "gwibber-accounts")):
57
cmd = os.path.join("bin", "gwibber-accounts")
59
cmd = "gwibber-accounts"
60
ret = subprocess.call([cmd])
61
self.notified[service] = type
64
self.notified[service] = type
65
if condition == "info":
66
condition = gtk.MESSAGE_INFO
68
condition = gtk.MESSAGE_ERROR
71
title = _("Gwibber Error")
72
dialog = gtk.MessageDialog(
75
buttons = gtk.BUTTONS_CLOSE,
76
message_format = message)
77
dialog.set_title(title)
78
dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)