~gtg-user/gtg/port-to-gtk3

« back to all changes in this revision

Viewing changes to GTG/gtk/browser/simple_color_selector.py

  • Committer: Izidor Matušov
  • Date: 2012-12-14 13:53:48 UTC
  • mfrom: (1240.1.17 trunk)
  • Revision ID: izidor.matusov@gmail.com-20121214135348-q7wn21y464xb1q2x
Merging trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
  "#CE5C00", "#C4A000", "#BABDB6", "#2E3436",
39
39
]
40
40
 
41
 
BUTTON_WIDTH  = 36
 
41
BUTTON_WIDTH = 36
42
42
BUTTON_HEIGHT = 24
43
43
 
44
 
class SimpleColorSelectorPaletteItem(Gtk.DrawingArea): # pylint: disable-msg=R0904,C0301
 
44
 
 
45
class SimpleColorSelectorPaletteItem(Gtk.DrawingArea):
 
46
# pylint: disable-msg=R0904,C0301
45
47
    """An item of the color selecctor palette"""
46
48
 
47
49
    def __init__(self, color=None):
63
65
        # Drawing context
64
66
        #cr_ctxt    = self.window.cairo_create() # pylint: disable-msg=E1101
65
67
        #gdkcontext = Gdk.CairoContext(cr_ctxt)
66
 
#FIXME
 
68
        #FIXME
67
69
        gdkcontext = cr
68
70
 
69
71
        # Draw rectangle
95
97
            gdkcontext.stroke()
96
98
            Gdk.cairo_set_source_rgba(gdkcontext, Gdk.RGBA(0, 0, 0, 0.50))
97
99
            gdkcontext.set_line_width(3.0)
98
 
            gdkcontext.move_to(pos_x       , pos_y+size/2)
 
100
            gdkcontext.move_to(pos_x, pos_y+size/2)
99
101
            gdkcontext.line_to(pos_x+size/2, pos_y+size)
100
 
            gdkcontext.line_to(pos_x+size  , pos_y)
 
102
            gdkcontext.line_to(pos_x+size, pos_y)
101
103
            gdkcontext.stroke()
102
104
 
103
105
    ### callbacks ###
104
 
 
105
106
    def on_expose(self, widget, cr): # pylint: disable-msg=W0613
106
107
        """Callback: redraws the widget when it is exposed"""
107
108
        self.__draw(cr)
112
113
        #self.__draw(cr)
113
114
 
114
115
    ### PUBLIC IF ###
115
 
 
116
116
    def set_color(self, color):
117
117
        """Defines the widget color"""
118
118
        self.color = color
128
128
 
129
129
 
130
130
class SimpleColorSelector(Gtk.VBox): # pylint: disable-msg=R0904,C0301
131
 
    """Widget displaying a palette of colors, possibly with a button allowing to
132
 
    define new colors."""
 
131
    """Widget displaying a palette of colors, possibly with a button allowing
 
132
     to define new colors."""
133
133
 
134
134
    def __init__(self, width=9, colors=None, custom_colors=None):
135
135
        Gtk.VBox.__init__(self)
286
286
        color_dialog.destroy()
287
287
 
288
288
    # public IF
289
 
 
290
289
    def has_color(self, col):
291
290
        """Returns True if the color is already present"""
292
291
        return col in self.colors or col in self.custom_colors