Source

vasm / mkit_themes.py

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# Copyright (C) 2010 Matthew McGowan
#
# Authors:
#   Matthew McGowan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import gtk
import colorsys

import logging

THEME_MESSAGE_DISPLAYED = False

class ColorArray:

    def __init__(self, color_array=None):
        self.color_array = {}
        if not color_array: return
        for state in (gtk.STATE_NORMAL, gtk.STATE_ACTIVE, gtk.STATE_SELECTED, \
            gtk.STATE_PRELIGHT, gtk.STATE_INSENSITIVE):
            self.color_array[state] = color_from_gdkcolor(color_array[state])
        return

    def set_color_array(self, normal, active, prelight, selected, insensitive):
        self.color_array[gtk.STATE_NORMAL] = normal
        self.color_array[gtk.STATE_ACTIVE] = active
        self.color_array[gtk.STATE_SELECTED] = selected
        self.color_array[gtk.STATE_PRELIGHT] = prelight
        self.color_array[gtk.STATE_INSENSITIVE] = insensitive
        return

    def __getitem__(self, state):
        return self.color_array[state]


class Color:

    def __init__(self, red, green, blue):
        self.red = red
        self.green = green
        self.blue = blue
        return

    def floats(self):
        return self.red, self.green, self.blue

    def gdkcolor(self):
        r,g,b = self.floats()
        return gtk.gdk.Color(int(r*65535), int(g*65535), int(b*65535))

    def lighten(self):
        return self.shade(1.3)

    def darken(self):
        return self.shade(0.7)

    def shade(self, factor):
        # as seen in clutter-color.c
        h,l,s = colorsys.rgb_to_hls(*self.floats())

        l *= factor
        if l > 1.0:
            l = 1.0
        elif l < 0:
            l = 0

        s *= factor
        if s > 1.0:
            s = 1.0
        elif s < 0:
            s = 0

        r,g,b = colorsys.hls_to_rgb(h,l,s)
        return Color(r,g,b)

    def mix(self, color2, mix_factor):
        # as seen in Murrine's cairo-support.c
        r1, g1, b1 = self.floats()
        r2, g2, b2 = color2.floats()
        r = r1*(1-mix_factor)+r2*mix_factor
        g = g1*(1-mix_factor)+g2*mix_factor
        b = b1*(1-mix_factor)+b2*mix_factor
        return Color(r,g,b)


# Theme base class with common methods
class Theme:

    def build_palette(self, gtksettings):
        style = gtk.rc_get_style_by_paths(gtksettings,
                                          'GtkWindow',
                                          'GtkWindow',
                                          gtk.Window)

        style = style or gtk.widget_get_default_style()
        
        # build pathbar color palette
        self.fg =    ColorArray(style.fg)
        self.bg =    ColorArray(style.bg)
        self.text =  ColorArray(style.text)
        self.base =  ColorArray(style.base)
        self.light = ColorArray(style.light)
        self.mid =   ColorArray(style.mid)
        self.dark =  ColorArray(style.dark)
        return


class Human(Theme):

    def get_properties(self, gtksettings):
        props = {
            'curvature': 2.5,
            'min-part-width': 48,
            'xpad': 8,
            'ypad': 4,
            'xthickness': 1,
            'ythickness': 1,
            'spacing': 5,
            'arrow-width': 13,
            'scroll-duration': 150,
            'enable-animations': gtksettings.get_property("gtk-enable-animations"),
            'override-base': False
            }
        return props

    def get_grad_palette(self):
        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:  (self.bg[gtk.STATE_NORMAL].shade(1.1),
                                       self.bg[gtk.STATE_NORMAL].shade(0.95)),

                  gtk.STATE_ACTIVE:   (self.bg[gtk.STATE_NORMAL].shade(1.00),
                                       self.bg[gtk.STATE_NORMAL].shade(0.75)),

                  gtk.STATE_SELECTED: (self.bg[gtk.STATE_NORMAL].shade(1.11),
                                       self.bg[gtk.STATE_NORMAL]),

                  gtk.STATE_PRELIGHT: (self.bg[gtk.STATE_NORMAL].shade(0.96),
                                       self.bg[gtk.STATE_NORMAL].shade(0.91)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_text_palette(self):
        palette = {gtk.STATE_NORMAL:        self.fg[gtk.STATE_NORMAL],
                   gtk.STATE_ACTIVE:        self.fg[gtk.STATE_NORMAL],
                   gtk.STATE_SELECTED:      self.fg[gtk.STATE_NORMAL],
                   gtk.STATE_PRELIGHT:      self.fg[gtk.STATE_NORMAL],
                   gtk.STATE_INSENSITIVE:   self.text[gtk.STATE_INSENSITIVE]}
        return palette

    def get_dark_line_palette(self):
        palette = {gtk.STATE_NORMAL:        self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_ACTIVE:        self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_PRELIGHT:      self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_SELECTED:      self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_INSENSITIVE:   self.bg[gtk.STATE_INSENSITIVE].darken()}
        return palette

    def get_light_line_palette(self):
        palette = {gtk.STATE_NORMAL:        self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_ACTIVE:        self.fg[gtk.STATE_NORMAL],
                   gtk.STATE_PRELIGHT:      self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_SELECTED:      self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_INSENSITIVE:   self.bg[gtk.STATE_INSENSITIVE]}
        return palette

    def get_text_states(self):
        states = {gtk.STATE_NORMAL:         gtk.STATE_NORMAL,
                  gtk.STATE_ACTIVE:         gtk.STATE_NORMAL,
                  gtk.STATE_PRELIGHT:       gtk.STATE_NORMAL,
                  gtk.STATE_SELECTED:       gtk.STATE_NORMAL,
                  gtk.STATE_INSENSITIVE:    gtk.STATE_INSENSITIVE}
        return states


class Clearlooks(Human):

    def get_properties(self, gtksettings):
        props = Human.get_properties(self, gtksettings)
        props['curvature'] = 3.5
        return props

    def get_grad_palette(self):
        # provide two colours per state for background vertical linear gradients

        selected_color = self.bg[gtk.STATE_NORMAL].mix(self.bg[gtk.STATE_SELECTED],
                                                       0.2)

        palette = {gtk.STATE_NORMAL:     (self.bg[gtk.STATE_NORMAL].shade(1.15),
                                          self.bg[gtk.STATE_NORMAL].shade(0.95)),

                  gtk.STATE_ACTIVE:      (self.bg[gtk.STATE_ACTIVE],
                                          self.bg[gtk.STATE_ACTIVE]),

                  gtk.STATE_SELECTED:    (selected_color.shade(1.175),
                                          selected_color),

                  gtk.STATE_PRELIGHT:    (self.bg[gtk.STATE_NORMAL].shade(1.3),
                                          selected_color.shade(1.1)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_light_line_palette(self):
        palette = Human.get_light_line_palette(self)
        palette[gtk.STATE_ACTIVE] = self.bg[gtk.STATE_ACTIVE]
        return palette


class InHuman(Theme):

    def get_properties(self, gtksettings):
        props = {
            'curvature': 2.5,
            'min-part-width': 48,
            'xpad': 8,
            'ypad': 4,
            'xthickness': 1,
            'ythickness': 1,
            'spacing': 5,
            'arrow-width': 13,
            'scroll-duration': 150,
            'enable-animations': gtksettings.get_property("gtk-enable-animations"),
            'override-base': False
            }
        return props

    def get_grad_palette(self):
        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:     (self.bg[gtk.STATE_NORMAL].shade(1.1),
                                          self.bg[gtk.STATE_NORMAL].shade(0.95)),

                  gtk.STATE_ACTIVE:      (self.bg[gtk.STATE_NORMAL].shade(1.00),
                                          self.bg[gtk.STATE_NORMAL].shade(0.75)),

                  gtk.STATE_SELECTED:    (self.bg[gtk.STATE_NORMAL].shade(1.09),
                                          self.bg),

                  gtk.STATE_PRELIGHT:    (self.bg[gtk.STATE_SELECTED].shade(1.35),
                                          self.bg[gtk.STATE_SELECTED].shade(1.1)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_text_palette(self):
        palette = {gtk.STATE_NORMAL:        self.text[gtk.STATE_NORMAL],
                   gtk.STATE_ACTIVE:        self.text[gtk.STATE_NORMAL],
                   gtk.STATE_SELECTED:      self.text[gtk.STATE_NORMAL],
                   gtk.STATE_PRELIGHT:      self.text[gtk.STATE_PRELIGHT],
                   gtk.STATE_INSENSITIVE:   self.text[gtk.STATE_INSENSITIVE]}
        return palette

    def get_dark_line_palette(self):
        palette = {gtk.STATE_NORMAL:        self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_ACTIVE:        self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_PRELIGHT:      self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_SELECTED:      self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_INSENSITIVE:   self.bg[gtk.STATE_INSENSITIVE].darken()}
        return palette

    def get_light_line_palette(self):
        palette = {gtk.STATE_NORMAL:        self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_ACTIVE:        self.bg[gtk.STATE_ACTIVE].lighten(),
                   gtk.STATE_PRELIGHT:      self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_SELECTED:      self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_INSENSITIVE:   self.bg[gtk.STATE_INSENSITIVE]}
        return palette

    def get_text_states(self):
        states = {gtk.STATE_NORMAL:         gtk.STATE_NORMAL,
                  gtk.STATE_ACTIVE:         gtk.STATE_NORMAL,
                  gtk.STATE_PRELIGHT:       gtk.STATE_NORMAL,
                  gtk.STATE_SELECTED:       gtk.STATE_NORMAL,
                  gtk.STATE_INSENSITIVE:    gtk.STATE_INSENSITIVE}
        return states


class DustSand(Theme):

    def get_properties(self, gtksettings):
        props = {
            'curvature': 3,
            'min-part-width': 48,
            'xpad': 8,
            'ypad': 4,
            'xthickness': 1,
            'ythickness': 1,
            'spacing': 5,
            'arrow-width': 13,
            'scroll-duration': 150,
            'enable-animations': gtksettings.get_property("gtk-enable-animations"),
            'override-base': False
            }
        return props

    def get_grad_palette(self):

        selected_color = self.bg[gtk.STATE_NORMAL].mix(self.bg[gtk.STATE_SELECTED],
                                                       0.4)

        prelight_color = self.bg[gtk.STATE_NORMAL].mix(self.bg[gtk.STATE_SELECTED],
                                                       0.175)

        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:    (self.bg[gtk.STATE_NORMAL].shade(1.42),
                                         self.bg[gtk.STATE_NORMAL].shade(1.1)),

                  gtk.STATE_ACTIVE:      (prelight_color,
                                          prelight_color.shade(1.07)),

                  gtk.STATE_SELECTED:    (selected_color.shade(1.35),
                                          selected_color.shade(1.1)),

                  gtk.STATE_PRELIGHT:    (prelight_color.shade(1.74),
                                          prelight_color.shade(1.42)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_text_palette(self):
        palette = {gtk.STATE_NORMAL:      self.text[gtk.STATE_NORMAL],
                   gtk.STATE_ACTIVE:      self.text[gtk.STATE_ACTIVE],
                   gtk.STATE_SELECTED:    self.text[gtk.STATE_SELECTED],
                   gtk.STATE_PRELIGHT:    self.text[gtk.STATE_PRELIGHT],
                   gtk.STATE_INSENSITIVE: self.text[gtk.STATE_INSENSITIVE]}
        return palette

    def get_dark_line_palette(self):
        palette = {gtk.STATE_NORMAL:      self.bg[gtk.STATE_NORMAL].shade(0.575),
                   gtk.STATE_ACTIVE:      self.bg[gtk.STATE_ACTIVE].shade(0.5),
                   gtk.STATE_PRELIGHT:    self.bg[gtk.STATE_PRELIGHT].shade(0.575),
                   gtk.STATE_SELECTED:    self.bg[gtk.STATE_SELECTED].shade(0.575),
                   gtk.STATE_INSENSITIVE: self.bg[gtk.STATE_NORMAL].darken()}
        return palette

    def get_light_line_palette(self):
        palette = {gtk.STATE_NORMAL:      self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_ACTIVE:      self.bg[gtk.STATE_ACTIVE].shade(0.95),
                   gtk.STATE_PRELIGHT:    self.bg[gtk.STATE_PRELIGHT].lighten(),
                   gtk.STATE_SELECTED:    self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_INSENSITIVE: self.bg[gtk.STATE_INSENSITIVE]}
        return palette

    def get_text_states(self):
        states = {gtk.STATE_NORMAL:      gtk.STATE_NORMAL,
                  gtk.STATE_ACTIVE:      gtk.STATE_NORMAL,
                  gtk.STATE_PRELIGHT:    gtk.STATE_NORMAL,
                  gtk.STATE_SELECTED:    gtk.STATE_NORMAL,
                  gtk.STATE_INSENSITIVE: gtk.STATE_INSENSITIVE}
        return states


class Dust(DustSand):

    def get_grad_palette(self):

        selected_color = color_from_string('#D9C7BD')

        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:    (self.bg[gtk.STATE_NORMAL].shade(1.145),
                                         self.bg[gtk.STATE_NORMAL].shade(0.985)),

                  gtk.STATE_ACTIVE:      (self.bg[gtk.STATE_ACTIVE].shade(1.2),
                                          self.bg[gtk.STATE_ACTIVE]),

                  gtk.STATE_SELECTED:    (selected_color.shade(1.2),
                                          selected_color.shade(0.975)),

                  gtk.STATE_PRELIGHT:    (self.bg[gtk.STATE_PRELIGHT].shade(1.35),
                                          self.bg[gtk.STATE_PRELIGHT].shade(1.05)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_dark_line_palette(self):
        palette = DustSand.get_dark_line_palette(self)
        palette[gtk.STATE_SELECTED] = self.bg[gtk.STATE_NORMAL].shade(0.575)
        return palette

    def get_light_line_palette(self):
        palette = DustSand.get_light_line_palette(self)
        palette[gtk.STATE_NORMAL] = self.bg[gtk.STATE_NORMAL].shade(1.1)
        selected_color = color_from_string('#D9C7BD')
        palette[gtk.STATE_SELECTED] = selected_color.shade(1.2)
        return palette


class Ambiance(DustSand):

    def get_properties(self, gtksettings):
        props = DustSand.get_properties(self, gtksettings)
        props['curvature'] = 4.5
        return props

    def get_grad_palette(self):
        focus_color = color_from_string('#FE765E')
        selected_color = self.bg[gtk.STATE_NORMAL].mix(focus_color,
                                                       0.07)
        prelight_color = self.bg[gtk.STATE_NORMAL].mix(focus_color,
                                                       0.33)

        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:    (self.bg[gtk.STATE_NORMAL],
                                         self.bg[gtk.STATE_NORMAL].shade(0.85)),

                  gtk.STATE_ACTIVE:     (self.bg[gtk.STATE_NORMAL].shade(0.94),
                                         self.bg[gtk.STATE_NORMAL].shade(0.65)),

                  gtk.STATE_SELECTED:   (selected_color.shade(1.0),
                                         selected_color.shade(0.85)),
    
                  gtk.STATE_PRELIGHT:   (prelight_color.shade(1.35),
                                         prelight_color.shade(1.1)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette


class AmbianceMaverick(DustSand):

    def get_properties(self, gtksettings):
        props = DustSand.get_properties(self, gtksettings)
        props['curvature'] = 4.5
        return props

    def get_grad_palette(self):
        selected_color = color_from_string('#F07746')
        selected_color = self.bg[gtk.STATE_NORMAL].mix(selected_color,
                                                       0.85)
        #prelight_color = self.bg[gtk.STATE_NORMAL].mix(selected_color,
        #                                               0.5)

        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:    (self.bg[gtk.STATE_NORMAL],
                                         self.bg[gtk.STATE_NORMAL].shade(0.85)),

                  gtk.STATE_ACTIVE:     (self.bg[gtk.STATE_ACTIVE].shade(0.935),
                                         self.bg[gtk.STATE_ACTIVE].shade(0.95)),

                  gtk.STATE_SELECTED:   (selected_color.shade(1.3),
                                         selected_color.shade(1.025)),
    
                  gtk.STATE_PRELIGHT:   (self.bg[gtk.STATE_PRELIGHT].shade(0.99),
                                         self.bg[gtk.STATE_PRELIGHT].shade(0.875)),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_dark_line_palette(self):
        palette = {gtk.STATE_NORMAL:      self.bg[gtk.STATE_NORMAL].shade(0.575),
                   gtk.STATE_ACTIVE:      self.bg[gtk.STATE_ACTIVE].shade(0.5),
                   gtk.STATE_PRELIGHT:    self.bg[gtk.STATE_PRELIGHT].shade(0.575),
                   gtk.STATE_SELECTED:    self.bg[gtk.STATE_NORMAL].shade(0.575),
                   gtk.STATE_INSENSITIVE: self.bg[gtk.STATE_NORMAL].darken()}
        return palette

    def get_light_line_palette(self):
        palette = DustSand.get_light_line_palette(self)
        palette[gtk.STATE_NORMAL] = self.bg[gtk.STATE_NORMAL].shade(1.1)
        selected_color = color_from_string('#F07746')
        palette[gtk.STATE_SELECTED] = selected_color.shade(1.525)
        return palette


class Radiance(Ambiance):

    def get_grad_palette(self):
        palette = Ambiance.get_grad_palette(self)
        palette[gtk.STATE_NORMAL] =  (self.base[gtk.STATE_NORMAL].shade(1.25),
                                      self.bg[gtk.STATE_NORMAL].shade(0.9))
        return palette


class NewWave(Theme):

    def get_properties(self, gtksettings):
        props = {
            'curvature': 2,
            'min-part-width': 48,
            'xpad': 8,
            'ypad': 4,
            'xthickness': 1,
            'ythickness': 1,
            'spacing': 4,
            'arrow-width': 13,
            'scroll-duration': 150,
            'enable-animations': gtksettings.get_property("gtk-enable-animations"),
            'override-base': True
            }
        return props

    def get_grad_palette(self):
        # provide two colours per state for background vertical linear gradients

        active_color = self.bg[gtk.STATE_ACTIVE].mix(color_from_string('#FDCF9D'),
                                                     0.45)

        selected_color = self.bg[gtk.STATE_NORMAL].mix(color_from_string('#FDCF9D'),
                                                       0.2)

        palette = {gtk.STATE_NORMAL:    (self.bg[gtk.STATE_NORMAL].shade(1.1),
                                         self.bg[gtk.STATE_NORMAL].shade(0.95)),

                  gtk.STATE_ACTIVE:     (active_color.shade(1.1),
                                         self.bg[gtk.STATE_ACTIVE].shade(0.95)),

                  gtk.STATE_PRELIGHT:   (color_from_string('#FDCF9D'),
                                         color_from_string('#FCAE87')),

                  gtk.STATE_SELECTED:   (selected_color.shade(1.2),
                                         selected_color),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_text_palette(self):
        palette = {gtk.STATE_NORMAL:        self.text[gtk.STATE_NORMAL],
                   gtk.STATE_ACTIVE:        self.text[gtk.STATE_NORMAL],
                   gtk.STATE_PRELIGHT:      self.text[gtk.STATE_NORMAL],
                   gtk.STATE_SELECTED:      self.text[gtk.STATE_SELECTED],
                   gtk.STATE_INSENSITIVE:   self.text[gtk.STATE_INSENSITIVE]}
        return palette

    def get_dark_line_palette(self):
        palette = {gtk.STATE_NORMAL:        self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_ACTIVE:        self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_PRELIGHT:      self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_SELECTED:      self.bg[gtk.STATE_NORMAL].darken(),
                   gtk.STATE_INSENSITIVE:   self.bg[gtk.STATE_INSENSITIVE].darken()}
        return palette

    def get_light_line_palette(self):
        palette = {gtk.STATE_NORMAL:        self.bg[gtk.STATE_NORMAL].lighten(),
                   gtk.STATE_ACTIVE:        self.bg[gtk.STATE_ACTIVE].shade(0.97),
                   gtk.STATE_PRELIGHT:      color_from_string('#FDCF9D'),
                   gtk.STATE_SELECTED:      self.bg[gtk.STATE_SELECTED].lighten(),
                   gtk.STATE_INSENSITIVE:   self.bg[gtk.STATE_INSENSITIVE]}
        return palette

    def get_text_states(self):
        states = {gtk.STATE_NORMAL:         gtk.STATE_NORMAL,
                  gtk.STATE_ACTIVE:         gtk.STATE_NORMAL,
                  gtk.STATE_PRELIGHT:       gtk.STATE_NORMAL,
                  gtk.STATE_SELECTED:       gtk.STATE_NORMAL,
                  gtk.STATE_INSENSITIVE:    gtk.STATE_INSENSITIVE}
        return states


class Hicolor(Theme):

    def get_properties(self, gtksettings):
        props = {
            'curvature': 0,
            'min-part-width': 48,
            'xpad': 15,
            'ypad': 10,
            'xthickness': 2,
            'ythickness': 2,
            'spacing': 10,
            'arrow-width': 15,
            'scroll-duration': 150,
            'enable-animations': gtksettings.get_property("gtk-enable-animations"),
            'override-base': False
            }
        return props

    def get_grad_palette(self):
        # provide two colours per state for background vertical linear gradients
        palette = {gtk.STATE_NORMAL:     (self.base[gtk.STATE_NORMAL],
                                          self.base[gtk.STATE_NORMAL]),

                  gtk.STATE_ACTIVE:      (self.base[gtk.STATE_ACTIVE],
                                          self.base[gtk.STATE_ACTIVE]),

                  gtk.STATE_SELECTED:    (self.base[gtk.STATE_SELECTED],
                                          self.base[gtk.STATE_SELECTED]),

                  gtk.STATE_PRELIGHT:    (self.base[gtk.STATE_PRELIGHT],
                                          self.base[gtk.STATE_PRELIGHT]),

                  gtk.STATE_INSENSITIVE: (self.bg[gtk.STATE_INSENSITIVE],
                                          self.bg[gtk.STATE_INSENSITIVE])
                  }
        return palette

    def get_text_palette(self):
        palette = {gtk.STATE_NORMAL:      self.text[gtk.STATE_NORMAL],
                   gtk.STATE_ACTIVE:      self.text[gtk.STATE_ACTIVE],
                   gtk.STATE_SELECTED:    self.text[gtk.STATE_SELECTED],
                   gtk.STATE_PRELIGHT:    self.text[gtk.STATE_PRELIGHT],
                   gtk.STATE_INSENSITIVE: self.text[gtk.STATE_INSENSITIVE]}
        return palette

    def get_dark_line_palette(self):
        palette = {gtk.STATE_NORMAL:      self.bg[gtk.STATE_SELECTED],
                   gtk.STATE_ACTIVE:      self.bg[gtk.STATE_ACTIVE],
                   gtk.STATE_PRELIGHT:    self.bg[gtk.STATE_PRELIGHT],
                   gtk.STATE_SELECTED:    self.bg[gtk.STATE_SELECTED],
                   gtk.STATE_INSENSITIVE: self.bg[gtk.STATE_INSENSITIVE]}
        return palette

    def get_light_line_palette(self):
        palette = {gtk.STATE_NORMAL:      self.bg[gtk.STATE_SELECTED],
                   gtk.STATE_ACTIVE:      self.bg[gtk.STATE_ACTIVE],
                   gtk.STATE_PRELIGHT:    self.bg[gtk.STATE_PRELIGHT],
                   gtk.STATE_SELECTED:    self.bg[gtk.STATE_SELECTED],
                   gtk.STATE_INSENSITIVE: self.bg[gtk.STATE_INSENSITIVE]}
        return palette

    def get_text_states(self):
        states = {gtk.STATE_NORMAL:      gtk.STATE_NORMAL,
                  gtk.STATE_ACTIVE:      gtk.STATE_ACTIVE,
                  gtk.STATE_PRELIGHT:    gtk.STATE_PRELIGHT,
                  gtk.STATE_SELECTED:    gtk.STATE_SELECTED,
                  gtk.STATE_INSENSITIVE: gtk.STATE_INSENSITIVE}
        return states


class ThemeRegistry:

    REGISTRY = {"Human": Human,
                "Human-Clearlooks": Clearlooks,
                "Clearlooks": Clearlooks,
                "InHuman": InHuman,
                "HighContrastInverse": Hicolor,
                "HighContrastLargePrintInverse": Hicolor,
                "Dust": Dust,
                "Dust Sand": DustSand,
                "New Wave": NewWave,
                "Ambiance": Ambiance,
                "Ambiance-maverick-beta": AmbianceMaverick,
                "Ambiance-maverick-beta-dark": Ambiance,
                "Radiance": Radiance}

    def retrieve(self, theme_name):
        # To keep the messages to a minimum
        global THEME_MESSAGE_DISPLAYED
        
        if self.REGISTRY.has_key(theme_name):
            if not THEME_MESSAGE_DISPLAYED:
                logging.debug("Styling hints found for %s..." % theme_name)
                THEME_MESSAGE_DISPLAYED = True
            return self.REGISTRY[theme_name]()

        if not THEME_MESSAGE_DISPLAYED:
            #logging.warn("No styling hints for %s were found... using Human hints." % theme_name)
            THEME_MESSAGE_DISPLAYED = True
        from mkit_themes import Clearlooks
        return Clearlooks()


# color coversion functions, these also appear in mkit
def color_from_gdkcolor(gdkcolor):
    return Color(gdkcolor.red_float, gdkcolor.green_float, gdkcolor.blue_float)

def color_from_string(spec):
    gdkcolor = gtk.gdk.color_parse(spec)
    return Color(gdkcolor.red_float, gdkcolor.green_float, gdkcolor.blue_float)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.