Ticket #4049: 0002-Improve-styling-of-the-autocomplete-list-SL-4049-V1.patch

File 0002-Improve-styling-of-the-autocomplete-list-SL-4049-V1.patch, 4.3 KB (added by manuq, 12 years ago)

Patch that gets closer to the mockup.

  • webtoolbar.py

    From 9ca338dc04f7285c97acd5f543803ecf2060e336 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Thu, 25 Oct 2012 00:19:12 -0300
    Subject: [PATCH browse 2/2] Improve styling of the autocomplete list - SL
     #4049
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    - add background to the entry to match the drop down list
    - make the list styleable
    - set the list minimun height to match four entries
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     webtoolbar.py | 44 +++++++++++++++++++++++++++++++++++++++-----
     1 file changed, 39 insertions(+), 5 deletions(-)
    
    diff --git a/webtoolbar.py b/webtoolbar.py
    index 4db684e..79b1bf6 100644
    a b from gi.repository import WebKit 
    2727from sugar3.graphics.toolbutton import ToolButton
    2828from sugar3.graphics import iconentry
    2929from sugar3.graphics.toolbarbox import ToolbarBox as ToolbarBase
    30 from sugar3.graphics.style import STANDARD_ICON_SIZE
     30from sugar3.graphics import style
    3131from sugar3.activity.widgets import ActivityToolbarButton
    3232from sugar3.activity.widgets import StopButton
    3333
    from browser import Browser 
    4040_MAX_HISTORY_ENTRIES = 15
    4141
    4242
     43class _SearchWindow(Gtk.Window):
     44    """A search window that can be styled in the theme."""
     45
     46    __gtype_name__ = "BrowseSearchWindow"
     47
     48    def __init__(self):
     49        Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
     50
     51
    4352class WebEntry(iconentry.IconEntry):
    4453    _COL_ADDRESS = 0
    4554    _COL_TITLE = 1
    class WebEntry(iconentry.IconEntry): 
    5059        self._address = None
    5160        self._search_view = self._search_create_view()
    5261
    53         self._search_window = Gtk.Window(type=Gtk.WindowType.POPUP)
     62        self._search_window = _SearchWindow()
    5463        self._search_window.add(self._search_view)
    5564        self._search_view.show()
    5665
    class WebEntry(iconentry.IconEntry): 
    6170                    'focus-out-event', self.__focus_out_event_cb)
    6271        self._change_hid = self.connect('changed', self.__changed_cb)
    6372
     73    def do_draw(self, cr):
     74        """Draw a background to better fit the search window."""
     75        if self._search_window.props.visible:
     76            original_path = cr.copy_path()
     77
     78            allocation = self.get_allocation()
     79            cr.set_source_rgb(0, 0, 0)
     80            cr.rectangle(0, 0, allocation.width, allocation.height)
     81            cr.paint()
     82
     83            cr.set_source_rgba(*style.COLOR_BUTTON_GREY.get_rgba())
     84            # Set the line width two times the theme border to make
     85            # the calculation easier.
     86            cr.set_line_width(style.LINE_WIDTH * 4)
     87            cr.move_to(0, allocation.height)
     88            cr.line_to(0, 0)
     89            cr.line_to(allocation.width, 0)
     90            cr.line_to(allocation.width, allocation.height)
     91            cr.stroke()
     92
     93            cr.new_path()
     94            cr.append_path(original_path)
     95
     96        iconentry.IconEntry.do_draw(self, cr)
     97
    6498    def _set_text(self, text):
    6599        """Set the text but block changes notification, so that we can
    66100           recognize changes caused directly by user actions"""
    class WebEntry(iconentry.IconEntry): 
    85119    def _search_create_view(self):
    86120        view = Gtk.TreeView()
    87121        view.props.headers_visible = False
    88         view.props.rules_hint = True
    89122
    90123        view.connect('button-press-event', self.__view_button_press_event_cb)
    91124
    class WebEntry(iconentry.IconEntry): 
    95128        cell = Gtk.CellRendererText()
    96129        cell.props.ellipsize = Pango.EllipsizeMode.END
    97130        cell.props.ellipsize_set = True
    98         cell.props.height = STANDARD_ICON_SIZE
     131        cell.props.height = style.STANDARD_ICON_SIZE
    99132        cell.props.font = 'Bold'
    100133        column.pack_start(cell, True)
    101134
    class WebEntry(iconentry.IconEntry): 
    131164        search_x = window_x + entry_allocation.x
    132165        search_y = window_y + gap + preferred_height
    133166        search_width = entry_allocation.width
    134         search_height = Gdk.Screen.height() / 3
     167        # Set minimun height to four entries.
     168        search_height = (style.STANDARD_ICON_SIZE + style.LINE_WIDTH * 2) * 4
    135169
    136170        self._search_window.move(search_x, search_y)
    137171        self._search_window.resize(search_width, search_height)