def __init__(self, model):
        GObject.GObject.__init__(self)

        self.runningnextstore = None
        self.scrolledrunningnext = None
        self.runningnextview = None
        self.__single_group = None

        self.channellists = {}
        self.manager = model
        self.manager.connect('group-added', self._on_manager_group_added)
        self.manager.connect('group-removed', self._on_manager_group_removed)

        self.connect('delete-event', Gtk.main_quit)
        self.connect('destroy-event', Gtk.main_quit)
        self.set_title(_("DVB Control Center"))
        self.set_default_size(800, 500)

        self.vbox_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.vbox_outer.show()
        self.add(self.vbox_outer)

        self.toolbar = None
        self.vbox_left = None
        self.__create_menu()
        self.__create_toolbar()

        self.hbox = Gtk.Box(spacing=6)
        self.vbox_outer.pack_start(self.hbox, True, True, 0)

        self.hpaned = Gtk.Paned()
        self.hpaned.set_border_width(3)
        self.hpaned.set_position(175)
        self.hbox.pack_start(self.hpaned, True, True, 0)

        self.vbox_left = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                 spacing=6)
        self.hpaned.pack1(self.vbox_left)

        self.devgroupslist = Gtk.ListStore(str, int, GObject.GObject)
        self.devgroupslist.connect("row-inserted",
                                   self._on_devgroupslist_inserted)

        self.devgroupscombo = Gtk.ComboBox.new_with_model_and_entry(
            self.devgroupslist)

        cell_adapter = Gtk.CellRendererText()
        self.devgroupscombo.pack_start(cell_adapter, True)
        self.devgroupscombo.set_entry_text_column(0)
        self.devgroupscombo.connect("changed", self._on_devgroupscombo_changed)
        self.vbox_left.pack_start(self.devgroupscombo, False, True, 0)

        self.channelsstore = None

        self.channelsview = ChannelsView()
        self.channelsview.set_headers_visible(False)
        self.channelsview.get_selection().connect("changed",
                                                  self._on_channel_selected)

        scrolledchannels = Gtk.ScrolledWindow()
        scrolledchannels.add(self.channelsview)
        scrolledchannels.set_policy(Gtk.PolicyType.AUTOMATIC,
                                    Gtk.PolicyType.AUTOMATIC)
        scrolledchannels.set_shadow_type(Gtk.ShadowType.IN)
        self.vbox_left.pack_start(scrolledchannels, True, True, 0)

        self.schedulestore = None

        self.help_eventbox = HelpBox()
        self.choose_group_text = _(
            "Choose a device group and channel on the left to view the program guide"
        )
        self.create_group_text = _(
            "No devices are configured. Please go to preferences to configure them."
        )
        self.no_events_text = _(
            "There is currently no schedule available for this channel")
        self.hpaned.pack2(self.help_eventbox)

        self.schedulepaned = SchedulePaned()
        self.schedulepaned.show()
        self.scheduleview = self.schedulepaned.get_treeview()
        self.scheduleview.connect("button-press-event",
                                  self._on_event_selected)

        self.get_device_groups()
        if len(self.devgroupslist) == 0:
            self.help_eventbox.set_markup(self.create_group_text)
        else:
            self._select_first_group()

        Gtk.Window.set_default_icon_name("gnome-dvb-daemon")
Пример #2
0
    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()
    def __init__(self, model, parent=None):
        Gtk.Dialog.__init__(self, title=_("Edit Channel Lists"), parent=parent)

        self.set_modal(True)
        self.set_destroy_with_parent(True)
        self.model = model
        self.devgroup = None
        self.channel_list = None

        self.set_default_size(600, 500)
        self.set_border_width(5)

        close_button = self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
        close_button.grab_default()

        self.vbox_main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                 spacing=12)
        self.vbox_main.set_border_width(5)
        self.get_content_area().pack_start(self.vbox_main, True, True, 0)

        # channel groups
        groups_box = Gtk.Box(spacing=6)
        groups_frame = BaseFrame("<b>%s</b>" % _("Channel groups"), groups_box)
        self.vbox_main.pack_start(groups_frame, False, True, 0)

        self.channel_groups = ChannelGroupsStore()
        self.channel_groups_view = ChannelGroupsView(self.channel_groups)
        self.channel_groups_view.set_headers_visible(False)
        self.channel_groups_view.get_selection().connect(
            "changed", self.on_group_changed)
        self.channel_groups_view.get_renderer().connect(
            "edited", self.on_channel_group_edited)

        scrolledgroups = Gtk.ScrolledWindow()
        scrolledgroups.add(self.channel_groups_view)
        scrolledgroups.set_policy(Gtk.PolicyType.NEVER,
                                  Gtk.PolicyType.AUTOMATIC)
        scrolledgroups.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        groups_box.pack_start(scrolledgroups, True, True, 0)

        groups_buttonbox = Gtk.ButtonBox(orientation=Gtk.Orientation.VERTICAL)
        groups_buttonbox.set_spacing(6)
        groups_buttonbox.set_layout(Gtk.ButtonBoxStyle.START)
        groups_box.pack_end(groups_buttonbox, False, False, 0)

        new_group_button = Gtk.Button(stock=Gtk.STOCK_ADD)
        new_group_button.connect("clicked", self.on_new_group_clicked)
        groups_buttonbox.pack_start(new_group_button, True, True, 0)

        self.del_group_button = Gtk.Button(stock=Gtk.STOCK_REMOVE)
        self.del_group_button.connect("clicked", self.on_delete_group_clicked)
        groups_buttonbox.pack_start(self.del_group_button, True, True, 0)

        # device groups
        self.devgroupslist = Gtk.ListStore(str, int, GObject.GObject)

        self.devgroupscombo = Gtk.ComboBox.new_with_model_and_entry(
            self.devgroupslist)
        self.devgroupscombo.connect("changed", self.on_devgroupscombo_changed)
        cell_adapter = Gtk.CellRendererText()
        self.devgroupscombo.pack_start(cell_adapter, True)
        self.devgroupscombo.set_entry_text_column(0)

        groups_label = Gtk.Label()
        groups_label.set_markup_with_mnemonic(_("_Group:"))
        groups_label.set_mnemonic_widget(self.devgroupscombo)

        groups_box = Gtk.Box(spacing=6)
        groups_box.pack_start(groups_label, False, True, 0)
        groups_box.pack_start(self.devgroupscombo, True, True, 0)

        self.devgroups_frame = BaseFrame("<b>%s</b>" % _("Device groups"),
                                         groups_box, False, False)
        self.vbox_main.pack_start(self.devgroups_frame, False, True, 0)

        # channels
        channels_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.vbox_main.pack_start(channels_box, True, True, 0)

        cbox = Gtk.Box(spacing=6)
        channels_box.pack_start(cbox, True, True, 0)

        # all channels
        self.channels_store = None
        self.channels_view = ChannelsView(self.channels_store)
        self.channels_view.set_headers_visible(False)
        self.channels_view.connect("row-activated",
                                   self.on_channels_view_activated)
        treesel = self.channels_view.get_selection()
        treesel.set_mode(Gtk.SelectionMode.MULTIPLE)
        treesel.connect("changed", self.on_channel_store_selected)

        left_frame = Frame("<b>%s</b>" % _("All channels"), self.channels_view)
        cbox.pack_start(left_frame, True, True, 0)

        # selected channels
        self.selected_channels_store = Gtk.ListStore(str, int)  # Name, sid
        self.selected_channels_view = Gtk.TreeView.new_with_model(
            self.selected_channels_store)
        self.selected_channels_view.set_reorderable(True)
        self.selected_channels_view.set_headers_visible(False)
        self.selected_channels_view.connect(
            "row-activated", self.on_selected_channels_view_activated)
        treesel = self.selected_channels_view.get_selection()
        treesel.connect("changed", self.on_selected_channels_changed)
        treesel.set_mode(Gtk.SelectionMode.MULTIPLE)
        col_name = Gtk.TreeViewColumn(_("Channel"))
        cell_name = Gtk.CellRendererText()
        col_name.pack_start(cell_name, True)
        col_name.add_attribute(cell_name, "markup", 0)
        self.selected_channels_view.append_column(col_name)
        self.selected_channels_view.show()

        self.scrolled_selected_channels = Gtk.ScrolledWindow()
        self.scrolled_selected_channels.set_shadow_type(
            Gtk.ShadowType.ETCHED_IN)
        self.scrolled_selected_channels.set_policy(Gtk.PolicyType.AUTOMATIC,
                                                   Gtk.PolicyType.AUTOMATIC)
        self.scrolled_selected_channels.add(self.selected_channels_view)

        self.select_group_helpbox = HelpBox()
        self.select_group_helpbox.set_markup(_("Choose a channel group"))
        self.right_frame = BaseFrame("<b>%s</b>" % _("Channels of group"),
                                     self.select_group_helpbox)
        cbox.pack_start(self.right_frame, True, True, 0)

        buttonbox = Gtk.ButtonBox()
        buttonbox.set_spacing(6)
        buttonbox.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        self.add_channel_button = Gtk.Button(stock=Gtk.STOCK_ADD)
        self.add_channel_button.connect("clicked", self.on_add_channel_clicked)
        buttonbox.pack_start(self.add_channel_button, True, True, 0)
        self.remove_channel_button = Gtk.Button(stock=Gtk.STOCK_REMOVE)
        self.remove_channel_button.connect("clicked",
                                           self.on_remove_channel_clicked)
        buttonbox.pack_start(self.remove_channel_button, True, True, 0)
        channels_box.pack_start(buttonbox, False, False, 0)

        self.del_group_button.set_sensitive(False)
        self.add_channel_button.set_sensitive(False)
        self.remove_channel_button.set_sensitive(False)

        self.fill_device_groups()
        self.fill_channel_groups()

        self.show_all()