Changes

Jump to navigation Jump to search
Line 160: Line 160:  
passedTime = 0
 
passedTime = 0
   −
if (x != self.mx or y != self.my):
+
if x != self.mx or y != self.my:
 
self.hideWidgetsTime = time.time()
 
self.hideWidgetsTime = time.time()
if (self.hiddenWidgets):
+
if self.hiddenWidgets:
 
self.showWidgets()
 
self.showWidgets()
 
self.hiddenWidgets = False
 
self.hiddenWidgets = False
Line 169: Line 169:       −
if (passedTime >= 3):
+
if passedTime >= 3:
if (not self.hiddenWidgets):
+
if not self.hiddenWidgets:
 
self.hideWidgets()
 
self.hideWidgets()
 
self.hiddenWidgets = True
 
self.hiddenWidgets = True
Line 204: Line 204:     
=== How do I get the amount of free space available on disk under the /home directory tree? ===
 
=== How do I get the amount of free space available on disk under the /home directory tree? ===
The following function uses the [http://docs.python.org/lib/module-statvfs.html statvfs] module. The following code demonstrates how to get the total amount of free space under /home.  
+
The following code demonstrates how to get the total amount of free space under /home.  
    
<pre>
 
<pre>
Line 210: Line 210:  
     def getFreespaceKb(self):
 
     def getFreespaceKb(self):
 
         stat = os.statvfs("/home")
 
         stat = os.statvfs("/home")
         freebytes  = stat[statvfs.F_BSIZE] * stat[statvfs.F_BAVAIL]
+
         freebytes  = stat.f_bsize * stat.f_bavail
 
         freekb = freebytes / 1024
 
         freekb = freebytes / 1024
 
         return freekb
 
         return freekb
Line 283: Line 283:     
     def announce_thread(self):
 
     def announce_thread(self):
         while (self.Running):
+
         while self.Running:
 
             time.sleep(1)
 
             time.sleep(1)
 
             print "thread running"
 
             print "thread running"
Line 328: Line 328:  
<pre>
 
<pre>
 
         if self.metadata['mime_type'] == 'text/plain':
 
         if self.metadata['mime_type'] == 'text/plain':
             if not self._jobject.metadata['title_set_by_user'] == '1':
+
             if self._jobject.metadata['title_set_by_user'] != '1':
 
                 if self._browser.props.title:
 
                 if self._browser.props.title:
 
                     # Set the title of this activity to be the current  
 
                     # Set the title of this activity to be the current  
Line 361: Line 361:  
         keyname = gtk.gdk.keyval_name(event.keyval)
 
         keyname = gtk.gdk.keyval_name(event.keyval)
 
          
 
          
         if (keyname == 'KP_Page_Up'):
+
         if keyname == 'KP_Page_Up':
 
             self._chat += "\nCircle Pressed!"
 
             self._chat += "\nCircle Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
         elif (keyname == 'KP_Page_Down'):
+
         elif keyname == 'KP_Page_Down':
 
             self._chat += "\nX Pressed!"
 
             self._chat += "\nX Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
         elif (keyname == 'KP_Home'):
+
         elif keyname == 'KP_Home':
 
             self._chat += "\nSquare Pressed!"
 
             self._chat += "\nSquare Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
         elif (keyname == 'KP_End'):
+
         elif keyname == 'KP_End':
 
             self._chat += "\nCheck Pressed!"
 
             self._chat += "\nCheck Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
Line 377: Line 377:  
</pre>
 
</pre>
    +
== How do I know if the screen has been rotated? ==
 +
 +
When the screen is rotated, GTK issues a CONFIGURE event. Test for this event and grab the screen dimensions in the event handler.
 +
 +
        self.window.add_events(gtk.gdk.CONFIGURE)
 +
        self.window.connect('configure-event', self._configure_cb)
 +
 +
    def _configure_cb(self, win, event):
 +
        width = gtk.gdk.screen_width()
 +
        height = gtk.gdk.screen_height()
 +
 +
This does not tell you the orientation, however. Allegedly on the XO hardware, you can use olpc-kbdshim (currently undocumented).
    
=== How do I detect if one of the joystick buttons has been pressed? ===
 
=== How do I detect if one of the joystick buttons has been pressed? ===
Line 394: Line 406:  
         keyname = gtk.gdk.keyval_name(event.keyval)
 
         keyname = gtk.gdk.keyval_name(event.keyval)
 
          
 
          
         if (keyname == 'KP_Up'):
+
         if keyname == 'KP_Up':
 
             self._chat += "\nUp Pressed!"
 
             self._chat += "\nUp Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
         elif (keyname == 'KP_Down'):
+
         elif keyname == 'KP_Down':
 
             self._chat += "\nDown Pressed!"
 
             self._chat += "\nDown Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
         elif (keyname == 'KP_Left'):
+
         elif keyname == 'KP_Left':
 
             self._chat += "\nLeft Pressed!"
 
             self._chat += "\nLeft Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
         elif (keyname == 'KP_Right'):
+
         elif keyname == 'KP_Right':
 
             self._chat += "\nRight Pressed!"
 
             self._chat += "\nRight Pressed!"
 
             self._chat_buffer.set_text(self._chat)
 
             self._chat_buffer.set_text(self._chat)
Line 410: Line 422:  
</pre>
 
</pre>
   −
=== How do i remove an specific button from the toolbar? ===
+
=== How do I remove a specific button from the toolbar? ===
    
This is an example of the share button is removed:
 
This is an example of the share button is removed:

Navigation menu