Changeset 1481

Show
Ignore:
Timestamp:
08/15/08 09:29:25 (5 months ago)
Author:
klattimer
Message:

Updated lots of UI related bits

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wine-doors/branches/0.2/src/engines/__init__.py

    r1373 r1481  
    99        Init function 
    1010        """ 
    11         self.parent = parent 
    12         self.log = self.parent.log             
     11        self.__parent = parent 
     12        self.__log = self.__parent.log             
    1313 
    1414    def Installed( self ): 
     
    5858        pass 
    5959 
     60 
     61    def GetCompatibility( self, compatibility ): 
     62        priority = 0 
     63        for item in compatibility: 
     64            (variant, version, rating) = item 
     65            engines = self.Available() 
     66            for engine in engines: 
     67                (en_variant, en_version, en_priority) = engine 
     68                if en_variant == variant and en_version == version and priority > en_priority: 
     69                    priority = en_priority 
     70                    best_engine = engine 
     71        return best_engine 
     72 
    6073class default: 
    61     def __init__ (self): 
    62         pass 
     74    def __init__ ( self, parent ): 
     75        self.__parent = parent    
    6376 
    6477    def __debug( self, command ): 
     
    174187        pass 
    175188 
     189 
    176190    def SubmitCrashReport( self ): 
    177191        pass 
     
    181195 
    182196    def SetArgs( self, args ): 
    183         self.args = self.SplitArgs( args ) 
     197        self.__args = self.SplitArgs( args ) 
    184198 
    185199    def SetExecutable( self, executable ): 
     
    190204            executable = self.__get_executable(executable) 
    191205 
    192         self.executable = self.__is_file(executable) 
     206        self.__executable = self.__is_file(executable) 
    193207 
    194208    def GetCommand( self ): 
     
    249263 
    250264        if self.debug: 
    251             self.return_value = self.__debug( self.GetCommand() ) 
    252             self.output = self.__get_output() 
    253         else: 
    254             self.return_value = self.__execute( self.GetCommand() ) 
    255             self.output = self.__get_output() 
     265            self.__return_value = self.__debug( self.GetCommand() ) 
     266            self.__output = self.__get_output() 
     267        else: 
     268            self.__return_value = self.__execute( self.GetCommand() ) 
     269            self.__output = self.__get_output() 
    256270 
    257271        self.__parse_output() 
  • wine-doors/branches/0.2/src/repositories.py

    r1478 r1481  
    110110            self.this_package['md5'] = self.md5 
    111111            self.this_package['gpg'] = self.gpg 
     112            self.this_package['version'] = "%s.%s-%s" % (self.major, self.minor, self.release) 
     113            self.this_package['major'] = self.major 
     114            self.this_package['minor'] = self.minor 
     115            self.this_package['release'] = self.release 
    112116            for item in self.metadata: 
    113117                self.this_package[item] = self.metadata[item] 
  • wine-doors/branches/0.2/src/ui/gtkui.py

    r1320 r1481  
    11import gtk, gobject, gtk.glade 
    2 import cairo, rsvg, math 
     2import cairo, rsvg, pango, math 
    33import os, sys, re 
    44import ui 
     
    77 
    88from const import * 
     9 
     10def ConvertGdkColor( color ): 
     11    r = float(color.red) / 65535 
     12    g = float(color.green) / 65535 
     13    b = float(color.blue) / 65535 
     14    return (r, g, b) 
     15 
     16def CreateGdkColor( r, g, b): 
     17    return gtk.gdk.Color( int(r * 65535), int(g * 65535), int(b * 65535) ) 
    918 
    1019class Window: 
     
    216225        self.window = None 
    217226 
    218 class TileCellRenderer ( gtk.GenericCellRenderer ): 
     227class CairoTile( Tile ): 
     228    def __init__( self ): 
     229        Tile.__init__( self ) 
     230 
     231    def _render( self ): 
     232        """ 
     233        Render the tile onto the cairo surface 
     234        """ 
     235        self.cairo.rectangle(self.x - 2, self.y - 2, self.cell_width + 4, self.cell_height + 4) 
     236        self.cairo.clip() 
     237 
     238class TileCellRenderer ( gtk.GenericCellRenderer, CairoTile ): 
    219239    """ 
    220240    Tile cell renderer for rendering an application tile 
     
    226246    def __init__( self ): 
    227247        self.__gobject_init__() 
     248        CairoTile.__init__( self ) 
    228249        self.cell_height = 60 
    229250        self.cell_width = 400 
     
    250271        self.x, self.y, self.cell_width, self.cell_height = cell_area 
    251272 
    252         self.CalculateSizes() 
    253         self.Render() 
     273        self._calculate_sizes() 
     274        self._render() 
    254275 
    255276    def on_get_size( self, widget, cell_area=None ): 
     
    264285        (data, self.buttons, style, rank, status) = self.data 
    265286 
    266         # TODO: Use repositories format for data, we don't have to explode it 
    267         # before feeding it into Tile 
    268  
    269         ( self.name, 
    270           self.version, 
    271           self.vendor, 
    272           self.homepage, 
    273           self.appdb, 
    274           self.short_description, 
    275           self.long_description, 
    276           self.installed_size, 
    277           self.download_size, 
    278           self.category, 
    279           self.icon ) = data 
    280          
     287        self.SetTitle( data['name'] ) 
     288        self.SetSummary( data['summary'] ) 
     289        self.SetDescription( data['description'] ) 
     290        self.SetIcon( data['icon'] ) 
     291        self.SetVotes( data['votes'] ) 
     292        self.SetVendor( data['vendor'] ) 
     293        self.SetHomepage( data['homepage'] ) 
     294        self.SetAppDB( data['appdb'] ) 
     295        self.SetCategory ( data['category'] ) 
     296        # self.SetDownloadSize( data['download_size'] ) 
     297        # self.SetInstalledSize( data['installed_size'] ) 
     298 
    281299        ( bgcolor,  
    282300          selected_light,  
     
    298316          self.mouse_y, 
    299317          self.mouse_over ) = status 
    300  
    301         # Background color 
    302         self.bg_r = float(bgcolor.red) / 65535 
    303         self.bg_g = float(bgcolor.green) / 65535 
    304         self.bg_b = float(bgcolor.blue) / 65535 
    305  
    306         # Light color for selected item 
    307         self.sl_r = float(selected_light.red) / 65535 
    308         self.sl_g = float(selected_light.green) / 65535 
    309         self.sl_b = float(selected_light.blue) / 65535 
    310  
    311         # Dark color for selected item 
    312         self.sd_r = float(selected_dark.red) / 65535 
    313         self.sd_g = float(selected_dark.green) / 65535 
    314         self.sd_b = float(selected_dark.blue) / 65535 
    315  
    316         # Text normal color 
    317         self.tn_r = float(text_normal.red) / 65535 
    318         self.tn_g = float(text_normal.green) / 65535 
    319         self.tn_b = float(text_normal.blue) / 65535 
    320  
    321         # Text selected color 
    322         self.ts_r = float(text_selected.red) / 65535 
    323         self.ts_g = float(text_selected.green) / 65535 
    324         self.ts_b = float(text_selected.blue) / 65535 
    325  
    326     def Render( self ): 
    327         """ 
    328         Render the tile onto the cairo surface 
    329         """ 
    330         self.cairo.rectangle(self.x - 2, self.y - 2, self.cell_width + 4, self.cell_height + 4) 
    331         self.cairo.clip() 
     318gobject.type_register( TileCellRenderer ) 
    332319 
    333320class SidebarCellRenderer ( gtk.GenericCellRenderer ): 
     
    389376        bgcolor, selected_light, selected_dark, text_normal, text_selected = style 
    390377 
    391         # Background color 
    392         self.bg_r = float(bgcolor.red) / 65535 
    393         self.bg_g = float(bgcolor.green) / 65535 
    394         self.bg_b = float(bgcolor.blue) / 65535 
    395  
    396         # Light color for selected item 
    397         self.sl_r = float(selected_light.red) / 65535 
    398         self.sl_g = float(selected_light.green) / 65535 
    399         self.sl_b = float(selected_light.blue) / 65535 
    400  
    401         # Dark color for selected item 
    402         self.sd_r = float(selected_dark.red) / 65535 
    403         self.sd_g = float(selected_dark.green) / 65535 
    404         self.sd_b = float(selected_dark.blue) / 65535 
    405  
    406         # Text normal color 
    407         self.tn_r = float(text_normal.red) / 65535 
    408         self.tn_g = float(text_normal.green) / 65535 
    409         self.tn_b = float(text_normal.blue) / 65535 
    410  
    411         # Text selected color 
    412         self.ts_r = float(text_selected.red) / 65535 
    413         self.ts_g = float(text_selected.green) / 65535 
    414         self.ts_b = float(text_selected.blue) / 65535 
     378        (self.bg_r, self.bg_g, self.bg_b ) = bgcolor 
     379        (self.sl_r, self.sl_g, self.sl_b ) = selected_light 
     380        (self.sd_r, self.sd_g, self.sd_b ) = selected_dark 
     381        (self.tn_r, self.tn_g, self.tn_b ) = text_normal 
     382        (self.ts_r, self.ts_g, self.ts_b ) = text_selected 
    415383 
    416384        # source the icon 
     
    527495            self.cairo.restore() 
    528496        self.on_get_size(self.widget, (0,0,50,80)) 
    529          
    530497gobject.type_register( SidebarCellRenderer ) 
    531 gobject.type_register( TileCellRenderer ) 
    532498 
    533499class WineDoorsHome(gtk.DrawingArea): 
     
    546512        cr.clip() 
    547513 
    548         self.draw(cr, *self.window.get_size()) 
    549  
    550     def draw(self, cr, width, height): 
     514        self.__draw(cr, *self.window.get_size()) 
     515 
     516    def __draw(self, cr, width, height): 
    551517        cr.set_source_rgb(1, 1, 1) 
    552518        cr.rectangle(0, 0, width, height) 
     
    559525        cr.paint() 
    560526        cr.restore() 
    561              
    562527 
    563528class WineDoorsGnome(ui.default): 
     
    614579        style = self.window['vb_main'].get_style() 
    615580 
    616         self.sidebar_color = style.light[gtk.STATE_SELECTED].copy() 
    617         self.selected_light_color = style.bg[gtk.STATE_SELECTED].copy() 
    618         self.selected_dark_color = style.dark[gtk.STATE_SELECTED].copy() 
    619         self.text_normal_color = style.text[gtk.STATE_NORMAL].copy() 
    620         self.text_selected_color = style.text[gtk.STATE_SELECTED].copy() 
    621  
    622581        # lighten the sidebar color, we try to match the theme-slab colors here 
    623582        # We're close enough with this hack 
    624         r = float(self.sidebar_color.red) / 65535 
    625         g = float(self.sidebar_color.green) / 65535 
    626         b = float(self.sidebar_color.blue) / 65535 
    627         h,s,v = colorsys.rgb_to_hsv ( r, g, b ) 
     583        sidebar_color = style.light[gtk.STATE_SELECTED] 
     584        r, g, b = ConvertGdkColor( sidebar_color ) 
     585        h, s, v = colorsys.rgb_to_hsv ( r, g, b ) 
    628586        s = s * 0.32 
    629587        v = v * 1.04 
    630         r,g,b = colorsys.hsv_to_rgb ( h, s, v ) 
     588        r, g, b = colorsys.hsv_to_rgb ( h, s, v ) 
    631589        if r > 1: r = 1 
    632590        if g > 1: g = 1 
    633591        if b > 1: b = 1 
    634         # TODO Save CPU cycles today, store everything as cairo compatible fractions 
    635         self.sidebar_color.red = int(r * 65535) 
    636         self.sidebar_color.green = int(g * 65535) 
    637         self.sidebar_color.blue = int(b * 65535)  
    638  
    639         self.style = ( self.sidebar_color,  
    640                        self.selected_light_color,  
    641                        self.selected_dark_color,  
    642                        self.text_normal_color, 
    643                        self.text_selected_color ) 
     592        self.__sidebar_color = CreateGdkColor( r, g, b ) 
     593         
     594        self.__sidebar_style = ( (r, g, b),  
     595                                 ConvertGdkColor(style.bg[gtk.STATE_SELECTED]),  
     596                                 ConvertGdkColor(style.dark[gtk.STATE_SELECTED]),  
     597                                 ConvertGdkColor(style.text[gtk.STATE_NORMAL]), 
     598                                 ConvertGdkColor(style.text[gtk.STATE_SELECTED]) ) 
    644599 
    645600    def main ( self ): 
     
    741696        self.window['tv_sidebar'].get_selection().set_mode(gtk.SELECTION_SINGLE) 
    742697        self.window['tv_sidebar'].set_model( model ) 
    743         self.window['tv_sidebar'].modify_base(gtk.STATE_NORMAL, self.sidebar_color)   
     698        self.window['tv_sidebar'].modify_base(gtk.STATE_NORMAL, self.__sidebar_color)   
    744699 
    745700        # this structure sucks and could easily be better, but we only use it to poke data in the tree... 
     
    750705 
    751706        # Add home and queue items 
    752         model.append( [ ("HOME", None, 0, self.style, False) ] ) 
    753         model.append( [ ("QUEUE", None, 3, self.style, False) ] ) 
     707        model.append( [ ("HOME", None, 0, self.__sidebar_style, False) ] ) 
     708        model.append( [ ("QUEUE", None, 3, self.__sidebar_style, False) ] ) 
    754709        # Add bottles by repository type 
    755         model.append( [ ("BOTTLES", None, 0, self.style, False) ] ) 
    756         model.append( [ ("Applications", "applications-accessories", 0, self.style, True) ] ) 
    757         model.append( [ ("Games", "applications-games", 0, self.style, True) ] ) 
    758         model.append( [ ("Imported", "document-save", 0, self.style, True) ] )      
    759         model.append( [ ("Libraries", "application-x-executable", 0, self.style, True) ] ) 
    760         model.append( [ ("Base System", "drive-harddisk", 0, self.style, True) ] )              
     710        model.append( [ ("BOTTLES", None, 0, self.__sidebar_style, False) ] ) 
     711        model.append( [ ("Applications", "applications-accessories", 0, self.__sidebar_style, True) ] ) 
     712        model.append( [ ("Games", "applications-games", 0, self.__sidebar_style, True) ] ) 
     713        model.append( [ ("Imported", "document-save", 0, self.__sidebar_style, True) ] )      
     714        model.append( [ ("Libraries", "application-x-executable", 0, self.__sidebar_style, True) ] ) 
     715        model.append( [ ("Base System", "drive-harddisk", 0, self.__sidebar_style, True) ] )              
    761716        # Add available parent 
    762         model.append( [ ("AVAILABLE", None, 0, self.style, False) ] ) 
     717        model.append( [ ("AVAILABLE", None, 0, self.__sidebar_style, False) ] ) 
    763718        # Add categories 
    764         model.append( [ ("Updates", "system-software-update", 6, self.style, True) ] ) 
    765         model.append( [ ("Accessories", "applications-accessories", 0, self.style, True) ] ) 
    766         model.append( [ ("Games", "applications-games", 0, self.style, True) ] ) 
    767         model.append( [ ("Internet", "applications-internet", 0, self.style, True) ] ) 
    768         model.append( [ ("Office", "applications-office", 0, self.style, True) ] ) 
    769         model.append( [ ("Programming", "applications-development", 0, self.style, True) ] ) 
    770         model.append( [ ("Sound & Video", "applications-multimedia", 4, self.style, True) ] ) 
    771         model.append( [ ("System Tools", "applications-utilities", 2, self.style, True) ] ) 
    772         model.append( [ ("Wine", "wine", 0, self.style, True) ] ) 
     719        model.append( [ ("Updates", "system-software-update", 6, self.__sidebar_style, True) ] ) 
     720        model.append( [ ("Accessories", "applications-accessories", 0, self.__sidebar_style, True) ] ) 
     721        model.append( [ ("Games", "applications-games", 0, self.__sidebar_style, True) ] ) 
     722        model.append( [ ("Internet", "applications-internet", 0, self.__sidebar_style, True) ] ) 
     723        model.append( [ ("Office", "applications-office", 0, self.__sidebar_style, True) ] ) 
     724        model.append( [ ("Programming", "applications-development", 0, self.__sidebar_style, True) ] ) 
     725        model.append( [ ("Sound & Video", "applications-multimedia", 4, self.__sidebar_style, True) ] ) 
     726        model.append( [ ("System Tools", "applications-utilities", 2, self.__sidebar_style, True) ] ) 
     727        model.append( [ ("Wine", "wine", 0, self.__sidebar_style, True) ] ) 
    773728 
    774729        self.window['tv_sidebar'].get_selection().select_path(selected_path)    
     
    887842        model = self.window['tv_sidebar'].get_model() 
    888843        treeiter = self.window['tv_sidebar'].get_selection().get_selected()[1] 
    889         (name, icon, items, style) = model.get_value(treeiter, SIDEBAR) 
     844        (name, icon, items, style, indent) = model.get_value(treeiter, SIDEBAR) 
    890845        if name == "HOME": 
    891846            return 
  • wine-doors/branches/0.2/src/ui/tile.py

    r1317 r1481  
    99class TileButton: 
    1010    def __init__ (self, parent, callback, text, name, x, y, w, h): 
    11         self.callback = callback 
    12         self.parent = parent 
    13         self.text = text 
    14         self.name = name 
    15         self.SetStatus(BUTTON_STATE_NORMAL) 
    16         self.SetRect(x, y, w, h) 
     11        self.__callback = callback 
     12        self.__parent = parent 
     13        self.__text = text 
     14        self.__name = name 
     15        self.__status = BUTTON_STATUS_NORMAL 
     16        self.__set_rect(x, y, w, h) 
    1717 
    18     def SetRect( self, x, y, w, h): 
    19         self.x = x 
    20         self.y = y 
     18    def __set_rect( self, x, y, w, h): 
     19        self.__x = x 
     20        self.__y = y 
     21        self.__w = w 
     22        self.__h = h 
     23 
     24    def __set_cursor( self ): 
     25        (self.__mouse_x, self.__mouse_y) = self.__parent.GetCursor() 
     26        if self.__mouse_x > self.__x and self.__mouse_x < self.__x + self.__w and \ 
     27           self.__mouse_y > self.__y and self.__mouse_y < self.__y + self.__h: 
     28            self.__status = BUTTON_STATUS_OVER 
     29        else: 
     30            self.__status = BUTTON_STATUS_NORMAL 
     31 
     32    def Click( self ): 
     33        self.__set_cursor() 
     34        if self.__status == BUTTON_STATUS_OVER: 
     35            self.__status = BUTTON_STATUS_ACTIVE 
     36            self.__callback( self.name ) 
     37        return self.__status 
     38 
     39class Tile: 
     40    def __init__ ( self ): 
     41        self.__buttons = [] 
     42        self.__step = 0 
     43 
     44    def Click( self, mouse_x, mouse_y ): 
     45        clicked = None 
     46        self.SetCursor( mouse_x, mouse_y) 
     47        for button in self.__buttons: 
     48            if button.Click() == BUTTON_STATUS_ACTIVE: 
     49                clicked = button 
     50        return clicked 
    2151 
    2252    def SetCursor( self, mouse_x, mouse_y ): 
    23         pass 
     53        self.__mouse_x = mouse_x 
     54        self.__mouse_y = mouse_y 
    2455 
    25     def SetStatus( self, status ): 
    26         self.status = status 
    27         if self.status == BUTTON_STATE_ACTIVE: 
    28             self.Clicked() 
    29  
    30     def GetStatus( self ): 
    31         return self.status 
    32  
    33     def Clicked( self ): 
    34         self.callback( self.name ) 
    35  
    36 class Tile: 
    37     def __init__ (self, parent, package_name, package_version, package_data): 
    38         pass 
    39  
    40     def Click( self, mouse_x, mouse_y ): 
    41         for button in self.buttons: 
    42             if button.GetStatus() == BUTTON_STATUS_OVER: 
    43                 button.SetStatus(BUTTON_STATE_ACTIVE) 
    44                 return button 
    45  
    46     def SetCoords( self, mouse_x, mouse_y ): 
    47         pass 
     56    def GetCursor( self ): 
     57        return (self.__mouse_x, self.__mouse_y) 
    4858 
    4959    def AddButton( self, callback, text, name, x=None,y=None, w=None, h=None ): 
    50         pass 
     60        self.__buttons.append( TileButton( self, callback, text, name, x, y, w, h ) ) 
    5161 
    5262    def DeleteButton( self, button ): 
    53         pass 
     63        self.__buttons.remove( button ) 
    5464 
    5565    def GetButtons( self ): 
    56         return self.buttons 
    57  
    58     def SetSummary( self, summary ): 
    59         self.summary = summary 
    60  
    61     def SetDescription( self, description ): 
    62         self.description = description 
     66        return self.__buttons 
    6367 
    6468    def SetOpts( self, show_icon, show_summary, show_description, \ 
    6569                       show_buttons, show_status_text, show_status_image, \ 
    6670                       show_rating, show_votes ): 
    67         self.show_icon = show_icon 
    68         self.show_summary = show_summary 
    69         self.show_description = show_description 
    70         self.show_buttons = show_buttons 
    71         self.show_status_text = show_status_text 
    72         self.show_status_image = show_status_image 
    73         self.show_rating = show_rating 
    74         self.show_votes = show_votes 
     71        self.__show_icon = show_icon 
     72        self.__show_summary = show_summary 
     73        self.__show_description = show_description 
     74        self.__show_buttons = show_buttons 
     75        self.__show_status_text = show_status_text 
     76        self.__show_status_image = show_status_image 
     77        self.__show_rating = show_rating 
     78        self.__show_votes = show_votes 
    7579 
    7680    def SetTitle( self, title ): 
    77         self.title = title 
     81        self.__title = title 
     82 
     83    def SetSummary( self, summary ): 
     84        self.__summary = summary 
     85 
     86    def SetDescription( self, description ): 
     87        self.__description = description 
    7888 
    7989    def SetIcon ( self, icon ): 
    80         self.icon = icon 
     90        self.__icon = icon 
     91 
     92    def SetRating ( self, rating ): 
     93        self.__rating = rating 
     94 
     95    def SetVotes ( self, votes ): 
     96        self.__votes = votes 
     97 
     98    def SetVendor ( self, vendor ): 
     99        self.__vendor = vendor 
     100 
     101    def SetHomepage ( self, homepage ): 
     102        self.__homepage = homepage 
     103 
     104    def SetAppDB ( self, appdb ): 
     105        self.__appdb = appdb 
     106 
     107    def SetCategory( self, category ): 
     108        self.__category = category 
     109 
     110    def SetDownloadSize( self, download_size ): 
     111        self.__download_size = download_size 
     112 
     113    def SetInstalledSize( self, installed_size ): 
     114        self.__installed_size = installed_size 
    81115 
    82116    def SetStatus( self, text=None, image=None): 
    83117        if text: 
    84             self.status_text = text 
     118            self.__status_text = text 
    85119        if image: 
    86             self.status_image = image 
     120            self.__status_image = image 
    87121 
    88     def SetRating ( self, rating ): 
    89         self.rating = rating 
    90  
    91     def SetVotes ( self, votes ): 
    92         self.votes = votes 
    93  
    94     def SetStyle( (title_size, title_weight), \ 
    95                   (description_size, description_weight), \ 
    96                   (summary_size, summary_weight) \ 
    97                 ): 
     122    def _calculate_sizes( self ): 
    98123        pass 
    99124 
    100125    def SetAnimationSteps( self, steps, delay): 
    101         self.steps = steps 
    102         self.delay = delay 
     126        self.__steps = steps 
     127        self.__delay = delay 
    103128 
    104129    def SetAnimationStep (self, step ): 
    105         self.step = step 
     130        self.__step = step 
    106131 
    107132    def AnimationTick( self ): 
    108         self.step = self.step + 1 
    109         if  self.step > self.steps: 
    110             self.step = 0 
     133        self.__step = self.__step + 1 
     134        if  self.__step > self.__steps: 
     135            self.__step = 0 
    111136 
    112137    def AnimationStart( self ): 
     
    114139    def AnimationStop( self ): 
    115140        pass 
    116     def CalculateSizes( self ): 
    117         pass