From 868f8b8207fbdb8031c7e946363b2b47e95fd86e Mon Sep 17 00:00:00 2001 From: Vlad Glushchuk Date: Mon, 25 Apr 2011 21:07:30 +0300 Subject: [PATCH] Make the dropdown list match the main window width --- kupfer/ui/browser.py | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py index 12ce6ce..4bf88bb 100644 --- a/kupfer/ui/browser.py +++ b/kupfer/ui/browser.py @@ -147,6 +147,7 @@ class LeafModel (object): cell.set_property("ellipsize", ELLIPSIZE_MIDDLE) cell.set_property("width-chars", 45) col = gtk.TreeViewColumn("item", cell) + col.set_property("expand", True) """ info_cell = gtk.CellRendererPixbuf() @@ -156,7 +157,8 @@ class LeafModel (object): info_col.add_attribute(info_cell, "icon-name", self.info_col) """ info_cell = gtk.CellRendererText() - info_cell.set_property("width-chars", 1) + #info_cell.set_property("width-chars", 1) + info_cell.set_property("width", 32) info_col = gtk.TreeViewColumn("info", info_cell) info_col.add_attribute(info_cell, "text", self.info_col) @@ -168,6 +170,7 @@ class LeafModel (object): nbr_col.add_attribute(nbr_cell, "text", self.rank_col) icon_cell = gtk.CellRendererPixbuf() + icon_cell.set_property("xpad", 3) #icon_cell.set_property("height", 32) #icon_cell.set_property("width", 32) #icon_cell.set_property("stock-size", gtk.ICON_SIZE_LARGE_TOOLBAR) @@ -650,33 +653,35 @@ class Search (gtk.Bin): def hide_table(self): self.list_window.hide() - def _show_table(self): + def _adjust_table_pos(self): table_maxlen = self.style_get_property('list-length') - opacity = 0.01*self.style_get_property('list-opacity') # self.window is a GdkWindow (of self's parent) win_width, win_height = self.window.get_size() pos_x, pos_y = self.window.get_position() # find origin in parent's coordinates self_x, self_y = self.translate_coordinates(self.get_parent(), 0, 0) - self_width = self.size_request()[0] + self_x -= 2 sub_x = pos_x sub_y = pos_y + win_height table_w, table_len = self.table.size_request() - subwin_height = min(table_len, table_maxlen) or 100 - subwin_width = self_width*2 - self_x + subwin_height = table_maxlen #min(table_len, table_maxlen) or 100 + subwin_width = win_width - abs(self_x)*2 if not text_direction_is_ltr(): sub_x += win_width - subwin_width + self_x else: sub_x -= self_x self.list_window.move(sub_x, sub_y) self.list_window.resize(subwin_width, subwin_height) + self._old_win_position = pos_x, pos_y + def _show_table(self): + self._adjust_table_pos() + opacity = 0.01*self.style_get_property('list-opacity') win = self.get_toplevel() self.list_window.set_transient_for(win) self.list_window.set_property("focus-on-map", False) self.list_window.set_opacity(opacity) self.list_window.show() - self._old_win_position = pos_x, pos_y def show_table(self): self.go_down(True) @@ -885,7 +890,7 @@ gtk.widget_class_install_style_property(Search, gtk.widget_class_install_style_property(Search, ('list-length', gobject.TYPE_INT, 'Result list length', 'Maximum length of the result list', - 50, 1024, 200, + 50, 1024, 32*6 + 2, gobject.PARAM_READABLE)) class LeafSearch (Search): @@ -1077,8 +1082,14 @@ class Interface (gobject.GObject): vbox.show_all() self.third.hide() self._widget = vbox + vbox.connect("size-allocate", self._resized) return vbox + def _resized(self, *ignored): + widget = self.current + if widget and widget.get_table_visible(): + widget._adjust_table_pos() + def _entry_realized(self, widget): self.update_text_mode() -- 1.7.1