From f86a6e024cd5884a42aaa87232351e35636ce0ed Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Fri, 15 Apr 2011 18:13:10 +0000 Subject: Pep8 corrections --- diff --git a/record.py b/record.py index c19fb02..cf73a61 100644 --- a/record.py +++ b/record.py @@ -65,6 +65,7 @@ if logging.getLogger().level <= logging.DEBUG: else: gst.debug_set_default_threshold(gst.LEVEL_ERROR) + class Record(activity.Activity): def __init__(self, handle): super(Record, self).__init__(handle) @@ -200,11 +201,16 @@ class Record(activity.Activity): main_box.show() self._media_view = MediaView() - self._media_view.connect('media-clicked', self._media_view_media_clicked) - self._media_view.connect('pip-clicked', self._media_view_pip_clicked) - self._media_view.connect('info-clicked', self._media_view_info_clicked) - self._media_view.connect('full-clicked', self._media_view_full_clicked) - self._media_view.connect('tags-changed', self._media_view_tags_changed) + self._media_view.connect('media-clicked', + self._media_view_media_clicked) + self._media_view.connect('pip-clicked', + self._media_view_pip_clicked) + self._media_view.connect('info-clicked', + self._media_view_info_clicked) + self._media_view.connect('full-clicked', + self._media_view_full_clicked) + self._media_view.connect('tags-changed', + self._media_view_tags_changed) self._media_view.show() self._controls_hbox = gtk.HBox() @@ -212,29 +218,34 @@ class Record(activity.Activity): self._shutter_button = ShutterButton() self._shutter_button.connect("clicked", self._shutter_clicked) - self._controls_hbox.pack_start(self._shutter_button, expand=True, fill=False) + self._controls_hbox.pack_start(self._shutter_button, expand=True, + fill=False) self._countdown_image = CountdownImage() - self._controls_hbox.pack_start(self._countdown_image, expand=True, fill=False) + self._controls_hbox.pack_start(self._countdown_image, expand=True, + fill=False) self._play_button = PlayButton() self._play_button.connect('clicked', self._play_pause_clicked) self._controls_hbox.pack_start(self._play_button, expand=False) self._playback_scale = PlaybackScale(self.model) - self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True) + self._controls_hbox.pack_start(self._playback_scale, expand=True, + fill=True) self._progress = ProgressInfo() self._controls_hbox.pack_start(self._progress, expand=True, fill=True) self._title_label = gtk.Label() - self._title_label.set_markup(""+_('Title:')+'') + self._title_label.set_markup("" + + _('Title:') + '') self._controls_hbox.pack_start(self._title_label, expand=False) self._title_entry = gtk.Entry() self._title_entry.modify_bg(gtk.STATE_INSENSITIVE, COLOR_BLACK) self._title_entry.connect('changed', self._title_changed) - self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10) + self._controls_hbox.pack_start(self._title_entry, expand=True, + fill=True, padding=10) container = RecordContainer(self._media_view, self._controls_hbox) main_box.pack_start(container, expand=True, fill=True, padding=6) @@ -279,11 +290,11 @@ class Record(activity.Activity): key = event.keyval - if key == gtk.keysyms.KP_Page_Up: # game key O + if key == gtk.keysyms.KP_Page_Up: # game key O if self._shutter_button.props.visible: if self._shutter_button.props.sensitive: self._shutter_button.clicked() - else: # return to live mode + else: # return to live mode self.model.set_state(constants.STATE_READY) elif key == gtk.keysyms.c and event.state == gdk.CONTROL_MASK: self._copy_to_clipboard(self._active_recd) @@ -344,7 +355,8 @@ class Record(activity.Activity): self._active_recd.setTitle(self._title_entry.get_text()) def _media_view_media_clicked(self, widget): - if self._play_button.props.visible and self._play_button.props.sensitive: + if self._play_button.props.visible and \ + self._play_button.props.sensitive: self._play_button.clicked() def _media_view_pip_clicked(self, widget): @@ -364,7 +376,8 @@ class Record(activity.Activity): return self._showing_info = True - if self.model.get_mode() in (constants.MODE_PHOTO, constants.MODE_AUDIO): + if self.model.get_mode() in (constants.MODE_PHOTO, + constants.MODE_AUDIO): func = self._media_view.show_info_photo else: func = self._media_view.show_info_video @@ -376,13 +389,15 @@ class Record(activity.Activity): self._title_entry.show() self._title_label.show() - func(recd.recorderName, recd.colorStroke, recd.colorFill, utils.getDateString(recd.time), recd.tags) + func(recd.recorderName, recd.colorStroke, recd.colorFill, + utils.getDateString(recd.time), recd.tags) def _media_view_full_clicked(self, widget): self._toggle_fullscreen() def _media_view_tags_changed(self, widget, tbuffer): - text = tbuffer.get_text(tbuffer.get_start_iter(), tbuffer.get_end_iter()) + text = tbuffer.get_text(tbuffer.get_start_iter(), + tbuffer.get_end_iter()) self._active_recd.setTags(text) def _toggle_fullscreen(self): @@ -396,7 +411,6 @@ class Record(activity.Activity): self._fullscreen = not self._fullscreen self._media_view.set_fullscreen(self._fullscreen) - def __mode_button_clicked(self, button): # Prevent mode/tab changing under certain conditions by immediately # changing back to the previously-selected toolbar @@ -427,13 +441,15 @@ class Record(activity.Activity): self._play_button.hide() self._playback_scale.hide() self._progress.hide() - self._controls_hbox.set_child_packing(self._shutter_button, expand=True, fill=False, padding=0, pack_type=gtk.PACK_START) + self._controls_hbox.set_child_packing(self._shutter_button, + expand=True, fill=False, padding=0, pack_type=gtk.PACK_START) self._shutter_button.set_normal() self._shutter_button.show() self._media_view.show_live() elif state == constants.STATE_RECORDING: self._shutter_button.set_recording() - self._controls_hbox.set_child_packing(self._shutter_button, expand=False, fill=False, padding=0, pack_type=gtk.PACK_START) + self._controls_hbox.set_child_packing(self._shutter_button, + expand=False, fill=False, padding=0, pack_type=gtk.PACK_START) self._progress.show() elif state == constants.STATE_PROCESSING: self._set_cursor_busy() @@ -458,10 +474,13 @@ class Record(activity.Activity): def add_thumbnail(self, recd, scroll_to_end): button = RecdButton(recd) - clicked_handler = button.connect("clicked", self._thumbnail_clicked, recd) + clicked_handler = button.connect("clicked", self._thumbnail_clicked, + recd) remove_handler = button.connect("remove-requested", self._remove_recd) - clipboard_handler = button.connect("copy-clipboard-requested", self._thumbnail_copy_clipboard) - button.set_data('handler-ids', (clicked_handler, remove_handler, clipboard_handler)) + clipboard_handler = button.connect("copy-clipboard-requested", + self._thumbnail_copy_clipboard) + button.set_data('handler-ids', (clicked_handler, remove_handler, + clipboard_handler)) self._thumb_tray.add_item(button) button.show() if scroll_to_end: @@ -476,7 +495,8 @@ class Record(activity.Activity): media_path = recd.getMediaFilepath() tmp_path = utils.getUniqueFilepath(media_path, 0) shutil.copyfile(media_path, tmp_path) - gtk.Clipboard().set_with_data([('text/uri-list', 0, 0)], self._clipboard_get, self._clipboard_clear, tmp_path) + gtk.Clipboard().set_with_data([('text/uri-list', 0, 0)], + self._clipboard_get, self._clipboard_clear, tmp_path) def _clipboard_get(self, clipboard, selection_data, info, path): selection_data.set("text/uri-list", 8, "file://" + path) @@ -552,7 +572,7 @@ class Record(activity.Activity): #downloading = self.ca.requestMeshDownload(recd) #self.MESHING = downloading - if True: #not downloading: + if True: # not downloading: #self.progressWindow.updateProgress(0, "") return recd.getMediaFilepath() @@ -595,6 +615,7 @@ class Record(activity.Activity): def _set_cursor_default(self): self.window.set_cursor(None) + class RecordContainer(gtk.Container): """ A custom Container that contains a media view area, and a controls hbox. @@ -632,7 +653,8 @@ class RecordContainer(gtk.Container): height=self.allocation.height, wclass=gdk.INPUT_OUTPUT, colormap=self.get_colormap(), - event_mask=self.get_events() | gdk.VISIBILITY_NOTIFY_MASK | gdk.EXPOSURE_MASK) + event_mask=self.get_events() | gdk.VISIBILITY_NOTIFY_MASK | \ + gdk.EXPOSURE_MASK) self.window.set_user_data(self) self.set_style(self.style.attach(self.window)) @@ -662,8 +684,9 @@ class RecordContainer(gtk.Container): @staticmethod def _constrain_4_3(width, height): - if (width % 4 == 0) and (height % 3 == 0) and ((width / 4) * 3) == height: - return width, height # nothing to do + if (width % 4 == 0) and (height % 3 == 0) and \ + ((width / 4) * 3) == height: + return width, height # nothing to do ratio = 4.0 / 3.0 if ratio * height > width: @@ -673,7 +696,7 @@ class RecordContainer(gtk.Container): height = (height / 3) * 3 width = int(ratio * height) - return width, height + return width, height @staticmethod def _center_in_plane(plane_size, size): @@ -686,9 +709,12 @@ class RecordContainer(gtk.Container): remaining_height = self.allocation.height - self._controls_hbox_height # give the mediaview the rest, constrained to 4/3 and centered - media_view_width, media_view_height = self._constrain_4_3(self.allocation.width, remaining_height) - media_view_x = self._center_in_plane(self.allocation.width, media_view_width) - media_view_y = self._center_in_plane(remaining_height, media_view_height) + media_view_width, media_view_height = \ + self._constrain_4_3(self.allocation.width, remaining_height) + media_view_x = self._center_in_plane( + self.allocation.width, media_view_width) + media_view_y = self._center_in_plane( + remaining_height, media_view_height) # send allocation to mediaview alloc = gdk.Rectangle() @@ -714,11 +740,13 @@ class RecordContainer(gtk.Container): for widget in (self._media_view, self._controls_hbox): callback(widget, data) + class PlaybackScale(gtk.HScale): def __init__(self, model): self.model = model self._change_handler = None - self._playback_adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0) + self._playback_adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, \ + 1.0, 1.0) super(PlaybackScale, self).__init__(self._playback_adjustment) self.set_draw_value(False) @@ -734,7 +762,8 @@ class PlaybackScale(gtk.HScale): def _button_press(self, widget, event): self.model.start_seek() - self._change_handler = self.connect('value-changed', self._value_changed) + self._change_handler = self.connect('value-changed', + self._value_changed) def _button_release(self, widget, event): self.disconnect(self._change_handler) @@ -919,19 +948,23 @@ class RecordToolbar(gtk.Toolbar): def set_quality(self, idx): self.quality.combo.set_active(idx) + class PhotoToolbar(RecordToolbar): def __init__(self): - super(PhotoToolbar, self).__init__('media-photo', with_quality=False, with_timer=True, with_duration=False) + super(PhotoToolbar, self).__init__('media-photo', with_quality=False, + with_timer=True, with_duration=False) class VideoToolbar(RecordToolbar): def __init__(self): - super(VideoToolbar, self).__init__('media-video', with_quality=True, with_timer=True, with_duration=True) + super(VideoToolbar, self).__init__('media-video', with_quality=True, + with_timer=True, with_duration=True) class AudioToolbar(RecordToolbar): def __init__(self): - super(AudioToolbar, self).__init__('media-audio', with_quality=False, with_timer=True, with_duration=True) + super(AudioToolbar, self).__init__('media-audio', with_quality=False, + with_timer=True, with_duration=True) class TimerCombo(ToolComboBox): @@ -939,8 +972,9 @@ class TimerCombo(ToolComboBox): def __init__(self): self._combo_box_text = gtk.combo_box_new_text() - super(TimerCombo, self).__init__(combo=self._combo_box_text, label_text=_('Timer:')) - + super(TimerCombo, self).__init__(combo=self._combo_box_text, + label_text=_('Timer:')) + for i in self.TIMERS: if i == 0: self._combo_box_text.append_text(_('Immediate')) @@ -950,7 +984,7 @@ class TimerCombo(ToolComboBox): self._combo_box_text.set_active(0) def get_value(self): - return TimerCombo.TIMERS[self._combo_box_text.get_active()] + return TimerCombo.TIMERS[self._combo_box_text.get_active()] def get_value_idx(self): return self._combo_box_text.get_active() @@ -968,7 +1002,8 @@ class DurationCombo(ToolComboBox): def __init__(self): self._combo_box_text = gtk.combo_box_new_text() - super(DurationCombo, self).__init__(combo=self._combo_box_text, label_text=_('Duration:')) + super(DurationCombo, self).__init__(combo=self._combo_box_text, + label_text=_('Duration:')) for i in self.DURATIONS: string = DurationCombo._minutes_string(i) @@ -988,6 +1023,7 @@ class DurationCombo(ToolComboBox): def _minutes_string(x): return ngettext('%s minute', '%s minutes', x) % x + class EditToolbar(gtk.Toolbar): def __init__(self, record_activity): @@ -1001,6 +1037,7 @@ class EditToolbar(gtk.Toolbar): def __copy_clicked(self, button): self._activity._copy_to_clipboard(self._activity._active_recd) + class ViewToolbar(gtk.Toolbar): def __init__(self, record_activity): -- cgit v0.9.1