shakaran

Untitled

Jun 17th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.93 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8; tab-width: 4; mode: python -*-
  3. # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-
  4. # vi: set ft=python sts=4 ts=4 sw=4 noet
  5. #
  6. # This file is part of FreeStation.
  7. #
  8. # FreeStation is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # FreeStation is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with Fail2Ban; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  21.  
  22. # Author: Ángel Guzmán Maeso
  23. #
  24. # $Revision$
  25.  
  26. __author__    = 'Ángel Guzmán Maeso'
  27. __version__   = '$Revision$'
  28. __date__      = '$Date$'
  29. __copyright__ = 'Copyright (c) 2012 Ángel Guzmán Maeso'
  30. __license__   = 'GPL'
  31.  
  32. from freestation.logger import Logger
  33. LOG = Logger('GUI').get()
  34.  
  35. import gi
  36. gi.require_version('Gtk', '3.0')
  37.  
  38. from gi.repository import Gdk, Gtk #@UnresolvedImport
  39. from gi.repository import GdkX11 #@UnresolvedImport # For get_xid() @UnusedImport
  40.  
  41. from freestation.constants import APP_NAME
  42. from freestation.widget_loader import WidgetLoader
  43.  
  44. class GUI2(Gtk.Window):
  45.    
  46.     __name__ = 'GUI' #@ReservedAssignment
  47.    
  48.     def __init__(self, application):
  49.         Gtk.Window.__init__(self, type = Gtk.WindowType.TOPLEVEL)
  50.        
  51.         LOG.debug('Starting')
  52.         self.application = application
  53.         self.__connect_signals()
  54.        
  55.         self.set_title(APP_NAME)
  56.         self.set_border_width(24)
  57.         self.set_decorated(False)
  58.  
  59.         self.__pack_widgets()
  60.  
  61.         self.add(self.box)
  62.         self.fullscreen()
  63.  
  64.         self.show_all()
  65.  
  66.     def __pack_widgets(self):
  67.         self.box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL, spacing = 6)
  68.        
  69.         from freestation.widgets import BrowserView
  70.        
  71.         self.browser_view_widget = BrowserView.BrowserView(None)
  72.  
  73.         self.box.pack_start(self.browser_view_widget , True, True, True)
  74.  
  75.     def __connect_signals(self):
  76.         self.connect('key-press-event', self.__key_press_event)
  77.         self.connect('delete-event',   self.application.on_destroy)
  78.                
  79.     def __key_press_event(self, widget, event) :
  80.         # event.keyval == Gdk.keyval_from_name("w")
  81.  
  82.         if event.string == 'q' :
  83.             if hasattr(self, 'browser_view_widget'):
  84.                 self.browser_view_widget.on_destroy()
  85.             widget.destroy()
  86.             self.application.on_destroy(widget, event)
  87.         elif event.string == 'f' :
  88.             self.unfullscreen()
Advertisement
Add Comment
Please, Sign In to add comment