from OmegaWM import * import OmegaWM ShiftMask = 1 ControlMask = 4 Mod1Mask = 8 Mod2Mask = 16 Mod3Mask = 32 Mod4Mask = 64 Mod5Mask = 128 NorthWestGravity = 1 NorthGravity = 2 NorthEastGravity = 3 WestGravity = 4 CenterGravity = 5 EastGravity = 6 SouthWestGravity = 7 SouthGravity = 8 SouthEastGravity = 9 theme_color="red" # red blue yellow pink green # Convenience and prettification wrappers class OmegaThemeImlib2: def __init__(self, wm): self.__theme__ = OmegaWM.OmegaThemeImlib2(wm) wm.theme = self.__theme__.theme self.setBorder = self.__theme__.setBorder def __add__(self, op): self.__theme__.add(op.action) return self class Imlib2Op: def __init__(self): self.__op__ = OmegaWM.Imlib2Op() self.action = self.__op__.action def __add__(self, op): if hasattr(op, "action"): self.__op__.add(op.action) else: self.__op__.add(op.condition) return self def __sub__(self, op): self.__op__.addNeg(op.action) return self def MyPixmapTheme(wm): def SetupHotspots(event): # Close action, kill client if pressed while ALT is held def CloseAction(event): if event.detail == 1: if event.state & Mod1Mask: event.hotspot.frame.active.kill() else: event.hotspot.frame.active.close() return False # Minimize / iconify action def MinimizeAction(event): if event.detail == 1: event.hotspot.frame.iconic = True # Maximize action, button 1 = horz+vert, 2 = vert, 3 = horz def MaximizeAction(event): frame = event.hotspot.frame if event.detail == 1: if frame.maximizedVert or frame.maximizedHorz: frame.setMaximized(False, False) else: frame.setMaximized(True, True) elif event.detail == 2: frame.maximizedVert = not frame.maximizedVert elif event.detail == 3: frame.maximizedHorz = not frame.maximizedHorz return False # Closure that returns a directional resize action def StartResizeAction(gravity): def _StartResize(event): if event.detail == 1: event.hotspot.frame.startResize( event.hotspot.x + event.x, event.hotspot.y + event.y, gravity ) return False return _StartResize # Stop resizing action def StopResizeAction(event): if event.detail == 1: event.hotspot.frame.fixate() return False frame = event.frame hotspot = OmegaHotspot(frame, "close") hotspot.moveResize(1, 3, 20, 20) hotspot.connect("click", CloseAction) hotspot.redrawOnButton = True hotspot.mapped = True hotspot = OmegaHotspot(frame, "minimize") hotspot.moveResize(-41, 3, 20, 20) hotspot.connect("click", MinimizeAction) hotspot.redrawOnButton = True hotspot.mapped = True hotspot = OmegaHotspot(frame, "maximize") hotspot.moveResize(-21, 3, 20, 20) hotspot.connect("click", MaximizeAction) hotspot.redrawOnButton = True hotspot.mapped = True hotspot = OmegaHotspot(frame, "grip-bl") hotspot.moveResize(0, -10, 13, 10) hotspot.connect("button-press", StartResizeAction(SouthWestGravity)) hotspot.connect("button-release", StopResizeAction) hotspot.mapped = True hotspot = OmegaHotspot(frame, "grip-br") hotspot.moveResize(-13, -10, 13, 13) hotspot.connect("button-press", StartResizeAction(SouthEastGravity)) hotspot.connect("button-release", StopResizeAction) hotspot.mapped = True # Hook up our setup routine wm.connect('new-frame', SetupHotspots) # Create a new empty theme instance theme = OmegaThemeImlib2(wm) # Border sizes (left, top, right, bottom) theme.setBorder(5, 20, 5, 7) # Inner border theme += Imlib2SetColor(0, 0, 0, 255) theme += Imlib2FillRectangle(2, 2, -4, -4) # Bottom left and right pixmaps (grips) # The title bar, twice, once for focused once for non-focused op = Imlib2Op() op += Imlib2ConditionFocus() #focused ( the images below can overlay each other, upper layers are further down the file ) op += Imlib2RenderImage(2, -10, "pixmaps/once/" + theme_color + "-bl.png") # Bottom left op += Imlib2RenderImage(-12, -10, "pixmaps/once/" + theme_color + "-br.png") # Bottom Right op += Imlib2RenderImageScaled(21, 0, -62, 20, "pixmaps/once/" + theme_color + "-noside.png") #middle text backgroun op += Imlib2RenderImage(11, 0, "pixmaps/once/" + theme_color + "-leftside.png") #left side of text background op += Imlib2RenderImage(-41, 0, "pixmaps/once/" + theme_color + "-rightside.png") #right side of text background op += Imlib2RenderImage(-11, 0, "pixmaps/once/toprightside.png") #extreme right corner op += Imlib2RenderImage(1, 0, "pixmaps/once/topleftside.png") #extreme left corner # unfocused op -= Imlib2RenderImage(2, -10, "pixmaps/once/bl-un.png") op -= Imlib2RenderImage(-12, -10, "pixmaps/once/br-un.png") op -= Imlib2RenderImageScaled(21, 0, -62, 20, "pixmaps/once/noside-un.png") op -= Imlib2RenderImage(11, 0, "pixmaps/once/leftside-un.png") op -= Imlib2RenderImage(-41, 0, "pixmaps/once/rightside-un.png") op -= Imlib2RenderImage(-11, 0, "pixmaps/once/toprightside.png") op -= Imlib2RenderImage(1, 0, "pixmaps/once/topleftside.png") theme += op def addButton(theme, ix, x, y, img): img1 = "pixmaps/once/" + theme_color + "-%s.png" % img img2 = "pixmaps/once/" + theme_color + "-%s-click.png" % img op = Imlib2Op() op += Imlib2ConditionHotspotPressed(img, 0) op += Imlib2RenderImage(x, y, img2) op -= Imlib2RenderImage(x, y, img1) theme += op addButton(theme, 0, 5, 5, "close") addButton(theme, 1, -30, 5, "minimize") addButton(theme, 2, -16, 5, "maximize") # Outer border theme += Imlib2SetColor(0, 0, 0, 255) theme += Imlib2FillRectangle(0, 0, 0, 2) theme += Imlib2FillRectangle(0, 0, 2, -2) theme += Imlib2FillRectangle(0, -2, 0, 2) theme += Imlib2FillRectangle(-2, 0, 2, 0) # The window title op = Imlib2Op() op += Imlib2ConditionFocus() op += Imlib2SetColor(0, 0, 0, 255) op -= Imlib2SetColor(10, 10, 10, 255) #op -= Imlib2RenderImageScaled(19, 0, -60, 20, "pixmaps/once/" + theme_color + "-glow.png") theme += op theme += Imlib2WindowTitle(22, 0, -60, 20, "luxi serif/10") theme += Imlib2RenderImageScaled(2, 0, -4, 20, "pixmaps/once/bar.png")