More work on the slide in windows
This commit is contained in:
parent
6cca4f34f3
commit
3497fd3ad2
@ -14,6 +14,9 @@ class PresenceWindow(gtk.Window):
|
|||||||
def __init__(self, activity_container):
|
def __init__(self, activity_container):
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
|
||||||
|
self.set_decorated(False)
|
||||||
|
self.set_skip_taskbar_hint(True)
|
||||||
|
|
||||||
self._activity_container = activity_container
|
self._activity_container = activity_container
|
||||||
|
|
||||||
self._pservice = PresenceService.get_instance()
|
self._pservice = PresenceService.get_instance()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
class WindowManager:
|
class WindowManager:
|
||||||
__managers_list = []
|
__managers_list = []
|
||||||
@ -13,12 +14,49 @@ class WindowManager:
|
|||||||
ABSOLUTE = 0
|
ABSOLUTE = 0
|
||||||
SCREEN_RELATIVE = 1
|
SCREEN_RELATIVE = 1
|
||||||
|
|
||||||
|
VISIBLE = 0
|
||||||
|
SLIDED_IN = 1
|
||||||
|
HIDDEN = 2
|
||||||
|
|
||||||
def __init__(self, window):
|
def __init__(self, window):
|
||||||
self._window = window
|
self._window = window
|
||||||
|
self._visibility = WindowManager.HIDDEN
|
||||||
|
|
||||||
WindowManager.__managers_list.append(self)
|
WindowManager.__managers_list.append(self)
|
||||||
|
|
||||||
window.connect("key-press-event", self.__key_press_event_cb)
|
window.connect("key-press-event", self.__key_press_event_cb)
|
||||||
|
window.connect("focus-in-event", self.__focus_in_event_cb)
|
||||||
|
window.connect_after("focus-out-event", self.__focus_out_event_cb)
|
||||||
|
|
||||||
|
def has_focus(self):
|
||||||
|
return self._window.has_toplevel_focus()
|
||||||
|
|
||||||
|
def _update_visibility(self):
|
||||||
|
show_slided_in = False
|
||||||
|
|
||||||
|
for manager in WindowManager.__managers_list:
|
||||||
|
if manager.has_focus():
|
||||||
|
show_slided_in = True
|
||||||
|
|
||||||
|
if manager._visibility is WindowManager.VISIBLE:
|
||||||
|
manager._window.show()
|
||||||
|
elif manager._visibility is WindowManager.HIDDEN:
|
||||||
|
manager._window.hide()
|
||||||
|
elif manager._visibility is WindowManager.SLIDED_IN:
|
||||||
|
if show_slided_in:
|
||||||
|
manager._window.show()
|
||||||
|
else:
|
||||||
|
manager._window.hide()
|
||||||
|
|
||||||
|
def __focus_change_idle(self):
|
||||||
|
self._update_visibility()
|
||||||
|
return False
|
||||||
|
|
||||||
|
def __focus_in_event_cb(self, window, event):
|
||||||
|
gobject.idle_add(self.__focus_change_idle)
|
||||||
|
|
||||||
|
def __focus_out_event_cb(self, window, event):
|
||||||
|
gobject.idle_add(self.__focus_change_idle)
|
||||||
|
|
||||||
def __key_press_event_cb(self, window, event):
|
def __key_press_event_cb(self, window, event):
|
||||||
manager = None
|
manager = None
|
||||||
@ -70,14 +108,16 @@ class WindowManager:
|
|||||||
self._window.resize(width, height)
|
self._window.resize(width, height)
|
||||||
|
|
||||||
def slide_window_in(self):
|
def slide_window_in(self):
|
||||||
self._window.show()
|
self._visibility = WindowManager.SLIDED_IN
|
||||||
|
self._update_visibility()
|
||||||
|
|
||||||
def slide_window_out(self):
|
def slide_window_out(self):
|
||||||
self._window.hide()
|
self._visibility = WindowManager.HIDDEN
|
||||||
|
self._update_visibility()
|
||||||
|
|
||||||
def show_window(self):
|
def show(self):
|
||||||
|
self._visibility = WindowManager.VISIBLE
|
||||||
|
|
||||||
|
def manage(self):
|
||||||
self._update_size_and_position()
|
self._update_size_and_position()
|
||||||
self._window.show()
|
self._update_visibility()
|
||||||
|
|
||||||
def hide_window(self):
|
|
||||||
self._window.hide()
|
|
||||||
|
@ -375,17 +375,19 @@ def main():
|
|||||||
|
|
||||||
presence_window = PresenceWindow(activity_container)
|
presence_window = PresenceWindow(activity_container)
|
||||||
|
|
||||||
wm = WindowManager(presence_window)
|
|
||||||
wm.set_width(0.15, WindowManager.SCREEN_RELATIVE)
|
|
||||||
wm.set_height(1.0, WindowManager.SCREEN_RELATIVE)
|
|
||||||
wm.set_position(WindowManager.LEFT)
|
|
||||||
wm.show_window()
|
|
||||||
|
|
||||||
wm = WindowManager(activity_container.window)
|
wm = WindowManager(activity_container.window)
|
||||||
wm.set_width(640, WindowManager.ABSOLUTE)
|
wm.set_width(640, WindowManager.ABSOLUTE)
|
||||||
wm.set_height(480, WindowManager.ABSOLUTE)
|
wm.set_height(480, WindowManager.ABSOLUTE)
|
||||||
wm.set_position(WindowManager.CENTER)
|
wm.set_position(WindowManager.CENTER)
|
||||||
wm.show_window()
|
wm.show()
|
||||||
|
wm.manage()
|
||||||
|
|
||||||
|
wm = WindowManager(presence_window)
|
||||||
|
|
||||||
|
wm.set_width(0.15, WindowManager.SCREEN_RELATIVE)
|
||||||
|
wm.set_height(1.0, WindowManager.SCREEN_RELATIVE)
|
||||||
|
wm.set_position(WindowManager.LEFT)
|
||||||
|
wm.manage()
|
||||||
|
|
||||||
console.set_parent_window(activity_container.window)
|
console.set_parent_window(activity_container.window)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user