custom background color and font, setup for keys
This commit is contained in:
parent
346adba2ad
commit
aba19728a8
17
main.py
17
main.py
|
@ -20,11 +20,12 @@ def gradient(x1,y1,x2,y2):
|
|||
return y1-y2/x1-x2
|
||||
|
||||
class MenuWindow(Gtk.Window):
|
||||
def __init__(self, options, colors):
|
||||
def __init__(self, options, colors,config):
|
||||
super().__init__()
|
||||
self.set_title("sike")
|
||||
self.options = options
|
||||
self.colors = colors
|
||||
self.config = config
|
||||
self.selected = None
|
||||
self.connect("destroy",Gtk.main_quit)
|
||||
self.set_resizable(False)
|
||||
|
@ -33,10 +34,13 @@ class MenuWindow(Gtk.Window):
|
|||
self.mouse_y = 0
|
||||
self.area = Gtk.DrawingArea()
|
||||
self.area.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
|
||||
self.area.add_events(Gdk.EventMask.KEY_PRESS_MASK)
|
||||
self.area.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
self.area.add_events(Gdk.EventMask.BUTTON_MOTION_MASK)
|
||||
self.area.connect("draw",self.draw_area)
|
||||
self.area.connect("button_release_event",self.on_selection)
|
||||
self.area.connect("key_press_event",self.on_keypress)
|
||||
self.area.connect("button_release_event",self.on_selection)
|
||||
self.area.connect("motion_notify_event",self.on_move)
|
||||
self.add(self.area)
|
||||
|
||||
|
@ -46,6 +50,9 @@ class MenuWindow(Gtk.Window):
|
|||
self.set_default_size(width/3,height)
|
||||
self.move(width-self.width,0)
|
||||
|
||||
def on_keypress(self,widget,data):
|
||||
print("woop")
|
||||
|
||||
def on_selection(self,widget,data):
|
||||
if self.selected != None:
|
||||
opt = self.options[self.selected]
|
||||
|
@ -104,10 +111,14 @@ class MenuWindow(Gtk.Window):
|
|||
self.lines = []
|
||||
width = widget.get_allocated_width()
|
||||
height = widget.get_allocated_height()
|
||||
bg = self.colors["background"]
|
||||
cr.set_source_rgb(bg[0],bg[1],bg[2])
|
||||
cr.rectangle(0,0,width,height)
|
||||
cr.fill()
|
||||
cr.translate(width,height/2) # All coordinates are relative to right center
|
||||
cp = cr.get_current_point()
|
||||
self.center = cr.user_to_device(cp[0],cp[1])
|
||||
cr.select_font_face("monospace",cairo.FontSlant.NORMAL,cairo.FontWeight.BOLD)
|
||||
cr.select_font_face(self.config["font"],cairo.FontSlant.NORMAL,cairo.FontWeight.BOLD)
|
||||
cr.set_line_width(4)
|
||||
cr.set_font_size(20)
|
||||
start_angle = (-math.pi/16)*(len(self.options)/2)
|
||||
|
@ -131,7 +142,7 @@ else:
|
|||
focused = i3.get_tree().find_focused()
|
||||
else:
|
||||
i3 = None
|
||||
win = MenuWindow(config_file["options"],config_file["colors"])
|
||||
win = MenuWindow(config_file["options"],config_file["colors"],config_file["config"])
|
||||
screen = win.get_screen()
|
||||
disp = screen.get_display()
|
||||
monitor_count = disp.get_n_monitors()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
[config]
|
||||
use_i3=true # If we are connecting to i3/sway or not.
|
||||
font="FantasqueSansMono" # Font
|
||||
|
||||
[colors] # Colors are an array of [r,g,b] as floats from 0 to 1
|
||||
selected=[0.72,0.74,0.41]
|
||||
deselected=[1,1,1]
|
||||
background=[0.11,0.12,0.13]
|
||||
|
||||
# All menu options are formatted like this.
|
||||
# There are 4 types: shell, internal, i3, and submenu.
|
||||
|
|
Reference in New Issue