Hud.py: fix typos in definitions of reposition_windows and kill_hud, eliminating errors when those functions are called

move pop-up window to button 3 when clicked on a stat window, added move/resize functionality to button 1 (hold shift to resize, or just click/drag to move)
restore opacity in windows (new window movement works with opacity set)
fix error in popup_window initilization referring to window instead of main_window, oops
This commit is contained in:
eblade 2008-11-10 05:58:55 -05:00
parent e713a9c654
commit 2074d755aa

View File

@ -116,13 +116,13 @@ class Hud:
return True return True
return False return False
def kill_hud(self, args): def kill_hud(self, *args):
for k in self.stat_windows.keys(): for k in self.stat_windows.keys():
self.stat_windows[k].window.destroy() self.stat_windows[k].window.destroy()
self.main_window.destroy() self.main_window.destroy()
self.deleted = True self.deleted = True
def reposition_windows(self, args): def reposition_windows(self, *args):
for w in self.stat_windows: for w in self.stat_windows:
self.stat_windows[w].window.move(self.stat_windows[w].x, self.stat_windows[w].window.move(self.stat_windows[w].x,
self.stat_windows[w].y) self.stat_windows[w].y)
@ -259,7 +259,8 @@ class Stat_Window:
# This handles all callbacks from button presses on the event boxes in # This handles all callbacks from button presses on the event boxes in
# the stat windows. There is a bit of an ugly kludge to separate single- # the stat windows. There is a bit of an ugly kludge to separate single-
# and double-clicks. # and double-clicks.
if event.button == 1: # left button event
if event.button == 3: # right button event
if event.type == gtk.gdk.BUTTON_PRESS: # left button single click if event.type == gtk.gdk.BUTTON_PRESS: # left button single click
if self.sb_click > 0: return if self.sb_click > 0: return
self.sb_click = gobject.timeout_add(250, self.single_click, widget) self.sb_click = gobject.timeout_add(250, self.single_click, widget)
@ -270,12 +271,14 @@ class Stat_Window:
self.double_click(widget, event, *args) self.double_click(widget, event, *args)
if event.button == 2: # middle button event if event.button == 2: # middle button event
pass
# print "middle button clicked" # print "middle button clicked"
if event.button == 3: # right button event
pass pass
# print "right button clicked"
if event.button == 1: # left button event
if event.state & gtk.gdk.SHIFT_MASK:
self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time)
else:
self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
def single_click(self, widget): def single_click(self, widget):
# Callback from the timeout in the single-click finding part of the # Callback from the timeout in the single-click finding part of the
@ -349,8 +352,9 @@ class Stat_Window:
# font = pango.FontDescription("Sans 8") # font = pango.FontDescription("Sans 8")
self.label[r][c].modify_font(font) self.label[r][c].modify_font(font)
if not os.name == 'nt': # seems to be a bug in opacity on windows # if not os.name == 'nt': # seems to be a bug in opacity on windows
self.window.set_opacity(parent.colors['hudopacity']) self.window.set_opacity(parent.colors['hudopacity'])
self.window.realize self.window.realize
self.window.move(self.x, self.y) self.window.move(self.x, self.y)
self.window.show_all() self.window.show_all()
@ -457,7 +461,7 @@ class Popup_window:
self.lab.set_text(pu_text) self.lab.set_text(pu_text)
self.window.show_all() self.window.show_all()
self.window.set_transient_for(stat_window.main_window) self.window.set_transient_for(stat_window.window)
# set_keep_above(1) for windows # set_keep_above(1) for windows
if os.name == 'nt': self.topify_window(self.window) if os.name == 'nt': self.topify_window(self.window)