def __init__(self, parent, device_group, channel=None, starttime=None, duration=60): """ @param parent: Parent window @type parent: Gtk.Window @param device_group: DeviceGroup instance """ Gtk.Dialog.__init__(self, parent=parent) self.set_modal(True) self.set_destroy_with_parent(True) self.set_default_size(320, -1) self.device_group = device_group self.date_valid = False self.allowed_delta = datetime.timedelta(hours=1) self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT) self.ok_button = self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT) self.set_border_width(5) table = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) table.set_column_spacing(18) table.set_row_spacing(6) table.set_border_width(5) self.get_content_area().pack_start(table, True, True, 0) label_channel = TextFieldLabel() table.add(label_channel) if channel == None: self.channel_selected = False self.set_title(_("Add Timer")) self.ok_button.set_sensitive(False) label_channel.set_markup_with_mnemonic(_("_Channel:")) self.channels = ChannelsStore(device_group) scrolledchannels = Gtk.ScrolledWindow(expand=True) scrolledchannels.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledchannels.set_shadow_type(Gtk.ShadowType.ETCHED_IN) table.attach_next_to(scrolledchannels, label_channel, Gtk.PositionType.BOTTOM, 2, 1) self.channelsview = ChannelsView(self.channels) self.channelsview.set_headers_visible(False) self.channelsview.get_selection().connect("changed", self._on_channel_changed) scrolledchannels.add(self.channelsview) label_channel.set_mnemonic_widget(self.channelsview) self.channelsview.grab_focus() else: self.channel_selected = True self.set_title(_("Edit Timer")) self.ok_button.set_sensitive(True) label_channel.set_text(_("Channel:")) self.channels = None self.channelsview = None channel_label = TextFieldLabel(channel) table.attach_next_to(channel_label, label_channel, Gtk.PositionType.RIGHT, 1, 1) label_start = TextFieldLabel() label_start.set_markup_with_mnemonic(_("_Start time:")) table.add(label_start) hbox = Gtk.Box(spacing=6, hexpand=True) table.attach_next_to(hbox, label_start, Gtk.PositionType.RIGHT, 1, 1) if starttime == None: starttime = datetime.datetime.now() self.datetime_box = DateTimeBox(starttime) self.datetime_box.connect("changed", self._on_datetime_changed) hbox.pack_start(self.datetime_box, True, True, 0) label_start.set_mnemonic_widget(self.datetime_box) label_duration = TextFieldLabel() label_duration.set_markup_with_mnemonic(_("_Duration:")) table.add(label_duration) duration_hbox = Gtk.Box(spacing=6, hexpand=True) table.attach_next_to(duration_hbox, label_duration, Gtk.PositionType.RIGHT, 1, 1) self.duration = Gtk.SpinButton() self.duration.set_range(1, 65535) self.duration.set_increments(1, 10) self.duration.set_width_chars(3) self.duration.set_value(60) duration_hbox.pack_start(self.duration, False, True, 0) label_duration.set_mnemonic_widget(self.duration) minutes_label = TextFieldLabel(_("minutes")) duration_hbox.pack_start(minutes_label, True, True, 0) self.set_start_time(starttime) self.set_duration(duration) table.show_all()
class DetailsDialog(Gtk.Dialog): def __init__(self, parent=None): Gtk.Dialog.__init__(self, parent=parent) self.set_destroy_with_parent(True) self.set_default_size(440, 350) self.set_border_width(5) self.get_action_area().set_layout(Gtk.ButtonBoxStyle.EDGE) self.rec_button = Gtk.Button(stock=Gtk.STOCK_MEDIA_RECORD) self.rec_button.show() self.get_action_area().pack_start(self.rec_button, True, True, 0) close_button = self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) close_button.grab_default() self.table = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) self.table.set_column_spacing(18) self.table.set_row_spacing(6) self.table.set_border_width(5) self.get_content_area().pack_start(self.table, True, True, 0) self._title = TextFieldLabel(hexpand=True) self._channel = TextFieldLabel(hexpand=True) self._date = TextFieldLabel(hexpand=True) self._duration = TextFieldLabel(hexpand=True) title_label = TextFieldLabel("<i>%s</i>" % _("Title:")) self.table.add(title_label) self.table.attach_next_to(self._title, title_label, Gtk.PositionType.RIGHT, 1, 1) channel_label = TextFieldLabel("<i>%s</i>" % _("Channel:")) self.table.add(channel_label) self.table.attach_next_to(self._channel, channel_label, Gtk.PositionType.RIGHT, 1, 1) date_label = TextFieldLabel("<i>%s</i>" % _("Date:")) self.table.add(date_label) self.table.attach_next_to(self._date, date_label, Gtk.PositionType.RIGHT, 1, 1) duration_label = TextFieldLabel("<i>%s</i>" % _("Duration:")) self.table.add(duration_label) self.table.attach_next_to(self._duration, duration_label, Gtk.PositionType.RIGHT, 1, 1) description_label = TextFieldLabel("<i>%s</i>" % _("Description:")) self.table.add(description_label) self.textview = Gtk.TextView() self.textview.set_editable(False) self.textview.set_wrap_mode(Gtk.WrapMode.WORD) self.textview.show() scrolledwin = Gtk.ScrolledWindow(expand=True) scrolledwin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolledwin.set_shadow_type(Gtk.ShadowType.IN) scrolledwin.set_margin_left(12) scrolledwin.add(self.textview) scrolledwin.show() self.table.attach_next_to(scrolledwin, description_label, Gtk.PositionType.BOTTOM, 2, 1) self.table.show_all() def set_description(self, text): self.textview.get_buffer().set_text(text) def set_title(self, title): Gtk.Dialog.set_title(self, title) self._title.set_text(title) def set_channel(self, channel): self._channel.set_text(channel) def set_duration(self, duration): duration_str = gnomedvb.seconds_to_time_duration_string(duration) self._duration.set_text(duration_str) def set_date(self, timestamp): date = datetime.datetime.fromtimestamp(timestamp) self._date.set_text(date.strftime("%c")) def get_record_button(self): return self.rec_button