| 1 |
################################################################################ |
|---|
| 2 |
# Copyright (C) 2006 Travis Shirk <travis@pobox.com> |
|---|
| 3 |
# |
|---|
| 4 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 5 |
# it under the terms of the GNU General Public License as published by |
|---|
| 6 |
# the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 |
# (at your option) any later version. |
|---|
| 8 |
# |
|---|
| 9 |
# This program is distributed in the hope that it will be useful, |
|---|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
# GNU General Public License for more details. |
|---|
| 13 |
# |
|---|
| 14 |
# You should have received a copy of the GNU General Public License |
|---|
| 15 |
# along with this program; if not, write to the Free Software |
|---|
| 16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 |
# |
|---|
| 18 |
# $Id$ |
|---|
| 19 |
################################################################################ |
|---|
| 20 |
import gtk |
|---|
| 21 |
import gtk_utils |
|---|
| 22 |
|
|---|
| 23 |
class Window: |
|---|
| 24 |
def __init__(self, window_name, glade_file): |
|---|
| 25 |
self._window_pos = (-1,-1) |
|---|
| 26 |
self._window_size = (-1,-1) |
|---|
| 27 |
|
|---|
| 28 |
self.xml = gtk_utils.get_glade(window_name, glade_file) |
|---|
| 29 |
self.window = self.xml.get_widget(window_name) |
|---|
| 30 |
self.window.set_icon_from_file('data/images/mesk-16.png') |
|---|
| 31 |
|
|---|
| 32 |
self.window.connect('delete-event', self._on_window_delete_event) |
|---|
| 33 |
self.window.connect('configure-event', self._on_window_configure_event) |
|---|
| 34 |
|
|---|
| 35 |
self.xml.signal_autoconnect(self) |
|---|
| 36 |
|
|---|
| 37 |
def show(self): |
|---|
| 38 |
self.window.show() |
|---|
| 39 |
def present(self): |
|---|
| 40 |
self.window.present() |
|---|
| 41 |
def hide(self): |
|---|
| 42 |
self.window.hide() |
|---|
| 43 |
def deiconify(self): |
|---|
| 44 |
self.window.deiconify() |
|---|
| 45 |
|
|---|
| 46 |
def is_visible(self): |
|---|
| 47 |
return self.window.get_property("visible") |
|---|
| 48 |
|
|---|
| 49 |
def _on_window_configure_event(self, win, event): |
|---|
| 50 |
if event.type == gtk.gdk.CONFIGURE: |
|---|
| 51 |
# Call into the Window over the event coords since event does not |
|---|
| 52 |
# account for window manager decoration sizes. |
|---|
| 53 |
self._window_pos = self.window.get_position() |
|---|
| 54 |
self._window_size = self.window.get_size() |
|---|
| 55 |
|
|---|
| 56 |
def _on_window_delete_event(self, win, event): |
|---|
| 57 |
self.hide() |
|---|
| 58 |
return True |
|---|