Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common/Util/ThemeWidgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'common/Util/ThemeWidgets.py')
-rw-r--r--common/Util/ThemeWidgets.py104
1 files changed, 52 insertions, 52 deletions
diff --git a/common/Util/ThemeWidgets.py b/common/Util/ThemeWidgets.py
index a138da7..478a73d 100644
--- a/common/Util/ThemeWidgets.py
+++ b/common/Util/ThemeWidgets.py
@@ -8,7 +8,7 @@ from common.Config import imagefile
from sugar3.graphics.combobox import ComboBox
from sugar3.graphics.palette import Palette, WidgetInvoker
-def Gdk_color_to_cairo(color):
+def gdk_color_to_cairo(color):
return (color.red/65536.0, color.green/65536.0, color.blue/65536.0)
class ITYPE:
@@ -17,7 +17,7 @@ class ITYPE:
class ImageHScale( Gtk.HScale ):
def __init__( self, image_name, adjustment = None, slider_border = 0, insensitive_name = None, trough_color = "#3D403A", snap = False ):
- GObject.GObject.__init__( self, adjustment )
+ Gtk.HScale.__init__( self, adjustment )
if snap: self.snap = 1/snap
else: self.snap = False
@@ -46,7 +46,7 @@ style "scale_style" {
}
widget "*%s*" style "scale_style"
""" % ( self.sliderPixbuf.get_width(), self.sliderPixbuf.get_height(), name)
- Gtk.rc_parse_string( rc_str )
+ gtk.rc_parse_string( rc_str )
self.pixbufWidth = self.sliderPixbuf.get_width()
self.pixbufHeight = self.sliderPixbuf.get_height()
@@ -97,9 +97,9 @@ widget "*%s*" style "scale_style"
sliderX = int((self.alloc.width - self.pixbufWidth)*(val-adj.lower)/(adj.upper - adj.lower))
if self.insensitivePixbuf != None and self.state == Gtk.StateType.INSENSITIVE:
- self.window.draw_pixbuf( gc, self.insensitivePixbuf, 0, 0, self.alloc.x + sliderX, self.alloc.y + self.sliderY, self.pixbufWidth, self.pixbufHeight, Gdk.RGB_DITHER_NORMAL, 0, 0 )
+ self.window.draw_pixbuf( gc, self.insensitivePixbuf, 0, 0, self.alloc.x + sliderX, self.alloc.y + self.sliderY, self.pixbufWidth, self.pixbufHeight, gtk.gdk.RGB_DITHER_NORMAL, 0, 0 )
else:
- self.window.draw_pixbuf( gc, self.sliderPixbuf, 0, 0, self.alloc.x + sliderX, self.alloc.y + self.sliderY, self.pixbufWidth, self.pixbufHeight, Gdk.RGB_DITHER_NORMAL, 0, 0 )
+ self.window.draw_pixbuf( gc, self.sliderPixbuf, 0, 0, self.alloc.x + sliderX, self.alloc.y + self.sliderY, self.pixbufWidth, self.pixbufHeight, gtk.gdk.RGB_DITHER_NORMAL, 0, 0 )
return True
@@ -113,7 +113,7 @@ class ImageVScale( Gtk.VScale ):
insensitive_name=None, trough_color="#3D403A", snap=False):
image_name = imagefile(image_name)
- GObject.GObject.__init__( self, adjustment )
+ Gtk.VScale.__init__( self, adjustment )
if snap: self.snap = 1/snap
else: self.snap = False
@@ -142,7 +142,7 @@ style "scale_style" {
}
widget "*%s*" style "scale_style"
""" % ( self.sliderPixbuf.get_width(), self.sliderPixbuf.get_height(), name)
- Gtk.rc_parse_string( rc_str )
+ gtk.rc_parse_string( rc_str )
self.pixbufWidth = self.sliderPixbuf.get_width()
self.pixbufHeight = self.sliderPixbuf.get_height()
@@ -190,10 +190,10 @@ widget "*%s*" style "scale_style"
else:
sliderY = int((self.alloc.height - self.pixbufHeight)*(val-adj.lower)/(adj.upper - adj.lower))
- if self.insensitivePixbuf != None and self.state == Gtk.STATE_INSENSITIVE:
- self.window.draw_pixbuf( gc, self.insensitivePixbuf, 0, 0, self.alloc.x + self.sliderX, self.alloc.y + sliderY, self.pixbufWidth, self.pixbufHeight, Gdk.RGB_DITHER_NORMAL, 0, 0 )
+ if self.insensitivePixbuf != None and self.state == gtk.STATE_INSENSITIVE:
+ self.window.draw_pixbuf( gc, self.insensitivePixbuf, 0, 0, self.alloc.x + self.sliderX, self.alloc.y + sliderY, self.pixbufWidth, self.pixbufHeight, gtk.gdk.RGB_DITHER_NORMAL, 0, 0 )
else:
- self.window.draw_pixbuf( gc, self.sliderPixbuf, 0, 0, self.alloc.x + self.sliderX, self.alloc.y + sliderY, self.pixbufWidth, self.pixbufHeight, Gdk.RGB_DITHER_NORMAL, 0, 0 )
+ self.window.draw_pixbuf( gc, self.sliderPixbuf, 0, 0, self.alloc.x + self.sliderX, self.alloc.y + sliderY, self.pixbufWidth, self.pixbufHeight, gtk.gdk.RGB_DITHER_NORMAL, 0, 0 )
return True
@@ -204,7 +204,7 @@ widget "*%s*" style "scale_style"
class XYSlider( Gtk.EventBox ):
def __init__( self, fixed, button, xadjustment, yadjustment, flipX = False, flipY = False ):
- GObject.GObject.__init__( self )
+ Gtk.EventBox.__init__( self )
self.fixed = fixed
self.button = button
@@ -221,7 +221,7 @@ class XYSlider( Gtk.EventBox ):
self.fWidth = self.fHeight = 1
self.bWidth = self.bHeight = 1
- self.add_events(Gdk.POINTER_MOTION_HINT_MASK)
+ self.add_events(gtk.gdk.POINTER_MOTION_HINT_MASK)
self.connect( "size-allocate", lambda w,a:self.updateAlloc() )
self.connect( "button-press-event", self.handlePress )
self.connect( "button-release-event", self.handleRelease )
@@ -229,7 +229,7 @@ class XYSlider( Gtk.EventBox ):
self.button.connect( "size-allocate", lambda w,a: self.updateButton() )
self.button.connect( "button-press-event", self.handleButtonPress )
self.button.connect( "button-release-event", self.handleButtonRelease )
- self.button.add_events(Gdk.BUTTON_MOTION_MASK|Gdk.POINTER_MOTION_HINT_MASK)
+ self.button.add_events(gtk.gdk.BUTTON_MOTION_MASK|gtk.gdk.POINTER_MOTION_HINT_MASK)
self.button.connect( "motion-notify-event", self.handleMotion )
self.xadjustment.connect( "changed", lambda a1: self.updateAdjustemnt("x") )
self.xadjustment.connect( "value-changed", lambda a1: self.updateLoc() )
@@ -310,7 +310,7 @@ class XYSlider( Gtk.EventBox ):
class RoundHBox( Gtk.HBox ):
def __init__( self, radius = 5, fillcolor = "#000", bordercolor = "#FFF", homogeneous = False, spacing = 0 ):
- GObject.GObject.__init__( self, homogeneous, spacing )
+ Gtk.HBox.__init__( self, homogeneous, spacing )
self.alloc = None
self.radius = radius
@@ -471,7 +471,7 @@ class RoundHBox( Gtk.HBox ):
class RoundVBox( Gtk.VBox ):
def __init__( self, radius = 5, fillcolor = "#000", bordercolor = "#FFF", homogeneous = False, spacing = 0 ):
- GObject.GObject.__init__( self, homogeneous, spacing )
+ Gtk.VBox.__init__( self, homogeneous, spacing )
self.alloc = None
self.radius = radius
@@ -544,7 +544,7 @@ class RoundVBox( Gtk.VBox ):
#TP.ProfileBegin( "Round*Box::expose" )
style = self.get_style()
- gc = style.fg_gc[Gtk.STATE_NORMAL]
+ gc = style.fg_gc[gtk.STATE_NORMAL]
startX = event.area.x - self.alloc.x
startY = event.area.y - self.alloc.y
@@ -612,7 +612,7 @@ class RoundVBox( Gtk.VBox ):
class RoundFixed( Gtk.Fixed ):
def __init__( self, radius = 5, fillcolor = "#000", bordercolor = "#FFF" ):
- GObject.GObject.__init__( self )
+ Gtk.Fixed.__init__( self )
self.alloc = None
self.radius = radius
@@ -691,7 +691,7 @@ class RoundFixed( Gtk.Fixed ):
# Note: could maybe do some optimization to fill only areas that are within the dirty rect, but drawing
# seems to be quite fast compared to python code, so just leave it at clipping by each geometry feature
- cr.set_source_rgb(*Gdk_color_to_cairo(self.bordercolor))
+ cr.set_source_rgb(*gdk_color_to_cairo(self.bordercolor))
if self.borderW:
if stopY > self.corner and startY < self.heightMINcorner:
if startX < self.borderW: # draw left border
@@ -756,7 +756,7 @@ class ImageButton(Gtk.Button):
#clickImg_path = imagefile(clickImg_path)
#enterImg_path = imagefile(enterImg_path)
- GObject.GObject.__init__(self)
+ Gtk.Button.__init__(self)
self.alloc = None
self.image = {}
self.itype = {}
@@ -778,21 +778,21 @@ class ImageButton(Gtk.Button):
self.iheightDIV2[name] = self.iheight[name]//2
def prepareImage( name, path ):
- pix = Gdk.pixbuf_new_from_file(path)
+ pix = gtk.gdk.pixbuf_new_from_file(path)
if pix.get_has_alpha():
if backgroundFill == None:
self.image[name] = pix
self.itype[name] = ITYPE.PIXBUF
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
colormap = self.get_colormap()
self.gc.foreground = colormap.alloc_color( backgroundFill, True, True )
self.image[name].draw_rectangle( self.gc, True, 0, 0, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
self.iwidth[name] = pix.get_width()
self.iwidthDIV2[name] = self.iwidth[name]//2
@@ -840,7 +840,7 @@ class ImageButton(Gtk.Button):
def expose(self, widget, event):
if self.itype[self.curImage] == ITYPE.PIXBUF:
- self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], Gdk.RGB_DITHER_NONE)
+ self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], gtk.gdk.RGB_DITHER_NONE)
else:
self.window.draw_drawable( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage] )
return True
@@ -857,15 +857,15 @@ class ImageButton(Gtk.Button):
self.image[name] = pix
self.itype[name] = ITYPE.PIXBUF
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
colormap = self.get_colormap()
self.gc.foreground = colormap.alloc_color( self.backgroundFill, True, True )
self.image[name].draw_rectangle( self.gc, True, 0, 0, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
self.iwidth[name] = pix.get_width()
self.iwidthDIV2[name] = self.iwidth[name]//2
@@ -890,14 +890,14 @@ class ImageButton(Gtk.Button):
self.queue_draw()
def on_btn_enter(self, widget, event):
- if event.mode == Gdk.CROSSING_NORMAL:
+ if event.mode == gtk.gdk.CROSSING_NORMAL:
self.upImage = "enter"
if self.down: self.curImage = "click"
else: self.curImage = "enter"
self.queue_draw()
def on_btn_leave(self, widget, event):
- if event.mode == Gdk.CROSSING_NORMAL:
+ if event.mode == gtk.gdk.CROSSING_NORMAL:
self.curImage = self.upImage = "main"
self.queue_draw()
@@ -918,7 +918,7 @@ class ImageToggleButton(Gtk.ToggleButton):
altImg_path = imagefile(altImg_path)
enterImg_path = imagefile(enterImg_path)
- GObject.GObject.__init__(self)
+ Gtk.ToggleButton.__init__(self)
self.alloc = None
self.within = False
self.clicked = False
@@ -994,7 +994,7 @@ class ImageToggleButton(Gtk.ToggleButton):
if self.itype[self.curImage] == ITYPE.PIXBUF:
cr.set_source_surface(self.image[self.curImage], 0, 0)
cr.paint()
- #self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], Gdk.RGB_DITHER_NONE)
+ #self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], gtk.gdk.RGB_DITHER_NONE)
else:
cr.set_source_surface(self.image[self.curImage], 0, 0)
cr.paint()
@@ -1092,13 +1092,13 @@ class ImageRadioButton(Gtk.RadioButton):
altImg_path = imagefile(altImg_path)
enterImg_path = imagefile(enterImg_path)
- GObject.GObject.__init__(self, group)
+ Gtk.RadioButton.__init__(self, group)
self.alloc = None
self.within = False
self.clicked = False
- win = Gdk.get_default_root_window()
- self.gc = Gdk.GC( win )
+ win = gtk.gdk.get_default_root_window()
+ self.gc = gtk.gdk.GC( win )
self.image = {}
self.itype = {}
self.iwidth = {}
@@ -1109,21 +1109,21 @@ class ImageRadioButton(Gtk.RadioButton):
self.backgroundFill = backgroundFill
def prepareImage( name, path ):
- pix = Gdk.pixbuf_new_from_file(path)
+ pix = gtk.gdk.pixbuf_new_from_file(path)
if pix.get_has_alpha():
if backgroundFill == None:
self.image[name] = pix
self.itype[name] = ITYPE.PIXBUF
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
colormap = self.get_colormap()
self.gc.foreground = colormap.alloc_color( backgroundFill, True, True )
self.image[name].draw_rectangle( self.gc, True, 0, 0, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
self.iwidth[name] = pix.get_width()
self.iwidthDIV2[name] = self.iwidth[name]//2
@@ -1163,7 +1163,7 @@ class ImageRadioButton(Gtk.RadioButton):
def expose(self, widget, event):
if self.itype[self.curImage] == ITYPE.PIXBUF:
- self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], Gdk.RGB_DITHER_NONE)
+ self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], gtk.gdk.RGB_DITHER_NONE)
else:
self.window.draw_drawable( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage] )
return True
@@ -1179,15 +1179,15 @@ class ImageRadioButton(Gtk.RadioButton):
self.image[name] = pix
self.itype[name] = ITYPE.PIXBUF
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
colormap = self.get_colormap()
self.gc.foreground = colormap.alloc_color( self.backgroundFill, True, True )
self.image[name].draw_rectangle( self.gc, True, 0, 0, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
else:
- self.image[name] = Gdk.Pixmap( win, pix.get_width(), pix.get_height() )
- self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), Gdk.RGB_DITHER_NONE )
+ self.image[name] = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ self.image[name].draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
self.itype[name] = ITYPE.PIXMAP
self.iwidth[name] = pix.get_width()
self.iwidthDIV2[name] = self.iwidth[name]//2
@@ -1226,7 +1226,7 @@ class ImageRadioButton(Gtk.RadioButton):
self.toggleImage( self )
def on_btn_enter(self, widget, event):
- if event.mode == Gdk.CROSSING_NORMAL:
+ if event.mode == gtk.gdk.CROSSING_NORMAL:
self.within = True
if not self.get_active() and not self.clicked:
self.curImage = "enter"
@@ -1235,7 +1235,7 @@ class ImageRadioButton(Gtk.RadioButton):
self.queue_draw()
def on_btn_leave(self, widget, event):
- if event.mode == Gdk.CROSSING_NORMAL:
+ if event.mode == gtk.gdk.CROSSING_NORMAL:
self.within = False
if not self.get_active():
self.curImage = "main"
@@ -1251,10 +1251,10 @@ class ImageRadioButton(Gtk.RadioButton):
class keyButton(Gtk.Button):
import cairo
def __init__(self, width, height, fillcolor, strokecolor):
- GObject.GObject.__init__(self)
+ Gtk.Button.__init__(self)
self.alloc = None
- win = Gdk.get_default_root_window()
- self.gc = Gdk.GC(win)
+ win = gtk.gdk.get_default_root_window()
+ self.gc = gtk.gdk.GC(win)
self.connect('expose-event', self.expose)
self.connect('size-allocate', self.size_allocate)
@@ -1307,7 +1307,7 @@ class keyButton(Gtk.Button):
class BigComboBox(Gtk.ComboBox):
def __init__(self):
- GObject.GObject.__init__(self)
+ Gtk.ComboBox.__init__(self)
self.model = Gtk.ListStore(int, str)
self.set_model(self.model)
self.text_renderer = Gtk.CellRendererText()