Implement sliding, dead slow with gradients.

Get keyboard focus in the dock with some evil hack.
This commit is contained in:
Marco Pesenti Gritti 2006-06-19 15:31:18 -04:00
parent 072fea84a0
commit 4cef4cb3bd
3 changed files with 46 additions and 5 deletions

View File

@ -24,6 +24,7 @@ class ChatEditor(gtk.HBox):
chat_view_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._text_view = richtext.RichTextView()
self._text_view.connect("key-press-event", self.__key_press_event_cb)
self._text_view.connect("button-press-event", self.__button_press_event_cb)
chat_view_sw.add(self._text_view)
self._text_view.show()
@ -86,3 +87,9 @@ class ChatEditor(gtk.HBox):
if event.keyval == gtk.keysyms.Return:
self._send()
return True
def __button_press_event_cb(self, text_view, event):
# Need to explicitly get keyboard focus in the window
# because docks doesn't take it by default.
toplevel = text_view.get_toplevel()
toplevel.window.focus()

View File

@ -17,6 +17,7 @@ class WindowManager:
def __init__(self, window):
self._window = window
self._sliding_pos = 0
WindowManager.__managers_list.append(self)
@ -71,20 +72,53 @@ class WindowManager:
x = int((screen_width - width) / 2)
y = int((screen_height - height) / 2)
elif self._position is WindowManager.LEFT:
x = 0
x = - int((1.0 - self._sliding_pos) * width)
y = int((screen_height - height) / 2)
elif self._position is WindowManager.TOP:
x = int((screen_width - width) / 2)
y = 0
y = - int((1.0 - self._sliding_pos) * height)
self._window.move(x, y)
self._window.resize(width, height)
def slide_window_in(self):
def __slide_in_timeout_cb(self):
self._window.show()
self._sliding_pos += 0.05
if self._sliding_pos > 1.0:
self._sliding_pos = 1.0
self._update_size_and_position()
if self._sliding_pos == 1.0:
return False
else:
return True
def __slide_out_timeout_cb(self):
self._window.show()
self._sliding_pos -= 0.05
if self._sliding_pos < 0:
self._sliding_pos = 0
self._update_size_and_position()
if self._sliding_pos == 0:
self._window.hide()
return False
else:
return True
def slide_window_in(self):
self._sliding_pos = 0
gobject.timeout_add(5, self.__slide_in_timeout_cb)
def slide_window_out(self):
self._window.hide()
self._sliding_pos = 1.0
gobject.timeout_add(5, self.__slide_out_timeout_cb)
def show(self):
self._window.show()

View File

@ -311,7 +311,7 @@ class ActivityContainer(dbus.service.Object):
self._chat_window = ChatWindow()
self._chat_window.set_transient_for(self.window)
self._presence_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
self._chat_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
self._chat_window.set_decorated(False)
self._chat_window.set_skip_taskbar_hint(True)