LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File kdm-make_it_cool.diff of Package kdebase4-workspace (Project DISCONTINUED:openSUSE:11.2)

Index: kdm/kfrontend/kgreeter.cpp
===================================================================
--- kdm/kfrontend/kgreeter.cpp.orig
+++ kdm/kfrontend/kgreeter.cpp
@@ -66,20 +66,20 @@ Foundation, Inc., 51 Franklin Street, Fi
 
 class UserListView : public QListWidget {
   public:
-	UserListView( QWidget *parent = 0 )
+	UserListView( bool _themed, QWidget *parent = 0 )
 		: QListWidget( parent )
 		, cachedSizeHint( -1, 0 )
+                , themed( _themed )
 	{
 		setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Ignored );
 		setUniformItemSizes( true );
 		setVerticalScrollMode( ScrollPerPixel );
 		setIconSize( QSize( 48, 48 ) );
-		setAlternatingRowColors( true );
+		setAlternatingRowColors( !themed );
 	}
 
 	mutable QSize cachedSizeHint;
 
-  protected:
 	virtual QSize sizeHint() const
 	{
 		if (!cachedSizeHint.isValid()) {
@@ -147,6 +147,7 @@ class UserListView : public QListWidget
 
   private:
 	bool m_suppressClick;
+	bool themed;
 };
 
 class UserListViewItem : public QListWidgetItem {
@@ -183,7 +184,7 @@ KGreeter::KGreeter( bool framed )
 	                             "PrevUser" );
 
 	if (_userList) {
-		userView = new UserListView( this );
+		userView = new UserListView( framed, this );
 		connect( userView, SIGNAL(itemClicked( QListWidgetItem * )),
 		         SLOT(slotUserClicked( QListWidgetItem * )) );
 		connect( userView, SIGNAL(itemDoubleClicked( QListWidgetItem * )),
@@ -191,8 +192,6 @@ KGreeter::KGreeter( bool framed )
 	}
 	if (_userCompletion)
 		userList = new QStringList;
-	if (userView || userList)
-		insertUsers();
 
 	sessMenu = new QMenu( this );
 	connect( sessMenu, SIGNAL(triggered( QAction * )),
@@ -361,8 +360,11 @@ UserList::UserList( char **in )
 			users.insert( *in );
 }
 
+#include <utmp.h>
+#include <utmpx.h>
+
 void
-KGreeter::insertUsers()
+KGreeter::insertUsers( int limit_users )
 {
 	struct passwd *ps;
 
@@ -387,6 +389,9 @@ KGreeter::insertUsers()
 	if (_showUsers == SHOW_ALL) {
 		UserList noUsers( _noUsers );
 		QSet<QString> dupes;
+                QStringList toinsert;
+
+                int count = 0;
 		for (setpwent(); (ps = getpwent()) != 0;) {
 			if (*ps->pw_dir && *ps->pw_shell &&
 			    (ps->pw_uid >= (unsigned)_lowUserId ||
@@ -398,10 +403,53 @@ KGreeter::insertUsers()
 				QString username( QFile::decodeName( ps->pw_name ) );
 				if (!dupes.contains( username )) {
 					dupes.insert( username );
-					insertUser( default_pix, username, ps );
+                                        toinsert.append( username );
+
+                                        if ( limit_users >= 0 && ++count > limit_users )
+                                            break;
 				}
 			}
 		}
+                if ( limit_users >= 0 && ++count > limit_users ) {
+                    utmpname( _PATH_WTMP );
+                    setutxent();
+                    toinsert = QStringList();
+                    dupes.clear();
+
+                    for ( count = 0; count < limit_users; ) {
+                        struct utmpx * ent = getutxent();
+                        if ( !ent )
+                            break;
+                        struct passwd *ps = getpwnam( ent->ut_user );
+                        if (ps && *ps->pw_dir && *ps->pw_shell &&
+			    (ps->pw_uid >= (unsigned)_lowUserId ||
+			     !ps->pw_uid && _showRoot) &&
+			    ( ps->pw_uid <= (unsigned)_highUserId ) &&
+			    !noUsers.hasUser( ps->pw_name ) &&
+			    !noUsers.hasGroup( ps->pw_gid ))
+                        {
+                            QString username( QFile::decodeName( ent->ut_user ) );
+                            if (!dupes.contains( username )) {
+                                dupes.insert( username );
+                                toinsert.append( username );
+                                count++;
+                            }
+                        }
+
+
+                    }
+                    endutxent();
+                }
+
+                for ( QStringList::ConstIterator it = toinsert.begin();
+                      it != toinsert.end(); ++it )
+                {
+                    // pretty stupid to do another lookup round, but the number is limited
+                    // and caching struct passwd is pretty ugly
+                    struct passwd *ps = getpwnam( QFile::encodeName( *it ) );
+                    if ( ps )
+                        insertUser( default_pix, *it, ps );
+                }
 	} else {
 		UserList users( _users );
 		if (users.hasGroups()) {
@@ -777,6 +825,9 @@ KStdGreeter::KStdGreeter()
 			break;
 	}
 
+        if (userView || userList)
+		insertUsers();
+
 	if (userView) {
 		if (clock)
 			inner_box->addWidget( clock, 0, Qt::AlignCenter );
@@ -890,6 +941,9 @@ KThemedGreeter::KThemedGreeter( KdmTheme
 
 	adjustGeometry();
 
+        // default
+        themer->setTypeVisible( "userlist", true );
+
 	themer->setWidget( this );
 
 	connect( themer, SIGNAL(activated( const QString & )),
@@ -973,6 +1027,13 @@ KThemedGreeter::KThemedGreeter( KdmTheme
 	completeMenu();
 #endif
 
+        if (userView || userList)
+        {
+            insertUsers(7);
+            themer->setTypeVisible( "userlist", true );
+        } else
+            themer->setTypeVisible( "userlist", false );
+
 	if ((system_button = themer->findNode( "system_button" ))) {
 		if (optMenu)
 			addAction( optMenu->menuAction() );
@@ -1003,7 +1064,10 @@ KThemedGreeter::pluginSetup()
 {
 	inherited::pluginSetup();
 
-	if (userView && verify->entitiesLocal() && verify->entityPresettable() && userlist_node) {
+        if (userView && verify->entitiesLocal() && verify->entityPresettable() && userlist_node) {
+                userView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+                userView->setMaximumHeight( userView->sizeHint().height() );
+
 		userlist_node->setWidget( userView );
 		userlist_rect->setVisible( true );
 	} else {
Index: kdm/kfrontend/kgreeter.h
===================================================================
--- kdm/kfrontend/kgreeter.h.orig
+++ kdm/kfrontend/kgreeter.h
@@ -71,7 +71,7 @@ class KGreeter : public KGDialog, public
   protected:
 	void installUserList();
 	void insertUser( const QImage &, const QString &, struct passwd * );
-	void insertUsers();
+	void insertUsers(int limit_users = -1);
 	void putSession( const QString &, const QString &, bool, const char * );
 	void insertSessions();
 	virtual void pluginSetup();
Index: kdm/kfrontend/themer/kdmitem.cpp
===================================================================
--- kdm/kfrontend/themer/kdmitem.cpp.orig
+++ kdm/kfrontend/themer/kdmitem.cpp
@@ -65,7 +65,6 @@ KdmItem::KdmItem( QObject *parent, const
 		      !modes.split( ",", QString::SkipEmptyParts ).contains( "console" ))))
 		{
 			m_visible = false;
-			return;
 		}
 
 		m_showType = sel.attribute( "type" );
@@ -78,7 +77,6 @@ KdmItem::KdmItem( QObject *parent, const
 			    themer()->typeVisible( m_showType ) == m_showTypeInvert)
 			{
 				m_visible = false;
-				return;
 			}
 		}
 
Index: kdm/kfrontend/themer/kdmlist.cpp
===================================================================
--- kdm/kfrontend/themer/kdmlist.cpp.orig
+++ kdm/kfrontend/themer/kdmlist.cpp
@@ -29,8 +29,6 @@ KdmList::KdmList( QObject *parent, const
 	: KdmItem( parent, node )
 {
 	itemType = "list";
-	if (!isVisible())
-		return;
 
 	// Read RECT TAGS
 	QDomNodeList childList = node.childNodes();
Index: kdm/kfrontend/themer/kdmthemer.cpp
===================================================================
--- kdm/kfrontend/themer/kdmthemer.cpp.orig
+++ kdm/kfrontend/themer/kdmthemer.cpp
@@ -227,11 +227,7 @@ KdmThemer::generateItems( KdmItem *paren
 			else if (type == "svg")
 				newItem = new KdmPixmap( parent, subnode );
 			else
-				continue;
-			if (!newItem->isVisible()) {
-				delete newItem;
-				continue;
-			}
+                                continue;
 			connect( newItem, SIGNAL(needUpdate( int, int, int, int )),
 			         SLOT(update( int, int, int, int )) );
 			connect( newItem, SIGNAL(needPlacement()),