Back to index

unity  6.0.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
unity.emulators.workspace.WorkspaceManager Class Reference
Inheritance diagram for unity.emulators.workspace.WorkspaceManager:
Inheritance graph
[legend]
Collaboration diagram for unity.emulators.workspace.WorkspaceManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def num_workspaces
def current_workspace
def refresh_workspace_information
def switch_to

Public Attributes

 desktop_height

Private Member Functions

def _coordinates_to_vp_number
def _coordinates_to_row_col
def _vp_number_to_row_col

Private Attributes

 _workspaces_wide
 _workspaces_high
 _viewport_width
 _viewport_height

Detailed Description

Class to manage switching to different workspaces.

Definition at line 22 of file workspace.py.


Constructor & Destructor Documentation

Definition at line 25 of file workspace.py.

00025 
00026     def __init__(self):
00027         super(WorkspaceManager, self).__init__()
00028         self.refresh_workspace_information()

Here is the call graph for this function:


Member Function Documentation

def unity.emulators.workspace.WorkspaceManager._coordinates_to_row_col (   self,
  vx,
  vy 
) [private]
Translate viewport coordinates to viewport row,col.

Definition at line 83 of file workspace.py.

00083 
00084     def _coordinates_to_row_col(self, vx, vy):
00085         """Translate viewport coordinates to viewport row,col."""
00086         row = vy / self._viewport_height
00087         col = vx / self._viewport_width
00088         return (row,col)

Here is the caller graph for this function:

Translate viewport coordinates to a viewport number.

Definition at line 78 of file workspace.py.

00078 
00079     def _coordinates_to_vp_number(self, vx, vy):
00080         """Translate viewport coordinates to a viewport number."""
00081         row,col = self._coordinates_to_row_col(vx, vy)
00082         return (row * self._workspaces_wide) + col

Here is the call graph for this function:

Here is the caller graph for this function:

def unity.emulators.workspace.WorkspaceManager._vp_number_to_row_col (   self,
  vp_number 
) [private]
Translate a viewport number to a viewport row/col.

Definition at line 89 of file workspace.py.

00089 
00090     def _vp_number_to_row_col(self, vp_number):
00091         """Translate a viewport number to a viewport row/col."""
00092         row = vp_number / self._workspaces_wide
00093         col = vp_number % self._workspaces_wide
00094         return (row,col)

Here is the caller graph for this function:

The current workspace number. 0 <= x < num_workspaces.

Definition at line 35 of file workspace.py.

00035 
00036     def current_workspace(self):
00037         """The current workspace number. 0 <= x < num_workspaces."""
00038         vx,vy = get_desktop_viewport()
00039         return self._coordinates_to_vp_number(vx, vy)

Here is the call graph for this function:

Here is the caller graph for this function:

The number of workspaces configured.

Definition at line 30 of file workspace.py.

00030 
00031     def num_workspaces(self):
00032         """The number of workspaces configured."""
00033         return self._workspaces_wide * self._workspaces_high

Here is the caller graph for this function:

Re-read information about available workspaces from compiz and X11.

Definition at line 40 of file workspace.py.

00040 
00041     def refresh_workspace_information(self):
00042         """Re-read information about available workspaces from compiz and X11."""
00043         self._workspaces_wide = get_compiz_option("core", "hsize")
00044         self._workspaces_high = get_compiz_option("core", "vsize")
00045         self._desktop_width, self.desktop_height = get_desktop_geometry()
00046         self._viewport_width = self._desktop_width / self._workspaces_wide
00047         self._viewport_height = self.desktop_height / self._workspaces_high

Here is the caller graph for this function:

def unity.emulators.workspace.WorkspaceManager.switch_to (   self,
  workspace_num 
)
Switch to the workspace specified.

ValueError is raised if workspace_num is outside 0<= workspace_num < num_workspaces.

Definition at line 48 of file workspace.py.

00048 
00049     def switch_to(self, workspace_num):
00050         """Switch to the workspace specified.
00051 
00052         ValueError is raised if workspace_num is outside 0<= workspace_num < num_workspaces.
00053 
00054         """
00055         if workspace_num < 0 or workspace_num >= self.num_workspaces:
00056             raise ValueError("Workspace number must be between 0 and %d" % self.num_workspaces)
00057 
00058         current_row, current_col = self._vp_number_to_row_col(self.current_workspace)
00059         target_row, target_col = self._vp_number_to_row_col(workspace_num)
00060         lefts = rights = ups = downs = 0
00061         if current_col > target_col:
00062             lefts = current_col - target_col
00063         else:
00064             rights = target_col - current_col
00065         if current_row > target_row:
00066             ups = current_row - target_row
00067         else:
00068             downs = target_row - current_row
00069 
00070         for i in range(lefts):
00071             self.keybinding("workspace/move_left")
00072         for i in range(rights):
00073             self.keybinding("workspace/move_right")
00074         for i in range(ups):
00075             self.keybinding("workspace/move_up")
00076         for i in range(downs):
00077             self.keybinding("workspace/move_down")

Here is the call graph for this function:


Member Data Documentation

Definition at line 46 of file workspace.py.

Definition at line 45 of file workspace.py.

Definition at line 43 of file workspace.py.

Definition at line 42 of file workspace.py.

Definition at line 44 of file workspace.py.


The documentation for this class was generated from the following file: