[nanny: 3/11] Added nanny-desktop-blocker



commit 47d98f84765c185a44e5e44a131ecc451660dd7e
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Thu Apr 1 04:09:45 2010 +0200

    Added nanny-desktop-blocker

 client/gnome/admin/Makefile.am                     |    4 +-
 client/gnome/admin/data/ui/Makefile.am             |    3 +-
 .../gnome/admin/data/ui/nanny_desktop_blocker.ui   |  111 +++++++++++++++++++
 client/gnome/admin/nanny-desktop-blocker           |   37 +++++++
 client/gnome/admin/src/DesktopBlocker.py           |  112 ++++++++++++++++++++
 client/gnome/admin/src/Makefile.am                 |    3 +-
 client/gnome/admin/src/__init__.py.in              |    1 +
 7 files changed, 267 insertions(+), 4 deletions(-)
---
diff --git a/client/gnome/admin/Makefile.am b/client/gnome/admin/Makefile.am
index 5a77c89..3bd8b0e 100644
--- a/client/gnome/admin/Makefile.am
+++ b/client/gnome/admin/Makefile.am
@@ -1,5 +1,5 @@
 SUBDIRS=data src
 
-sbin_SCRIPTS = nanny-admin-console nanny-blacklist-manager
+sbin_SCRIPTS = nanny-admin-console nanny-blacklist-manager nanny-desktop-blocker
 
-EXTRA_DIST = nanny-admin-console nanny-blacklist-manager
+EXTRA_DIST = nanny-admin-console nanny-blacklist-manager nanny-desktop-blocker
diff --git a/client/gnome/admin/data/ui/Makefile.am b/client/gnome/admin/data/ui/Makefile.am
index 2d00f97..500adbe 100644
--- a/client/gnome/admin/data/ui/Makefile.am
+++ b/client/gnome/admin/data/ui/Makefile.am
@@ -3,6 +3,7 @@ ui_DATA = nanny_admin_console.ui \
 	     nac_wcf_edit_dialog.ui \
 	     nac_wcf_dialog.ui \
 	     nbm_pbl_dialog.ui \
-	     nbm_pbl_edit_dialog.ui
+	     nbm_pbl_edit_dialog.ui	\
+	     nanny_desktop_blocker.ui
 
 EXTRA_DIST=$(ui_DATA)
diff --git a/client/gnome/admin/data/ui/nanny_desktop_blocker.ui b/client/gnome/admin/data/ui/nanny_desktop_blocker.ui
new file mode 100644
index 0000000..295f222
--- /dev/null
+++ b/client/gnome/admin/data/ui/nanny_desktop_blocker.ui
@@ -0,0 +1,111 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="window1">
+    <property name="modal">True</property>
+    <property name="decorated">False</property>
+    <child>
+      <object class="GtkVBox" id="db_main_vbox">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkAlignment" id="alignment1">
+            <property name="visible">True</property>
+            <property name="xscale">0</property>
+            <property name="yscale">0</property>
+            <child>
+              <object class="GtkHBox" id="hbox1">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkImage" id="image1">
+                    <property name="visible">True</property>
+                    <property name="stock">gtk-dialog-warning</property>
+                    <property name="icon-size">6</property>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkVBox" id="vbox2">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="xpad">9</property>
+                        <property name="label" translatable="yes">&lt;span size="25000" foreground="white"&gt;&lt;b&gt;You've used your computer use time&lt;/b&gt;&lt;/span&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="info_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">&lt;span foreground="white"&gt;&lt;big&gt;You've time available if you need to close documents or aplications.&lt;/big&gt;&lt;/span&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment2">
+            <property name="visible">True</property>
+            <property name="xalign">1</property>
+            <property name="xscale">0</property>
+            <property name="yscale">0</property>
+            <property name="top_padding">12</property>
+            <property name="bottom_padding">12</property>
+            <property name="right_padding">12</property>
+            <child>
+              <object class="GtkHBox" id="hbox2">
+                <property name="visible">True</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkButton" id="db_time_button">
+                    <property name="label" translatable="yes">5 minutes, please</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="db_close_button">
+                    <property name="label" translatable="yes">close session</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/client/gnome/admin/nanny-desktop-blocker b/client/gnome/admin/nanny-desktop-blocker
new file mode 100644
index 0000000..95eb5e7
--- /dev/null
+++ b/client/gnome/admin/nanny-desktop-blocker
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009,2010 Junta de Andalucia
+# 
+# Authors:
+#   Roberto Majadas <roberto.majadas at openshine.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+# USA
+
+import syslog
+import gtk 
+import gettext
+import __builtin__
+
+import nanny.client.gnome.admin
+
+if __name__ == '__main__':
+    __builtin__._ = gettext.gettext
+
+    desktop_blocker = nanny.client.gnome.admin.DesktopBlocker()
+    desktop_blocker.show()
+    gtk.gdk.keyboard_grab(desktop_blocker.window)
+    gtk.main()
+
diff --git a/client/gnome/admin/src/DesktopBlocker.py b/client/gnome/admin/src/DesktopBlocker.py
new file mode 100644
index 0000000..c2d897b
--- /dev/null
+++ b/client/gnome/admin/src/DesktopBlocker.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2009,2010 Junta de Andalucia
+# 
+# Authors:
+#   Roberto Majadas <roberto.majadas at openshine.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+# USA
+
+import os
+import sys
+import dbus
+
+import gtk
+import gtk.gdk
+import cairo
+import pango
+import gobject
+
+import nanny.client.common
+import nanny.client.gnome.admin
+import time
+
+
+class DesktopBlocker(gtk.Window):
+    def __init__(self):
+        gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)
+        self.set_property("skip-taskbar-hint", True)
+        self.set_property("skip-pager-hint", True)
+        self.set_property("focus-on-map", True)
+        self.set_keep_above(True)
+        self.fullscreen()
+        self.set_modal(True)
+
+        self.bg_pixbuf = None
+        
+        screen = gtk.gdk.screen_get_default()
+        x0,y0,x1,y1 = screen.get_monitor_geometry(0)
+        
+        self.set_default_size(screen.get_width(), screen.get_height())
+        self.set_decorated(False)
+        self.set_app_paintable(True)
+
+
+        nanny.client.common.Utils.ui_magic (self,
+                                            ui_file = os.path.join (nanny.client.gnome.admin.ui_files_dir, "nanny_desktop_blocker.ui"),
+                                            prefix = "db")
+        self.main_vbox.unparent()
+        self.add(self.main_vbox)
+        self.main_vbox.show_all()
+
+        self.__setup_background()
+        self.stick()
+
+        #Signals 
+        self.close_button.connect("clicked", self.__close_button_clicked_cb, None)
+        self.time_button.connect("clicked", self.__time_button_clicked_cb, None)
+
+    
+    def __setup_background(self):
+        screen = self.get_screen()
+        colormap = screen.get_rgba_colormap()
+        
+        if colormap != None and screen.is_composited() :
+            self.set_colormap(colormap)
+            self.__is_composited = True
+        else:
+            self.__is_composited = False
+
+        self.connect("expose-event", self.__window_expose_event_cb)
+    
+    def __window_expose_event_cb(self, widget, event):
+        context = self.window.cairo_create()
+
+        if self.__is_composited :
+            context.set_operator(cairo.OPERATOR_SOURCE)
+            context.set_source_rgba(0.2, 0.2, 0.2, 0.8)
+            context.paint()
+        else:
+            context.set_source_rgb(0.2, 0.2, 0.2)
+            context.paint()
+
+        return False
+        
+    def __close_button_clicked_cb(self, widget, data):
+        sys.exit(0)
+        
+    def __time_button_clicked_cb(self, widget, data):
+        gtk.gdk.keyboard_ungrab()
+        self.hide()
+        gobject.timeout_add(1000*60*5, self.__timeout_cb)
+
+    def __timeout_cb(self):
+        self.show()
+        self.time_button.hide()
+        gtk.gdk.keyboard_grab(self.window)
+        return False
+
+        
diff --git a/client/gnome/admin/src/Makefile.am b/client/gnome/admin/src/Makefile.am
index fee5fca..ed6350d 100644
--- a/client/gnome/admin/src/Makefile.am
+++ b/client/gnome/admin/src/Makefile.am
@@ -3,4 +3,5 @@ uilib_PYTHON = __init__.py \
 	       AdminConsole.py \
 	       ConfigureProxyDialog.py \
 	       BlacklistManager.py \
-	       ScheduleCalendar.py
+	       ScheduleCalendar.py \
+	       DesktopBlocker.py
diff --git a/client/gnome/admin/src/__init__.py.in b/client/gnome/admin/src/__init__.py.in
index 1290c37..4f46831 100644
--- a/client/gnome/admin/src/__init__.py.in
+++ b/client/gnome/admin/src/__init__.py.in
@@ -35,3 +35,4 @@ from AdminConsole import AdminConsole
 from ConfigureProxyDialog import ConfigureProxyDialog
 from ScheduleCalendar import ScheduleCalendar
 from BlacklistManager import BlacklistManager
+from DesktopBlocker import DesktopBlocker



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]