diff options
-rw-r--r-- | common/Util/Credits.py | 22 | ||||
-rw-r--r-- | common/Util/InstrumentPanel.py | 54 | ||||
-rw-r--r-- | common/Util/KeyboardWindow.py | 42 | ||||
-rw-r--r-- | common/Util/LoopSettings.py | 104 | ||||
-rw-r--r-- | common/Util/Network.py | 18 | ||||
-rw-r--r-- | common/Util/ThemeWidgets.py | 104 |
6 files changed, 175 insertions, 169 deletions
diff --git a/common/Util/Credits.py b/common/Util/Credits.py index 1bd0e0a..c8d2644 100644 --- a/common/Util/Credits.py +++ b/common/Util/Credits.py @@ -1,27 +1,29 @@ # -*- coding: utf-8 -*- -from gi.repository import Gtk +import pygtk +pygtk.require( '2.0' ) +import gtk -class Credits( Gtk.Window ): +class Credits( gtk.Window ): def __init__(self , handleCreditsCloseCallback , pos): - Gtk.Window.__init__( self, Gtk.WINDOW_TOPLEVEL ) - self.set_type_hint(Gdk.WINDOW_TYPE_HINT_DIALOG) + gtk.Window.__init__( self, gtk.WINDOW_TOPLEVEL ) + self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.connect('destroy' , self.destroy) #self.set_decorated(False) self.handleCreditsCloseCallback = handleCreditsCloseCallback self.move(pos[0] , pos[1]) - self.vbox = Gtk.VBox() - self.tb = Gtk.TextBuffer() + self.vbox = gtk.VBox() + self.tb = gtk.TextBuffer() self.tb.set_text('miniTamTam\n\nby\n\nOlivier Bélanger\nJames Bergstra\nEric Lamothe\nNathanaël Lécaudé\nAdrian Martin\nJean Piché\nSean Wood\n\nThanks to\n\nBarry Vercoe\nVictor Lazzarini\nMarco Pesenti Gritti\nSimon Schampijer\nPeter Kirn\n\nUniversité de Montréal 2006') - self.tw = Gtk.TextView(buffer = self.tb) + self.tw = gtk.TextView(buffer = self.tb) self.tw.set_editable(False) self.tw.set_cursor_visible(False) #self.tw.set_right_margin(10) #self.tw.set_left_margin(10) - self.tw.set_justification(Gtk.JUSTIFY_CENTER) + self.tw.set_justification(gtk.JUSTIFY_CENTER) self.vbox.add(self.tw) - self.closeButton = Gtk.Button(label='X') + self.closeButton = gtk.Button(label='X') self.closeButton.connect('clicked' , self.destroy) self.vbox.add(self.closeButton) self.add(self.vbox) @@ -34,4 +36,4 @@ class Credits( Gtk.Window ): if __name__ == '__main__': credits = Credits() - Gtk.main()
\ No newline at end of file + gtk.main()
\ No newline at end of file diff --git a/common/Util/InstrumentPanel.py b/common/Util/InstrumentPanel.py index 8c0a2d6..6620031 100644 --- a/common/Util/InstrumentPanel.py +++ b/common/Util/InstrumentPanel.py @@ -1,4 +1,6 @@ -from gi.repository import Gtk +import pygtk +pygtk.require( '2.0' ) +import gtk import time @@ -7,9 +9,9 @@ import common.Config as Config from common.Util.ThemeWidgets import * Tooltips = Config.Tooltips -class InstrumentPanel( Gtk.EventBox ): +class InstrumentPanel( gtk.EventBox ): def __init__(self,setInstrument = None, playInstrument = None, enterMode = False, micRec = None, synthRec = None, rowLen = 8, _instDic = None, force_load = True ): - Gtk.EventBox.__init__(self) + gtk.EventBox.__init__(self) self.instrumentDB = InstrumentDB.getRef() self.setInstrument = setInstrument @@ -44,13 +46,13 @@ class InstrumentPanel( Gtk.EventBox ): if Config.DEBUG > 4: print "InstrumentPanel load", self.loadStage if self.loadStage[0] == 0: - color = Gdk.color_parse(Config.PANEL_BCK_COLOR) - self.modify_bg(Gtk.STATE_NORMAL, color) + color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR) + self.modify_bg(gtk.STATE_NORMAL, color) self.loadStage[0] = 1 if timeout >= 0 and time.time() > timeout: return False if self.loadStage[0] == 1: - self.tooltips = Gtk.Tooltips() + self.tooltips = gtk.Tooltips() self.loadStage[0] = 2 if timeout >= 0 and time.time() > timeout: return False @@ -59,7 +61,7 @@ class InstrumentPanel( Gtk.EventBox ): self.recstate = False self.lastInstrumentWidget = None - self.mainVBox = Gtk.VBox() + self.mainVBox = gtk.VBox() self.loadStage[0] = 3 if timeout >= 0 and time.time() > timeout: return False @@ -148,7 +150,7 @@ class InstrumentPanel( Gtk.EventBox ): def loadToolbar( self, timeout = -1, loadStage = [0,0,0] ): if loadStage[1] == 0: - self.loadData["toolbarBox"] = Gtk.HBox() + self.loadData["toolbarBox"] = gtk.HBox() self.firstTbBtn = None self.loadStage[1] = 1 if timeout >= 0 and time.time() > timeout: return False @@ -239,17 +241,17 @@ class InstrumentPanel( Gtk.EventBox ): def loadInstrumentViewport( self ): self.instrumentBox = RoundHBox(fillcolor = Config.INSTRUMENT_GRID_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) - self.scrollWin = Gtk.ScrolledWindow() - self.scrollWin.set_policy(Gtk.POLICY_NEVER,Gtk.POLICY_AUTOMATIC) + self.scrollWin = gtk.ScrolledWindow() + self.scrollWin.set_policy(gtk.POLICY_NEVER,gtk.POLICY_AUTOMATIC) - self.tableEventBox = Gtk.EventBox() - color = Gdk.color_parse(Config.INSTRUMENT_GRID_COLOR) - self.tableEventBox.modify_bg(Gtk.STATE_NORMAL, color) + self.tableEventBox = gtk.EventBox() + color = gtk.gdk.color_parse(Config.INSTRUMENT_GRID_COLOR) + self.tableEventBox.modify_bg(gtk.STATE_NORMAL, color) self.scrollWin.add_with_viewport(self.tableEventBox) - self.tableEventBox.get_parent().set_shadow_type( Gtk.SHADOW_NONE ) + self.tableEventBox.get_parent().set_shadow_type( gtk.SHADOW_NONE ) self.instrumentBox.pack_start(self.scrollWin,True,True,0) - self.mainVBox.pack_start(self.instrumentBox, True, True, 0) + self.mainVBox.pack_start(self.instrumentBox) self.show_all() def prepareInstrumentTable(self,category = 'all'): @@ -276,7 +278,7 @@ class InstrumentPanel( Gtk.EventBox ): if instrumentNum % cols is not 0: #S'il y a un reste rows = rows + 1 - self.instTable = Gtk.Table(rows,cols,True) + self.instTable = gtk.Table(rows,cols,True) self.instTable.set_row_spacings(0) self.instTable.set_col_spacings(0) @@ -285,7 +287,7 @@ class InstrumentPanel( Gtk.EventBox ): if row*cols+col >= instrumentNum: break instBox = self.instDic[instruments[row*cols+col]] - self.instTable.attach(instBox, col, col+1, row, row+1, Gtk.SHRINK, Gtk.SHRINK, 0, 0) + self.instTable.attach(instBox, col, col+1, row, row+1, gtk.SHRINK, gtk.SHRINK, 0, 0) self.tableEventBox.add(self.instTable) self.instTable.show_all() @@ -300,7 +302,7 @@ class InstrumentPanel( Gtk.EventBox ): def handleInstrumentButtonClick(self,widget,instrument): if widget.get_active() is True and self.recstate == False: if self.setInstrument: - widget.event( Gdk.Event( Gdk.LEAVE_NOTIFY ) ) # fake the leave event + widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event self.setInstrument(instrument) if self.playInstrument: self.playInstrument(instrument) if self.enterMode: @@ -329,11 +331,11 @@ class InstrumentPanel( Gtk.EventBox ): btn.handler_unblock(btn.clickedHandler) -class DrumPanel( Gtk.EventBox ): +class DrumPanel( gtk.EventBox ): def __init__(self, setDrum = None): - Gtk.EventBox.__init__(self) - color = Gdk.color_parse(Config.PANEL_BCK_COLOR) - self.modify_bg(Gtk.STATE_NORMAL, color) + gtk.EventBox.__init__(self) + color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR) + self.modify_bg(gtk.STATE_NORMAL, color) self.setDrum = setDrum self.instrumentList = [] @@ -365,7 +367,7 @@ class DrumPanel( Gtk.EventBox ): def setDrums(self,widget,data): if widget.get_active(): if self.setDrum: - widget.event( Gdk.Event( Gdk.LEAVE_NOTIFY ) ) # fake the leave event + widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event self.setDrum(data) def set_activeInstrument( self, instrument, state ): @@ -376,9 +378,9 @@ class DrumPanel( Gtk.EventBox ): btn.handler_unblock(btn.clickedHandler) if __name__ == "__main__": - win = Gtk.Window() + win = gtk.Window() wc = DrumPanel(None) win.add(wc) win.show() - #start the Gtk event loop - Gtk.main() + #start the gtk event loop + gtk.main() diff --git a/common/Util/KeyboardWindow.py b/common/Util/KeyboardWindow.py index a244bdb..e828967 100644 --- a/common/Util/KeyboardWindow.py +++ b/common/Util/KeyboardWindow.py @@ -1,20 +1,22 @@ -from gi.repository import Gtk +import pygtk +pygtk.require( '2.0' ) +import gtk import random from common.Util.ThemeWidgets import keyButton import common.Config as Config KEY_MAP_PIANO = Config.KEY_MAP_PIANO -class KeyboardWindow(Gtk.Window): +class KeyboardWindow(gtk.Window): def __init__(self, size = None, pos = 0, popup = False): if popup is False: - Gtk.Window.__init__(self , Gtk.WINDOW_TOPLEVEL) + gtk.Window.__init__(self , gtk.WINDOW_TOPLEVEL) else: - Gtk.Window.__init__(self , Gtk.WINDOW_POPUP) - color = Gdk.color_parse("#000000") - self.modify_bg(Gtk.STATE_NORMAL, color) + gtk.Window.__init__(self , gtk.WINDOW_POPUP) + color = gtk.gdk.color_parse("#000000") + self.modify_bg(gtk.STATE_NORMAL, color) self.set_decorated(False) - self.add_events(Gdk.BUTTON_PRESS_MASK | Gdk.BUTTON_RELEASE_MASK | Gdk.ENTER_NOTIFY_MASK | Gdk.KEY_PRESS_MASK) + self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.KEY_PRESS_MASK) self.connect("key-press-event",self.handle_keypress) self.connect("key-release-event",self.handle_keyrelease) self.connect("button-press-event",self.handle_mousePress) @@ -47,23 +49,23 @@ class KeyboardWindow(Gtk.Window): self.btn_dic = {} - mainvbox = Gtk.VBox() - mainhbox = Gtk.HBox() + mainvbox = gtk.VBox() + mainhbox = gtk.HBox() #Main keyboard section - vbox = Gtk.VBox() + vbox = gtk.VBox() for row in [1,2,3,4,5]: - hbox = Gtk.HBox() + hbox = gtk.HBox() for key in self.rows[row]: self.btn_dic[key[0]] = keyButton(self.pixel_space * key[1], self.height, [0,0,0], [0.5,0.5,0.5]) hbox.pack_start(self.btn_dic[key[0]], padding = self.pixel_space//2) vbox.pack_start(hbox, padding = self.pixel_space//2) - mainhbox.pack_start(vbox, True, True, 0) + mainhbox.pack_start(vbox) #Right part of the keyboard - right_vbox = Gtk.VBox() - right_tophbox = Gtk.HBox() - right_lowhbox = Gtk.HBox() + right_vbox = gtk.VBox() + right_tophbox = gtk.HBox() + right_lowhbox = gtk.HBox() self.btn_dic[self.right_section[0][0]] = keyButton(self.pixel_space * self.right_section[0][1], self.height, [0,0,0], [0.5,0.5,0.5]) self.btn_dic[self.right_section[1][0]] = keyButton(self.pixel_space * self.right_section[1][1][0], self.pixel_space * self.right_section[1][1][1], [0,0,0], [0.5,0.5,0.5]) @@ -82,7 +84,7 @@ class KeyboardWindow(Gtk.Window): right_vbox.pack_start(right_lowhbox, padding = self.pixel_space//2) #Mouse buttons - mouse_hbox = Gtk.HBox() + mouse_hbox = gtk.HBox() self.btn_dic["left_mouse"] = keyButton(self.pixel_space * 6, self.pixel_space * 2, [0,0,0], [0.5,0.5,0.5]) self.btn_dic["right_mouse"] = keyButton(self.pixel_space * 6, self.pixel_space * 2, [0,0,0], [0.5,0.5,0.5]) mouse_hbox.pack_start(self.btn_dic["left_mouse"], True, True, self.pixel_space//2) @@ -94,8 +96,8 @@ class KeyboardWindow(Gtk.Window): self.btn_dic[key].connect("enter",self.handle_mouseEnter) self.btn_dic[key].connect("leave",self.handle_mouseLeave) - mainhbox.pack_start(right_vbox, True, True, 0) - mainvbox.pack_start(mainhbox, True, True, 0) + mainhbox.pack_start(right_vbox) + mainvbox.pack_start(mainhbox) mainvbox.pack_start(mouse_hbox, padding = self.pixel_space//2) self.add(mainvbox) @@ -173,6 +175,6 @@ class KeyboardWindow(Gtk.Window): if __name__ == "__main__": win = KeyboardWindow() - win.connect("destroy",Gtk.main_quit) + win.connect("destroy",gtk.main_quit) win.show_all() - Gtk.main() + gtk.main() diff --git a/common/Util/LoopSettings.py b/common/Util/LoopSettings.py index f26fbd2..a36dd94 100644 --- a/common/Util/LoopSettings.py +++ b/common/Util/LoopSettings.py @@ -1,17 +1,17 @@ -import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk -from gi.repository import GObject +import pygtk +pygtk.require('2.0') +import gtk +import gobject import os from common.Util.ThemeWidgets import * import common.Config as Config import commands Tooltips = Config.Tooltips() -class LoopSettings( Gtk.VBox ): +class LoopSettings( gtk.VBox ): def __init__( self, popup, playFunction, setChannelFunction, doneLoopSettingsPopup ): - Gtk.VBox.__init__( self ) - self.tooltips = Gtk.Tooltips() + gtk.VBox.__init__( self ) + self.tooltips = gtk.Tooltips() self.popup = popup self.playFunction = playFunction self.setChannel = setChannelFunction @@ -24,114 +24,114 @@ class LoopSettings( Gtk.VBox ): self.register = 0 self.ok = True - self.settingsBox = Gtk.HBox() - self.pack_start(self.settingsBox, True, True, 0) + self.settingsBox = gtk.HBox() + self.pack_start(self.settingsBox) - self.fixed = Gtk.Fixed() - self.settingsBox.pack_start(self.fixed, True, True, 0) + self.fixed = gtk.Fixed() + self.settingsBox.pack_start(self.fixed) - self.mainBox = Gtk.VBox() + self.mainBox = gtk.VBox() - self.controlsBox = Gtk.HBox() + self.controlsBox = gtk.HBox() self.GUI = {} - nameBox = Gtk.VBox() - self.nameEntry = Gtk.Entry() + nameBox = gtk.VBox() + self.nameEntry = gtk.Entry() self.nameEntry.set_text("name_of_the_sound") - nameBox.pack_start(self.nameEntry, True, True, 0) + nameBox.pack_start(self.nameEntry) self.mainBox.pack_start(nameBox, False, False, 5) - loopedBox = Gtk.HBox() - loopedLabel = Gtk.Label("Looped sound: ") - loopedBox.pack_start(loopedLabel, True, True, 0) + loopedBox = gtk.HBox() + loopedLabel = gtk.Label("Looped sound: ") + loopedBox.pack_start(loopedLabel) loopedToggle = ImageToggleButton('checkOff.png', 'checkOn.png') loopedToggle.connect('button-press-event', self.handleLooped ) - loopedBox.pack_start(loopedToggle, True, True, 0) + loopedBox.pack_start(loopedToggle) self.mainBox.pack_start(loopedBox, False, False, 5) - categoryBox = Gtk.HBox() - categoryMenu = Gtk.MenuBar() - cmenu = Gtk.Menu() + categoryBox = gtk.HBox() + categoryMenu = gtk.MenuBar() + cmenu = gtk.Menu() for cat in Config.CATEGORIES: if cat != 'all': - entry = Gtk.MenuItem(cat) + entry = gtk.MenuItem(cat) cmenu.append(entry) entry.connect("activate", self.handleCategory, cat) entry.show() - self.categoryButton = Gtk.Button("Category") + self.categoryButton = gtk.Button("Category") self.categoryButton.connect_object("event", self.categoryBtnPress, cmenu) - categoryBox.pack_end(self.categoryButton, True, True, 0) + categoryBox.pack_end(self.categoryButton) #self.mainBox.pack_start(categoryBox, False, False, 5) - registerBox = Gtk.HBox() - registerMenu = Gtk.MenuBar() - rmenu = Gtk.Menu() + registerBox = gtk.HBox() + registerMenu = gtk.MenuBar() + rmenu = gtk.Menu() self.registerList = ['LOW', 'MID', 'HIGH', 'PUNCH'] for reg in self.registerList: - entry = Gtk.MenuItem(reg) + entry = gtk.MenuItem(reg) rmenu.append(entry) entry.connect("activate", self.handleRegister, self.registerList.index(reg)) entry.show() - self.registerButton = Gtk.Button("Register") + self.registerButton = gtk.Button("Register") self.registerButton.connect_object("event", self.registerBtnPress, rmenu) - registerBox.pack_end(self.registerButton, True, True, 0) + registerBox.pack_end(self.registerButton) self.mainBox.pack_start(registerBox, False, False, 5) - startBox = Gtk.VBox() - self.startAdjust = Gtk.Adjustment( 0.01, 0, 1., .001, .001, 0) + startBox = gtk.VBox() + self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0) self.GUI['startSlider'] = ImageVScale('sliderEditVolume.png', self.startAdjust, 7) self.startAdjust.connect("value-changed", self.handleStart) self.GUI['startSlider'].set_inverted(True) self.GUI['startSlider'].set_size_request(50, 200) - self.startEntry = Gtk.Entry() + self.startEntry = gtk.Entry() self.startEntry.set_width_chars(5) self.handleStart( self.startAdjust ) startBox.pack_start(self.GUI['startSlider'], True, True, 5) startBox.pack_start(self.startEntry, True, True, 5) - self.controlsBox.pack_start(startBox, True, True, 0) + self.controlsBox.pack_start(startBox) - endBox = Gtk.VBox() - self.endAdjust = Gtk.Adjustment( 0.9, 0, 1, .001, .001, 0) + endBox = gtk.VBox() + self.endAdjust = gtk.Adjustment( 0.9, 0, 1, .001, .001, 0) self.GUI['endSlider'] = ImageVScale('sliderEditVolume.png', self.endAdjust, 7) self.endAdjust.connect("value-changed", self.handleEnd) self.GUI['endSlider'].set_inverted(True) self.GUI['endSlider'].set_size_request(50, 200) - self.endEntry = Gtk.Entry() + self.endEntry = gtk.Entry() self.endEntry.set_width_chars(5) self.handleEnd( self.endAdjust ) endBox.pack_start(self.GUI['endSlider'], True, True, 5) endBox.pack_start(self.endEntry, True, True, 5) - self.controlsBox.pack_start(endBox, True, True, 0) + self.controlsBox.pack_start(endBox) - durBox = Gtk.VBox() - self.durAdjust = Gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0) + durBox = gtk.VBox() + self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0) self.GUI['durSlider'] = ImageVScale('sliderEditVolume.png', self.durAdjust, 7) self.durAdjust.connect("value-changed", self.handleDur) self.GUI['durSlider'].set_inverted(True) self.GUI['durSlider'].set_size_request(50, 200) - self.durEntry = Gtk.Entry() + self.durEntry = gtk.Entry() self.durEntry.set_width_chars(5) self.handleDur( self.durAdjust ) durBox.pack_start(self.GUI['durSlider'], True, True, 5) durBox.pack_start(self.durEntry, True, True, 5) - self.controlsBox.pack_start(durBox, True, True, 0) + self.controlsBox.pack_start(durBox) self.mainBox.pack_start(self.controlsBox, False, False, 5) - previewBox = Gtk.VBox() + previewBox = gtk.VBox() self.playStopButton = ImageToggleButton('miniplay.png', 'stop.png') self.playStopButton.connect('button-press-event' , self.handlePlayButton) - previewBox.pack_start(self.playStopButton, True, True, 0) + previewBox.pack_start(self.playStopButton) self.mainBox.pack_start(previewBox, False, False, 5) - checkBox = Gtk.VBox() + checkBox = gtk.VBox() checkButton = ImageButton('check.png') checkButton.connect('clicked' , self.handleCheck) - checkBox.pack_start(checkButton, True, True, 0) + checkBox.pack_start(checkButton) self.mainBox.pack_start(checkBox, False, False, 5) self.fixed.put( self.mainBox, 0, 0 ) @@ -174,7 +174,7 @@ class LoopSettings( Gtk.VBox ): self.loopedSound = True def categoryBtnPress(self, widget, event): - if event.type == Gdk.BUTTON_PRESS: + if event.type == gtk.gdk.BUTTON_PRESS: widget.popup(None, None, None, event.button, event.time) return True return False @@ -184,7 +184,7 @@ class LoopSettings( Gtk.VBox ): self.categoryButton.set_label(self.category) def registerBtnPress(self, widget, event): - if event.type == Gdk.BUTTON_PRESS: + if event.type == gtk.gdk.BUTTON_PRESS: widget.popup(None, None, None, event.button, event.time) return True return False @@ -218,7 +218,7 @@ class LoopSettings( Gtk.VBox ): if self.ok: self.playFunction(widget.get_active(), self.loopedSound) if self.loopedSound == False and widget.get_active() == False: - self.timeoutStop = GObject.timeout_add(int(self.soundLength * 1000)+500, self.playButtonState) + self.timeoutStop = gobject.timeout_add(int(self.soundLength * 1000)+500, self.playButtonState) def setButtonState(self): self.ok = False @@ -228,5 +228,5 @@ class LoopSettings( Gtk.VBox ): def playButtonState(self): self.ok = False self.playStopButton.set_active(False) - GObject.source_remove(self.timeoutStop) + gobject.source_remove(self.timeoutStop) self.ok = True diff --git a/common/Util/Network.py b/common/Util/Network.py index e704a6a..79fbab5 100644 --- a/common/Util/Network.py +++ b/common/Util/Network.py @@ -18,8 +18,8 @@ import xdrlib import random import time -from gi.repository import Gtk -from gi.repository import GObject +import gtk +import gobject import common.Config as Config PORT = 24460 @@ -92,12 +92,12 @@ class Listener( threading.Thread ): continue else: break # exit thread - Gdk.threads_enter() + gtk.gdk.threads_enter() self.owner._processSockets( inputReady ) - Gdk.threads_leave() + gtk.gdk.threads_leave() except socket.error, (value, message): print "Listener:: socket error: " + message - Gdk.threads_leave() + gtk.gdk.threads_leave() break class Connection: @@ -292,7 +292,7 @@ class Network: print "Network::introducePeer:: FAILED to open socket: " + message return if poke.connect_ex( (ip, WAIT_PORT) ): # failed to connect - GObject.timeout_add( 500, self._pokePeer, poke, ip, 0 ) + gobject.timeout_add( 500, self._pokePeer, poke, ip, 0 ) else: # connected if Config.DEBUG > 1: print "Netwtork:: introduction succeeded" poke.close() @@ -302,7 +302,7 @@ class Network: if retry > 120: # give up print "Network::introducePeer:: peer failed to respond after 60 seconds, giving up!" else: - GObject.timeout_add( 500, self._pokePeer, poke, ip, retry+1 ) + gobject.timeout_add( 500, self._pokePeer, poke, ip, retry+1 ) else: # connected if Config.DEBUG > 1: print "Netwtork:: introduction succeeded" poke.close() @@ -539,7 +539,7 @@ class Network: con.recvBuf = con.recvBuf[con.waitingForData:] con.waitingForData = 0 for func in self.processMessage[con.message]: - GObject.idle_add( func, sock, con.message, data ) + gobject.idle_add( func, sock, con.message, data ) else: return # wait for more data @@ -548,7 +548,7 @@ class Network: if MSG_SIZE[con.message] == 0: con.recvBuf = con.recvBuf[1:] for func in self.processMessage[con.message]: - GObject.idle_add( func, sock, con.message, "" ) + gobject.idle_add( func, sock, con.message, "" ) else: con.waitingForData = MSG_SIZE[con.message] con.recvBuf = con.recvBuf[1:] 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() |