Ticket #3738: Imports-Replaced.diff
File Imports-Replaced.diff, 55.5 KB (added by humitos, 12 years ago) |
---|
-
button.py
diff --git a/button.py b/button.py index 66cf80b..2408bfa 100644
a b 1 import gobject2 import gtk1 from gi.repository import GObject 2 from gi.repository import Gtk 3 3 from gettext import gettext as _ 4 4 5 from sugar .graphics.palette import Palette6 from sugar .graphics.tray import TrayButton5 from sugar3.graphics.palette import Palette 6 from sugar3.graphics.tray import TrayButton 7 7 import constants 8 8 import utils 9 9 10 10 class RecdButton(TrayButton): 11 11 __gsignals__ = { 12 'remove-requested': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),13 'copy-clipboard-requested': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),12 'remove-requested': (GObject.SignalFlags.RUN_LAST, None, ()), 13 'copy-clipboard-requested': (GObject.SignalFlags.RUN_LAST, None, ()), 14 14 } 15 15 16 16 def __init__(self, recd): … … class RecdButton(TrayButton): 23 23 palette = Palette(recd.title) 24 24 self.set_palette(palette) 25 25 26 self._rem_menu_item = gtk.MenuItem(_('Remove'))26 self._rem_menu_item = Gtk.MenuItem(_('Remove')) 27 27 self._rem_menu_item_handler = self._rem_menu_item.connect('activate', self._remove_clicked) 28 28 palette.menu.append(self._rem_menu_item) 29 29 self._rem_menu_item.show() … … class RecdButton(TrayButton): 34 34 if self._recd.buddy and not self._recd.downloadedFromBuddy: 35 35 return 36 36 37 self._copy_menu_item = gtk.MenuItem(_('Copy to clipboard'))37 self._copy_menu_item = Gtk.MenuItem(_('Copy to clipboard')) 38 38 self._copy_menu_item_handler = self._copy_menu_item.connect('activate', self._copy_clipboard_clicked) 39 39 self.get_palette().menu.append(self._copy_menu_item) 40 40 self._copy_menu_item.show() … … class RecdButton(TrayButton): 43 43 return self._recd 44 44 45 45 def get_image(self): 46 img = gtk.Image()46 img = Gtk.Image() 47 47 ipb = self._recd.getThumbPixbuf() 48 48 if self._recd.type == constants.TYPE_PHOTO: 49 49 path = 'object-photo.svg' … … class RecdButton(TrayButton): 54 54 55 55 pixbuf = utils.load_colored_svg(path, self._recd.colorStroke, self._recd.colorFill) 56 56 if ipb: 57 ipb.composite(pixbuf, 8, 8, ipb.get_width(), ipb.get_height(), 8, 8, 1, 1, gtk.gdk.INTERP_BILINEAR, 255)57 ipb.composite(pixbuf, 8, 8, ipb.get_width(), ipb.get_height(), 8, 8, 1, 1, GdkPixbuf.InterpType.BILINEAR, 255) 58 58 img.set_from_pixbuf(pixbuf) 59 59 img.show() 60 60 return img -
collab.py
diff --git a/collab.py b/collab.py index 34a0c21..0a64026 100644
a b import logging 2 2 import xml.dom.minidom 3 3 import os 4 4 5 import gobject5 from gi.repository import GObject 6 6 import telepathy 7 7 import telepathy.client 8 8 9 from sugar .presence import presenceservice10 from sugar .presence.tubeconn import TubeConnection11 from sugar import util9 from sugar3.presence import presenceservice 10 from sugar3.presence.tubeconn import TubeConnection 11 from sugar3 import util 12 12 13 13 import utils 14 14 import serialize … … class RecordCollab(object): 152 152 recd.meshDownloading = True 153 153 recd.meshDownlodingPercent = 0.0 154 154 self.activity.update_download_progress(recd) 155 recd.meshReqCallbackId = gobject.timeout_add(self._collab_timeout, self._check_recd_request, recd)155 recd.meshReqCallbackId = GObject.timeout_add(self._collab_timeout, self._check_recd_request, recd) 156 156 self._tube.requestRecdBits(Instance.keyHashPrintable, sender, recd.mediaMd5) 157 157 158 158 def _next_round_robin_buddy(self, recd): 159 159 logger.debug('meshNextRoundRobinBuddy') 160 160 if recd.meshReqCallbackId: 161 gobject.source_remove(recd.meshReqCallbackId)161 GObject.source_remove(recd.meshReqCallbackId) 162 162 recd.meshReqCallbackId = 0 163 163 164 164 # delete any stub of a partially downloaded file … … class RecordCollab(object): 233 233 if recd.downloadedFromBuddy: 234 234 logger.debug('_meshCheckOnRecdRequest: recdRequesting.downloadedFromBuddy') 235 235 if recd.meshReqCallbackId: 236 gobject.source_remove(recd.meshReqCallbackId)236 GObject.source_remove(recd.meshReqCallbackId) 237 237 recd.meshReqCallbackId = 0 238 238 return False 239 239 if recd.deleted: 240 240 logger.debug('_meshCheckOnRecdRequest: recdRequesting.deleted') 241 241 if recd.meshReqCallbackId: 242 gobject.source_remove(recd.meshReqCallbackId)242 GObject.source_remove(recd.meshReqCallbackId) 243 243 recd.meshReqCallbackId = 0 244 244 return False 245 245 if recd.meshDownloadingProgress: … … class RecordCollab(object): 251 251 logger.debug('_meshCheckOnRecdRequest: ! recdRequesting.meshDownloadingProgress') 252 252 #that buddy we asked info from isn't responding; next buddy! 253 253 #self.meshNextRoundRobinBuddy( recdRequesting ) 254 gobject.idle_add(self._next_round_robin_buddy, recd)254 GObject.idle_add(self._next_round_robin_buddy, recd) 255 255 return False 256 256 257 257 def _recd_bits_arrived_cb(self, remote_object, md5sum, part, num_parts, bytes, sender): … … class RecordCollab(object): 273 273 return 274 274 275 275 #update that we've heard back about this, reset the timeout 276 gobject.source_remove(recd.meshReqCallbackId)277 recd.meshReqCallbackId = gobject.timeout_add(self._collab_timeout, self._check_recd_request, recd)276 GObject.source_remove(recd.meshReqCallbackId) 277 recd.meshReqCallbackId = GObject.timeout_add(self._collab_timeout, self._check_recd_request, recd) 278 278 279 279 #update the progress bar 280 280 recd.meshDownlodingPercent = (part+0.0)/(num_parts+0.0) … … class RecordCollab(object): 289 289 return 290 290 291 291 logger.debug('Finished receiving %s' % recd.title) 292 gobject.source_remove(recd.meshReqCallbackId)292 GObject.source_remove(recd.meshReqCallbackId) 293 293 recd.meshReqCallbackId = 0 294 294 recd.meshDownloading = False 295 295 recd.meshDownlodingPercent = 1.0 -
constants.py
diff --git a/constants.py b/constants.py index 2e0f54c..3b09683 100644
a b 2 2 import os 3 3 from gettext import gettext as _ 4 4 5 from sugar .activity import activity5 from sugar3.activity import activity 6 6 7 7 MODE_PHOTO = 0 8 8 MODE_VIDEO = 1 -
glive.py
diff --git a/glive.py b/glive.py index 8618284..d380428 100644
a b import os 22 22 from gettext import gettext as _ 23 23 import time 24 24 25 import gtk25 from gi.repository import Gtk 26 26 import gst 27 27 import pygst 28 28 pygst.require('0.10') 29 import gobject30 gobject.threads_init()29 from gi.repository import GObject 30 GObject.threads_init() 31 31 32 from sugar .activity.activity import get_bundle_path32 from sugar3.activity.activity import get_bundle_path 33 33 import logging 34 34 35 35 from instance import Instance … … class Glive: 379 379 audioBus = audioline.get_bus() 380 380 audioBus.add_signal_watch() 381 381 self._audio_transcode_handler = audioBus.connect('message', self._onMuxedAudioMessageCb, audioline) 382 self._transcode_id = gobject.timeout_add(200, self._transcodeUpdateCb, audioline)382 self._transcode_id = GObject.timeout_add(200, self._transcodeUpdateCb, audioline) 383 383 audioline.set_state(gst.STATE_PLAYING) 384 384 385 385 def _get_tags(self, type): … … class Glive: 421 421 self._pipeline.remove(self._photobin) 422 422 423 423 self._pic_exposure_open = False 424 pic = gtk.gdk.pixbuf_loader_new_with_mime_type("image/jpeg")424 pic = GdkPixbuf.Pixbuf.loader_new_with_mime_type("image/jpeg") 425 425 pic.write( buffer ) 426 426 pic.close() 427 427 pixBuf = pic.get_pixbuf() … … class Glive: 516 516 return 517 517 518 518 self._thumb_exposure_open = False 519 loader = gtk.gdk.pixbuf_loader_new_with_mime_type("image/jpeg")519 loader = GdkPixbuf.Pixbuf.loader_new_with_mime_type("image/jpeg") 520 520 loader.write(buffer) 521 521 loader.close() 522 522 self.thumbBuf = loader.get_pixbuf() … … class Glive: 538 538 self._video_transcode_handler = muxBus.connect('message', self._onMuxedVideoMessageCb, muxline) 539 539 self._mux_pipes.append(muxline) 540 540 #add a listener here to monitor % of transcoding... 541 self._transcode_id = gobject.timeout_add(200, self._transcodeUpdateCb, muxline)541 self._transcode_id = GObject.timeout_add(200, self._transcodeUpdateCb, muxline) 542 542 muxline.set_state(gst.STATE_PLAYING) 543 543 544 544 def _transcodeUpdateCb( self, pipe ): … … class Glive: 566 566 if message.type != gst.MESSAGE_EOS: 567 567 return True 568 568 569 gobject.source_remove(self._video_transcode_handler)569 GObject.source_remove(self._video_transcode_handler) 570 570 self._video_transcode_handler = None 571 gobject.source_remove(self._transcode_id)571 GObject.source_remove(self._transcode_id) 572 572 self._transcode_id = None 573 573 pipe.set_state(gst.STATE_NULL) 574 574 pipe.get_bus().remove_signal_watch() … … class Glive: 586 586 if message.type != gst.MESSAGE_EOS: 587 587 return True 588 588 589 gobject.source_remove(self._audio_transcode_handler)589 GObject.source_remove(self._audio_transcode_handler) 590 590 self._audio_transcode_handler = None 591 gobject.source_remove(self._transcode_id)591 GObject.source_remove(self._transcode_id) 592 592 self._transcode_id = None 593 593 pipe.set_state(gst.STATE_NULL) 594 594 pipe.get_bus().remove_signal_watch() … … class Glive: 617 617 self.stop() 618 618 619 619 if self._audio_transcode_handler: 620 gobject.source_remove(self._audio_transcode_handler)620 GObject.source_remove(self._audio_transcode_handler) 621 621 self._audio_transcode_handler = None 622 622 if self._transcode_id: 623 gobject.source_remove(self._transcode_id)623 GObject.source_remove(self._transcode_id) 624 624 self._transcode_id = None 625 625 if self._video_transcode_handler: 626 gobject.source_remove(self._video_transcode_handler)626 GObject.source_remove(self._video_transcode_handler) 627 627 self._video_transcode_handler = None 628 628 629 629 wav_path = os.path.join(Instance.instancePath, "output.wav") -
gplay.py
diff --git a/gplay.py b/gplay.py index 168fb22..acd8e7f 100644
a b 18 18 #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 19 #THE SOFTWARE. 20 20 21 import gobject22 gobject.threads_init()21 from gi.repository import GObject 22 GObject.threads_init() 23 23 import pygst 24 24 pygst.require('0.10') 25 25 import gst … … import gst 27 27 import logging 28 28 logger = logging.getLogger('record:gplay.py') 29 29 30 class Gplay( gobject.GObject):30 class Gplay(GObject.GObject): 31 31 __gsignals__ = { 32 'playback-status-changed': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_FLOAT)),32 'playback-status-changed': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_INT, GObject.TYPE_FLOAT)), 33 33 } 34 34 35 35 def __init__(self, activity_obj): … … class Gplay(gobject.GObject): 86 86 self._player.set_state(gst.STATE_PLAYING) 87 87 self._emit_playback_status(0) 88 88 89 self._playback_monitor_handler = gobject.timeout_add(500, self._playback_monitor)89 self._playback_monitor_handler = GObject.timeout_add(500, self._playback_monitor) 90 90 91 91 def _playback_monitor(self): 92 92 try: … … class Gplay(gobject.GObject): 108 108 109 109 def stop(self): 110 110 if self._playback_monitor_handler: 111 gobject.source_remove(self._playback_monitor_handler)111 GObject.source_remove(self._playback_monitor_handler) 112 112 self._playback_monitor_handler = None 113 113 114 114 self._player.set_state(gst.STATE_NULL) -
iconcombobox.py
diff --git a/iconcombobox.py b/iconcombobox.py index d5eb807..c7e508c 100644
a b 18 18 #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 19 #THE SOFTWARE. 20 20 21 import gtk21 from gi.repository import Gtk 22 22 23 from sugar .graphics.combobox import ComboBox24 from sugar .graphics import style23 from sugar3.graphics.combobox import ComboBox 24 from sugar3.graphics import style 25 25 26 26 27 class IconComboBox( gtk.ToolItem):27 class IconComboBox(Gtk.ToolItem): 28 28 def __init__(self, icon_name, **kwargs): 29 gtk.ToolItem.__init__(self, **kwargs)29 GObject.GObject.__init__(self, **kwargs) 30 30 31 31 self.icon_name = icon_name 32 32 self.set_border_width(style.DEFAULT_PADDING) -
instance.py
diff --git a/instance.py b/instance.py index bcee466..259bc2d 100644
a b 1 1 import os 2 2 3 from sugar import profile4 from sugar import util3 from sugar3 import profile 4 from sugar3 import util 5 5 6 6 class Instance: 7 7 key = profile.get_pubkey() -
mediaview.py
diff --git a/mediaview.py b/mediaview.py index 01567ff..4128132 100644
a b 1 1 import os 2 2 from gettext import gettext as _ 3 3 4 import gobject5 import gtk6 from g tk import gdk4 from gi.repository import GObject 5 from gi.repository import Gtk 6 from gi.repository import Gdk 7 7 8 8 import constants 9 9 import utils 10 10 11 COLOR_BLACK = gdk.color_parse('#000000')12 COLOR_WHITE = gdk.color_parse('#ffffff')13 COLOR_GREY = gdk.color_parse('#808080')11 COLOR_BLACK = Gdk.color_parse('#000000') 12 COLOR_WHITE = Gdk.color_parse('#ffffff') 13 COLOR_GREY = Gdk.color_parse('#808080') 14 14 15 class XoIcon( gtk.Image):15 class XoIcon(Gtk.Image): 16 16 def __init__(self): 17 17 super(XoIcon, self).__init__() 18 18 … … class XoIcon(gtk.Image): 21 21 self.set_from_pixbuf(pixbuf) 22 22 23 23 24 class InfoView( gtk.EventBox):24 class InfoView(Gtk.EventBox): 25 25 """ 26 26 A metadata view/edit widget, that presents a primary view area in the top 27 27 right and a secondary view area in the bottom left. 28 28 """ 29 29 __gsignals__ = { 30 'primary-allocated': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),31 'secondary-allocated': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),32 'tags-changed': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT,)),30 'primary-allocated': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_PYOBJECT,)), 31 'secondary-allocated': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_PYOBJECT,)), 32 'tags-changed': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_OBJECT,)), 33 33 } 34 34 35 35 def __init__(self): 36 36 super(InfoView, self).__init__() 37 self.modify_bg( gtk.STATE_NORMAL, COLOR_GREY)37 self.modify_bg(Gtk.StateType.NORMAL, COLOR_GREY) 38 38 39 39 self.connect('size-allocate', self._size_allocate) 40 40 41 self._outer_vbox = gtk.VBox(spacing=7)41 self._outer_vbox = Gtk.VBox(spacing=7) 42 42 self.add(self._outer_vbox) 43 43 44 hbox = gtk.HBox()44 hbox = Gtk.HBox() 45 45 self._outer_vbox.pack_start(hbox, expand=True, fill=True) 46 46 47 inner_vbox = gtk.VBox(spacing=5)47 inner_vbox = Gtk.VBox(spacing=5) 48 48 hbox.pack_start(inner_vbox, expand=True, fill=True, padding=6) 49 49 50 author_hbox = gtk.HBox()51 inner_vbox.pack_start(author_hbox, expand=False)50 author_hbox = Gtk.HBox() 51 inner_vbox.pack_start(author_hbox, False, True, 0) 52 52 53 label = gtk.Label()53 label = Gtk.Label() 54 54 label.set_markup('<b>' + _('Author:') + '</b>') 55 author_hbox.pack_start(label, expand=False)55 author_hbox.pack_start(label, False, True, 0) 56 56 57 57 self._xo_icon = XoIcon() 58 author_hbox.pack_start(self._xo_icon, expand=False)58 author_hbox.pack_start(self._xo_icon, False, True, 0) 59 59 60 self._author_label = gtk.Label()61 author_hbox.pack_start(self._author_label, expand=False)60 self._author_label = Gtk.Label() 61 author_hbox.pack_start(self._author_label, False, True, 0) 62 62 63 self._date_label = gtk.Label()63 self._date_label = Gtk.Label() 64 64 self._date_label.set_line_wrap(True) 65 alignment = gtk.Alignment(0.0, 0.5, 0.0, 0.0)65 alignment = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) 66 66 alignment.add(self._date_label) 67 inner_vbox.pack_start(alignment, expand=False)67 inner_vbox.pack_start(alignment, False, True, 0) 68 68 69 label = gtk.Label()69 label = Gtk.Label() 70 70 label.set_markup('<b>' + _('Tags:') + '</b>') 71 alignment = gtk.Alignment(0.0, 0.5, 0.0, 0.0)71 alignment = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) 72 72 alignment.add(label) 73 inner_vbox.pack_start(alignment, expand=False)73 inner_vbox.pack_start(alignment, False, True, 0) 74 74 75 textview = gtk.TextView()75 textview = Gtk.TextView() 76 76 self._tags_buffer = textview.get_buffer() 77 77 self._tags_buffer.connect('changed', self._tags_changed) 78 78 inner_vbox.pack_start(textview, expand=True, fill=True) 79 79 80 80 # the main viewing widget will be painted exactly on top of this one 81 alignment = gtk.Alignment(1.0, 0.0, 0.0, 0.0)82 self._view_bg = gtk.EventBox()83 self._view_bg.modify_bg( gtk.STATE_NORMAL, COLOR_BLACK)81 alignment = Gtk.Alignment.new(1.0, 0.0, 0.0, 0.0) 82 self._view_bg = Gtk.EventBox() 83 self._view_bg.modify_bg(Gtk.StateType.NORMAL, COLOR_BLACK) 84 84 alignment.add(self._view_bg) 85 hbox.pack_start(alignment, expand=False)85 hbox.pack_start(alignment, False, True, 0) 86 86 87 87 # the secondary viewing widget will be painted exactly on top of this one 88 alignment = gtk.Alignment(0.0, 1.0, 0.0, 0.0)89 self._live_bg = gtk.EventBox()90 self._live_bg.modify_bg( gtk.STATE_NORMAL, COLOR_BLACK)88 alignment = Gtk.Alignment.new(0.0, 1.0, 0.0, 0.0) 89 self._live_bg = Gtk.EventBox() 90 self._live_bg.modify_bg(Gtk.StateType.NORMAL, COLOR_BLACK) 91 91 alignment.add(self._live_bg) 92 self._outer_vbox.pack_start(alignment, expand=False)92 self._outer_vbox.pack_start(alignment, False, True, 0) 93 93 94 94 def fit_to_allocation(self, allocation): 95 95 # main viewing area: 50% of each dimension … … class InfoView(gtk.EventBox): 127 127 def _tags_changed(self, widget): 128 128 self.emit('tags-changed', widget) 129 129 130 class VideoBox( gtk.EventBox):130 class VideoBox(Gtk.EventBox): 131 131 """ 132 132 A widget with its own window for rendering a gstreamer video sink onto. 133 133 """ 134 134 def __init__(self): 135 135 super(VideoBox, self).__init__() 136 self.unset_flags( gtk.DOUBLE_BUFFERED)137 self.set_flags( gtk.APP_PAINTABLE)136 self.unset_flags(Gtk.DOUBLE_BUFFERED) 137 self.set_flags(Gtk.APP_PAINTABLE) 138 138 self._sink = None 139 139 self._xid = None 140 140 self.connect('realize', self._realize) … … class VideoBox(gtk.EventBox): 154 154 self._sink = sink 155 155 sink.set_xwindow_id(self._xid) 156 156 157 class FullscreenButton( gtk.EventBox):157 class FullscreenButton(Gtk.EventBox): 158 158 def __init__(self): 159 159 super(FullscreenButton, self).__init__() 160 160 161 161 path = os.path.join(constants.GFX_PATH, 'max-reduce.svg') 162 self._enlarge_pixbuf = gdk.pixbuf_new_from_file(path)162 self._enlarge_pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) 163 163 self.width = self._enlarge_pixbuf.get_width() 164 164 self.height = self._enlarge_pixbuf.get_height() 165 165 166 166 path = os.path.join(constants.GFX_PATH, 'max-enlarge.svg') 167 self._reduce_pixbuf = gdk.pixbuf_new_from_file_at_size(path, self.width, self.height)167 self._reduce_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(path, self.width, self.height) 168 168 169 self._image = gtk.Image()169 self._image = Gtk.Image() 170 170 self.set_enlarge() 171 171 self._image.show() 172 172 self.add(self._image) … … class FullscreenButton(gtk.EventBox): 178 178 self._image.set_from_pixbuf(self._reduce_pixbuf) 179 179 180 180 181 class InfoButton( gtk.EventBox):181 class InfoButton(Gtk.EventBox): 182 182 def __init__(self): 183 183 super(InfoButton, self).__init__() 184 184 185 185 path = os.path.join(constants.GFX_PATH, 'corner-info.svg') 186 pixbuf = gdk.pixbuf_new_from_file(path)186 pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) 187 187 self.width = pixbuf.get_width() 188 188 self.height = pixbuf.get_height() 189 189 190 self._image = gtk.image_new_from_pixbuf(pixbuf)190 self._image = Gtk.image_new_from_pixbuf(pixbuf) 191 191 self._image.show() 192 192 self.add(self._image) 193 193 194 194 195 class ImageBox( gtk.EventBox):195 class ImageBox(Gtk.EventBox): 196 196 def __init__(self): 197 197 super(ImageBox, self).__init__() 198 198 self._pixbuf = None 199 self._image = gtk.Image()199 self._image = Gtk.Image() 200 200 self.add(self._image) 201 201 202 202 def show(self): … … class ImageBox(gtk.EventBox): 219 219 if width == self._pixbuf.get_width() and height == self._pixbuf.get_height(): 220 220 pixbuf = self._pixbuf 221 221 else: 222 pixbuf = self._pixbuf.scale_simple(width, height, gdk.INTERP_BILINEAR)222 pixbuf = self._pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR) 223 223 224 224 self._image.set_from_pixbuf(pixbuf) 225 225 226 226 self._image.set_size_request(width, height) 227 227 self.set_size_request(width, height) 228 228 229 class MediaView( gtk.EventBox):229 class MediaView(Gtk.EventBox): 230 230 """ 231 231 A widget to show the main record UI with a video feed, but with some 232 232 extra features: possibility to show images, information UI about media, … … class MediaView(gtk.EventBox): 240 240 """ 241 241 __gtype_name__ = "MediaView" 242 242 __gsignals__ = { 243 'media-clicked': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),244 'pip-clicked': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),245 'full-clicked': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),246 'info-clicked': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),247 'tags-changed': ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT,)),243 'media-clicked': (GObject.SignalFlags.RUN_LAST, None, ()), 244 'pip-clicked': (GObject.SignalFlags.RUN_LAST, None, ()), 245 'full-clicked': (GObject.SignalFlags.RUN_LAST, None, ()), 246 'info-clicked': (GObject.SignalFlags.RUN_LAST, None, ()), 247 'tags-changed': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_OBJECT,)), 248 248 } 249 249 250 250 MODE_LIVE = 0 … … class MediaView(gtk.EventBox): 268 268 super(MediaView, self).__init__() 269 269 self.connect('size-allocate', self._size_allocate) 270 270 self.connect('motion-notify-event', self._motion_notify) 271 self.set_events( gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK)271 self.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK) 272 272 273 self._fixed = gtk.Fixed()273 self._fixed = Gtk.Fixed() 274 274 self.add(self._fixed) 275 275 276 276 self._info_view = InfoView() … … class MediaView(gtk.EventBox): 314 314 def _motion_notify(self, widget, event): 315 315 if self._hide_controls_timer: 316 316 # remove timer, it will be reprogrammed right after 317 gobject.source_remove(self._hide_controls_timer)317 GObject.source_remove(self._hide_controls_timer) 318 318 else: 319 319 self._show_controls() 320 320 321 self._hide_controls_timer = gobject.timeout_add(2000, self._hide_controls)321 self._hide_controls_timer = GObject.timeout_add(2000, self._hide_controls) 322 322 323 323 def _show_controls(self): 324 324 if self._mode in (MediaView.MODE_LIVE, MediaView.MODE_VIDEO, MediaView.MODE_PHOTO, MediaView.MODE_STILL): … … class MediaView(gtk.EventBox): 332 332 333 333 def _hide_controls(self): 334 334 if self._hide_controls_timer: 335 gobject.source_remove(self._hide_controls_timer)335 GObject.source_remove(self._hide_controls_timer) 336 336 self._hide_controls_timer = None 337 337 338 338 self._full_button.hide() … … class MediaView(gtk.EventBox): 430 430 self._mode = new_mode 431 431 432 432 if self._hide_controls_timer: 433 gobject.source_remove(self._hide_controls_timer)433 GObject.source_remove(self._hide_controls_timer) 434 434 self._hide_controls_timer = None 435 435 436 436 if self._allocation: … … class MediaView(gtk.EventBox): 466 466 467 467 def set_fullscreen(self, fullscreen): 468 468 if self._hide_controls_timer: 469 gobject.source_remove(self._hide_controls_timer)469 GObject.source_remove(self._hide_controls_timer) 470 470 self._hide_controls_timer = None 471 471 472 472 if fullscreen: … … class MediaView(gtk.EventBox): 495 495 496 496 def show_photo(self, path): 497 497 if path: 498 pixbuf = gdk.pixbuf_new_from_file(path)498 pixbuf = GdkPixbuf.Pixbuf.new_from_file(path) 499 499 self._image_box.set_pixbuf(pixbuf) 500 500 self._switch_mode(MediaView.MODE_PHOTO) 501 501 -
model.py
diff --git a/model.py b/model.py index 1af2487..7390763 100644
a b import os 27 27 import time 28 28 import json 29 29 30 import gobject30 from gi.repository import GObject 31 31 import gst 32 32 33 import sugar .profile34 import sugar .env33 import sugar3.profile 34 import sugar3.env 35 35 36 36 import aplay 37 37 import constants … … class Model: 99 99 return self.glive.get_has_camera() 100 100 101 101 def get_nickname(self): 102 return sugar .profile.get_nick_name()102 return sugar3.profile.get_nick_name() 103 103 104 104 def get_mode(self): 105 105 return self._mode … … class Model: 131 131 return 132 132 133 133 if self._countdown_handle: 134 gobject.source_remove(self._countdown_handle)134 GObject.source_remove(self._countdown_handle) 135 135 self._countdown_handle = None 136 136 self._countdown_value = 0 137 137 self.activity.set_countdown(0) … … class Model: 202 202 self.set_progress(0, '') 203 203 self._timer_value = self.activity.get_selected_duration() 204 204 self._timer_duration = self._timer_value 205 self._timer_handle = gobject.timeout_add(1000, self._timer_tick)205 self._timer_handle = GObject.timeout_add(1000, self._timer_tick) 206 206 207 207 self.activity.set_shutter_sensitive(True) 208 208 self.set_state(constants.STATE_RECORDING) … … class Model: 215 215 216 216 def _stop_media_capture(self): 217 217 if self._timer_handle: 218 gobject.source_remove(self._timer_handle)218 GObject.source_remove(self._timer_handle) 219 219 self._timer_handle = None 220 220 self._timer_value = 0 221 221 … … class Model: 255 255 if timer > 0: 256 256 self.activity.set_shutter_sensitive(False) 257 257 self._countdown_value = self.activity.get_selected_timer() 258 self._countdown_handle = gobject.timeout_add(1000, self._countdown_tick)258 self._countdown_handle = GObject.timeout_add(1000, self._countdown_tick) 259 259 return 260 260 261 261 # otherwise, capture normally … … class Model: 263 263 264 264 # called from gstreamer thread 265 265 def still_ready(self, pixbuf): 266 gobject.idle_add(self.activity.show_still, pixbuf)266 GObject.idle_add(self.activity.show_still, pixbuf) 267 267 268 268 def add_recd(self, recd): 269 269 self.mediaHashs[recd.type].append(recd) … … class Model: 286 286 #now that we've saved both the image and its pixbuf, we get their md5s 287 287 self.createNewRecordedMd5Sums( recd ) 288 288 289 gobject.idle_add(self.add_recd, recd, priority=gobject.PRIORITY_HIGH)290 gobject.idle_add(self.activity.set_shutter_sensitive, True, priority=gobject.PRIORITY_HIGH)289 GObject.idle_add(self.add_recd, recd, priority=GObject.PRIORITY_HIGH) 290 GObject.idle_add(self.activity.set_shutter_sensitive, True, priority=GObject.PRIORITY_HIGH) 291 291 292 292 # called from gstreamer thread 293 293 def save_video(self, path, still): … … class Model: 299 299 300 300 self.createNewRecordedMd5Sums( recd ) 301 301 302 gobject.idle_add(self.add_recd, recd, priority=gobject.PRIORITY_HIGH)303 gobject.idle_add(self.set_state, constants.STATE_READY)302 GObject.idle_add(self.add_recd, recd, priority=GObject.PRIORITY_HIGH) 303 GObject.idle_add(self.set_state, constants.STATE_READY) 304 304 305 305 def save_audio(self, path, still): 306 306 recd = self.createNewRecorded(constants.TYPE_AUDIO) … … class Model: 317 317 318 318 self.createNewRecordedMd5Sums( recd ) 319 319 320 gobject.idle_add(self.add_recd, recd, priority=gobject.PRIORITY_HIGH)321 gobject.idle_add(self.set_state, constants.STATE_READY)320 GObject.idle_add(self.add_recd, recd, priority=GObject.PRIORITY_HIGH) 321 GObject.idle_add(self.set_state, constants.STATE_READY) 322 322 323 323 def _playback_status_changed(self, widget, status, value): 324 324 self.activity.set_playback_scale(value) … … class Model: 386 386 recd.title = _('%(type)s by %(name)s') % {'type': stringType, 387 387 'name': recd.recorderName} 388 388 389 color = sugar .profile.get_color()389 color = sugar3.profile.get_color() 390 390 recd.colorStroke = color.get_stroke_color() 391 391 recd.colorFill = color.get_fill_color() 392 392 -
record.py
diff --git a/record.py b/record.py index 5c06f20..3c032f8 100644
a b import shutil 24 24 from gettext import gettext as _ 25 25 from gettext import ngettext 26 26 27 import gtk28 from g tk import gdk27 from gi.repository import Gtk 28 from gi.repository import Gdk 29 29 import cairo 30 import pango30 from gi.repository import Pango 31 31 import pangocairo 32 32 import pygst 33 33 pygst.require('0.10') 34 34 import gst 35 35 36 from sugar .activity import activity37 from sugar .graphics.toolcombobox import ToolComboBox38 from sugar .graphics.toolbarbox import ToolbarBox39 from sugar .graphics.toolbarbox import ToolbarButton40 from sugar .graphics.radiotoolbutton import RadioToolButton41 from sugar .activity.widgets import StopButton42 from sugar .activity.widgets import ActivityToolbarButton36 from sugar3.activity import activity 37 from sugar3.graphics.toolcombobox import ToolComboBox 38 from sugar3.graphics.toolbarbox import ToolbarBox 39 from sugar3.graphics.toolbarbox import ToolbarButton 40 from sugar3.graphics.radiotoolbutton import RadioToolButton 41 from sugar3.activity.widgets import StopButton 42 from sugar3.activity.widgets import ActivityToolbarButton 43 43 44 44 from model import Model 45 45 from button import RecdButton … … import hw 52 52 from iconcombobox import IconComboBox 53 53 54 54 logger = logging.getLogger('record.py') 55 COLOR_BLACK = gdk.color_parse('#000000')56 COLOR_WHITE = gdk.color_parse('#ffffff')55 COLOR_BLACK = Gdk.color_parse('#000000') 56 COLOR_WHITE = Gdk.color_parse('#ffffff') 57 57 58 58 gst.debug_set_active(True) 59 59 gst.debug_set_colored(False) … … class Record(activity.Activity): 68 68 self.props.enable_fullscreen_mode = False 69 69 Instance(self) 70 70 71 self.add_events( gtk.gdk.VISIBILITY_NOTIFY_MASK)71 self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK) 72 72 self.connect("visibility-notify-event", self._visibility_changed) 73 73 74 74 #the main classes … … class Record(activity.Activity): 105 105 super(Record, self).close() 106 106 107 107 def _visibility_changed(self, widget, event): 108 self.model.set_visible(event. state != gtk.gdk.VISIBILITY_FULLY_OBSCURED)108 self.model.set_visible(event.get_state() != Gdk.VisibilityState.FULLY_OBSCURED) 109 109 110 110 def _shared_cb(self, activity): 111 111 self.model.collab.set_activity_shared() … … class Record(activity.Activity): 161 161 self._audio_button.connect('clicked', self._mode_button_clicked) 162 162 self._toolbar.insert(self._audio_button, -1) 163 163 164 self._toolbar.insert( gtk.SeparatorToolItem(), -1)164 self._toolbar.insert(Gtk.SeparatorToolItem(), -1) 165 165 166 166 self._toolbar_controls = RecordControl(self._toolbar) 167 167 168 separator = gtk.SeparatorToolItem()168 separator = Gtk.SeparatorToolItem() 169 169 separator.props.draw = False 170 170 separator.set_expand(True) 171 171 self._toolbar.insert(separator, -1) 172 172 self._toolbar.insert(StopButton(self), -1) 173 173 self.get_toolbar_box().show_all() 174 174 175 main_box = gtk.VBox()175 main_box = Gtk.VBox() 176 176 self.set_canvas(main_box) 177 main_box.get_parent().modify_bg( gtk.STATE_NORMAL, COLOR_BLACK)177 main_box.get_parent().modify_bg(Gtk.StateType.NORMAL, COLOR_BLACK) 178 178 main_box.show() 179 179 180 180 self._media_view = MediaView() … … class Record(activity.Activity): 185 185 self._media_view.connect('tags-changed', self._media_view_tags_changed) 186 186 self._media_view.show() 187 187 188 self._controls_hbox = gtk.HBox()188 self._controls_hbox = Gtk.HBox() 189 189 self._controls_hbox.show() 190 190 191 191 self._shutter_button = ShutterButton() … … class Record(activity.Activity): 197 197 198 198 self._play_button = PlayButton() 199 199 self._play_button.connect('clicked', self._play_pause_clicked) 200 self._controls_hbox.pack_start(self._play_button, expand=False)200 self._controls_hbox.pack_start(self._play_button, False, True, 0) 201 201 202 202 self._playback_scale = PlaybackScale(self.model) 203 203 self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True) … … class Record(activity.Activity): 205 205 self._progress = ProgressInfo() 206 206 self._controls_hbox.pack_start(self._progress, expand=True, fill=True) 207 207 208 self._title_label = gtk.Label()208 self._title_label = Gtk.Label() 209 209 self._title_label.set_markup("<b><span foreground='white'>"+_('Title:')+'</span></b>') 210 self._controls_hbox.pack_start(self._title_label, expand=False)210 self._controls_hbox.pack_start(self._title_label, False, True, 0) 211 211 212 self._title_entry = gtk.Entry()213 self._title_entry.modify_bg( gtk.STATE_INSENSITIVE, COLOR_BLACK)212 self._title_entry = Gtk.Entry() 213 self._title_entry.modify_bg(Gtk.StateType.INSENSITIVE, COLOR_BLACK) 214 214 self._title_entry.connect('changed', self._title_changed) 215 215 self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10) 216 216 … … class Record(activity.Activity): 243 243 244 244 key = event.keyval 245 245 246 if key == gtk.keysyms.KP_Page_Up: # game key O246 if key == Gdk.KEY_KP_Page_Up: # game key O 247 247 if self._shutter_button.props.visible: 248 248 if self._shutter_button.props.sensitive: 249 249 self._shutter_button.clicked() 250 250 else: # return to live mode 251 251 self.model.set_state(constants.STATE_READY) 252 elif key == gtk.keysyms.c and event.state == gdk.CONTROL_MASK:252 elif key == Gdk.KEY_c and event.get_state() == Gdk.ModifierType.CONTROL_MASK: 253 253 self._copy_to_clipboard(self._active_recd) 254 elif key == gtk.keysyms.i:254 elif key == Gdk.KEY_i: 255 255 self._toggle_info() 256 elif key == gtk.keysyms.Escape:256 elif key == Gdk.KEY_Escape: 257 257 if self._fullscreen: 258 258 self._toggle_fullscreen() 259 259 … … class Record(activity.Activity): 377 377 self._play_button.hide() 378 378 self._playback_scale.hide() 379 379 self._progress.hide() 380 self._controls_hbox.set_child_packing(self._shutter_button, expand=True, fill=False, padding=0, pack_type= gtk.PACK_START)380 self._controls_hbox.set_child_packing(self._shutter_button, expand=True, fill=False, padding=0, pack_type=Gtk.PACK_START) 381 381 self._shutter_button.set_normal() 382 382 self._shutter_button.set_sensitive(True) 383 383 self._shutter_button.show() 384 384 self._media_view.show_live() 385 385 elif state == constants.STATE_RECORDING: 386 386 self._shutter_button.set_recording() 387 self._controls_hbox.set_child_packing(self._shutter_button, expand=False, fill=False, padding=0, pack_type= gtk.PACK_START)387 self._controls_hbox.set_child_packing(self._shutter_button, expand=False, fill=False, padding=0, pack_type=Gtk.PACK_START) 388 388 self._progress.show() 389 389 elif state == constants.STATE_PROCESSING: 390 390 self._set_cursor_busy() … … class Record(activity.Activity): 427 427 media_path = recd.getMediaFilepath() 428 428 tmp_path = utils.getUniqueFilepath(media_path, 0) 429 429 shutil.copyfile(media_path, tmp_path) 430 gtk.Clipboard().set_with_data([('text/uri-list', 0, 0)], self._clipboard_get, self._clipboard_clear, tmp_path)430 Gtk.Clipboard().set_with_data([('text/uri-list', 0, 0)], self._clipboard_get, self._clipboard_clear, tmp_path) 431 431 432 432 def _clipboard_get(self, clipboard, selection_data, info, path): 433 433 selection_data.set("text/uri-list", 8, "file://" + path) … … class Record(activity.Activity): 541 541 self.set_progress(recd.meshDownlodingPercent, msg) 542 542 543 543 def _set_cursor_busy(self): 544 self.window.set_cursor( gdk.Cursor(gdk.WATCH))544 self.window.set_cursor(Gdk.Cursor.new(Gdk.WATCH)) 545 545 546 546 def _set_cursor_default(self): 547 547 self.window.set_cursor(None) 548 548 549 class RecordContainer( gtk.Container):549 class RecordContainer(Gtk.Container): 550 550 """ 551 551 A custom Container that contains a media view area, and a controls hbox. 552 552 … … class RecordContainer(gtk.Container): 566 566 super(RecordContainer, self).__init__() 567 567 568 568 for widget in (self._media_view, self._controls_hbox): 569 if widget. flags() & gtk.REALIZED:569 if widget.get_realized(): 570 570 widget.set_parent_window(self.window) 571 571 572 572 widget.set_parent(self) 573 573 574 574 def do_realize(self): 575 self.set_flags( gtk.REALIZED)575 self.set_flags(Gtk.REALIZED) 576 576 577 self.window = gdk.Window(577 self.window = Gdk.Window( 578 578 self.get_parent_window(), 579 window_type= gdk.WINDOW_CHILD,579 window_type=Gdk.WINDOW_CHILD, 580 580 x=self.allocation.x, 581 581 y=self.allocation.y, 582 582 width=self.allocation.width, 583 583 height=self.allocation.height, 584 wclass= gdk.INPUT_OUTPUT,584 wclass=Gdk.INPUT_OUTPUT, 585 585 colormap=self.get_colormap(), 586 event_mask=self.get_events() | gdk.VISIBILITY_NOTIFY_MASK | gdk.EXPOSURE_MASK)586 event_mask=self.get_events() | Gdk.EventMask.VISIBILITY_NOTIFY_MASK | Gdk.EventMask.EXPOSURE_MASK) 587 587 self.window.set_user_data(self) 588 588 589 589 self.set_style(self.style.attach(self.window)) … … class RecordContainer(gtk.Container): 642 642 media_view_y = self._center_in_plane(remaining_height, media_view_height) 643 643 644 644 # send allocation to mediaview 645 alloc = gdk.Rectangle()645 alloc = () 646 646 alloc.width = media_view_width 647 647 alloc.height = media_view_height 648 648 alloc.x = media_view_x … … class RecordContainer(gtk.Container): 651 651 652 652 # position hbox at the bottom of the window, with the requested height, 653 653 # and the same width as the media view 654 alloc = gdk.Rectangle()654 alloc = () 655 655 alloc.x = media_view_x 656 656 alloc.y = self.allocation.height - self._controls_hbox_height 657 657 alloc.width = media_view_width 658 658 alloc.height = self._controls_hbox_height 659 659 self._controls_hbox.size_allocate(alloc) 660 660 661 if self. flags() & gtk.REALIZED:661 if self.get_realized(): 662 662 self.window.move_resize(*allocation) 663 663 664 664 def do_forall(self, include_internals, callback, data): 665 665 for widget in (self._media_view, self._controls_hbox): 666 666 callback(widget, data) 667 667 668 class PlaybackScale( gtk.HScale):668 class PlaybackScale(Gtk.HScale): 669 669 def __init__(self, model): 670 670 self.model = model 671 671 self._change_handler = None 672 self._playback_adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0)672 self._playback_adjustment = Gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0) 673 673 super(PlaybackScale, self).__init__(self._playback_adjustment) 674 674 675 675 self.set_draw_value(False) 676 self.set_update_policy( gtk.UPDATE_CONTINUOUS)676 self.set_update_policy(Gtk.UPDATE_CONTINUOUS) 677 677 self.connect('button-press-event', self._button_press) 678 678 self.connect('button-release-event', self._button_release) 679 679 … … class PlaybackScale(gtk.HScale): 693 693 self.model.end_seek() 694 694 695 695 696 class ProgressInfo( gtk.VBox):696 class ProgressInfo(Gtk.VBox): 697 697 def __init__(self): 698 698 super(ProgressInfo, self).__init__() 699 699 700 self._progress_bar = gtk.ProgressBar()701 self._progress_bar.modify_bg( gtk.STATE_NORMAL, COLOR_BLACK)702 self._progress_bar.modify_bg( gtk.STATE_INSENSITIVE, COLOR_BLACK)700 self._progress_bar = Gtk.ProgressBar() 701 self._progress_bar.modify_bg(Gtk.StateType.NORMAL, COLOR_BLACK) 702 self._progress_bar.modify_bg(Gtk.StateType.INSENSITIVE, COLOR_BLACK) 703 703 self.pack_start(self._progress_bar, expand=True, fill=True, padding=5) 704 704 705 self._label = gtk.Label()706 self._label.modify_fg( gtk.STATE_NORMAL, COLOR_WHITE)705 self._label = Gtk.Label() 706 self._label.modify_fg(Gtk.StateType.NORMAL, COLOR_WHITE) 707 707 self.pack_start(self._label, expand=True, fill=True) 708 708 709 709 def show(self): … … class ProgressInfo(gtk.VBox): 723 723 self._label.set_text(text) 724 724 725 725 726 class CountdownImage( gtk.Image):726 class CountdownImage(Gtk.Image): 727 727 def __init__(self): 728 728 super(CountdownImage, self).__init__() 729 729 self._countdown_images = {} … … class CountdownImage(gtk.Image): 731 731 def _generate_image(self, num): 732 732 w = 55 733 733 h = w 734 pixmap = gdk.Pixmap(self.get_window(), w, h, -1)734 pixmap = Gdk.Pixmap(self.get_window(), w, h, -1) 735 735 ctx = pixmap.cairo_create() 736 736 ctx.rectangle(0, 0, w, h) 737 737 ctx.set_source_rgb(0, 0, 0) … … class CountdownImage(gtk.Image): 749 749 ctx.set_source_rgb(255, 255, 255) 750 750 pctx = pangocairo.CairoContext(ctx) 751 751 play = pctx.create_layout() 752 font = pango.FontDescription("sans 30")752 font = Pango.FontDescription("sans 30") 753 753 play.set_font_description(font) 754 754 play.set_text(str(num)) 755 755 dim = play.get_pixel_extents() … … class CountdownImage(gtk.Image): 768 768 self.set_from_pixmap(self._countdown_images[num], None) 769 769 770 770 771 class ShutterButton( gtk.Button):771 class ShutterButton(Gtk.Button): 772 772 def __init__(self): 773 gtk.Button.__init__(self)774 self.set_relief( gtk.RELIEF_NONE)773 GObject.GObject.__init__(self) 774 self.set_relief(Gtk.ReliefStyle.NONE) 775 775 self.set_focus_on_click(False) 776 self.modify_bg( gtk.STATE_ACTIVE, COLOR_BLACK)776 self.modify_bg(Gtk.StateType.ACTIVE, COLOR_BLACK) 777 777 778 778 path = os.path.join(constants.GFX_PATH, 'media-record.png') 779 self._rec_image = gtk.image_new_from_file(path)779 self._rec_image = Gtk.image_new_from_file(path) 780 780 781 781 path = os.path.join(constants.GFX_PATH, 'media-record-red.png') 782 self._rec_red_image = gtk.image_new_from_file(path)782 self._rec_red_image = Gtk.image_new_from_file(path) 783 783 784 784 path = os.path.join(constants.GFX_PATH, 'media-insensitive.png') 785 self._insensitive_image = gtk.image_new_from_file(path)785 self._insensitive_image = Gtk.image_new_from_file(path) 786 786 787 787 self.set_normal() 788 788 … … class ShutterButton(gtk.Button): 800 800 self.set_image(self._rec_red_image) 801 801 802 802 803 class PlayButton( gtk.Button):803 class PlayButton(Gtk.Button): 804 804 def __init__(self): 805 805 super(PlayButton, self).__init__() 806 self.set_relief( gtk.RELIEF_NONE)806 self.set_relief(Gtk.ReliefStyle.NONE) 807 807 self.set_focus_on_click(False) 808 self.modify_bg( gtk.STATE_ACTIVE, COLOR_BLACK)808 self.modify_bg(Gtk.StateType.ACTIVE, COLOR_BLACK) 809 809 810 810 path = os.path.join(constants.GFX_PATH, 'media-play.png') 811 self._play_image = gtk.image_new_from_file(path)811 self._play_image = Gtk.image_new_from_file(path) 812 812 813 813 path = os.path.join(constants.GFX_PATH, 'media-pause.png') 814 self._pause_image = gtk.image_new_from_file(path)814 self._pause_image = Gtk.image_new_from_file(path) 815 815 816 816 self.set_play() 817 817 … … class RecordControl(): 831 831 self._duration_combo = DurationCombo() 832 832 toolbar.insert(self._duration_combo, -1) 833 833 834 preferences_toolbar = gtk.Toolbar()835 combo = gtk.combo_box_new_text()834 preferences_toolbar = Gtk.Toolbar() 835 combo = Gtk.ComboBoxText() 836 836 self.quality = ToolComboBox(combo=combo, label_text=_('Quality:')) 837 837 self.quality.combo.append_text(_('Low')) 838 838 if hw.get_xo_version() != 1: -
recorded.py
diff --git a/recorded.py b/recorded.py index 9296742..5ed4855 100644
a b 19 19 #THE SOFTWARE. 20 20 21 21 import os 22 import gtk22 from gi.repository import Gtk 23 23 24 24 import constants 25 25 from instance import Instance … … class Recorded: 107 107 def getThumbPixbuf( self ): 108 108 thumbFilepath = self.getThumbFilepath() 109 109 if thumbFilepath and os.path.isfile(thumbFilepath): 110 return gtk.gdk.pixbuf_new_from_file(thumbFilepath)110 return GdkPixbuf.Pixbuf.new_from_file(thumbFilepath) 111 111 else: 112 112 return None 113 113 … … class Recorded: 132 132 else: 133 133 audioFilepath = self.getAudioImageFilepath() 134 134 if (audioFilepath != None): 135 audioPixbuf = gtk.gdk.pixbuf_new_from_file(audioFilepath)135 audioPixbuf = GdkPixbuf.Pixbuf.new_from_file(audioFilepath) 136 136 137 137 return audioPixbuf 138 138 -
recordtube.py
diff --git a/recordtube.py b/recordtube.py index c2a60bb..7628e2c 100644
a b 1 1 import os 2 2 import logging 3 3 4 import gobject4 from gi.repository import GObject 5 5 from dbus.service import signal 6 6 from dbus.gobject_service import ExportedGObject 7 7 … … class RecordTube(ExportedGObject): 14 14 15 15 __gsignals__ = { 16 16 'recd-bits-arrived': 17 ( gobject.SIGNAL_RUN_FIRST, None, [object,object,object,object,object]),17 (GObject.SignalFlags.RUN_FIRST, None, [object,object,object,object,object]), 18 18 'recd-request': 19 ( gobject.SIGNAL_RUN_FIRST, None, [object,object]),19 (GObject.SignalFlags.RUN_FIRST, None, [object,object]), 20 20 'new-recd': 21 ( gobject.SIGNAL_RUN_FIRST, None, [object,object]),21 (GObject.SignalFlags.RUN_FIRST, None, [object,object]), 22 22 'recd-unavailable': 23 ( gobject.SIGNAL_RUN_FIRST, None, [object,object])23 (GObject.SignalFlags.RUN_FIRST, None, [object,object]) 24 24 } 25 25 26 26 -
serialize.py
diff --git a/serialize.py b/serialize.py index 687bbaa..1d28c6a 100644
a b 1 1 from xml.dom.minidom import getDOMImplementation 2 2 import cStringIO 3 3 import os 4 import gtk4 from gi.repository import Gtk 5 5 import logging 6 6 7 from sugar .datastore import datastore7 from sugar3.datastore import datastore 8 8 9 9 import constants 10 10 from instance import Instance … … def _saveMediaToDatastore(el, recd, activity): 264 264 datastorePreviewPixbuf = recd.getAudioImagePixbuf() 265 265 elif recd.type == constants.TYPE_PHOTO: 266 266 datastorePreviewFilepath = recd.getMediaFilepath() 267 datastorePreviewPixbuf = gtk.gdk.pixbuf_new_from_file(datastorePreviewFilepath)267 datastorePreviewPixbuf = GdkPixbuf.Pixbuf.new_from_file(datastorePreviewFilepath) 268 268 269 269 if datastorePreviewPixbuf: 270 270 datastorePreviewWidth = 300 271 271 datastorePreviewHeight = 225 272 272 if datastorePreviewPixbuf.get_width() != datastorePreviewWidth: 273 datastorePreviewPixbuf = datastorePreviewPixbuf.scale_simple(datastorePreviewWidth, datastorePreviewHeight, gtk.gdk.INTERP_NEAREST)273 datastorePreviewPixbuf = datastorePreviewPixbuf.scale_simple(datastorePreviewWidth, datastorePreviewHeight, GdkPixbuf.InterpType.NEAREST) 274 274 275 275 datastorePreviewBase64 = utils.getStringFromPixbuf(datastorePreviewPixbuf) 276 276 mediaObject.metadata['preview'] = datastorePreviewBase64 -
setup.py
diff --git a/setup.py b/setup.py index 876cd3f..95390a3 100755
a b 16 16 # along with this program; if not, write to the Free Software 17 17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 18 19 from sugar .activity import bundlebuilder19 from sugar3.activity import bundlebuilder 20 20 21 21 bundlebuilder.start() 22 22 -
tray.py
diff --git a/tray.py b/tray.py index 4f7956d..d171c3d 100644
a b 15 15 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 16 # Boston, MA 02111-1307, USA. 17 17 18 import gobject19 import gtk20 import hippo18 from gi.repository import GObject 19 from gi.repository import Gtk 20 from gi.repository import Hippo 21 21 22 import sugar 23 from sugar .graphics import style24 from sugar .graphics.icon import Icon22 import sugar3 23 from sugar3.graphics import style 24 from sugar3.graphics.icon import Icon 25 25 26 26 _PREVIOUS_PAGE = 0 27 27 _NEXT_PAGE = 1 28 28 29 class _TrayViewport( gtk.Viewport):29 class _TrayViewport(Gtk.Viewport): 30 30 __gproperties__ = { 31 31 'can-scroll' : (bool, None, None, False, 32 gobject.PARAM_READABLE),32 GObject.PARAM_READABLE), 33 33 } 34 34 35 35 def __init__(self, orientation): 36 36 self.orientation = orientation 37 37 self._can_scroll = False 38 38 39 gobject.GObject.__init__(self)39 GObject.GObject.__init__(self) 40 40 41 self.set_shadow_type( gtk.SHADOW_NONE)41 self.set_shadow_type(Gtk.ShadowType.NONE) 42 42 43 self.traybar = gtk.Toolbar()43 self.traybar = Gtk.Toolbar() 44 44 self.traybar.set_orientation(orientation) 45 45 self.traybar.set_show_arrow(False) 46 46 self.add(self.traybar) … … class _TrayViewport(gtk.Viewport): 55 55 self._scroll_next() 56 56 57 57 def _scroll_next(self): 58 if self.orientation == gtk.ORIENTATION_HORIZONTAL:58 if self.orientation == Gtk.Orientation.HORIZONTAL: 59 59 adj = self.get_hadjustment() 60 60 new_value = adj.value + self.allocation.width 61 61 adj.value = min(new_value, adj.upper - self.allocation.width) … … class _TrayViewport(gtk.Viewport): 65 65 adj.value = min(new_value, adj.upper - self.allocation.height) 66 66 67 67 def _scroll_to_end(self): 68 if self.orientation == gtk.ORIENTATION_HORIZONTAL:68 if self.orientation == Gtk.Orientation.HORIZONTAL: 69 69 adj = self.get_hadjustment() 70 70 adj.value = adj.upper# - self.allocation.width 71 71 else: … … class _TrayViewport(gtk.Viewport): 73 73 adj.value = adj.upper - self.allocation.height 74 74 75 75 def _scroll_previous(self): 76 if self.orientation == gtk.ORIENTATION_HORIZONTAL:76 if self.orientation == Gtk.Orientation.HORIZONTAL: 77 77 adj = self.get_hadjustment() 78 78 new_value = adj.value - self.allocation.width 79 79 adj.value = max(adj.lower, new_value) … … class _TrayViewport(gtk.Viewport): 83 83 adj.value = max(adj.lower, new_value) 84 84 85 85 def do_size_request(self, requisition): 86 child_requisition = self. child.size_request()87 if self.orientation == gtk.ORIENTATION_HORIZONTAL:86 child_requisition = self.get_child().size_request() 87 if self.orientation == Gtk.Orientation.HORIZONTAL: 88 88 requisition[0] = 0 89 89 requisition[1] = child_requisition[1] 90 90 else: … … class _TrayViewport(gtk.Viewport): 97 97 98 98 def _size_allocate_cb(self, viewport, allocation): 99 99 bar_requisition = self.traybar.get_child_requisition() 100 if self.orientation == gtk.ORIENTATION_HORIZONTAL:100 if self.orientation == Gtk.Orientation.HORIZONTAL: 101 101 can_scroll = bar_requisition[0] > allocation.width 102 102 else: 103 103 can_scroll = bar_requisition[1] > allocation.height … … class _TrayViewport(gtk.Viewport): 106 106 self._can_scroll = can_scroll 107 107 self.notify('can-scroll') 108 108 109 class _TrayScrollButton( gtk.Button):109 class _TrayScrollButton(Gtk.Button): 110 110 def __init__(self, icon_name, scroll_direction): 111 gobject.GObject.__init__(self)111 GObject.GObject.__init__(self) 112 112 113 113 self._viewport = None 114 114 115 115 self._scroll_direction = scroll_direction 116 116 117 self.set_relief( gtk.RELIEF_NONE)117 self.set_relief(Gtk.ReliefStyle.NONE) 118 118 self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE) 119 119 120 120 icon = Icon(icon_name = icon_name, 121 icon_size= gtk.ICON_SIZE_SMALL_TOOLBAR)121 icon_size=Gtk.IconSize.SMALL_TOOLBAR) 122 122 self.set_image(icon) 123 123 icon.show() 124 124 … … class _TrayScrollButton(gtk.Button): 138 138 139 139 viewport = property(fset=set_viewport) 140 140 141 class HTray( gtk.VBox):141 class HTray(Gtk.VBox): 142 142 def __init__(self, **kwargs): 143 gobject.GObject.__init__(self, **kwargs)143 GObject.GObject.__init__(self, **kwargs) 144 144 145 separator = hippo.Canvas()146 box = hippo.CanvasBox(145 separator = Hippo.Canvas() 146 box = Hippo.CanvasBox( 147 147 border_color=0xffffffff, 148 148 background_color=0xffffffff, 149 149 box_height=1, … … class HTray(gtk.VBox): 151 151 separator.set_root(box) 152 152 self.pack_start(separator, False) 153 153 154 hbox = gtk.HBox()155 self.pack_start(hbox )154 hbox = Gtk.HBox() 155 self.pack_start(hbox, True, True, 0) 156 156 157 157 scroll_left = _TrayScrollButton('go-left', _PREVIOUS_PAGE) 158 scroll_left_event = gtk.EventBox()158 scroll_left_event = Gtk.EventBox() 159 159 scroll_left_event.add(scroll_left) 160 160 scroll_left_event.set_size_request(55, -1) 161 161 hbox.pack_start(scroll_left_event, False) 162 162 163 self._viewport = _TrayViewport( gtk.ORIENTATION_HORIZONTAL)164 hbox.pack_start(self._viewport )163 self._viewport = _TrayViewport(Gtk.Orientation.HORIZONTAL) 164 hbox.pack_start(self._viewport, True, True, 0) 165 165 self._viewport.show() 166 166 167 167 scroll_right = _TrayScrollButton('go-right', _NEXT_PAGE) 168 scroll_right_event = gtk.EventBox()168 scroll_right_event = Gtk.EventBox() 169 169 scroll_right_event.add(scroll_right) 170 170 scroll_right_event.set_size_request(55, -1) 171 171 hbox.pack_start(scroll_right_event, False) 172 172 173 173 scroll_left.set_focus_on_click(False) 174 scroll_left_event.modify_bg( gtk.STATE_NORMAL, sugar.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color())175 scroll_left.modify_bg( gtk.STATE_ACTIVE, sugar.graphics.style.COLOR_BUTTON_GREY.get_gdk_color())174 scroll_left_event.modify_bg(Gtk.StateType.NORMAL, sugar3.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color()) 175 scroll_left.modify_bg(Gtk.StateType.ACTIVE, sugar3.graphics.style.COLOR_BUTTON_GREY.get_gdk_color()) 176 176 177 177 scroll_right.set_focus_on_click(False) 178 scroll_right_event.modify_bg( gtk.STATE_NORMAL, sugar.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color())179 scroll_right.modify_bg( gtk.STATE_ACTIVE, sugar.graphics.style.COLOR_BUTTON_GREY.get_gdk_color())178 scroll_right_event.modify_bg(Gtk.StateType.NORMAL, sugar3.graphics.style.COLOR_TOOLBAR_GREY.get_gdk_color()) 179 scroll_right.modify_bg(Gtk.StateType.ACTIVE, sugar3.graphics.style.COLOR_BUTTON_GREY.get_gdk_color()) 180 180 181 181 scroll_left.viewport = self._viewport 182 182 scroll_right.viewport = self._viewport -
utils.py
diff --git a/utils.py b/utils.py index 28adc9c..e8fadc3 100644
a b import base64 2 2 import rsvg 3 3 import re 4 4 import os 5 import gtk5 from gi.repository import Gtk 6 6 import time 7 7 from time import strftime 8 8 … … def _saveDataToBufferCb(buf, data): 20 20 21 21 22 22 def getPixbufFromString(str): 23 pbl = gtk.gdk.PixbufLoader()23 pbl = GdkPixbuf.PixbufLoader() 24 24 data = base64.b64decode( str ) 25 25 pbl.write(data) 26 26 pbl.close() … … def getUniqueFilepath( path, i ): 49 49 return os.path.abspath( newPath ) 50 50 51 51 def generate_thumbnail(pixbuf): 52 return pixbuf.scale_simple(108, 81, gtk.gdk.INTERP_BILINEAR)52 return pixbuf.scale_simple(108, 81, GdkPixbuf.InterpType.BILINEAR) 53 53 54 54 def getDateString( when ): 55 55 return strftime( "%c", time.localtime(when) )