def __init__(self, desk): self.desk = desk self.label = None self.eb = None self.gc = None self.box = gtk.VBox(False, 0) if config.desk_views(config): self.area = gtk.DrawingArea() self.cmap = self.area.get_colormap() self.box.pack_start(self.area, True, True, 0) self.area.add_events(gtk.gdk.EXPOSURE_MASK | gtk.gdk.BUTTON_PRESS_MASK) self.area.connect('expose-event', self.cb_exposed) self.area.connect('button_press_event', self.cb_button_press) else: self.area = None self.cmap = None if config.show_desk_names: self.eb = gtk.EventBox() self.eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.pager_bgcolor)) self.label = gtk.Label() self.eb.add(self.label) self.box.pack_start(self.eb, False, False, 2) self.eb.connect('button_press_event', self.cb_button_press) self.box.show_all()
def cb_prop_change(widget, e): if e.atom in ('_NET_CLIENT_LIST', '_NET_ACTIVE_WINDOW', '_NET_CURRENT_DESKTOP', '_NET_CLIENT_LIST_STACKING', '_NET_DESKTOP_NAMES'): update_all() elif e.atom == '_NET_VISIBLE_DESKTOPS': update_desktop_order() update_all() elif e.atom == '_NET_NUMBER_OF_DESKTOPS': if state.desk_num < len(desktops): while state.desk_num < len(desktops): lastdesk = None for i, d in enumerate(desktops): if lastdesk is None or d.desk > desktops[lastdesk].desk: lastdesk = i desktops.pop(lastdesk).destroy() elif state.desk_num > len(desktops): expand = config.desk_views(config) while state.desk_num > len(desktops): d = Desktop(len(desktops)) _box.pack_start(d.box, expand, expand, 0) desktops.append(d) update_desktop_order() update_all()
def init(): global _window, _box _window = gtk.Window(gtk.WINDOW_TOPLEVEL) _window.connect('delete_event', gtk.main_quit) if config.dock: _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK) else: _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) if config.sticky: _window.stick() if config.above: _window.set_keep_above(True) _window.set_resizable(False) _window.set_decorated(False) _window.set_title('pager-multihead') _window.set_skip_pager_hint(True) _window.set_skip_taskbar_hint(True) _window.set_geometry_hints(None, min_width=config.width, min_height=config.height, max_width=config.width, max_height=config.height) _window.move(config.x, config.y) _window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.pager_bgcolor)) expand = config.desk_views(config) if state.orient == 'H': _box = gtk.HBox(expand, 0) else: _box = gtk.VBox(expand, 0) _window.add(_box) for i in xrange(state.desk_num): d = Desktop(i) _box.pack_start(d.box, expand, expand, 0) desktops.append(d) update_desktop_order() _window.show_all() # If the user says to set struts, we *will* do it. # We are a little bit smart, though... We'll account for dead area. # This does not allow for between-monitor struts... For another day! if config.struts: wx, wy, ww, wh = config.x, config.y, config.width, config.height mx, my, mw, mh = rect.get_monitor_area((wx, wy, ww, wh), state.monitors) rw, rh = state.root_geom['width'], state.root_geom['height'] struts = { nm: 0 for nm in [ 'left', 'right', 'top', 'bottom', 'left_start_y', 'left_end_y', 'right_start_y', 'right_end_y', 'top_start_x', 'top_end_x', 'bottom_start_x', 'bottom_end_x' ] } if state.orient == 'V': # left or right? if wx < rw / 2: # left struts['left'] = ww + mx + wx struts['left_start_y'] = wy struts['left_end_y'] = wy + wh else: # right struts['right'] = ww + rw - mw - mx struts['right_start_y'] = wy struts['right_end_y'] = wy + wh else: # top or bottom? if wy < rh / 2: # top struts['top'] = wh + my struts['top_start_x'] = wx struts['top_end_x'] = wx + ww else: #bottom struts['bottom'] = wh + rh - mh - my struts['bottom_start_x'] = wx struts['bottom_end_x'] = wx + ww ewmh.set_wm_strut_partial_checked(_window.window.xid, **struts).check()
def init(): global _window, _box _window = gtk.Window(gtk.WINDOW_TOPLEVEL) _window.connect('delete_event', gtk.main_quit) if config.dock: _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK) else: _window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) if config.sticky: _window.stick() if config.above: _window.set_keep_above(True) _window.set_resizable(False) _window.set_decorated(False) _window.set_title('pager-multihead') _window.set_skip_pager_hint(True) _window.set_skip_taskbar_hint(True) _window.set_geometry_hints(None, min_width=config.width, min_height=config.height, max_width=config.width, max_height=config.height) _window.move(config.x, config.y) _window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(config.pager_bgcolor)) expand = config.desk_views(config) if state.orient == 'H': _box = gtk.HBox(expand, 0) else: _box = gtk.VBox(expand, 0) _window.add(_box) for i in xrange(state.desk_num): d = Desktop(i) _box.pack_start(d.box, expand, expand, 0) desktops.append(d) update_desktop_order() _window.show_all() # If the user says to set struts, we *will* do it. # We are a little bit smart, though... We'll account for dead area. # This does not allow for between-monitor struts... For another day! if config.struts: wx, wy, ww, wh = config.x, config.y, config.width, config.height mx, my, mw, mh = rect.get_monitor_area((wx, wy, ww, wh), state.monitors) rw, rh = state.root_geom['width'], state.root_geom['height'] struts = { nm: 0 for nm in ['left', 'right', 'top', 'bottom', 'left_start_y', 'left_end_y', 'right_start_y', 'right_end_y', 'top_start_x', 'top_end_x', 'bottom_start_x', 'bottom_end_x'] } if state.orient == 'V': # left or right? if wx < rw / 2: # left struts['left'] = ww + mx + wx struts['left_start_y'] = wy struts['left_end_y'] = wy + wh else: # right struts['right'] = ww + rw - mw - mx struts['right_start_y'] = wy struts['right_end_y'] = wy + wh else: # top or bottom? if wy < rh / 2: # top struts['top'] = wh + my struts['top_start_x'] = wx struts['top_end_x'] = wx + ww else: #bottom struts['bottom'] = wh + rh - mh - my struts['bottom_start_x'] = wx struts['bottom_end_x'] = wx + ww ewmh.set_wm_strut_partial_checked(_window.window.xid, **struts).check()