~ubuntu-branches/ubuntu/maverick/awn-extras-applets/maverick

« back to all changes in this revision

Viewing changes to applets/maintained/slickswitcher/switch.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-08-29 14:29:52 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20100829142952-rhvuetyms9bv5uu7
Tags: upstream-0.4.0+bzr1372
ImportĀ upstreamĀ versionĀ 0.4.0+bzr1372

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
 
# -*- coding: utf-8 -*-
3
2
#
4
3
# Copyright (c) 2010 sharkbaitbobby <sharkbaitbobby+awn@gmail.com>
5
4
#
57
56
        if current_workspace is None:
58
57
            current_workspace = self.screen.get_active_workspace()
59
58
 
 
59
        if current_workspace is None:
 
60
            return 1
 
61
 
60
62
        #Get the workspace width
61
63
        workspace_width = current_workspace.get_width()
62
64
 
63
65
        #Return the number of columns
64
 
        return workspace_width / self.width
 
66
        num = workspace_width / self.width
 
67
        if num <= 0:
 
68
            return 1
 
69
        else:
 
70
            return num
65
71
 
66
72
    #Return the number of rows
67
73
    def get_num_rows(self, current_workspace=None):
69
75
        if current_workspace is None:
70
76
            current_workspace = self.screen.get_active_workspace()
71
77
 
 
78
        if current_workspace is None:
 
79
            return 1
 
80
 
72
81
        #Get the workspace height
73
82
        workspace_height = current_workspace.get_height()
74
83
 
75
84
        #Return the number of columns
76
 
        return workspace_height / self.height
 
85
        num = workspace_height / self.height
 
86
        if num <= 0:
 
87
            return 1
 
88
        else:
 
89
            return num
77
90
 
78
91
    #Return the number of the current workspace
79
92
    def get_current_workspace_num(self, current_workspace=None):
81
94
        if current_workspace is None:
82
95
            current_workspace = self.screen.get_active_workspace()
83
96
 
 
97
        if current_workspace is None:
 
98
            return 1
 
99
 
84
100
        if not current_workspace.is_virtual():
85
101
            return current_workspace.get_number() + 1
86
102
 
107
123
        #Get the current workspace
108
124
        current_workspace = self.screen.get_active_workspace()
109
125
 
 
126
        if current_workspace is None:
 
127
            return
 
128
 
110
129
        #Get the number of the current workspace
111
130
        current_workspace_num = self.get_current_workspace_num(current_workspace)
112
131