def __init__(self): """Initialise. """ gtk.EventBox.__init__(self) import application self.app = application.get_app() self.actions = set() self.default_action = None self.bindings = None #: dict of bindings being edited self.vbox = gtk.VBox() self.add(self.vbox) # Display strings for action names self.action_labels = dict() # Model: combo cellrenderer's liststore ls = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.action_liststore = ls self.action_liststore_value_column = 0 self.action_liststore_display_column = 1 # Model: main list's liststore # This is reflected into self.bindings when it changes column_types = [gobject.TYPE_STRING] * 3 ls = gtk.ListStore(*column_types) self.action_column = 0 self.bp_column = 1 self.bpd_column = 2 for sig in ("row-changed", "row-deleted", "row_inserted"): ls.connect(sig, self._liststore_updated_cb) self.liststore = ls # Bindings hash observers, external interface self.bindings_observers = [] #: List of cb(editor) callbacks # View: treeview scrolledwin = gtk.ScrolledWindow() scrolledwin.set_shadow_type(gtk.SHADOW_IN) tv = gtk.TreeView() tv.set_model(ls) scrolledwin.add(tv) self.vbox.pack_start(scrolledwin, True, True) tv.set_size_request(480, 320) tv.set_headers_clickable(True) self.treeview = tv self.selection = tv.get_selection() self.selection.connect("changed", self._selection_changed_cb) # Column 0: action name cell = gtk.CellRendererCombo() cell.set_property("model", self.action_liststore) cell.set_property("text-column", self.action_liststore_display_column) cell.set_property("mode", gtk.CELL_RENDERER_MODE_EDITABLE) cell.set_property("editable", True) cell.set_property("has-entry", False) cell.connect("changed", self._action_cell_changed_cb) col = gtk.TreeViewColumn(_("Action"), cell) col.set_cell_data_func(cell, self._liststore_action_datafunc) col.set_min_width(150) col.set_resizable(False) col.set_expand(False) col.set_sort_column_id(self.action_column) tv.append_column(col) # Column 1: button press cell = gtk.CellRendererText() cell.set_property("ellipsize", pango.ELLIPSIZE_END) cell.set_property("mode", gtk.CELL_RENDERER_MODE_EDITABLE) cell.set_property("editable", True) cell.connect("edited", self._bp_cell_edited_cb) cell.connect("editing-started", self._bp_cell_editing_started_cb) col = gtk.TreeViewColumn(_("Button press"), cell) col.add_attribute(cell, "text", self.bpd_column) col.set_expand(True) col.set_resizable(True) col.set_min_width(200) col.set_sort_column_id(self.bpd_column) tv.append_column(col) # List editor toolbar (inline-toolbar for gtk3) list_tools = gtk.Toolbar() list_tools.set_style(gtk.TOOLBAR_ICONS) list_tools.set_icon_size(widgets.ICON_SIZE_LARGE) context = list_tools.get_style_context() context.add_class("inline-toolbar") self.vbox.pack_start(list_tools, False, False) # Add binding btn = gtk.ToolButton() btn.set_tooltip_text(_("Add a new binding")) btn.set_icon_name("mypaint-add-symbolic") btn.connect("clicked", self._add_button_clicked_cb) list_tools.add(btn) # Remove (inactive if list is empty) btn = gtk.ToolButton() btn.set_icon_name("mypaint-remove-symbolic") btn.set_tooltip_text(_("Remove the current binding")) btn.connect("clicked", self._remove_button_clicked_cb) list_tools.add(btn) self.remove_button = btn self._updating_model = False
def init(self, context): self._log.debug("init") self._preferences = Preferences() self._show_tasks = self._preferences.get_bool("IssuesShowTasks", True) self._show_warnings = self._preferences.get_bool( "IssuesShowWarnings", True) self._context = context self._icons = { Issue.SEVERITY_WARNING: pixbuf_new_from_file(find_resource("icons/warning.png")), Issue.SEVERITY_ERROR: pixbuf_new_from_file(find_resource("icons/error.png")), Issue.SEVERITY_INFO: None, Issue.SEVERITY_TASK: pixbuf_new_from_file(find_resource("icons/task.png")) } self._store = gtk.ListStore(Pixbuf, str, str, object) self._view = gtk.TreeView(self._store) column = gtk.TreeViewColumn() column.set_title("Message") pixbuf_renderer = gtk.CellRendererPixbuf() column.pack_start(pixbuf_renderer, False) column.add_attribute(pixbuf_renderer, "pixbuf", 0) text_renderer = gtk.CellRendererText() column.pack_start(text_renderer, True) column.add_attribute(text_renderer, "markup", 1) self._view.append_column(column) self._view.insert_column_with_attributes(-1, "File", gtk.CellRendererText(), markup=2) self._handlers[self._view] = self._view.connect( "row-activated", self._on_row_activated) self._scr = gtk.ScrolledWindow() self._scr.add(self._view) self._scr.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._scr.set_shadow_type(gtk.SHADOW_IN) self.pack_start(self._scr, True) # toolbar self._button_warnings = gtk.ToggleToolButton() self._button_warnings.set_tooltip_text("Show/Hide Warnings") image = gtk.Image() image.set_from_file(find_resource("icons/warning.png")) self._button_warnings.set_icon_widget(image) self._button_warnings.set_active(self._show_warnings) self._handlers[self._button_warnings] = self._button_warnings.connect( "toggled", self.__on_warnings_toggled) self._button_tasks = gtk.ToggleToolButton() self._button_tasks.set_tooltip_text("Show/Hide Tasks") imageTask = gtk.Image() imageTask.set_from_file(find_resource("icons/task.png")) self._button_tasks.set_icon_widget(imageTask) self._button_tasks.set_active(self._show_tasks) self._handlers[self._button_tasks] = self._button_tasks.connect( "toggled", self.__on_tasks_toggled) toolbar = gtk.Toolbar() toolbar.set_orientation(gtk.ORIENTATION_VERTICAL) toolbar.set_style(gtk.TOOLBAR_ICONS) toolbar.set_icon_size(gtk.ICON_SIZE_MENU) toolbar.insert(self._button_warnings, -1) toolbar.insert(self._button_tasks, -1) self.pack_start(toolbar, False) self._issues = [] self._preferences.register_monitor(self) self._log.debug("init finished")
def __init__(self, *args, **kwargs): super(WinCSV, self).__init__(*args, **kwargs) self.dialog = gtk.Dialog(parent=self.parent, flags=gtk.DIALOG_DESTROY_WITH_PARENT) self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.dialog.set_icon(TRYTON_ICON) self.dialog.connect('response', self.response) dialog_vbox = gtk.VBox() self.add_header(dialog_vbox) hbox_mapping = gtk.HBox(True) dialog_vbox.pack_start(hbox_mapping, True, True, 0) frame_fields = gtk.Frame() frame_fields.set_shadow_type(gtk.SHADOW_NONE) viewport_fields = gtk.Viewport() scrolledwindow_fields = gtk.ScrolledWindow() scrolledwindow_fields.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) viewport_fields.add(scrolledwindow_fields) frame_fields.add(viewport_fields) label_all_fields = gtk.Label(_('<b>All fields</b>')) label_all_fields.set_use_markup(True) frame_fields.set_label_widget(label_all_fields) hbox_mapping.pack_start(frame_fields, True, True, 0) vbox_buttons = gtk.VBox(False, 10) vbox_buttons.set_border_width(5) hbox_mapping.pack_start(vbox_buttons, False, True, 0) button_add = gtk.Button(_('_Add'), stock=None, use_underline=True) button_add.set_alignment(0.0, 0.0) img_button = gtk.Image() img_button.set_from_stock('tryton-list-add', gtk.ICON_SIZE_BUTTON) button_add.set_image(img_button) button_add.connect_after('clicked', self.sig_sel) vbox_buttons.pack_start(button_add, False, False, 0) button_remove = gtk.Button(_('_Remove'), stock=None, use_underline=True) button_remove.set_alignment(0.0, 0.0) img_button = gtk.Image() img_button.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_BUTTON) button_remove.set_image(img_button) button_remove.connect_after('clicked', self.sig_unsel) vbox_buttons.pack_start(button_remove, False, False, 0) button_remove_all = gtk.Button(_('_Clear'), stock=None, use_underline=True) button_remove_all.set_alignment(0.0, 0.0) img_button = gtk.Image() img_button.set_from_stock('tryton-clear', gtk.ICON_SIZE_BUTTON) button_remove_all.set_image(img_button) button_remove_all.connect_after('clicked', self.sig_unsel_all) vbox_buttons.pack_start(button_remove_all, False, False, 0) hseparator_buttons = gtk.HSeparator() vbox_buttons.pack_start(hseparator_buttons, False, False, 3) self.add_buttons(vbox_buttons) frame_fields_selected = gtk.Frame() frame_fields_selected.set_shadow_type(gtk.SHADOW_NONE) viewport_fields_selected = gtk.Viewport() scrolledwindow_fields_selected = gtk.ScrolledWindow() scrolledwindow_fields_selected.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) viewport_fields_selected.add(scrolledwindow_fields_selected) frame_fields_selected.add(viewport_fields_selected) label_fields_selected = gtk.Label(_('<b>Fields selected</b>')) label_fields_selected.set_use_markup(True) frame_fields_selected.set_label_widget(label_fields_selected) hbox_mapping.pack_start(frame_fields_selected, True, True, 0) frame_csv_param = gtk.Frame() frame_csv_param.set_shadow_type(gtk.SHADOW_ETCHED_OUT) dialog_vbox.pack_start(frame_csv_param, False, True, 0) alignment_csv_param = gtk.Alignment(0.5, 0.5, 1, 1) alignment_csv_param.set_padding(7, 7, 7, 7) frame_csv_param.add(alignment_csv_param) vbox_csv_param = gtk.VBox() alignment_csv_param.add(vbox_csv_param) self.add_chooser(vbox_csv_param) expander_csv = gtk.Expander() vbox_csv_param.pack_start(expander_csv, False, True, 0) label_csv_param = gtk.Label(_('CSV Parameters')) expander_csv.set_label_widget(label_csv_param) table = gtk.Table(2, 4, False) table.set_border_width(8) table.set_row_spacings(9) table.set_col_spacings(8) expander_csv.add(table) label_csv_delimiter = gtk.Label(_('Delimiter:')) label_csv_delimiter.set_alignment(1, 0.5) table.attach(label_csv_delimiter, 0, 1, 0, 1) self.csv_delimiter = gtk.Entry() self.csv_delimiter.set_max_length(1) if os.name == 'nt' and ',' == locale.localeconv()['decimal_point']: delimiter = ';' else: delimiter = ',' self.csv_delimiter.set_text(delimiter) self.csv_delimiter.set_width_chars(1) label_csv_delimiter.set_mnemonic_widget(self.csv_delimiter) table.attach(self.csv_delimiter, 1, 2, 0, 1) label_csv_quotechar = gtk.Label(_("Quote char:")) label_csv_quotechar.set_alignment(1, 0.5) table.attach(label_csv_quotechar, 2, 3, 0, 1) self.csv_quotechar = gtk.Entry() self.csv_quotechar.set_text("\"") self.csv_quotechar.set_width_chars(1) label_csv_quotechar.set_mnemonic_widget(self.csv_quotechar) table.attach(self.csv_quotechar, 3, 4, 0, 1) label_csv_enc = gtk.Label(_("Encoding:")) label_csv_enc.set_alignment(1, 0.5) table.attach(label_csv_enc, 0, 1, 1, 2) if hasattr(gtk, 'ComboBoxText'): self.csv_enc = gtk.ComboBoxText() else: self.csv_enc = gtk.combo_box_new_text() for i, encoding in enumerate(encodings): self.csv_enc.append_text(encoding) if ((os.name == 'nt' and encoding == 'cp1252') or (os.name != 'nt' and encoding == 'utf_8')): self.csv_enc.set_active(i) label_csv_enc.set_mnemonic_widget(self.csv_enc) table.attach(self.csv_enc, 1, 2, 1, 2) self.add_csv_header_param(table) button_cancel = gtk.Button("gtk-cancel", stock="gtk-cancel") self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL) button_ok = gtk.Button("gtk-ok", stock="gtk-ok") self.dialog.add_action_widget(button_ok, gtk.RESPONSE_OK) self.dialog.vbox.pack_start(dialog_vbox) self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.view1.connect('row-expanded', self.on_row_expanded) scrolledwindow_fields.add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) scrolledwindow_fields_selected.add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field name'), cell, text=0) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field name'), cell, text=0) self.view2.append_column(column) self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.model_populate(self._get_fields(self.model)) self.view1.set_model(self.model1) self.view1.connect('row-activated', self.sig_sel) self.view2.set_model(self.model2) self.view2.connect('row-activated', self.sig_unsel) sensible_allocation = self.sensible_widget.get_allocation() self.dialog.set_default_size(sensible_allocation.width, sensible_allocation.height) self.dialog.show_all() center_window(self.dialog, self.parent, self.sensible_widget) self.register() if sys.platform != 'darwin': self.view2.drag_source_set( gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK, [ gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0) ], gtk.gdk.ACTION_MOVE) self.view2.drag_dest_set(gtk.DEST_DEFAULT_ALL, [ gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0) ], gtk.gdk.ACTION_MOVE) self.view2.connect('drag-begin', self.drag_begin) self.view2.connect('drag-motion', self.drag_motion) self.view2.connect('drag-drop', self.drag_drop) self.view2.connect("drag-data-get", self.drag_data_get) self.view2.connect('drag-data-received', self.drag_data_received) self.view2.connect('drag-data-delete', self.drag_data_delete)
def __init__(self): self.xml = xml self.notebook = xml.get_widget("notebook") self.label_dict = {} self.tooltip_dict = {} label = xml.get_widget("select_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_user_roles_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_dir_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_domain_admin_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_in_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_out_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_common_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_manages_label") self.label_dict[label] = label.get_text() label = xml.get_widget("select_booleans_label") self.label_dict[label] = label.get_text() label = xml.get_widget("existing_user_treeview") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("transition_treeview") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_tcp_all_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_tcp_reserved_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_tcp_unreserved_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_tcp_entry") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_udp_all_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_udp_reserved_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_udp_unreserved_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("in_udp_entry") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("out_tcp_entry") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("out_udp_entry") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("out_tcp_all_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("out_udp_all_checkbutton") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("boolean_treeview") self.tooltip_dict[label] = label.get_tooltip_text() label = xml.get_widget("write_treeview") self.tooltip_dict[label] = label.get_tooltip_text() try: self.all_types = sepolicy.generate.get_all_types() self.all_modules = get_all_modules() self.all_roles = sepolicy.generate.get_all_roles() self.all_users = sepolicy.generate.get_all_users() except RuntimeError as e: self.all_types = [] self.all_modules = [] self.all_roles = [] self.all_users = [] self.error(str(e)) self.name = "" xml.signal_connect("on_delete_clicked", self.delete) xml.signal_connect("on_delete_boolean_clicked", self.delete_boolean) xml.signal_connect("on_exec_select_clicked", self.exec_select) xml.signal_connect("on_init_script_select_clicked", self.init_script_select) xml.signal_connect("on_add_clicked", self.add) xml.signal_connect("on_add_boolean_clicked", self.add_boolean) xml.signal_connect("on_add_dir_clicked", self.add_dir) xml.signal_connect("on_about_clicked", self.on_about_clicked) xml.get_widget("cancel_button").connect("clicked", self.quit) self.forward_button = xml.get_widget("forward_button") self.forward_button.connect("clicked", self.forward) self.back_button = xml.get_widget("back_button") self.back_button.connect("clicked", self.back) self.boolean_dialog = xml.get_widget("boolean_dialog") self.boolean_name_entry = xml.get_widget("boolean_name_entry") self.boolean_description_entry = xml.get_widget( "boolean_description_entry") self.pages = {} for i in sepolicy.generate.USERS: self.pages[i] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] self.pages[sepolicy.generate.RUSER] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.ADMIN_PAGE, self.USER_TRANSITION_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] self.pages[sepolicy.generate.LUSER] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] self.pages[sepolicy.generate.SANDBOX] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] self.pages[sepolicy.generate.EUSER] = [ self.SELECT_TYPE_PAGE, self.EXISTING_USER_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] for i in sepolicy.generate.APPLICATIONS: self.pages[i] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.COMMON_APPS_PAGE, self.FILES_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] self.pages[sepolicy.generate.USER] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.USER_TRANSITION_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.COMMON_APPS_PAGE, self.FILES_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE ] self.current_page = 0 self.back_button.set_sensitive(0) self.network_buttons = {} self.in_tcp_all_checkbutton = xml.get_widget("in_tcp_all_checkbutton") self.in_tcp_reserved_checkbutton = xml.get_widget( "in_tcp_reserved_checkbutton") self.in_tcp_unreserved_checkbutton = xml.get_widget( "in_tcp_unreserved_checkbutton") self.in_tcp_entry = self.xml.get_widget("in_tcp_entry") self.network_buttons[self.in_tcp_all_checkbutton] = [ self.in_tcp_reserved_checkbutton, self.in_tcp_unreserved_checkbutton, self.in_tcp_entry ] self.out_tcp_all_checkbutton = xml.get_widget( "out_tcp_all_checkbutton") self.out_tcp_reserved_checkbutton = xml.get_widget( "out_tcp_reserved_checkbutton") self.out_tcp_unreserved_checkbutton = xml.get_widget( "out_tcp_unreserved_checkbutton") self.out_tcp_entry = self.xml.get_widget("out_tcp_entry") self.network_buttons[self.out_tcp_all_checkbutton] = [ self.out_tcp_entry ] self.in_udp_all_checkbutton = xml.get_widget("in_udp_all_checkbutton") self.in_udp_reserved_checkbutton = xml.get_widget( "in_udp_reserved_checkbutton") self.in_udp_unreserved_checkbutton = xml.get_widget( "in_udp_unreserved_checkbutton") self.in_udp_entry = self.xml.get_widget("in_udp_entry") self.network_buttons[self.in_udp_all_checkbutton] = [ self.in_udp_reserved_checkbutton, self.in_udp_unreserved_checkbutton, self.in_udp_entry ] self.out_udp_all_checkbutton = xml.get_widget( "out_udp_all_checkbutton") self.out_udp_entry = self.xml.get_widget("out_udp_entry") self.network_buttons[self.out_udp_all_checkbutton] = [ self.out_udp_entry ] for b in self.network_buttons.keys(): b.connect("clicked", self.network_all_clicked) self.boolean_treeview = self.xml.get_widget("boolean_treeview") self.boolean_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.boolean_treeview.set_model(self.boolean_store) self.boolean_store.set_sort_column_id(0, gtk.SORT_ASCENDING) col = gtk.TreeViewColumn(_("Name"), gtk.CellRendererText(), text=0) self.boolean_treeview.append_column(col) col = gtk.TreeViewColumn(_("Description"), gtk.CellRendererText(), text=1) self.boolean_treeview.append_column(col) self.role_treeview = self.xml.get_widget("role_treeview") self.role_store = gtk.ListStore(gobject.TYPE_STRING) self.role_treeview.set_model(self.role_store) self.role_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.role_store.set_sort_column_id(0, gtk.SORT_ASCENDING) col = gtk.TreeViewColumn(_("Role"), gtk.CellRendererText(), text=0) self.role_treeview.append_column(col) self.existing_user_treeview = self.xml.get_widget( "existing_user_treeview") self.existing_user_store = gtk.ListStore(gobject.TYPE_STRING) self.existing_user_treeview.set_model(self.existing_user_store) self.existing_user_store.set_sort_column_id(0, gtk.SORT_ASCENDING) col = gtk.TreeViewColumn(_("Existing_User"), gtk.CellRendererText(), text=0) self.existing_user_treeview.append_column(col) for i in self.all_roles: iter = self.role_store.append() self.role_store.set_value(iter, 0, i[:-2]) self.in_tcp_reserved_checkbutton = xml.get_widget( "in_tcp_reserved_checkbutton") self.transition_treeview = self.xml.get_widget("transition_treeview") self.transition_store = gtk.ListStore(gobject.TYPE_STRING) self.transition_treeview.set_model(self.transition_store) self.transition_treeview.get_selection().set_mode( gtk.SELECTION_MULTIPLE) self.transition_store.set_sort_column_id(0, gtk.SORT_ASCENDING) col = gtk.TreeViewColumn(_("Application"), gtk.CellRendererText(), text=0) self.transition_treeview.append_column(col) self.user_transition_treeview = self.xml.get_widget( "user_transition_treeview") self.user_transition_store = gtk.ListStore(gobject.TYPE_STRING) self.user_transition_treeview.set_model(self.user_transition_store) self.user_transition_treeview.get_selection().set_mode( gtk.SELECTION_MULTIPLE) self.user_transition_store.set_sort_column_id(0, gtk.SORT_ASCENDING) col = gtk.TreeViewColumn(_("Application"), gtk.CellRendererText(), text=0) self.user_transition_treeview.append_column(col) for i in self.all_users: iter = self.user_transition_store.append() self.user_transition_store.set_value(iter, 0, i[:-2]) iter = self.existing_user_store.append() self.existing_user_store.set_value(iter, 0, i[:-2]) self.admin_treeview = self.xml.get_widget("admin_treeview") self.admin_store = gtk.ListStore(gobject.TYPE_STRING) self.admin_treeview.set_model(self.admin_store) self.admin_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.admin_store.set_sort_column_id(0, gtk.SORT_ASCENDING) col = gtk.TreeViewColumn(_("Application"), gtk.CellRendererText(), text=0) self.admin_treeview.append_column(col) try: for u in sepolicy.interface.get_user(): iter = self.transition_store.append() self.transition_store.set_value(iter, 0, u) for a in sepolicy.interface.get_admin(): iter = self.admin_store.append() self.admin_store.set_value(iter, 0, a) except ValueError as e: self.error(e.message)
def loadControls(self): def separator_filter(model, iter, data=None): return model.get_value(iter, 2) gw = self.gladeFile.get_widget self.dlgPrefs = gw('dlgPreferences') self.cboPlayer = gw('cboPlayer') self.lblPlayerCommand = gw('lblPlayerCommand') self.txtPlayerCommand = gw('txtPlayerCommand') self.btnPlayerTest = gw('btnPlayerTest') self.chkPlayWelcome = gw('chkPlayWelcome') self.chkCustomWelcome = gw('chkCustomWelcome') self.lblCustomWelcome = gw('lblCustomWelcome') self.txtWelcomeText = gw('txtWelcomeText') self.chkSaveVoice = gw('chkSaveVoice') self.chkSaveSize = gw('chkSaveSize') self.chkSingleRecord = gw('chkRecordSingleTrack') self.chkWordWrap = gw('chkWordWrap') self.chkLoadVariants = gw('chkLoadVariants') self.tvwLanguages = gw('tvwLanguages') self.chooserLanguagePath = gw('chooserLanguagePath') self.btnRefresh = gw('btnRefresh') self.btnOk = gw('btnOk') self.imgExecutableMbrola = gw('imgExecutableMbrola') self.lblExecutableMbrolaStatus = gw('lblExecutableMbrolaStatus') self.lblLanguagesDetected = gw('lblLanguagesDetected') # Prepare model for players combo listStore = gtk.ListStore(gtk.gdk.Pixbuf, str, bool) self.cboPlayer.set_model(listStore) # First is image cell = gtk.CellRendererPixbuf() self.cboPlayer.pack_start(cell, False) self.cboPlayer.add_attribute(cell, 'pixbuf', 0) # Second is text cell = gtk.CellRendererText() self.cboPlayer.pack_start(cell, False) self.cboPlayer.add_attribute(cell, 'text', 1) self.cboPlayer.set_row_separator_func(separator_filter) # Load icons and text for methods listStore.append([Pixbuf_load_file( handlepaths.getPath('icons', 'alsalogo.png'), (24, 24)), _('ALSA - Advanced Linux Sound Architecture'), False]) listStore.append([Pixbuf_load_file( handlepaths.getPath('icons', 'palogo.png'), (24, 24)), _('PulseAudio sound server'), False]) listStore.append([None, '_', True]) listStore.append([None, _('Custom sound application'), False]) # Change testing button caption Button_change_stock_description(self.btnPlayerTest, _('_Test'), True) # Create model and sorted model for mbrola languages self.modelMbrola = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str) #self.tvwLanguages.set_model(self.modelMbrola) sortedModel = gtk.TreeModelSort(self.modelMbrola) sortedModel.set_sort_column_id(1, gtk.SORT_ASCENDING) self.tvwLanguages.set_model(sortedModel) # Create columns for tvwLanguages COL_LANG_IMG, COL_LANG_LANG, COL_LANG_RES, COL_LANG_STATUS = range(4) cell = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn('') column.pack_start(cell) column.set_attributes(cell, pixbuf=COL_LANG_IMG) self.tvwLanguages.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Language'), cell, text=COL_LANG_LANG) column.set_sort_column_id(COL_LANG_LANG) column.set_resizable(True) self.tvwLanguages.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Resource'), cell, text=COL_LANG_RES) column.set_sort_column_id(COL_LANG_RES) column.set_resizable(True) self.tvwLanguages.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Status'), cell, text=COL_LANG_STATUS) column.set_sort_column_id(COL_LANG_STATUS) column.set_resizable(True) self.tvwLanguages.append_column(column) # Order by Language column #column = self.tvwLanguages.get_column(COL_LANG_LANG) #column.set_sort_column_id(COL_LANG_LANG) #column.set_sort_order(gtk.SORT_ASCENDING) #column.set_sort_indicator(True) # Plugins self.tvwPlugins = gw('tvwPlugins') self.btnPluginInfo = gw('btnPluginInfo') self.btnPluginConfigure = gw('btnPluginConfigure') Button_change_stock_description(self.btnPluginInfo, _('_About plugin'), True) Button_change_stock_description(self.btnPluginConfigure, _('_Configure plugin'), True) # Create model for plugins list self.modelPlugins = gtk.ListStore( bool, # active gtk.gdk.Pixbuf, # icon str, # name str # markup ) sortedModel = gtk.TreeModelSort(self.modelPlugins) sortedModel.set_sort_column_id(COL_NAME, gtk.SORT_ASCENDING) self.tvwPlugins.set_model(sortedModel) cell = gtk.CellRendererToggle() cell.connect('toggled', self.on_pluginenable_toggle) column = gtk.TreeViewColumn(None, cell, active=COL_ACTIVE) self.tvwPlugins.append_column(column) cell = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn(None, cell, pixbuf=COL_ICON) self.tvwPlugins.append_column(column) cell = gtk.CellRendererText() cell.set_property('ellipsize', pango.ELLIPSIZE_END) column = gtk.TreeViewColumn(None, cell, markup=COL_MARKUP) column.set_resizable(True) self.tvwPlugins.append_column(column)
def __init__(self, settings=None): self.glade = gtk.glade.XML(get_resource("config.glade")) self.config_page = self.glade.get_widget("prefs_box") self.pref_dialog = component.get("Preferences").pref_dialog fb_icon = self.glade.get_widget("fb_icon") image = get_resource("fb_icon16.png") fb_icon.set_from_file(image) model = gtk.ListStore(str) view = self.glade.get_widget('saved_handlers_listview') renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("Profile Name", renderer, text=0) view.append_column(column) model.set_sort_column_id(0, gtk.SORT_ASCENDING) self.handlers_list = EditableList(view, model) model = gtk.ListStore(str, str, str, str) view = self.glade.get_widget('rule_listview') options = [ ("Field:", VALID_FIELDS), ("Comparison Operator:", SORT_OPERATORS), ] for col_index, tup in enumerate(options): name, items = tup combo_model = gtk.ListStore(str) for item in items: combo_model.append([item]) cb = build_combo_renderer_cb(model, col_index, items) renderer = build_combo_cellrenderer(combo_model, cb) column = gtk.TreeViewColumn(name, renderer, text=col_index) view.append_column(column) renderer = gtk.CellRendererText() renderer.set_property("editable", True) def text_edited(widget, path, text): model[path][2] = text renderer.connect("edited", text_edited) column = gtk.TreeViewColumn("Pattern to Match:", renderer, text=2) view.append_column(column) self.rules_list = EditableList(view, model) self.glade.signal_autoconnect({ "on_add_handler": self.on_add_handler, "on_remove_handler": self.handlers_list.remove, "on_edit_handler": self.on_edit_handler, "on_move_rule_up": self.rules_list.move_up, "on_move_rule_down": self.rules_list.move_down, "on_remove_rule": self.rules_list.remove, "on_add_rule": self.on_add_rule, "on_auto_sort_help_clicked": self.on_auto_sort_help_clicked, "on_debug_button_clicked": self.on_debug_button_clicked, "on_license_button_clicked": self.on_license_button_clicked, }) self.gather_time = None if settings: self.populate_settings(settings)
def configure_widgets(self, dialog, tree): rend = gtk.CellRendererText() col = gtk.TreeViewColumn("", rend, text=0) tree.append_column(col) tree.get_selection().set_mode(gtk.SELECTION_NONE)
def draw_view(self, model, xml, units): self.view = xml.get_widget('param_tree') self.view.set_model(model) self.view.set_tooltip_column(6) self.model = model #Set the row renderers self.name_render = gtk.CellRendererText() self.name_render.set_property('foreground-set', True) self.name_render.set_property('weight-set', True) #self.param_render = gtk.CellRendererText() #self.param_render.set_property('editable',True) #self.param_render.connect('edited', self.set_param_callback,model) #self.param_render.set_property('foreground-set',True) #self.param_render.set_property('weight-set',True) self.icon_render = gtk.CellRendererPixbuf() self.toggle_render = gtk.CellRendererToggle() self.toggle_render.connect('toggled', self.toggle_callback, model) self.toggle_render.set_property('indicator-size', 0) self.units_render = gtk.CellRendererText() self.units_render.set_property('editable', True) #self.units_render.set_property('model',self.umodel) #self.units_render.set_property('text-column',0) self.units_render.set_property('foreground-set', True) self.units_render.set_property('weight-set', True) #self.units_render.set_property('has-entry',False) self.units = units self._units = [] #self.units_render.connect('editing-started',self.populate_units,model,self.units) self.units_render.connect('edited', self.set_units_callback, model) self.description_render = gtk.CellRendererText() self.description_render.set_property('foreground-set', True) self.description_render.set_property('weight-set', True) #Set the column views self.name_column = gtk.TreeViewColumn('Parameter', self.name_render, text=0, foreground=4, weight=5) #self.name_column.pack_start(self.toggle_render_name,False) #self.name_column.set_attributes(self.param_render,text=1) self.description_column = gtk.TreeViewColumn('Description', self.description_render, text=6, foreground=4, weight=5) #self.param_column = gtk.TreeViewColumn('Value') #self.param_column.set_expand(False) #self.param_column.pack_start(self.param_render,False) #self.param_column.set_attributes(self.param_render,text=1, foreground =5, weight=6) #self.param_column.set_expand(False) self.toggle_column = gtk.TreeViewColumn('Status') self.toggle_column.pack_start(self.icon_render, False) self.toggle_column.pack_start(self.toggle_render, False) self.toggle_column.set_attributes(self.icon_render, pixbuf=2) self.units_column = gtk.TreeViewColumn('Value', self.units_render, text=1, foreground=4, weight=5) self.view.append_column(self.name_column) self.view.append_column(self.toggle_column) #self.view.append_column(self.param_column) self.view.append_column(self.units_column) self.view.append_column(self.description_column) return self.view
def add_column(self, name, index): cell = gtk.CellRendererText() #cell.set_property('cell-background', 'gray') col = gtk.TreeViewColumn(name, cell, text=index) self.tree.append_column(col)
def showSelect(self): selLabel=gtk.Label("Please select the test items") scrollWin=gtk.ScrolledWindow() scrollWin.set_size_request(300,400) scrollWin.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.vbox.pack_start(selLabel, False,False, 20) store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_INT ) self.con_db() self.get_type_from_db() self.typeNum = 0 #self.get_kblayout() for item in self.alltype: store.append((item[0], None, item[1])) self.typeNum += 1 treeView = gtk.TreeView(store) cell2 = gtk.CellRendererToggle() cell2.set_property('activatable', True) cell2.connect( 'toggled', self.on_item_clicked, store) cell1 = gtk.CellRendererText() cell1.set_property( 'editable', False ) #cell1.connect( 'edited', self.col0_edited_cb, store ) column1 = gtk.TreeViewColumn("Test type\t\t\t\t\t\t\t", cell1, text=0) column2 = gtk.TreeViewColumn("\t\t\t\t\tSelect", cell2 ) column2.add_attribute( cell2, "active", 1) #cell.connect("toggled", self.on_item_clicked) treeView.append_column(column1) treeView.append_column(column2) treeView.columns_autosize() scrollWin.add(treeView) #select all self.chkAll = gtk.CheckButton("Check All") self.chkAll.set_active(False) self.chkAll.unset_flags(gtk.CAN_FOCUS) self.chkAll.connect("clicked", self.on_chkAll_clicked, store) #just all automatic test item self.chkOnlyAuto = gtk.CheckButton("Auto test all automatic items") self.chkOnlyAuto.set_active(False) self.chkOnlyAuto.unset_flags(gtk.CAN_FOCUS) self.chkOnlyAuto.connect("clicked", self.on_chkOnlyAuto_clicked, store) #total select label self.selMsgLabel = gtk.Label() hbox1 = gtk.HBox() hbox1.pack_end(self.selMsgLabel, False, False,5) hbox2 = gtk.HBox() hbox2.pack_start(self.chkAll, False, False, 0) hbox2.pack_start(self.chkOnlyAuto, False, False, 30) #start button startBtn = gtk.Button("Start") startBtn.connect("clicked", self.start_test_clicked, store) startBtn.set_size_request(100, 30) startBtn.set_tooltip_text("Click me,start test") self.set_button_bg_color(startBtn, button_bg_color) hbox3 = gtk.HBox() hbox3.pack_start(startBtn, True, False, 0) startBtn.set_size_request(100, 30) treeView.set_rules_hint(True) self.vbox.pack_start(scrollWin, False,False, 2) self.vbox.pack_start(hbox1, False,False, 0) self.vbox.pack_start(hbox2, False,False, 20) self.vbox.pack_start(hbox3, False,False, 20)
def CreateColumns(self, treeView): rendererText = gtk.CellRendererText() column = gtk.TreeViewColumn("Name", rendererText, text=0) column.set_sort_column_id(0) self.treeView.append_column(column)
def __init__(self, node): gtk.Window.__init__(self) self.set_default_size(640, 480) self.trayIcon = gtk.status_icon_new_from_stock(gtk.STOCK_FIND) self.trayIcon.connect('popup-menu', self._trayIconRightClick) self.trayIcon.connect('activate', self._trayIconClick) self.node = node self.connect("delete-event", self._hideWindow) # Layout the window highLevelVbox = gtk.VBox(spacing=3) self.add(highLevelVbox) highLevelVbox.show() notebook = gtk.Notebook() notebook.set_tab_pos(pos=gtk.POS_TOP) notebook.show() highLevelVbox.pack_start(notebook, expand=True, fill=True) vbox = gtk.VBox(spacing=3) vbox.show() notebook.append_page(vbox, gtk.Label('Search P2P Network')) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vbox.pack_start(sw) # Create tree model model = self.createListStore([]) # Create tree view self.dhtTreeView = gtk.TreeView(model) self.dhtTreeView.set_rules_hint(True) self.dhtTreeView.set_search_column(0) self.dhtTreeView.connect('row-activated', self.downloadFile) # Add the tree view to the scrolling window sw.add(self.dhtTreeView) # column for file name/description column = gtk.TreeViewColumn('File list:', gtk.CellRendererText(), text=0) column.set_sort_column_id(0) self.dhtTreeView.append_column(column) # Add the controls # Search for keyword hbox = gtk.HBox(False, 8) hbox.show() label = gtk.Label("Search:") hbox.pack_start(label, False, False, 0) label.show() entryKeyword = gtk.Entry() hbox.pack_start(entryKeyword, expand=True, fill=True) entryKeyword.show() button = gtk.Button('Search') hbox.pack_start(button, expand=False, fill=False) button.connect("clicked", self.search, entryKeyword) button.show() self.progressBar = gtk.ProgressBar() self.progressBar.show() hbox.pack_start(self.progressBar, expand=True, fill=True) self.progressBar.show() vbox.pack_start(hbox, expand=False, fill=False) ######### Publish data vbox = gtk.VBox(spacing=3) vbox.show() notebook.append_page(vbox, gtk.Label('Share Local Files')) # List view sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vbox.pack_start(sw) model = self.createListStore([]) self.localTreeView = gtk.TreeView(model) self.localTreeView.set_rules_hint(True) self.localTreeView.set_search_column(0) self.localTreeView.connect('row-activated', self.downloadFile) sw.add(self.localTreeView) column = gtk.TreeViewColumn('Shared Files:', gtk.CellRendererText(), text=0) column.set_sort_column_id(0) self.localTreeView.append_column(column) hbox = gtk.HBox(False, 8) hbox.show() label = gtk.Label("Share directory:") hbox.pack_start(label, False, False, 0) label.show() self.entryDir = gtk.Entry() hbox.pack_start(self.entryDir, expand=True, fill=True) self.entryDir.show() button = gtk.Button('Browse') hbox.pack_start(button, expand=False, fill=False) button.connect("clicked", self.browseDirectory, self.entryDir.get_text) button.show() button = gtk.Button('Publish') hbox.pack_start(button, expand=False, fill=False) button.connect("clicked", self.publishDirectory, self.entryDir.get_text) button.show() vbox.pack_start(hbox, expand=False, fill=False) self._setupTCPNetworking() self.show_all()
def __init__(self): Tab.__init__(self) builder = component.get("MainWindow").get_builder() self._name = "Peers" self._child_widget = builder.get_object("peers_tab") self._tab_label = builder.get_object("peers_tab_label") self.peer_menu = builder.get_object("menu_peer_tab") component.get("MainWindow").connect_signals({ "on_menuitem_add_peer_activate": self._on_menuitem_add_peer_activate, }) self.listview = builder.get_object("peers_listview") self.listview.props.has_tooltip = True self.listview.connect("button-press-event", self._on_button_press_event) self.listview.connect("query-tooltip", self._on_query_tooltip) # country pixbuf, ip, client, downspeed, upspeed, country code, int_ip, seed/peer icon, progress self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, float, gtk.gdk.Pixbuf, float) self.cached_flag_pixbufs = {} self.seed_pixbuf = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("seeding16.png")) self.peer_pixbuf = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("downloading16.png")) # key is ip address, item is row iter self.peers = {} # Country column column = gtk.TreeViewColumn() render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "pixbuf", 0) column.set_sort_column_id(5) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(20) column.set_reorderable(True) self.listview.append_column(column) # Address column column = gtk.TreeViewColumn(_("Address")) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "pixbuf", 7) render = gtk.CellRendererText() column.pack_start(render, False) column.add_attribute(render, "text", 1) column.set_sort_column_id(6) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Client column column = gtk.TreeViewColumn(_("Client")) render = gtk.CellRendererText() column.pack_start(render, False) column.add_attribute(render, "text", 2) column.set_sort_column_id(2) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Progress column column = gtk.TreeViewColumn(_("Progress")) render = gtk.CellRendererProgress() column.pack_start(render, True) column.set_cell_data_func(render, cell_data_progress, 8) column.set_sort_column_id(8) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Down Speed column column = gtk.TreeViewColumn(_("Down Speed")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed, 3) column.set_sort_column_id(3) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) column.set_reorderable(True) self.listview.append_column(column) # Up Speed column column = gtk.TreeViewColumn(_("Up Speed")) render = gtk.CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed, 4) column.set_sort_column_id(4) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) # Bugfix: Last column needs max_width set to stop scrollbar appearing column.set_max_width(150) column.set_reorderable(True) self.listview.append_column(column) self.listview.set_model(self.liststore) self.load_state() self.torrent_id = None
def __init__(self, app, root=''): gtk.VBox.__init__(self, False, 0) self.mw = app.mw self.app = app self.caption_label = TabIconCaption(gtk.STOCK_HARDDISK, self.caption) self.root = root self.current_dir = "" + config.fb_current_directory spacer = gtk.VBox() self.add(spacer) self.set_border_width(5) nav_panel = gtk.HBox() nav_panel.set_border_width(3) self.back_but = NavigationButton(gtk.STOCK_GO_BACK, _('Go Back')) nav_panel.pack_start(self.back_but, False) self.back_but.connect('clicked', self.action_back) self.up_but = NavigationButton(gtk.STOCK_GO_UP, _('Go Up')) nav_panel.pack_start(self.up_but, False) self.up_but.connect('clicked', self.action_up) self.forward_but = NavigationButton(gtk.STOCK_GO_FORWARD, _('Go Forward')) nav_panel.pack_start(self.forward_but, False) self.forward_but.connect('clicked', self.action_forward) self.home_but = NavigationButton(gtk.STOCK_HOME, _('Home directory')) nav_panel.pack_start(self.home_but, False) self.home_but.connect('clicked', self.action_home) separator = gtk.VSeparator() nav_panel.pack_start(separator, False, padding=2) self.refr_but = NavigationButton(gtk.STOCK_REFRESH, _('Refresh')) nav_panel.pack_start(self.refr_but, False) self.refr_but.connect('clicked', self.update_view) separator = gtk.VSeparator() nav_panel.pack_start(separator, False, padding=2) self.find_but = NavigationToggleButton(gtk.STOCK_FIND, _('Show all files')) nav_panel.pack_start(self.find_but, False) self.find_but.connect('clicked', self.update_view) spacer.pack_start(nav_panel, False) self.listmodel = FileListModel() self.treeview = gtk.TreeView() self.column = gtk.TreeViewColumn() self.column.set_title(_('Log Entries')) render_pixbuf = gtk.CellRendererPixbuf() self.column.pack_start(render_pixbuf, expand=False) self.column.add_attribute(render_pixbuf, 'pixbuf', 0) render_text = gtk.CellRendererText() self.column.pack_start(render_text, expand=True) self.column.add_attribute(render_text, 'text', 1) self.treeview.append_column(self.column) self.treeview.connect('row-activated', self.open_file) self.scrolledwindow = gtk.ScrolledWindow() self.scrolledwindow.add(self.treeview) self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) spacer.pack_end(self.scrolledwindow, True) self.treeview.set_model(self.listmodel) self.treeview.set_rules_hint(True) events.connect(events.CONFIG_MODIFIED, self.update_by_config) self.find_but.set_active(config.fb_show_all_files) self.update_view()
def __init__(self): gtk.Window.__init__(self) self.set_title("Dependency Explorer") self.set_default_size(500, 500) self.connect("delete-event", gtk.main_quit) # Create the data models self.pkg_model = gtk.ListStore(gobject.TYPE_STRING) self.pkg_model.set_sort_column_id(COL_PKG_NAME, gtk.SORT_ASCENDING) self.depends_model = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING) self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, gtk.SORT_ASCENDING) pane = gtk.HPaned() pane.set_position(250) self.add(pane) # The master list of packages scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_IN) self.pkg_treeview = gtk.TreeView(self.pkg_model) self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed) column = gtk.TreeViewColumn("Package", gtk.CellRendererText(), text=COL_PKG_NAME) self.pkg_treeview.append_column(column) pane.add1(scrolled) scrolled.add(self.pkg_treeview) box = gtk.VBox(homogeneous=True, spacing=4) # Runtime Depends scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_IN) self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends") self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) scrolled.add(self.rdep_treeview) box.add(scrolled) # Build Depends scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_IN) self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends") self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) scrolled.add(self.dep_treeview) box.add(scrolled) pane.add2(box) # Reverse Depends scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_IN) self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends") self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT) scrolled.add(self.revdep_treeview) box.add(scrolled) pane.add2(box) self.show_all()
def setup_preferences(self, prefs): refresh_dialog = lambda v: self.refresh_icon_and_forecast() def refresh_curved_dialog(value): self.forecaster.setup_forecast_dialog() refresh_dialog(None) # dummy value refresh_map = lambda v: self.set_map_pixbuf(self.map_pixbuf) # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile(os.path.join(theme_dir, theme, "scalable/status/weather-clear.svg")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/weather-clear.png")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/weather-clear.svg")) themes = sorted(filter(filter_theme, os.listdir(theme_dir))) self.themes = [system_theme_name] + themes + ["moonbeam"] def refresh_theme_and_dialog(value): self.setup_theme() refresh_dialog(None) self.setup_theme() """ General preferences """ self.search_window = prefs.get_object("locations-search-dialog") def response_event_cb(widget, response): if response < 0: self.search_window.hide() self.search_window.connect("response", response_event_cb) self.search_window.connect("delete_event", lambda w, e: True) def location_button_clicked_cb(widget): self.init_search_window() self.search_list.append([_("No records found"), None]) self.search_window.show_all() prefs.get_object("button-location").connect( "clicked", location_button_clicked_cb) unit_combobox = prefs.get_object("combobox-temperature-unit") awnlib.add_cell_renderer_text(unit_combobox) for i in temperature_units: unit_combobox.append_text(i) theme_combobox = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(theme_combobox) for i in self.themes: theme_combobox.append_text(i) if self.applet.settings["theme"] not in self.themes: self.applet.settings["theme"] = self.themes[0] tempicon_checkbutton = prefs.get_object("checkbutton-temperature-icon") fontsize_hbox = prefs.get_object("hbox-font-size") fontsize_hbox.set_sensitive(tempicon_checkbutton.get_active()) tempicon_checkbutton.connect( "toggled", lambda w: fontsize_hbox.set_sensitive(w.get_active())) self.location_label = prefs.get_object("locationLabel") self.location_label.set_markup("<b>%s</b>" % self.applet.settings["location"]) binder = self.applet.settings.get_binder(prefs) binder.bind("show-temperature-icon", "checkbutton-temperature-icon", key_callback=self.refresh_icon) binder.bind("temperature-font-size", "combobox-font-size", key_callback=self.refresh_icon) binder.bind("temperature-unit", "combobox-temperature-unit", key_callback=refresh_dialog) binder.bind("theme", "combobox-theme", key_callback=refresh_theme_and_dialog) binder.bind("curved_dialog", "curvedCheckbutton", key_callback=refresh_curved_dialog) binder.bind("map_maxwidth", "mapWidthSpinbutton", key_callback=refresh_map) self.applet.settings.load_bindings(binder) """ Location search window """ self.search_list = gtk.ListStore(str, str) self.treeview = prefs.get_object("location-treeview") self.treeview.set_model(self.search_list) self.treeview.append_column( gtk.TreeViewColumn("Location", gtk.CellRendererText(), text=0)) self.ok_button = prefs.get_object("location-ok-button") self.ok_button.connect("clicked", self.ok_button_clicked_cb) self.treeview.connect("cursor-changed", lambda w: self.ok_button.set_sensitive(True)) self.treeview.connect("row-activated", lambda v, p, c: self.ok_button_clicked_cb()) find_button = prefs.get_object("location-find-button") self.location_entry = prefs.get_object("location-entry") def location_entry_changed_cb(widget): find_button.set_sensitive(len(self.location_entry.get_text()) > 0) self.location_entry.connect("changed", location_entry_changed_cb) self.location_entry.connect("activate", self.search_locations_cb) find_button.connect("clicked", self.search_locations_cb)
def __init__(self, session): '''class constructor''' self._model = None dialog = extension.get_default('dialog') pbr = extension.get_default('avatar renderer') self.pbr = pbr() gui.ContactList.__init__(self, session, dialog) gtk.TreeView.__init__(self) self.set_enable_search( False ) #we enable our searching widget with CTRL+F in MainWindow.py self.online_group = None # added self.online_group_iter = None # added self.no_group = None self.no_group_iter = None self.offline_group = None self.offline_group_iter = None self.hide_on_filtering = False self.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, [('emesene-contact', 0, 0), ('text/html', 0, 1), ('text/plain', 0, 2)], gtk.gdk.ACTION_COPY) self.enable_model_drag_dest([('emesene-contact', 0, 0)], gtk.gdk.ACTION_DEFAULT) self.contact_handler = gui.base.ContactHandler(session, dialog, self) self.group_handler = gui.base.GroupHandler(session, dialog, self) if self.session.config.d_weights is None: self.session.config.d_weights = {} # [0] the image (None for groups), # [1] the object (group or contact), # [2] the string to display # [3] a boolean indicating if the pixbuf should # be shown (False for groups, True for contacts) # [4] the status image # [5] an int that is used to allow ordering specified by the user # [6] a boolean indicating special groups always False for contacts, True # for special groups like "No group" # [7] a boolean indicating if the contact is offline self._model = gtk.TreeStore(gtk.Image, object, str, bool, gtk.gdk.Pixbuf, int, bool, bool) self.model = self._model.filter_new(root=None) self.model.set_visible_func(self._visible_func) self._model.set_sort_func(1, self._sort_method) self._model.set_sort_column_id(1, gtk.SORT_ASCENDING) self.set_model(self.model) self.tooltips = Tooltips.Tooltips() self.connect('motion-notify-event', self.tooltips.on_motion) self.connect('leave-notify-event', self.tooltips.on_leave) crt = extension.get_and_instantiate('nick renderer') crt.set_property('ellipsize', pango.ELLIPSIZE_END) pbr_status = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn() column.set_expand(True) self.exp_column = gtk.TreeViewColumn() self.exp_column.set_max_width(16) self.append_column(self.exp_column) self.append_column(column) self.set_expander_column(self.exp_column) column.pack_start(self.pbr, False) column.pack_start(crt, True) column.pack_start(pbr_status, False) column.add_attribute(self.pbr, 'image', 0) column.add_attribute(crt, 'markup', 2) column.add_attribute(self.pbr, 'visible', 3) column.add_attribute(pbr_status, 'visible', 3) column.add_attribute(pbr_status, 'pixbuf', 4) column.add_attribute(self.pbr, 'offline', 7) self.set_search_column(2) self.set_headers_visible(False) self.connect('row-activated', self._on_row_activated) self.connect('button-release-event', self._on_button_press_event) self.connect('row-expanded', self._on_expand) self.connect('row-collapsed', self._on_collapse) self.connect('drag-data-get', self._on_drag_data_get) self.connect('drag-drop', self._on_drag_drop)
def on_open_clicked(self, *args): Win = MyWindow() Win.w.hscale1.set_range(0.0, 1) Win.w.vscale1.set_range(0.0, 1) Win.w.spinbutton1.set_range(0.0, 1) distributions = [ "Fedora", "Sabayon", "Debian", "Arch Linux", "Crunchbang" ] liststore = Gtk.ListStore(str) for item in distributions: liststore.append([item]) cell = Gtk.CellRendererText() Win.w.combobox1.pack_start(cell, True) Win.w.combobox1.add_attribute(cell, "text", 0) Win.w.combobox1.set_model(liststore) textbuffer = Gtk.TextBuffer() #textbuffer.set_text('this\nis\na\nmultiline\ntext') Win.w.textview1.set_buffer(textbuffer) """ column = Gtk.TreeViewColumn('Column 0') column1 = Gtk.TreeViewColumn('Column 1') Win.w.treeview1.append_column(column) Win.w.treeview1.append_column(column1) cell = Gtk.CellRendererText() column.pack_start(cell, True) column.add_attribute(cell, 'text', 0) Win.w.treeview1.set_search_column(0) column.set_sort_column_id(0) Win.w.treeview1.set_reorderable(True) """ columns = ["First Name", "Last Name", "Phone Number"] phonebook = [["Jurg", "Billeter", "555-0123"], ["Johannes", "Schmid", "555-1234"], ["Julita", "Inca", "555-2345"], ["Javier", "Jardon", "555-3456"], ["Jason", "Clinton", "555-4567"], ["Random J.", "Hacker", "555-5678"]] for i in range(len(columns)): cell = Gtk.CellRendererText() if i == 0: cell.props.weight_set = True cell.props.weight = Pango.WEIGHT_BOLD col = Gtk.TreeViewColumn(columns[i], cell, text=i) Win.w.treeview1.append_column(col) Win.w.treeview1.set_model(Gtk.ListStore(str, str, str)) dict = { "window1": "Example GTK 2", "button1": "Click", "togglebutton1": "Click me too", "checkbutton1": True, "entry1": "Some text", "spinbutton1": 0.2, "combobox1": 2, "comboboxtext1": 3, "label1": "<b>Bold label</b>", "linkbutton1": "https://www.google.com", "accellabel1": "<i>Italic accellabel</i>", "scalebutton1": 30, "volumebutton1": 0.8, "scale1": 0.5, "scale2": 0.6, "calendar1": datetime.today(), "treeview1": phonebook, "textview1": 'this\nis\na\nmultiline\ntext', "radiobutton1": False, "radiobutton2": True, "radiobutton3": True, # The last one wins. "spinner1": True, "progressbar1": 0.5, } Win.w.show(dict) dict = { "checkbutton1": "Is checked", 'volumebutton1': 'Volume', 'scalebutton1': 'Scale button', 'linkbutton1': 'Go to google.com', 'radiobutton1': 'First', 'radiobutton2': 'Second', 'radiobutton3': 'Third', } Win.w.show(dict) #print(Win.w.get()) Win.show()
def __init__(self, tree): # 7 rows and 3 columns gtk.Table.__init__(self, 7, 3) tree.connect('cursor-changed', self.cursor_changed) self.last_selected = None # Enabled checkbutton enabled_label = gtk.Label('Enabled:') self.enabled_field = enabled_checkbutton = gtk.CheckButton() enabled_checkbutton.set_tooltip_text( 'If not checked, Definition won\'t be included in Saved Configuration.' ) self.attach(enabled_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) self.attach(enabled_checkbutton, 1, 3, 0, 1, yoptions=gtk.FILL) #Value Field value_label = gtk.Label('Value:') self.string_value_field = gtk.Entry() self.int_value_field = gtk.SpinButton() self.int_value_field.set_adjustment(gtk.Adjustment(0, 0, 2**32 - 1, 1)) self.int_value_field.hide() self.bool_value_field = gtk.combo_box_new_text() self.bool_value_field.append_text('YES') self.bool_value_field.append_text('NO') self.bool_value_field.hide() value_box = gtk.VBox() value_box.add(self.string_value_field) value_box.add(self.int_value_field) value_box.add(self.bool_value_field) self.value_check_field = value_checkbutton = gtk.CheckButton() value_checkbutton.set_tooltip_text( 'If not checked, Value won\'t be included in Saved Configuration.') value_checkbutton.set_active(True) self.attach(value_label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) self.attach(value_box, 1, 2, 1, 2, gtk.FILL, gtk.FILL) self.attach(value_checkbutton, 2, 3, 1, 2, gtk.FILL, gtk.FILL) # Add Sub-Definition button add_definition_button = gtk.Button('Add Sub-Definition') def add_sub_definition(button): model, selected = tree.get_selection().get_selected() if selected is not None: model.append(selected, ( '', '', False, True, '', False, {}, )) self.value_check_field.set_active(False) # auto disable value add_definition_button.connect('clicked', add_sub_definition) self.attach(add_definition_button, 0, 3, 2, 3, yoptions=gtk.FILL) # Remove Sub-Definition button remove_definition_button = gtk.Button('Remove Definition') def remove_definition(button): model, selected = tree.get_selection().get_selected() if selected is not None and not model[selected][2]: model.remove(selected) self.clear() remove_definition_button.connect('clicked', remove_definition) self.attach(remove_definition_button, 0, 3, 3, 4, yoptions=gtk.FILL) # Add/Remove Attribute Buttons add_attribute_button = gtk.Button('Add Attribute') remove_attribute_button = gtk.Button('Remove Attribute') button_table = gtk.Table(1, 3) add_attribute_button.connect( 'clicked', lambda button: attributes_model.append(( 'var', '0', ))) def remove_attribute(button): model, selected = attributes_list.get_selection().get_selected() if selected is not None: model.remove(selected) remove_attribute_button.connect('clicked', remove_attribute) button_table.attach(add_attribute_button, 0, 2, 0, 1) button_table.attach(remove_attribute_button, 2, 3, 0, 1) self.attach(button_table, 0, 3, 4, 5, yoptions=gtk.FILL) # Attributes TreeView attributes_label = gtk.Label('Attributes:') attributes_list = gtk.TreeView( gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)) attributes_scroll = gtk.ScrolledWindow() attributes_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) attributes_scroll.set_shadow_type(gtk.SHADOW_OUT) attributes_scroll.set_border_width(5) attributes_scroll.add(attributes_list) self.attributes_field = attributes_model = attributes_list.get_model() def edited_handler(cell, path, text, data): model, col = data model[path][col] = text variable_column = gtk.TreeViewColumn('Variable') variable_column.set_min_width(gtk.gdk.Screen().get_width() / 11) variable_renderer = gtk.CellRendererText() variable_renderer.set_property('editable', True) variable_renderer.connect('edited', edited_handler, ( attributes_model, 0, )) variable_column.pack_start(variable_renderer) variable_column.add_attribute(variable_renderer, 'text', 0) value_column = gtk.TreeViewColumn('Value') value_renderer = gtk.CellRendererText() value_renderer.set_property('editable', True) value_renderer.connect('edited', edited_handler, ( attributes_model, 1, )) value_column.pack_start(value_renderer) value_column.add_attribute(value_renderer, 'text', 1) attributes_list.append_column(variable_column) attributes_list.append_column(value_column) self.attach(attributes_label, 0, 3, 5, 6, yoptions=gtk.FILL) self.attach(attributes_scroll, 0, 3, 6, 7)
def on_button12_clicked(self,widget): self.window1.get_widget("window1").hide() def auto(widget, other = None): active = ns.window.get_widget("checkbutton1").get_active() ns.window.get_widget("treeview1").set_sensitive(not active) def update_initramfs(): ns.window.get_widget("progressbar1").show() ns.window.get_widget("hbuttonbox1").set_sensitive(False) uname = os.popen('uname -r').read().strip() process = subprocess.Popen(['mkinitramfs', '-o', '/boot/initrd.img-'+uname, uname], stdout=subprocess.PIPE, stderr=None) while process.poll() == None: while gtk.events_pending(): gtk.main_iteration_do() time.sleep(.1) ns.window.get_widget("progressbar1").pulse() process.wait() ns.window.get_widget("progressbar1").hide() ns.window.get_widget("hbuttonbox1").set_sensitive(True) def cancel(widget, other = None): ns.window.get_widget("window3").destroy() self.window1.get_widget("window1").show() def ok(widget, other = None): if ns.window.get_widget("checkbutton1").get_active(): os.system("update-alternatives --auto default.plymouth") update_initramfs() msg_info(_("Done! Now plymouth will use the default, auto-selected theme.")) else: model, treeiter = ns.window.get_widget("treeview1").get_selection().get_selected() if treeiter == None: msg_error(_("Please, select a theme!")) return theme = model.get(treeiter, 1)[0] os.system('update-alternatives --set default.plymouth "%s"' % theme) update_initramfs() ns.window.get_widget("window3").destroy() self.window1.get_widget("window1").show() def create(widget, other = None): theme_name = msg_input('', _('Enter your plymouth theme name. eg. PinguyBuilder Theme (please use only alphanumeric characters)'), _('Name:'), 'PinguyBuilder Theme') if theme_name == False or theme_name == None: return elif theme_name == '': msg_error(_("You must specify theme name!")) return theme_name_fixed = theme_name.replace(' ','-').replace('/','-').replace('..','-').replace('\\','-') theme_dir = "/lib/plymouth/themes/" + theme_name_fixed if os.path.exists(theme_dir): overwrite = msg_confirm(_('The theme "%s" already exists! Do you want to overwrite it?') % theme_name) if overwrite: shutil.rmtree(theme_dir) else: return dialog = gtk.FileChooserDialog(title=_("Select 1920x1080 PNG image..."),action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_current_folder(self.working_dir) filter = gtk.FileFilter() filter.set_name(_("PNG Images")) filter.add_mime_type("image/png") dialog.add_filter(filter) filter = gtk.FileFilter() filter.set_name(_("All files")) filter.add_pattern("*") dialog.add_filter(filter) response = dialog.run() if response == gtk.RESPONSE_OK: filename = dialog.get_filename() self.working_dir = os.path.dirname(filename) dialog.destroy() while gtk.events_pending(): gtk.main_iteration_do() os.makedirs(theme_dir) now = datetime.datetime.now() theme_pic = os.path.join(theme_dir, os.path.basename(filename)) shutil.copy(filename, theme_pic) shutil.copy('/etc/PinguyBuilder/plymouth/PinguyBuilder-theme/progress_bar.png', theme_dir+'/progress_bar.png') shutil.copy('/etc/PinguyBuilder/plymouth/PinguyBuilder-theme/progress_box.png', theme_dir+'/progress_box.png') script_name = "/lib/plymouth/themes/"+theme_name_fixed+"/"+theme_name_fixed+".script" script = open("/etc/PinguyBuilder/plymouth/PinguyBuilder-theme/PinguyBuilder-theme.script").read().replace("__THEMEPIC__", os.path.basename(theme_pic)) open(script_name, 'w+').write(script) config_name = "/lib/plymouth/themes/"+theme_name_fixed+"/"+theme_name_fixed+".plymouth" config = open("/etc/PinguyBuilder/plymouth/PinguyBuilder-theme/PinguyBuilder-theme.plymouth").read() config = config.replace("__THEMENAME__", theme_name) config = config.replace("__THEMEDIR__", theme_name_fixed) open(config_name, 'w+').write(config) os.system('update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth "%(config_name)s" 80' % ({'config_name': config_name})) os.system('update-alternatives --set default.plymouth "%(config_name)s"' % ({'config_name': config_name})) ns.window.get_widget("checkbutton1").set_active(False) update_initramfs() msg_info(_("Your plymouth theme named %(theme_name)s with the picture %(theme_pic)s has been created.") % ({'theme_name': theme_name, 'theme_pic': theme_pic})) else: dialog.destroy() shutil.rmtree(theme_dir) list_themes() def preview(widget, other = None): output = os.popen('update-alternatives --display default.plymouth').read().strip() m = re.search(_('default.plymouth - (manual|auto) mode'), output) if m == None: ns.window.get_widget("window3").show() return mode = m.group(1) if mode == _('auto'): ns.window.get_widget("window3").hide() while gtk.events_pending(): gtk.main_iteration_do() os.system("plymouth-preview") ns.window.get_widget("window3").show() else: model, treeiter = ns.window.get_widget("treeview1").get_selection().get_selected() if treeiter == None: msg_error(_("Please, select a theme!")) return theme = model.get(treeiter, 1)[0] ns.window.get_widget("window3").hide() while gtk.events_pending(): gtk.main_iteration_do() output = os.popen('update-alternatives --display default.plymouth').read().strip() m = re.search(_('default.plymouth - (manual|auto) mode'), output) if m == None: ns.window.get_widget("window3").show() return mode = m.group(1) m = re.search(_('link\s*currently\s*points\s*to\s*(.*)'), output) if m == None: ns.window.get_widget("window3").show() return link = m.group(1) os.system('update-alternatives --set default.plymouth "%s"' % theme) os.system("plymouth-preview") ns.window.get_widget("window3").show() if mode == _('auto'): os.system('update-alternatives --auto default.plymouth') else: os.system('update-alternatives --set default.plymouth "%s"' % link) def list_themes(): ns.liststore.clear() output = os.popen('update-alternatives --display default.plymouth').read().strip() m = re.search(_('default.plymouth - (manual|auto) mode'), output) if m == None: ns.window.get_widget("window3").show() return mode = m.group(1) m = re.search(_('link\s*currently\s*points\s*to\s*(.*)'), output) if m == None: ns.window.get_widget("window3").show() return link = m.group(1).strip() lines = os.popen('update-alternatives --list default.plymouth').read().strip().split('\n') for row in lines: if row != "": config = ConfigParser.ConfigParser() config.readfp(open(row)) name = config.get('Plymouth Theme', 'Name') iter = ns.liststore.append([name, row]) if mode == _('manual') and row == link: ns.window.get_widget("treeview1").get_selection().select_iter(iter) ns.window.get_widget("checkbutton1").set_active(mode == _('auto')) ns = Namespace() ns.window = gtk.glade.XML(self.gladefile,"window3" ,APP) gtk.glade.bindtextdomain(APP,DIR) dic = { "on_window3_delete_event" : (cancel) , "on_button1_clicked" : (cancel) , "on_button2_clicked" : (ok) , "on_button3_clicked" : (create) , "on_button4_clicked" : (preview) , "on_checkbutton1_toggled" : (auto) } ns.window.signal_autoconnect (dic) ns.liststore = gtk.ListStore(str, str) ns.window.get_widget("treeview1").set_model(ns.liststore) ns.tvcolumn1 = gtk.TreeViewColumn(_('Name')) ns.tvcolumn2 = gtk.TreeViewColumn(_('Directory')) ns.cell1 = gtk.CellRendererText() ns.cell2 = gtk.CellRendererText() ns.tvcolumn1.pack_start(ns.cell1, True) ns.tvcolumn2.pack_start(ns.cell2, True) ns.tvcolumn1.set_attributes(ns.cell1, text=0) ns.tvcolumn2.set_attributes(ns.cell2, text=1) ns.window.get_widget("treeview1").append_column(ns.tvcolumn1) ns.window.get_widget("treeview1").append_column(ns.tvcolumn2) list_themes() ns.window.get_widget("window3").show()
def add_column(descr, colid): column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid) treeview.append_column(column)
def show(self): self.glade = gtk.glade.XML( deluge.common.resource_filename( "deluge.ui.gtkui", os.path.join("glade", "create_torrent_dialog.glade"))) self.config = ConfigManager("gtkui.conf") self.dialog = self.glade.get_widget("create_torrent_dialog") self.dialog.set_transient_for(component.get("MainWindow").window) self.glade.signal_autoconnect({ "on_button_file_clicked": self._on_button_file_clicked, "on_button_folder_clicked": self._on_button_folder_clicked, "on_button_remote_path_clicked": self._on_button_remote_path_clicked, "on_button_cancel_clicked": self._on_button_cancel_clicked, "on_button_save_clicked": self._on_button_save_clicked, "on_button_up_clicked": self._on_button_up_clicked, "on_button_add_clicked": self._on_button_add_clicked, "on_button_remove_clicked": self._on_button_remove_clicked, "on_button_down_clicked": self._on_button_down_clicked }) # path, icon, size self.files_treestore = gtk.TreeStore(str, str, gobject.TYPE_UINT64) column = gtk.TreeViewColumn(_("Filename")) render = gtk.CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, "stock-id", 1) render = gtk.CellRendererText() column.pack_start(render, True) column.add_attribute(render, "text", 0) column.set_expand(True) self.glade.get_widget("treeview_files").append_column(column) column = gtk.TreeViewColumn(_("Size")) render = gtk.CellRendererText() column.pack_start(render) column.set_cell_data_func(render, listview.cell_data_size, 2) self.glade.get_widget("treeview_files").append_column(column) self.glade.get_widget("treeview_files").set_model(self.files_treestore) self.glade.get_widget("treeview_files").set_show_expanders(False) # tier, url self.trackers_liststore = gtk.ListStore(int, str) self.glade.get_widget("tracker_treeview").append_column( gtk.TreeViewColumn(_("Tier"), gtk.CellRendererText(), text=0)) self.glade.get_widget("tracker_treeview").append_column( gtk.TreeViewColumn(_("Tracker"), gtk.CellRendererText(), text=1)) self.glade.get_widget("tracker_treeview").set_model( self.trackers_liststore) self.trackers_liststore.set_sort_column_id(0, gtk.SORT_ASCENDING) if not client.is_localhost() and client.connected(): self.glade.get_widget("button_remote_path").show() else: self.glade.get_widget("button_remote_path").hide() self.dialog.show()
def parse(self, model, root_node, fields): dict_widget = {} btn_list=[] attrs = tools.node_attributes(root_node) on_write = attrs.get('on_write', '') editable = attrs.get('editable', False) if editable: treeview = EditableTreeView(editable) else: treeview = DecoratedTreeView(editable) treeview.colors = dict() self.treeview = treeview for color_spec in attrs.get('colors', '').split(';'): if color_spec: colour, test = color_spec.split(':') treeview.colors[colour] = test treeview.set_property('rules-hint', True) if not self.title: self.title = attrs.get('string', 'Unknown') treeview.sequence = False for node in root_node.childNodes: node_attrs = tools.node_attributes(node) if node.localName == 'button': cell = Cell('button')(node_attrs['string']) cell.attrs=node_attrs cell.name=node_attrs['name'] cell.type=node_attrs.get('type','object') cell.context=node_attrs.get('context',{}) cell.model=model treeview.cells[node_attrs['name']] = cell col = gtk.TreeViewColumn(None, cell) btn_list.append(col) cell.set_property('editable',False) col._type = 'Button' col.name = node_attrs['name'] if node.localName == 'field': fname = str(node_attrs['name']) if fields[fname]['type'] in ('image', 'binary'): continue # not showed types if fname == 'sequence': treeview.sequence = True for boolean_fields in ('readonly', 'required'): if boolean_fields in node_attrs: if node_attrs[boolean_fields] in ('True', 'False'): node_attrs[boolean_fields] = eval(node_attrs[boolean_fields]) else: node_attrs[boolean_fields] = bool(int(node_attrs[boolean_fields])) fields[fname].update(node_attrs) node_attrs.update(fields[fname]) cell = Cell(fields[fname]['type'])(fname, treeview, node_attrs, self.window) treeview.cells[fname] = cell renderer = cell.renderer write_enable = editable and not node_attrs.get('readonly', False) if isinstance(renderer, gtk.CellRendererToggle): renderer.set_property('activatable', write_enable) elif isinstance(renderer, (gtk.CellRendererText, gtk.CellRendererCombo, date_renderer.DecoratorRenderer)): renderer.set_property('editable', write_enable) if write_enable: renderer.connect_after('editing-started', send_keys, treeview) col = gtk.TreeViewColumn(None, renderer) col_label = gtk.Label('') if fields[fname].get('required', False): col_label.set_markup('<b>%s</b>' % cgi.escape(fields[fname]['string'])) else: col_label.set_text(fields[fname]['string']) col_label.show() col.set_widget(col_label) col.name = fname col._type = fields[fname]['type'] col.set_cell_data_func(renderer, cell.setter) col.set_clickable(True) twidth = { 'integer': 60, 'float': 80, 'float_time': 80, 'date': 70, 'datetime': 120, 'selection': 90, 'char': 100, 'one2many': 50, 'many2many': 50, 'boolean': 20, } if 'width' in fields[fname]: width = int(fields[fname]['width']) else: width = twidth.get(fields[fname]['type'], 100) col.set_min_width(width) if not treeview.sequence: col.connect('clicked', sort_model, treeview) col.set_resizable(True) #col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) visval = eval(str(fields[fname].get('invisible', 'False')), {'context':self.screen.context}) col.set_visible(not visval) n = treeview.append_column(col) for tree_op in TREE_OPS: if tree_op in fields[fname]: if tree_op in ('sum', 'avg') \ and fields[fname]['type'] not in ('integer', 'float', 'float_time'): continue label = gtk.Label() label.set_use_markup(True) label_str = fields[fname][tree_op] + ': ' label_bold = bool(int(fields[fname].get( '%s_bold' % tree_op, 0)) ) if label_bold: label.set_markup('<b>%s</b>' % label_str) else: label.set_markup(label_str) label_wid = gtk.Label() label_wid.set_use_markup(True) dict_widget[n] = ( fname, label, label_wid, fields[fname].get('digits', (16,2))[1], label_bold, tree_op ) for btn in btn_list: treeview.append_column(btn) return treeview, dict_widget, [], on_write
def __init__(self): self.columns = ["ID","Name","Lastname","Gender","DoB","Phone","Address"] icon = os.path.expanduser("~") + \ '/gnuhealth_plugins/frl/icons/federation.svg' self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_icon_from_file(icon) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) # Border and title self.window.set_border_width(10) self.window.set_title("GNU Health Federation Resource Locator") # Entry for the resource (eg, people) self.resource = gtk.Entry(max=20) self.resource.set_text("people") # Entry to find Federation ID or other info when using fuzzy srch self.query = gtk.Entry(max=100) # Search Button self.search_button = gtk.Button(label=None, stock=gtk.STOCK_FIND) # Fuzzy search self.fuzzy_search = gtk.CheckButton(label="Fuzzy") # Call method search_resource upon receiving the clicked signal self.search_button.connect("clicked", self.search_resource, self.resource, self.query, self.fuzzy_search) self.hbox = gtk.HBox (True, 10) self.hbox.pack_start (self.resource) self.hbox.pack_start (self.query) self.hbox.pack_start (self.search_button) self.hbox.pack_start (self.fuzzy_search) self.resource.show() self.query.show() self.search_button.show() self.fuzzy_search.show() self.search_frame = gtk.Frame() self.search_frame.add (self.hbox) self.main_table = gtk.Table(rows=2, columns=2, homogeneous=False) # Create the main tree view for the results self.results = gtk.ListStore(str, str, str, str, str, str, str) self.treeview = gtk.TreeView(self.results) # Let pick at most one row self.treeselection = self.treeview.get_selection () self.treeselection.set_mode (gtk.SELECTION_SINGLE) # Process once the row is activated (double-click or enter) self.treeview.connect('row-activated', self.get_values) # Add and render the columns for n in range(len(self.columns)): self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn(self.columns[n], self.cell, text=n) self.treeview.append_column(self.col) # attach the query box on the table self.main_table.attach(self.search_frame,0,1,0,1) # attach the query box on the table self.main_table.attach(self.treeview,0,1,1,2) self.window.add (self.main_table) # Display the objects self.hbox.show() self.search_frame.show() self.treeview.show() self.main_table.show() self.window.show()
def __init__(self, parent=None): gtk.Object.__init__(self) self.parent = parent self._gui = load_ui_file("preferences.ui") self.window = self.get_widget('preferences_window') self.window.connect("delete_event", self.on_delete_window) # Translators: 'None' refers here to the Todo list choice in Hamster preferences (Tracking tab) self.activities_sources = [("", _("None")), ("evo", "Evolution"), ("gtg", "Getting Things Gnome")] self.todo_combo = gtk.combo_box_new_text() for code, label in self.activities_sources: self.todo_combo.append_text(label) self.todo_combo.connect("changed", self.on_todo_combo_changed) self.get_widget("todo_pick").add(self.todo_combo) # create and fill activity tree self.activity_tree = self.get_widget('activity_list') self.get_widget("activities_label").set_mnemonic_widget( self.activity_tree) self.activity_store = ActivityStore() self.external_listeners = [] self.activityColumn = gtk.TreeViewColumn(_("Name")) self.activityColumn.set_expand(True) self.activityCell = gtk.CellRendererText() self.external_listeners.extend([ (self.activityCell, self.activityCell.connect('edited', self.activity_name_edited_cb, self.activity_store)) ]) self.activityColumn.pack_start(self.activityCell, True) self.activityColumn.set_attributes(self.activityCell, text=1) self.activityColumn.set_sort_column_id(1) self.activity_tree.append_column(self.activityColumn) self.activity_tree.set_model(self.activity_store) self.selection = self.activity_tree.get_selection() self.external_listeners.extend([ (self.selection, self.selection.connect('changed', self.activity_changed, self.activity_store)) ]) # create and fill category tree self.category_tree = self.get_widget('category_list') self.get_widget("categories_label").set_mnemonic_widget( self.category_tree) self.category_store = CategoryStore() self.categoryColumn = gtk.TreeViewColumn(_("Category")) self.categoryColumn.set_expand(True) self.categoryCell = gtk.CellRendererText() self.external_listeners.extend([ (self.categoryCell, self.categoryCell.connect('edited', self.category_edited_cb, self.category_store)) ]) self.categoryColumn.pack_start(self.categoryCell, True) self.categoryColumn.set_attributes(self.categoryCell, text=1) self.categoryColumn.set_sort_column_id(1) self.categoryColumn.set_cell_data_func(self.categoryCell, self.unsorted_painter) self.category_tree.append_column(self.categoryColumn) self.category_store.load() self.category_tree.set_model(self.category_store) selection = self.category_tree.get_selection() self.external_listeners.extend([ (selection, selection.connect('changed', self.category_changed_cb, self.category_store)) ]) self.day_start = widgets.TimeInput(dt.time(5, 30)) self.get_widget("day_start_placeholder").add(self.day_start) self.load_config() # Allow enable drag and drop of rows including row move self.activity_tree.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, self.TARGETS, gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE) self.category_tree.enable_model_drag_dest(self.TARGETS, gtk.gdk.ACTION_MOVE) self.activity_tree.connect("drag_data_get", self.drag_data_get_data) self.category_tree.connect("drag_data_received", self.on_category_drop) #select first category selection = self.category_tree.get_selection() selection.select_path((0, )) self.prev_selected_activity = None self.prev_selected_category = None # create and fill workspace tree self.workspace_tree = self.get_widget('workspace_list') self.workspace_store = WorkspaceStore() self.wNameColumn = gtk.TreeViewColumn(_("Name")) self.wNameColumn.set_expand(True) self.wNameCell = gtk.CellRendererText() self.wNameCell.set_property('editable', False) self.wActivityColumn = gtk.TreeViewColumn(_("Activity")) self.wActivityColumn.set_expand(True) self.wActivityCell = gtk.CellRendererText() self.wActivityCell.set_property('editable', True) self.external_listeners.extend([ (self.wActivityCell, self.wActivityCell.connect('edited', self.on_workspace_activity_edited)) ]) self.wNameColumn.pack_start(self.wNameCell, True) self.wNameColumn.set_attributes(self.wNameCell) self.wNameColumn.set_sort_column_id(1) self.wNameColumn.set_cell_data_func(self.wNameCell, self.workspace_name_celldata) self.workspace_tree.append_column(self.wNameColumn) self.wActivityColumn.pack_start(self.wActivityCell, True) self.wActivityColumn.set_attributes(self.wActivityCell, text=2) self.wActivityColumn.set_sort_column_id(1) self.workspace_tree.append_column(self.wActivityColumn) self.workspace_tree.set_model(self.workspace_store) # disable notification thing if pynotify is not available try: import pynotify except: self.get_widget("notification_preference_frame").hide() self.external_listeners.extend([ (self.day_start, self.day_start.connect("time-entered", self.on_day_start_changed)) ]) # disable workspace tracking if wnck is not there if wnck: self.screen = wnck.screen_get_default() for workspace in self.screen.get_workspaces(): self.on_workspace_created(self.screen, workspace) self.external_listeners.extend([ (self.screen, self.screen.connect("workspace-created", self.on_workspace_created)), (self.screen, self.screen.connect("workspace-destroyed", self.on_workspace_deleted)) ]) else: self.get_widget("workspace_tab").hide() # Redmine configuration self.get_widget("notebook1").connect("switch-page", self.on_notebook_page_switch) self.get_widget("redmine_enabled").connect( "toggled", self.on_redmine_integration_checkbox_toggled) self.get_widget("redmine_test_button").connect( "clicked", self.on_test_connection_button_click) self.get_widget("redmine_save_button").connect( "clicked", self.on_save_configuration_button_click) self._gui.connect_signals(self) self.show()
def create_carbono(self): """Creates a view for individual bug""" vbox = gtk.VBox() label = gtk.Label(_("Create image")) vbox.pack_start(label, False, False) # create the list of bugs view sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) # list of levels lstore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) # bugs treeview treeview = gtk.TreeView(lstore) treeview.set_rules_hint(True) treeview.set_search_column(self.COLUMN_DEVICE) treeview.connect('row-activated', self.partition_selected, lstore) renderer = gtk.CellRendererText() # column for device column = gtk.TreeViewColumn(_("Device"), renderer, text=self.COLUMN_DEVICE) column.set_sort_column_id(self.COLUMN_DEVICE) column.set_resizable(True) column.set_expand(False) treeview.append_column(column) # column for filesystem column = gtk.TreeViewColumn(_("File system"), renderer, text=self.COLUMN_FS) column.set_sort_column_id(self.COLUMN_FS) column.set_resizable(True) column.set_expand(False) treeview.append_column(column) # column for size renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(_("Size"), renderer, text=self.COLUMN_SIZE) column.set_sort_column_id(self.COLUMN_SIZE) column.set_resizable(False) column.set_expand(True) treeview.append_column(column) # column for used size renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(_("Used"), renderer, text=self.COLUMN_USED) column.set_sort_column_id(self.COLUMN_USED) column.set_resizable(False) column.set_expand(True) treeview.append_column(column) sw.add(treeview) vbox.pack_start(sw) sizegroup1 = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) sizegroup2 = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) hbox, image_hd = self.build_value_pair(sizegroup1, _("Hard-disk image to save"), "image.img", value_sizegroup=sizegroup2) vbox.pack_start(hbox, False, False) hbox, image_net = self.build_value_pair(sizegroup1, _("Network address to save"), "224.51.105.100", value_sizegroup=sizegroup2) vbox.pack_start(hbox, False, False) return vbox
def initialize_display(self): """Set up the Arithmetic activity.""" self._logger = logging.getLogger('arithmetic-activity') self.starttime = 0 self.endtime = 0 self.secondsleft = "" self.question = "" self.answer = "" self.cloud.scoreboard = groupthink.CausalDict( value_translator=score_codec) self.scoreboard = self.cloud.scoreboard self.mynickname = profile.get_nick_name() self.scoreboard[self.mynickname] = ImmutableScore() self._question_index = 0 self._puzzle_hashes = set() self._puzzle_code = {} self._active_mode_hashes = set() # Main layout vbox = gtk.VBox() # Set a startpoint for a shared seed self.cloud.startpoint = groupthink.HighScore(self.timer.time(), 0) # Scoreboard scorebox = gtk.VBox() self.model = gtk.TreeStore( gobject.TYPE_STRING, # name gobject.TYPE_INT, # last round score gobject.TYPE_INT, # total score gobject.TYPE_FLOAT) # time for last question self.treeview = treeview = gtk.TreeView(self.model) cellrenderer = gtk.CellRendererText() col1 = gtk.TreeViewColumn(_("Name"), cellrenderer, text=0) col2 = gtk.TreeViewColumn(_("Round score"), cellrenderer, text=1) col3 = gtk.TreeViewColumn(_("Total score"), cellrenderer, text=2) col4 = gtk.TreeViewColumn(_("Time for answering last question"), cellrenderer, text=3) treeview.append_column(col1) treeview.append_column(col2) treeview.append_column(col3) treeview.append_column(col4) my_score = self.scoreboard[self.mynickname] self.olditer = self.model.insert_before(None, None) self.model.set_value(self.olditer, 0, self.mynickname) self.model.set_value(self.olditer, 1, my_score.last_score) self.model.set_value(self.olditer, 2, my_score.cumulative_score) self.model.set_value(self.olditer, 3, my_score.last_time) treeview.expand_all() scorebox.pack_start(treeview) # Horizontal fields difficultybox = gtk.HBox() periodbox = gtk.HBox() toprowbox = gtk.HBox() modebox = gtk.HBox() self.inner_modebox = gtk.HBox() questionbox = gtk.HBox() answerbox = gtk.HBox() decisionbox = gtk.HBox() lastroundbox = gtk.HBox() bottomrowbox = gtk.HBox() countdownbox = gtk.HBox() # Labels difficultylabel = gtk.Label(_("Difficulty: ")) periodlabel = gtk.Label(_("Period: ")) periodunitslabel = gtk.Label(" sec ") modelabel = gtk.Label(_("Puzzles: ")) questionlabel = gtk.Label(_("Question: ")) answerlabel = gtk.Label(_("Answer: ")) decisionlabel = gtk.Label(_("You were: ")) lastroundlabel = gtk.Label(_("Last round: ")) self.lastanswerlabel = gtk.Label("") staticcountdownlabel = gtk.Label(_("Time until next question: ")) self.countdownlabel = gtk.Label("") # ToggleButtons for difficulty self.cloud.easytoggle = groupthink.gtk_tools.SharedToggleButton("< 10") self.cloud.mediumtoggle = groupthink.gtk_tools.SharedToggleButton( "< 20") self.cloud.hardtoggle = groupthink.gtk_tools.SharedToggleButton("< 50") self.cloud.easytoggle.set_active(False) self.cloud.mediumtoggle.set_active(False) self.cloud.hardtoggle.set_active(False) self.cloud.easytoggle.connect("toggled", self.easy_cb) self.cloud.mediumtoggle.connect("toggled", self.medium_cb) self.cloud.hardtoggle.connect("toggled", self.hard_cb) # Entry for puzzle period self.cloud.periodentry = groupthink.gtk_tools.RecentEntry(max=2) self.cloud.periodentry.modify_font(pango.FontDescription("Mono 14")) self.cloud.periodentry.set_text(str(self.period)) self.cloud.periodentry.set_width_chars(2) self.cloud.periodentry.connect("changed", self._period_cb) # Puzzle generators self.cloud.puzzles = groupthink.AddOnlySet() self.cloud.puzzles.register_listener(self.new_puzzles_cb) # Text entry box for question self.questionentry = gtk.TextView() self.questionentry.modify_font(pango.FontDescription("Mono 14")) self.questionentry.set_property("editable", False) # Text entry box for answer self.answerentry = gtk.Entry(max=50) self.answerentry.modify_font(pango.FontDescription("Sans 14")) self.answerentry.connect("activate", self.answer_cb) # Whether the user was correct self.decisionentry = gtk.Entry(max=50) self.decisionentry.modify_font(pango.FontDescription("Sans 14")) self.decisionentry.set_property("editable", False) # Packing difficultybox.pack_start(difficultylabel, expand=False) difficultybox.pack_start(self.cloud.easytoggle, expand=False) difficultybox.pack_start(self.cloud.mediumtoggle, expand=False) difficultybox.pack_start(self.cloud.hardtoggle, expand=False) periodbox.pack_start(periodlabel, expand=False) periodbox.pack_start(self.cloud.periodentry, expand=False) periodbox.pack_start(periodunitslabel, expand=False) toprowbox.pack_start(difficultybox, expand=False) toprowbox.pack_end(periodbox, expand=False) questionbox.pack_start(questionlabel, expand=False) questionbox.pack_start(self.questionentry) modebox.pack_start(modelabel, expand=False) modebox.pack_start(self.inner_modebox) answerbox.pack_start(answerlabel, expand=False) answerbox.pack_start(self.answerentry) decisionbox.pack_start(decisionlabel, expand=False) decisionbox.pack_start(self.decisionentry) lastroundbox.pack_start(lastroundlabel, expand=False) lastroundbox.pack_start(self.lastanswerlabel, expand=False) countdownbox.pack_start(staticcountdownlabel, expand=False) countdownbox.pack_start(self.countdownlabel, expand=False) bottomrowbox.pack_start(countdownbox) bottomrowbox.pack_end(lastroundbox) vbox.pack_start(toprowbox, expand=False) vbox.pack_start(modebox, expand=False) vbox.pack_start(questionbox, expand=False) vbox.pack_start(answerbox, expand=False) vbox.pack_start(decisionbox, expand=False) vbox.pack_start(countdownbox, expand=False) vbox.pack_start(bottomrowbox, expand=False) vbox.pack_start(scorebox) # Set defaults for questions. self.setup_puzzles() self.cloud.easytoggle.set_active(True) # Make a new question. self.generate_new_question() self.start_question() self.start_countdown() self.answerentry.grab_focus() self.lastanswerlabel.set_markup("") return vbox
def __set_columns(self, filters): report_view_hbox = gtk.HBox(False, 0) report_treeview = gtk.TreeView() if filters["user_id"] == -1 and filters["event_id"] == -1: #List self.__report_list = gtk.ListStore(int, str, str) #Add column to list report_treeview.append_column( gtk.TreeViewColumn(_("N°"), gtk.CellRendererText(), text=0)) report_treeview.append_column( gtk.TreeViewColumn(_("Usuario"), gtk.CellRendererText(), text=1)) report_treeview.append_column( gtk.TreeViewColumn(_("Total Asistencia"), gtk.CellRendererText(), text=2)) elif filters["event_id"] != -1: self.__report_list = gtk.ListStore(int, str, str, str, str, str) report_treeview.append_column( gtk.TreeViewColumn(_("N°"), gtk.CellRendererText(), text=0)) report_treeview.append_column( gtk.TreeViewColumn(_("Usuario"), gtk.CellRendererText(), text=1)) report_treeview.append_column( gtk.TreeViewColumn(_("Fecha"), gtk.CellRendererText(), text=2)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Entrada"), gtk.CellRendererText(), text=3)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Salida"), gtk.CellRendererText(), text=4)) report_treeview.append_column( gtk.TreeViewColumn(_("Total Asistencia"), gtk.CellRendererText(), text=5)) elif filters["user_id"] != -1: if self.__config_param["app"]["events_attendance"] == "True": self.__report_list = gtk.ListStore(int, str, str, str, str, str) report_treeview.append_column( gtk.TreeViewColumn(_("N°"), gtk.CellRendererText(), text=0)) report_treeview.append_column( gtk.TreeViewColumn(_("Evento"), gtk.CellRendererText(), text=1)) report_treeview.append_column( gtk.TreeViewColumn(_("Fecha"), gtk.CellRendererText(), text=2)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Entrada"), gtk.CellRendererText(), text=3)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Salida"), gtk.CellRendererText(), text=4)) report_treeview.append_column( gtk.TreeViewColumn(_("Total Asistencia"), gtk.CellRendererText(), text=5)) else: self.__report_list = gtk.ListStore(int, str, str, str, str) report_treeview.append_column( gtk.TreeViewColumn(_("N°"), gtk.CellRendererText(), text=0)) report_treeview.append_column( gtk.TreeViewColumn(_("Fecha"), gtk.CellRendererText(), text=1)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Entrada"), gtk.CellRendererText(), text=2)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Salida"), gtk.CellRendererText(), text=3)) report_treeview.append_column( gtk.TreeViewColumn(_("Total Asistencia"), gtk.CellRendererText(), text=4)) else: self.__report_list = gtk.ListStore(int, str, str, str, str) report_treeview.append_column( gtk.TreeViewColumn(_("N°"), gtk.CellRendererText(), text=0)) report_treeview.append_column( gtk.TreeViewColumn(_("Fecha"), gtk.CellRendererText(), text=1)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Entrada"), gtk.CellRendererText(), text=3)) report_treeview.append_column( gtk.TreeViewColumn(_("Hora Salida"), gtk.CellRendererText(), text=4)) report_treeview.append_column( gtk.TreeViewColumn(_("Total Asistencia"), gtk.CellRendererText(), text=5)) report_treeview.set_model(self.__report_list) scroll = gtk.ScrolledWindow() scroll.add(report_treeview) report_view_hbox.pack_start(scroll, True, True, 0) frame_widgets = self.__frame_report_view.get_children() for widget in frame_widgets: self.__frame_report_view.remove(widget) self.__frame_report_view.add(report_view_hbox) self.__frame_report_view.show_all()
def table_insert(self, iter_insert, table=None, table_justification=None, text_buffer=None): """Insert a Table at the Given Iter""" if not text_buffer: text_buffer = self.dad.curr_buffer if table != None: self.dad.table_columns = len(table['matrix'][0]) self.dad.table_rows = len(table['matrix']) - 1 headers = table['matrix'][-1] table_col_min = table['col_min'] table_col_max = table['col_max'] else: headers = [_("click me")] * self.dad.table_columns table_col_min = self.dad.table_col_min table_col_max = self.dad.table_col_max anchor = text_buffer.create_child_anchor(iter_insert) anchor.liststore = gtk.ListStore(*(str, ) * self.dad.table_columns) anchor.treeview = gtk.TreeView(anchor.liststore) for element in range(self.dad.table_columns): label = gtk.Label('<b>' + headers[element] + '</b>') label.set_use_markup(True) label.set_tooltip_text(_("Click to Edit the Column Settings")) label.show() renderer_text = gtk.CellRendererText() renderer_text.set_property('editable', True) renderer_text.set_property('wrap-width', table_col_max) renderer_text.set_property('wrap-mode', pango.WRAP_WORD_CHAR) renderer_text.set_property( 'font-desc', pango.FontDescription(self.dad.text_font)) renderer_text.connect('edited', self.on_table_cell_edited, anchor.liststore, element) renderer_text.connect('editing-started', self.on_table_cell_editing_started, anchor.liststore, element) column = gtk.TreeViewColumn("", renderer_text, text=element) column.set_min_width(table_col_min) column.set_clickable(True) column.set_widget(label) column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) column.connect('clicked', self.table_column_clicked, anchor, element) anchor.treeview.append_column(column) anchor.headers = headers anchor.table_col_min = table_col_min anchor.table_col_max = table_col_max anchor.treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH) anchor.treeview.connect('button-press-event', self.on_mouse_button_clicked_treeview_table, anchor) anchor.treeview.connect('key_press_event', self.on_key_press_treeview_table, anchor) anchor.frame = gtk.Frame() anchor.frame.add(anchor.treeview) anchor.frame.set_shadow_type(gtk.SHADOW_NONE) anchor.eventbox = gtk.EventBox() anchor.eventbox.add(anchor.frame) self.dad.sourceview.add_child_at_anchor(anchor.eventbox, anchor) anchor.eventbox.show_all() for row in range(self.dad.table_rows): row_iter = anchor.liststore.append([""] * self.dad.table_columns) if table != None: for column in range(self.dad.table_columns): try: anchor.liststore[row_iter][column] = table['matrix'][ row][column] except: pass # there are cases when some rows have less columns if table_justification: text_iter = text_buffer.get_iter_at_child_anchor(anchor) self.dad.state_machine.apply_object_justification( text_iter, table_justification, text_buffer) elif self.dad.user_active: # if I apply a justification, the state is already updated self.dad.state_machine.update_state()
def __init__( self, data=None, more=None ): # Load configuration file try: configfile = open(self.Section, 'r') self.section = configfile.readline() configfile.close() except: self.section = '' if self.section == '': self.section = 'default' # Initialize parameters self.selectedMac = None self.selectedSessionId = None self.config = ConfigParser.RawConfigParser() if os.path.exists(self.Ini): self.config.read(self.Ini) else: self.config.read(self.DefIni) # Setup the sections store and selection boxes self.sectionStore = gtk.ListStore(gobject.TYPE_STRING) self.sectionBox = gtk.ComboBox(self.sectionStore) self.sectionBox2 = gtk.ComboBox(self.sectionStore) cell = gtk.CellRendererText() self.sectionBox.pack_start(cell, True) self.sectionBox.add_attribute(cell, 'text', 0) self.sectionBox2.pack_start(cell, True) self.sectionBox2.add_attribute(cell, 'text', 0) for section in self.config.sections(): self.sectionStore.append([ section ]) self.sessionsStore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.sessionsView = gtk.TreeView(self.sessionsStore) cell = gtk.CellRendererText() col = gtk.TreeViewColumn("MAC", cell, text=0) self.sessionsView.append_column(col) cell = gtk.CellRendererText() col = gtk.TreeViewColumn("IP", cell, text=1) self.sessionsView.append_column(col) self.sessionsView.connect( "cursor-changed", self.row1, "cursor-changed" ) self.vboxSessions = gtk.VBox( ) self.vboxSessionBtns = gtk.HBox( homogeneous = True ) self.sesRefresh = gtk.Button( "Refresh" ) self.sesAuth = gtk.Button( "Auth" ) self.sesRelease = gtk.Button( "Release" ) self.sesBlock = gtk.Button( "Block" ) self.sesAuth.set_sensitive( False ) self.sesRelease.set_sensitive( False ) self.sesBlock.set_sensitive( False ) self.sessionView = gtk.Label(""); self.vboxSessions.pack_start( self.sessionsView ) self.vboxSessions.pack_start( self.sessionView, False ) self.vboxSessionBtns.pack_start( self.sesRefresh ) self.vboxSessionBtns.pack_start( self.sesAuth ) self.vboxSessionBtns.pack_start( self.sesRelease ) self.vboxSessionBtns.pack_start( self.sesBlock ) self.vboxSessions.pack_start( self.vboxSessionBtns, False ) self.sesRefresh.connect( "clicked", self.chilliQuery ) self.sesRelease.connect( "clicked", self.sessionRelease ) self.sesBlock.connect( "clicked", self.sessionBlock ) self.sesAuth.connect( "clicked", self.sessionAuthorize ) self.vboxSessions.show() self.sesRefresh.show() self.sesAuth.show() self.sesRelease.show() self.sesBlock.show() self.sessionView.show() self.sessionsView.show() self.vboxSessionBtns.show() self.btnStart = gtk.Button( "Start" ) self.btnStop = gtk.Button( "Stop" ) self.btnStart.set_sensitive( False ) self.btnStop.set_sensitive( False ) self.btnStart.connect( "clicked", self.startCoovaChilli ) self.btnStop.connect( "clicked", self.stopCoovaChilli )