def show_devices(self): self._label.hide() if self.devicesview == None: self.devicesview = Gtk.TreeView.new_with_model(self.deviceslist) self.devicesview.get_selection().connect("changed", self.on_device_selection_changed) cell_name = Gtk.CellRendererText() col_name = Gtk.TreeViewColumn(_("Name")) col_name.pack_start(cell_name, True) col_name.set_cell_data_func(cell_name, self.name_data_func, None) self.devicesview.append_column(col_name) cell_type = Gtk.CellRendererText() col_type = Gtk.TreeViewColumn(_("Type")) col_type.pack_start(cell_type, True) col_type.add_attribute(cell_type, "text", 1) self.devicesview.append_column(col_type) scrolledview = Gtk.ScrolledWindow() scrolledview.set_shadow_type(Gtk.ShadowType.ETCHED_IN) scrolledview.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledview.add(self.devicesview) scrolledview.show_all() text = "<b>%s</b>" % _("Select the device you want to configure.") self.frame = BaseFrame(text, scrolledview) self.frame.show() self.pack_start(self.frame, True, True, 0) self.devicesview.grab_focus() if len(self.deviceslist) == 1: self.emit("next-page")
def __init__(self, parent, model, device_type): Gtk.Dialog.__init__(self, title=_("Add to Group"), parent=parent, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.set_modal(True) self.set_destroy_with_parent(True) self.__selected_group = None self.set_border_width(5) self.vbox_main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12) self.vbox_main.set_border_width(5) self.vbox_main.show() self.get_content_area().pack_start(self.vbox_main, True, True, 0) groupbox = Gtk.Box(spacing=18) groupbox.show() group_frame = BaseFrame("<b>%s</b>" % _("Add Device to Group"), groupbox) group_frame.show() self.vbox_main.pack_start(group_frame, True, True, 0) group_label = TextFieldLabel() group_label.show() group_label.set_markup_with_mnemonic(_("_Group:")) groupbox.pack_start(group_label, False, False, 0) self.groups = Gtk.ListStore(str, GObject.TYPE_PYOBJECT) combo = Gtk.ComboBox.new_with_model(self.groups) combo.connect("changed", self.on_combo_changed) cell = Gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, "text", 0) combo.show() group_label.set_mnemonic_widget(combo) groupbox.pack_start(combo, True, True, 0) def append_groups(groups): for group in groups: if group.get_type() == device_type: name = group["name"] if name == "": name = "Group %d" % group["id"] self.groups.append([name, group]) model.get_registered_device_groups(result_handler=append_groups)
def __init__(self, parent): Gtk.Dialog.__init__( self, title=_("Create new Group"), parent=parent, flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.set_modal(True) self.set_destroy_with_parent(True) self.set_default_size(400, 150) self.set_border_width(5) self.vbox_main = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12) self.vbox_main.set_border_width(5) self.vbox_main.show() self.get_content_area().pack_start(self.vbox_main, True, True, 0) self.table = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL) self.table.set_column_spacing(18) self.table.set_row_spacing(6) self.table.show() general_frame = BaseFrame("<b>%s</b>" % _("General"), self.table) general_frame.show() self.vbox_main.pack_start(general_frame, True, True, 0) name = TextFieldLabel() name.set_markup_with_mnemonic(_("_Name:")) name.show() self.name_entry = Gtk.Entry(hexpand=True) self.name_entry.show() name.set_mnemonic_widget(self.name_entry) self.table.add(name) self.table.attach_next_to(self.name_entry, name, Gtk.PositionType.RIGHT, 1, 1) self.channels = TextFieldLabel() self.channels.set_markup_with_mnemonic(_("Channels _file:")) self.channels.show() self.channelsbox = Gtk.Box(spacing=6, hexpand=True) self.channelsbox.show() self.channels_entry = Gtk.Entry() self.channels_entry.set_editable(False) self.channels_entry.show() self.channelsbox.pack_start(self.channels_entry, True, True, 0) self.channels.set_mnemonic_widget(self.channels_entry) channels_open = Gtk.Button(stock=Gtk.STOCK_OPEN) channels_open.connect("clicked", self._on_channels_open_clicked) channels_open.show() self.channelsbox.pack_start(channels_open, False, False, 0) self.table.add(self.channels) self.table.attach_next_to(self.channelsbox, self.channels, Gtk.PositionType.RIGHT, 1, 1) recbox = Gtk.Box(spacing=18) recbox.show() recordings_frame = BaseFrame("<b>%s</b>" % _("Recordings"), recbox) recordings_frame.show() self.vbox_main.pack_start(recordings_frame, True, True, 0) recordings = TextFieldLabel() recordings.set_markup_with_mnemonic(_("_Directory:")) recordings.show() recbox.pack_start(recordings, False, True, 0) recentrybox = Gtk.Box(spacing=6) recentrybox.show() recbox.pack_start(recentrybox, True, True, 0) self.recordings_entry = Gtk.Entry() self.recordings_entry.set_editable(False) self.recordings_entry.show() recentrybox.pack_start(self.recordings_entry, True, True, 0) recordings.set_mnemonic_widget(self.recordings_entry) recordings_open = Gtk.Button(stock=Gtk.STOCK_OPEN) recordings_open.connect("clicked", self._on_recordings_open_clicked) recordings_open.show() recentrybox.pack_start(recordings_open, False, False, 0)
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()