Mercurial > libervia-desktop-kivy
annotate src/cagou/core/common.py @ 107:f0cf44df8486
JidWidget: first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Jan 2017 21:21:22 +0100 |
parents | 3efca1b10b2f |
children |
rev | line source |
---|---|
26
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr//bin/env python2 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org) |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 """common widgets, which can be reused everywhere""" |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from kivy.uix.image import Image |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from kivy.uix.behaviors import ButtonBehavior |
107 | 24 from kivy.uix.boxlayout import BoxLayout |
25 from cagou import G | |
26
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 class IconButton(ButtonBehavior, Image): |
3efca1b10b2f
common: first draft of a module were common widgets will be put
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 pass |
107 | 30 |
31 | |
32 class JidWidget(ButtonBehavior, BoxLayout): | |
33 | |
34 def __init__(self, jid, profile, **kwargs): | |
35 self.jid = jid | |
36 self.profile = profile | |
37 self.nick = kwargs.get('nick') | |
38 super(JidWidget, self).__init__(**kwargs) | |
39 | |
40 def getImage(self, wid): | |
41 host = G.host | |
42 if host.contact_lists[self.profile].isRoom(self.jid.bare): | |
43 wid.opacity = 0 | |
44 return "" | |
45 else: | |
46 return host.getAvatar(self.jid, profile=self.profile) or host.getDefaultAvatar(self.jid) |