← Back to team overview

pyneighborhood team mailing list archive

[Branch ~pyneighborhood/pyneighborhood/devel] Rev 572: Hilight wrong executable fields in option window.

 

------------------------------------------------------------
revno: 572
committer: Stefan J. Betz <info@xxxxxxxxxxxxxxx>
branch nick: pyneighborhood
timestamp: Fri 2011-04-01 21:16:14 +0200
message:
  Hilight wrong executable fields in option window.
modified:
  pyneighborhood/misc.py
  pyneighborhood/options.py
  ui/options.glade


--
lp:pyneighborhood
https://code.launchpad.net/~pyneighborhood/pyneighborhood/devel

Your team pyNeighborhood is subscribed to branch lp:pyneighborhood.
To unsubscribe from this branch go to https://code.launchpad.net/~pyneighborhood/pyneighborhood/devel/+edit-subscription
=== modified file 'pyneighborhood/misc.py'
--- pyneighborhood/misc.py	2011-03-22 19:44:39 +0000
+++ pyneighborhood/misc.py	2011-04-01 19:16:14 +0000
@@ -18,7 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sys import argv
-from os import getenv, environ
+from os import getenv, environ, access, F_OK, X_OK
 from os.path import exists, dirname, abspath, join, split, basename
 from optparse import OptionParser
 from Queue import Queue
@@ -119,6 +119,12 @@
     if loglevel != -1 and level >= loglevel:
         events.put((icon, message))
 
+def check_executable(executable):
+    """
+    Check if executable is a valid filename and the executable bit is set.
+    """
+    return True if access(executable,F_OK+X_OK) else False
+
 # Simple Exception based MountpointError exception
 class MountpointError(Exception):
     """

=== modified file 'pyneighborhood/options.py'
--- pyneighborhood/options.py	2011-03-16 20:15:19 +0000
+++ pyneighborhood/options.py	2011-04-01 19:16:14 +0000
@@ -23,7 +23,7 @@
 from stat import S_ISUID, ST_MODE
 from os import stat
 from pyneighborhood import config
-from pyneighborhood.misc import unpad, sharepath, homeconfdir
+from pyneighborhood.misc import unpad, sharepath, homeconfdir, check_executable
 from pyneighborhood.events import browsingevent
 
 _ = gettext.gettext
@@ -97,6 +97,15 @@
                 return
             self.sudoentry.set_sensitive(False)
 
+    def _executable_changed(self, widget):
+        """
+        Check if widget has an executable content.
+        """
+        if check_executable(widget.get_text()):
+            widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color("white"))
+        else:
+            widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color("red"))
+
     def __init__(self, parent):
         """
         Constructor, creates the Windows and many more...

=== modified file 'ui/options.glade'
--- ui/options.glade	2011-01-03 13:49:18 +0000
+++ ui/options.glade	2011-04-01 19:16:14 +0000
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
@@ -32,7 +32,8 @@
                       <object class="GtkEntry" id="cifsmount">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <signal name="changed" handler="_executable_changed"/>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -43,7 +44,7 @@
                       <object class="GtkEntry" id="cifsoptions">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -56,7 +57,8 @@
                       <object class="GtkEntry" id="cifsumount">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <signal name="changed" handler="_executable_changed"/>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -156,7 +158,7 @@
                       <object class="GtkEntry" id="username-entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -167,7 +169,7 @@
                       <object class="GtkEntry" id="password-entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -211,7 +213,7 @@
                       <object class="GtkEntry" id="mountpoint-entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -287,7 +289,8 @@
                       <object class="GtkEntry" id="sudo-entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <signal name="changed" handler="_executable_changed"/>
                       </object>
                       <packing>
                         <property name="position">1</property>
@@ -340,7 +343,8 @@
                       <object class="GtkEntry" id="options-filemanager-entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">●</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                        <signal name="changed" handler="_executable_changed"/>
                       </object>
                       <packing>
                         <property name="position">1</property>