~ubuntu-branches/ubuntu/wily/blueman/wily

« back to all changes in this revision

Viewing changes to blueman/gui/PixbufTable.py

  • Committer: Package Import Robot
  • Author(s): Sean Davis
  • Date: 2015-09-07 12:48:18 UTC
  • mfrom: (2.3.11 sid)
  • Revision ID: package-import@ubuntu.com-20150907124818-evulc0mhjotz8q29
Tags: 2.0-1ubuntu1
* Merge from Debian unstable (LP: #1482626). Remaining changes:
  - debian/patches/03_filemanage_fix.patch:
    + Dropped, no longer needed.
  - debian/patches/dhcpclient_priority
  - debian/patches/01_dont_autostart_lxde.patch
    + Refreshed patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Valmantas Paliksa <walmis at balticum-tv dot lt>
2
 
# Copyright (C) 2008 Tadas Dailyda <tadas at dailyda dot com>
3
 
#
4
 
# Licensed under the GNU General Public License Version 3
5
 
#
6
 
# This program is free software: you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation, either version 3 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
19
 
 
20
 
from gi.repository import Gtk
21
 
import math
22
 
 
23
 
class PixbufTable:
24
 
        def __init__(self, percol=2, spacingx=1, spacingy=1, size=24):
25
 
                self.percol = percol
26
 
                self.spacingx=spacingx
27
 
                self.spacingy=spacingy
28
 
                self.size=size
29
 
                
30
 
                self.cols = 0
31
 
                
32
 
                self.pixbuffs = {}
33
 
                
34
 
                self.recalc()
35
 
 
36
 
 
37
 
        def recalc(self):
38
 
                if len(self.pixbuffs) == 0:
39
 
                        self.total_width = 0
40
 
                        self.total_height = 0
41
 
                        self.rows = 0
42
 
                        self.cols = 0
43
 
                        return
44
 
                
45
 
                self.cols = int(math.ceil(float(len(self.pixbuffs)) / self.percol))
46
 
 
47
 
 
48
 
                spacing_width = (self.cols -1) * self.spacingx
49
 
 
50
 
                
51
 
 
52
 
                if len(self.pixbuffs) >= self.percol:
53
 
                        self.rows = self.percol
54
 
                else:
55
 
                        self.rows = len(self.pixbuffs)
56
 
                        
57
 
                spacing_height = (self.rows -1) * self.spacingy
58
 
                        
59
 
                self.total_width = self.cols * self.size + spacing_width
60
 
                self.total_height = self.rows * self.size + spacing_height              
61
 
        
62
 
        def get(self):
63
 
                return self.pixbuffs
64
 
                
65
 
        def set(self, name, pixbuf):
66
 
                if pixbuf != None:
67
 
                        self.pixbuffs[name] = pixbuf
68
 
                else:
69
 
                        if name in self.pixbuffs:
70
 
                                del self.pixbuffs[name]
71
 
                self.recalc()
72
 
 
73