diff --git a/ChangeLog b/ChangeLog index 1f6769d04..45b896bd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-10-05 Zsolt Foldvari + * src/DisplayTabs/_GalleryTab.py (build_interface): Create custom cell + renderer for labels for better control. + 2007-10-05 Benny Malengier * src/DisplayTabs/_GalleryTab.py: remove bug that leads to database corruption, if media is deleted in mediaview, remove media in all open gallery tabs diff --git a/src/DisplayTabs/_GalleryTab.py b/src/DisplayTabs/_GalleryTab.py index 9f39ff2c3..5651ee126 100644 --- a/src/DisplayTabs/_GalleryTab.py +++ b/src/DisplayTabs/_GalleryTab.py @@ -28,6 +28,7 @@ from gettext import gettext as _ import cPickle as pickle import urlparse +import os #------------------------------------------------------------------------- # @@ -35,7 +36,7 @@ import urlparse # #------------------------------------------------------------------------- import gtk -import os +import pango #------------------------------------------------------------------------- # @@ -145,27 +146,46 @@ class GalleryTab(ButtonTab): self.iconmodel.connect_after('row-deleted', self._update_internal_list) def build_interface(self): - + """Setup the GUI. + + It includes an IconView placed inside of a ScrolledWindow. + + """ + item_width = 125 + + # create the model used with the icon view self._build_icon_model() + # build the icon view self.iconlist = gtk.IconView() self.iconlist.set_pixbuf_column(0) - self.iconlist.set_text_column(1) + # set custom text cell renderer for better control + text_renderer = gtk.CellRendererText() + text_renderer.set_property('xalign', 0.5) + text_renderer.set_property('yalign', 0.0) + text_renderer.set_property('wrap-mode', pango.WRAP_WORD_CHAR) + text_renderer.set_property('wrap-width', item_width) + self.iconlist.pack_end(text_renderer) + self.iconlist.set_attributes(text_renderer, text=1) + + # set basic properties of the icon view self.iconlist.set_margin(12) - try: - # This is only available for pygtk 2.8 - self.iconlist.set_reorderable(True) - except AttributeError: - pass - self.iconlist.set_item_width(125) - self.iconlist.set_spacing(24) + self.iconlist.set_spacing(24) + self.iconlist.set_item_width(item_width) self.iconlist.set_selection_mode(gtk.SELECTION_SINGLE) + if gtk.pygtk_version >= (2, 8, 0): + self.iconlist.set_reorderable(True) + + # connect the signals self.iconlist.connect('selection-changed', self._selection_changed) self.iconlist.connect('button_press_event', self.double_click) self._connect_icon_model() + # create the scrolled window scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + + # put everything together scroll.add(self.iconlist) self.pack_start(scroll, True)