def __init__(self): super(Player, self).__init__() self.adjustment = Gtk.Adjustment.new(0.0, 0.0, 100.0, 0.5, 10.0, 0.0) self.adjustment.connect('value-changed', self.on_adjustment_changed) self.progress = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, self.adjustment) self.progress.set_hexpand(True) self.progress.set_sensitive(False) self.progress.set_draw_value(False) self.progress.connect('button-press-event', self.on_mouse_press) self.progress.connect('button-release-event', self.on_mouse_release) font = Font() font.set_size(8) self.current_time = Gtk.Label('00:00:00.00', xalign=0, xpad=6) self.current_time.modify_font(font.to_pango_desc()) self.changing_time = Gtk.Label(' ', xpad=6) self.changing_time.modify_font(font.to_pango_desc()) self.total_time = Gtk.Label('00:00:00.00', xalign=1, xpad=6) self.total_time.modify_font(font.to_pango_desc()) self.track_label = Gtk.Label(' ') self.play_pause_button = Gtk.Button() self.play_pause_button.set_image(self.play_img) self.play_pause_button.connect('clicked', self.play_pause_action) self.stop_button = Gtk.Button() self.stop_button.set_image(self.stop_img) self.stop_button.connect('clicked', self.stop_action) self.set_column_spacing(6) self.set_row_spacing(3) self.attach(self.track_label, 0, 0, 3, 1) self.attach(self.current_time, 0, 1, 1, 1) self.attach(self.changing_time, 1, 1, 1, 1) self.attach(self.total_time, 2, 1, 1, 1) self.attach(self.progress, 0, 2, 3, 1) self.attach(self.play_pause_button, 3, 2, 1, 1) self.attach(self.stop_button, 4, 2, 1, 1) self.duration = 360000000 self.duration_str = '0' self.player_state = PlayerState.STOPPED self.player = AudioStreamer() self.timeout_id = GObject.timeout_add(1000, self.on_timeout, None) self.mouse_moving = False
def __init__(self, podcast): super(PodcastRow, self).__init__() self.remove_img = get_gtk_image_from_file('./icons/delete.png', 12, 12) self.refresh_img = get_gtk_image_from_file('./icons/update.png', 12, 12) self.refresh = Gtk.Button() self.refresh.set_image(self.refresh_img) self.refresh.set_relief(Gtk.ReliefStyle.NONE) self.remove = Gtk.Button() self.remove.set_image(self.remove_img) self.remove.set_relief(Gtk.ReliefStyle.NONE) hbox1 = Gtk.HBox() hbox1.pack_start(self.refresh, False, True, 0) hbox1.pack_start(self.remove , False, True, 0) self.box_revealer = Gtk.Revealer() self.box_revealer.add(hbox1) self.box_revealer.set_transition_type(Gtk.RevealerTransitionType.NONE) hbox2 = Gtk.HBox(spacing=6) hbox2.pack_start(Gtk.Label(podcast.date, xalign=0), True, True, 0) hbox2.pack_start(self.box_revealer, True, True, 0) self.spinner = Gtk.Spinner() self.load_revealer = Gtk.Revealer.new() self.load_revealer.add(self.spinner) self.load_revealer.set_transition_type(Gtk.RevealerTransitionType.SLIDE_LEFT) font = Font() font.set_weight(FontWeight.BOLD) name = Gtk.Label(podcast.name, xalign=0, yalign=0) name.modify_font(font.to_pango_desc()) revbox = Gtk.HBox(spacing=0) revbox.pack_start(self.load_revealer, False, True, 0) revbox.pack_start(name, True, True, 0) pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(podcast.image, 75, 75, True) image = Gtk.Image.new_from_pixbuf(pixbuf) image.set_alignment(0,0) summary = Gtk.Label(podcast.summary, xalign=0, yalign=0) summary.set_max_width_chars(60) summary.set_lines(4) summary.set_ellipsize(Pango.EllipsizeMode.END) expander = Gtk.Expander.new('Description') expander.add(summary) grid = Gtk.Grid() grid.set_column_spacing(6) grid.attach(image , 0, 0, 1, 3) grid.attach(revbox , 1, 0, 1, 1) grid.attach(expander, 1, 1, 1, 1) grid.attach(hbox2, 1, 2, 1, 1) self.add(grid) self.podcast = podcast self.buttonsConnected = False