Changeset 1481
- Timestamp:
- 08/15/08 09:29:25 (5 months ago)
- Files:
-
- wine-doors/branches/0.2/src/engines/__init__.py (modified) (6 diffs)
- wine-doors/branches/0.2/src/repositories.py (modified) (1 diff)
- wine-doors/branches/0.2/src/ui/gtkui.py (modified) (15 diffs)
- wine-doors/branches/0.2/src/ui/tile.py (modified) (2 diffs)
- wine-doors/branches/0.2/src/wine-exec.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wine-doors/branches/0.2/src/engines/__init__.py
r1373 r1481 9 9 Init function 10 10 """ 11 self. parent = parent12 self. log = self.parent.log11 self.__parent = parent 12 self.__log = self.__parent.log 13 13 14 14 def Installed( self ): … … 58 58 pass 59 59 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 60 73 class default: 61 def __init__ ( self):62 pass74 def __init__ ( self, parent ): 75 self.__parent = parent 63 76 64 77 def __debug( self, command ): … … 174 187 pass 175 188 189 176 190 def SubmitCrashReport( self ): 177 191 pass … … 181 195 182 196 def SetArgs( self, args ): 183 self. args = self.SplitArgs( args )197 self.__args = self.SplitArgs( args ) 184 198 185 199 def SetExecutable( self, executable ): … … 190 204 executable = self.__get_executable(executable) 191 205 192 self. executable = self.__is_file(executable)206 self.__executable = self.__is_file(executable) 193 207 194 208 def GetCommand( self ): … … 249 263 250 264 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() 256 270 257 271 self.__parse_output() wine-doors/branches/0.2/src/repositories.py
r1478 r1481 110 110 self.this_package['md5'] = self.md5 111 111 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 112 116 for item in self.metadata: 113 117 self.this_package[item] = self.metadata[item] wine-doors/branches/0.2/src/ui/gtkui.py
r1320 r1481 1 1 import gtk, gobject, gtk.glade 2 import cairo, rsvg, math2 import cairo, rsvg, pango, math 3 3 import os, sys, re 4 4 import ui … … 7 7 8 8 from const import * 9 10 def 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 16 def CreateGdkColor( r, g, b): 17 return gtk.gdk.Color( int(r * 65535), int(g * 65535), int(b * 65535) ) 9 18 10 19 class Window: … … 216 225 self.window = None 217 226 218 class TileCellRenderer ( gtk.GenericCellRenderer ): 227 class 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 238 class TileCellRenderer ( gtk.GenericCellRenderer, CairoTile ): 219 239 """ 220 240 Tile cell renderer for rendering an application tile … … 226 246 def __init__( self ): 227 247 self.__gobject_init__() 248 CairoTile.__init__( self ) 228 249 self.cell_height = 60 229 250 self.cell_width = 400 … … 250 271 self.x, self.y, self.cell_width, self.cell_height = cell_area 251 272 252 self. CalculateSizes()253 self. Render()273 self._calculate_sizes() 274 self._render() 254 275 255 276 def on_get_size( self, widget, cell_area=None ): … … 264 285 (data, self.buttons, style, rank, status) = self.data 265 286 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 281 299 ( bgcolor, 282 300 selected_light, … … 298 316 self.mouse_y, 299 317 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() 318 gobject.type_register( TileCellRenderer ) 332 319 333 320 class SidebarCellRenderer ( gtk.GenericCellRenderer ): … … 389 376 bgcolor, selected_light, selected_dark, text_normal, text_selected = style 390 377 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 415 383 416 384 # source the icon … … 527 495 self.cairo.restore() 528 496 self.on_get_size(self.widget, (0,0,50,80)) 529 530 497 gobject.type_register( SidebarCellRenderer ) 531 gobject.type_register( TileCellRenderer )532 498 533 499 class WineDoorsHome(gtk.DrawingArea): … … 546 512 cr.clip() 547 513 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): 551 517 cr.set_source_rgb(1, 1, 1) 552 518 cr.rectangle(0, 0, width, height) … … 559 525 cr.paint() 560 526 cr.restore() 561 562 527 563 528 class WineDoorsGnome(ui.default): … … 614 579 style = self.window['vb_main'].get_style() 615 580 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 622 581 # lighten the sidebar color, we try to match the theme-slab colors here 623 582 # 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 ) 628 586 s = s * 0.32 629 587 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 ) 631 589 if r > 1: r = 1 632 590 if g > 1: g = 1 633 591 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]) ) 644 599 645 600 def main ( self ): … … 741 696 self.window['tv_sidebar'].get_selection().set_mode(gtk.SELECTION_SINGLE) 742 697 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) 744 699 745 700 # this structure sucks and could easily be better, but we only use it to poke data in the tree... … … 750 705 751 706 # 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) ] ) 754 709 # 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) ] ) 761 716 # Add available parent 762 model.append( [ ("AVAILABLE", None, 0, self. style, False) ] )717 model.append( [ ("AVAILABLE", None, 0, self.__sidebar_style, False) ] ) 763 718 # 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) ] ) 773 728 774 729 self.window['tv_sidebar'].get_selection().select_path(selected_path) … … 887 842 model = self.window['tv_sidebar'].get_model() 888 843 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) 890 845 if name == "HOME": 891 846 return wine-doors/branches/0.2/src/ui/tile.py
r1317 r1481 9 9 class TileButton: 10 10 def __init__ (self, parent, callback, text, name, x, y, w, h): 11 self. callback = callback12 self. parent = parent13 self. text = text14 self. name = name15 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) 17 17 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 39 class 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 21 51 22 52 def SetCursor( self, mouse_x, mouse_y ): 23 pass 53 self.__mouse_x = mouse_x 54 self.__mouse_y = mouse_y 24 55 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) 48 58 49 59 def AddButton( self, callback, text, name, x=None,y=None, w=None, h=None ): 50 pass60 self.__buttons.append( TileButton( self, callback, text, name, x, y, w, h ) ) 51 61 52 62 def DeleteButton( self, button ): 53 pass63 self.__buttons.remove( button ) 54 64 55 65 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 63 67 64 68 def SetOpts( self, show_icon, show_summary, show_description, \ 65 69 show_buttons, show_status_text, show_status_image, \ 66 70 show_rating, show_votes ): 67 self. show_icon = show_icon68 self. show_summary = show_summary69 self. show_description = show_description70 self. show_buttons = show_buttons71 self. show_status_text = show_status_text72 self. show_status_image = show_status_image73 self. show_rating = show_rating74 self. show_votes = show_votes71 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 75 79 76 80 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 78 88 79 89 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 81 115 82 116 def SetStatus( self, text=None, image=None): 83 117 if text: 84 self. status_text = text118 self.__status_text = text 85 119 if image: 86 self. status_image = image120 self.__status_image = image 87 121 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 ): 98 123 pass 99 124 100 125 def SetAnimationSteps( self, steps, delay): 101 self. steps = steps102 self. delay = delay126 self.__steps = steps 127 self.__delay = delay 103 128 104 129 def SetAnimationStep (self, step ): 105 self. step = step130 self.__step = step 106 131 107 132 def AnimationTick( self ): 108 self. step = self.step + 1109 if self. step > self.steps:110 self. step = 0133 self.__step = self.__step + 1 134 if self.__step > self.__steps: 135 self.__step = 0 111 136 112 137 def AnimationStart( self ): … … 114 139 def AnimationStop( self ): 115 140 pass 116 def CalculateSizes( self ):117 pass
