Exemple #1
0
    def __init__(self, model, parent):

        gtk.TreeView.__init__(self)
        self.set_model(model)
        self.__model = model
        self.__parent = parent

        # Create popup menu
        self.__popup_menu = lumGroupTreeViewMenu(self.__parent)
        self.connect("button-press-event", self.on_button_press_event)

        # Load image
        pixbuf_path = os.path.join(package_dir, "ui", "group.png")
        pixbuf_image = gtk.Image()
        pixbuf_image.set_from_file(pixbuf_path)
        pixbuf = pixbuf_image.get_pixbuf()

        # Group image
        renderer = gtk.CellRendererPixbuf()
        renderer.set_property("pixbuf", pixbuf)
        column = gtk.TreeViewColumn()
        column.pack_start(renderer)
        column.set_expand(False)
        self.append_column(column)

        # Group name
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn()
        column.pack_start(renderer)
        column.set_title(_("Group"))
        column.add_attribute(renderer, "text", 0)
        column.set_expand(True)
        self.append_column(column)
        
        # Group ID
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn()
        column.pack_start(renderer)
        column.set_title("GID")
        column.set_expand(True)
        column.add_attribute(renderer, "text", 1)
        self.append_column(column)
Exemple #2
0
Fichier : app.py Projet : robol/lum
    def __init__(self):

        # Quite a hack, but working
        self.__datapath = os.path.realpath(os.path.join(__file__, os.path.pardir))

        global lum_application
        if lum_application is not None:
            raise LumErorr("Cannot create more that one lum_application!")
        else:
            lum_application = self
    
        self.__group_store = GroupStore(self.__datapath)
        self.__user_store = UserStore(self.__datapath, self.__group_store)
        
        # Gobject constructor
        gobject.GObject.__init__ (self)
        
        # Load interface file
        self.__builder = create_builder("LumApp.ui")
        
        # Load main window
        self.__window = self.__builder.get_object("window")
        
        # Signal definition
        signals = {
        
            # Quit signals
            'on_quit_menu_item_activate':         gtk.main_quit,
            'window_destroy_event_cb':            gtk.main_quit,
            'on_window_destroy':                gtk.main_quit,
            
            # Callbacks
            'on_about_menu_item_activate':        self.show_about_dialog,
            'on_new_user_menu_item_activate':    self.create_new_user_dialog,
            'on_connect_menu_item_activate':     self.connect,
            'on_reload_user_list_menu_item_activate':     self.reload_user_list,
            'on_delete_user_menu_item_activate':        self.delete_user,
            'on_forget_password_menu_item_activate':    self.forget_password,
            'on_edit_user_menu_item_activate':            self.edit_user,
            'on_change_password_menu_item_activate': self.change_password,
            'on_disconnect_menu_item_activate': self.disconnect,

            # Group menu callbacks
            'on_new_group_menuitem_activate':    self.new_group,
            'on_delete_group_menuitem_activate': self.delete_group,
            'on_properties_group_menuitem_activate': self.group_properties,
            
        }
        
        # Autoconnect signals
        self.__builder.connect_signals (signals)
        
        # Create initial configuration
        self.__configuration = Configuration()
        
        # Change the model of the treeview
        self.__user_treeview = UserTreeView(self.__user_store, self)
        self.__user_treeview.apply_filter(self.__builder.get_object("filter_user_entry"))
        self.__builder.get_object("user_scrolled_window").add(self.__user_treeview)
        self.__group_treeview = GroupTreeView(self.__group_store, self)
        self.__group_treeview.apply_filter(self.__builder.get_object("filter_group_entry"))
        self.__builder.get_object("group_scrolled_window").add(self.__group_treeview)
        
        # Some initial values
        self.__uri, self.__bind_dn = None, None
        
        # Create popup menu
        self.__user_popup_menu = lumUserTreeViewMenu(self)
        self.__group_popup_menu = lumGroupTreeViewMenu(self)