Changeset 197

Show
Ignore:
Timestamp:
Mon Dec 17 14:56:53 2007
Author:
manatlan
Message:

- PictureSelector? was moved from common to commongtk (more logical)
- (deb/rpm) the jbrout launcher run jbrout with "python" (no more force
python2.4)

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/common.py

    r174 r197  
    12 12 ## GNU General Public License for more details.  
    13 13 ##  
    14   import gtk, gobject  
    15 14  
    16 15 def _(m):  
     
    69 68         runWith(["gnome-open","mozilla-firefox","firefox","konqueror","epiphany","galeon"],unicode(url),False)  
    70 69  
    71   # Class pictureselector  
    72   # This class provides a thumbnailview with a slider. It behaves as a normaol gtk class, and emits the signal "value_changed"  
    73   # whenever a user changes the slider  
    74    
    75   class PictureSelector(gtk.VBox):  
    76    
    77       def __init__(self, photo_list):  
    78           gtk.VBox.__init__(self)  
    79    
    80           self.photo_list = photo_list  
    81    
    82           #self.photo_list.sort(lambda f, s: int(int(s.date) - int(f.date))) # The integer cast is for the result is needed because the dates are usually of type long, and a comparison needs an int  
    83           self.photo_list.sort(lambda f, s: cmp(s.date,f.date)) # manatlan was here  
    84    
    85           # Create all the visual elements  
    86           self.thumb_display = gtk.Image()  
    87           self.slider        = gtk.HScrollbar()  
    88           self.text_display  = gtk.Label("Photo 1/1")  
    89           self.pack_start(self.thumb_display, expand = False)  
    90           self.pack_start(self.slider, expand = True, fill = True)  
    91           self.pack_start(self.text_display, expand = False)  
    92    
    93           # Initialize the slider  
    94           if (len(self.photo_list) > 1):  
    95               self.slider.set_range(1, len(self.photo_list))  
    96               self.slider.set_increments(1, 10)  
    97    
    98           self.updateDisplay()  
    99           # --Instead of this, wouldnt it make sense just to not show the slider?  
    100           # Otherwise the photo looks ugly all grey. See below  
    101           # --Daniel Patterson (dbpatterson@riseup.net) 12th June 2007  
    102    
    103           # Create the callbacks  
    104           self.slider.connect("value_changed", self.onSliderChange)  
    105    
    106           # Display everything  
    107           if (len(self.photo_list)>1):  
    108               self.slider.show()         
    109           self.text_display.show()  
    110           self.thumb_display.show()  
    111    
    112       def onSliderChange(self, widget):  
    113           # Update the display of the text widget and the thumbnail  
    114           self.updateDisplay()  
    115    
    116           # Emit a signal that we have changed  
    117           self.emit("value_changed", self)  
    118    
    119       def getValue(self):  
    120           # Returns the index value of the photolist. Watch out for off-by-one errors!  
    121           slider_value = int(self.slider.get_value())  
    122           if (slider_value == 0):  
    123               slider_value = 1  
    124           return slider_value - 1  
    125    
    126       def updateDisplay(self):  
    127           photo_num = self.getValue()  
    128           self.text_display.set_text("Photo %d/%d: %s" % (photo_num + 1, len(self.photo_list), self.photo_list[photo_num].name))  
    129           self.thumb_display.set_from_pixbuf(self.photo_list[photo_num].getThumb())  
    130    
    131       def set_sensitive(self, value):  
    132           # Make the widget greyed out or active. If the photo list has only one picture, it can never be active  
    133           if (value == True) and (len(self.photo_list) < 2):  
    134               value = False  
    135    
    136           if (value == True):  
    137               gtk.VBox.set_sensitive(self, True)  
    138           else:  
    139               gtk.VBox.set_sensitive(self, False)  
    140    
    141   # Create the "value_changed" signal and connect it to the PictureSelector class  
    142   gobject.signal_new("value_changed", PictureSelector, gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))  
    143 70  
    144 71 if __name__ == "__main__":  
  • trunk/plugins/comment/comment.py

    r185 r197  
    14 14 import os  
    15 15 import gtk  
    16   from common import PictureSelector  
      16 from commongtk import PictureSelector  
    16 16  
    17 17 from libs.gladeapp import GladeApp  
  • trunk/plugins/viewExif/viewExif.py

    r194 r197  
    19 19  
    20 20 import gtk  
    21   from common import PictureSelector  
      21 from commongtk import PictureSelector  
    21 21  
    22 22 from libs.gladeapp import GladeApp  
  • trunk/plugins/multiexport/winexport.py

    r181 r197  
    15 15 import gtk  
    16 16 import time  
    17   from common import PictureSelector  
      17 from commongtk import PictureSelector  
    17 17  
    18 18 from __main__ import GladeApp # no "libs.gladeapp", because there is a libs dir here ;-(  
  • trunk/commongtk.py

    r182 r197  
    15 15 import pygtk  
    16 16 pygtk.require('2.0')  
    17   import gtk,os  
      17 import gtk,os,gobject  
    17 17 import common  
    18 18 #~ from __main__ import _  
     
    317 317  
    318 318  
      319 # Class pictureselector  
      320 # This class provides a thumbnailview with a slider. It behaves as a normaol gtk class, and emits the signal "value_changed"  
      321 # whenever a user changes the slider  
      322  
      323 class PictureSelector(gtk.VBox):  
      324  
      325     def __init__(self, photo_list):  
      326         gtk.VBox.__init__(self)  
      327  
      328         self.photo_list = photo_list  
      329  
      330         #self.photo_list.sort(lambda f, s: int(int(s.date) - int(f.date))) # The integer cast is for the result is needed because the dates are usually of type long, and a comparison needs an int  
      331         self.photo_list.sort(lambda f, s: cmp(s.date,f.date)) # manatlan was here  
      332  
      333         # Create all the visual elements  
      334         self.thumb_display = gtk.Image()  
      335         self.slider        = gtk.HScrollbar()  
      336         self.text_display  = gtk.Label("Photo 1/1")  
      337         self.pack_start(self.thumb_display, expand = False)  
      338         self.pack_start(self.slider, expand = True, fill = True)  
      339         self.pack_start(self.text_display, expand = False)  
      340  
      341         # Initialize the slider  
      342         if (len(self.photo_list) > 1):  
      343             self.slider.set_range(1, len(self.photo_list))  
      344             self.slider.set_increments(1, 10)  
      345  
      346         self.updateDisplay()  
      347         # --Instead of this, wouldnt it make sense just to not show the slider?  
      348         # Otherwise the photo looks ugly all grey. See below  
      349         # --Daniel Patterson (dbpatterson@riseup.net) 12th June 2007  
      350  
      351         # Create the callbacks  
      352         self.slider.connect("value_changed", self.onSliderChange)  
      353  
      354         # Display everything  
      355         if (len(self.photo_list)>1):  
      356             self.slider.show()         
      357         self.text_display.show()  
      358         self.thumb_display.show()  
      359  
      360     def onSliderChange(self, widget):  
      361         # Update the display of the text widget and the thumbnail  
      362         self.updateDisplay()  
      363  
      364         # Emit a signal that we have changed  
      365         self.emit("value_changed", self)  
      366  
      367     def getValue(self):  
      368         # Returns the index value of the photolist. Watch out for off-by-one errors!  
      369         slider_value = int(self.slider.get_value())  
      370         if (slider_value == 0):  
      371             slider_value = 1  
      372         return slider_value - 1  
      373  
      374     def updateDisplay(self):  
      375         photo_num = self.getValue()  
      376         self.text_display.set_text("Photo %d/%d: %s" % (photo_num + 1, len(self.photo_list), self.photo_list[photo_num].name))  
      377         self.thumb_display.set_from_pixbuf(self.photo_list[photo_num].getThumb())  
      378  
      379     def set_sensitive(self, value):  
      380         # Make the widget greyed out or active. If the photo list has only one picture, it can never be active  
      381         if (value == True) and (len(self.photo_list) < 2):  
      382             value = False  
      383  
      384         if (value == True):  
      385             gtk.VBox.set_sensitive(self, True)  
      386         else:  
      387             gtk.VBox.set_sensitive(self, False)  
      388  
      389 # Create the "value_changed" signal and connect it to the PictureSelector class  
      390 gobject.signal_new("value_changed", PictureSelector, gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))  
      391  
      392  
    319 393 if __name__ == "__main__":  
    320 394     l=[('ana', 'potes'),('Anna', 'voisin'),('beer', 'drinks')]