Browse Source

Fix coding style

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@231 7c53e7cc-98ea-0310-8f1f-a0b24da60408
iwamatsu 9 years ago
parent
commit
ae2b9db56d
15 changed files with 157 additions and 158 deletions
  1. 9 9
      Ck.h
  2. 1 1
      PAM.cpp
  3. 11 12
      app.cpp
  4. 15 15
      app.h
  5. 5 6
      cfg.cpp
  6. 5 5
      cfg.h
  7. 14 15
      image.cpp
  8. 20 20
      image.h
  9. 1 1
      log.cpp
  10. 8 8
      main.cpp
  11. 3 3
      numlock.cpp
  12. 14 14
      numlock.h
  13. 5 5
      panel.cpp
  14. 18 18
      panel.h
  15. 28 26
      png.c

+ 9 - 9
Ck.h

@@ -16,31 +16,31 @@
 #include <dbus/dbus.h>
 
 namespace Ck {
-  class Exception {
-  public:
+	class Exception {
+	public:
 	std::string func;
 	std::string errstr;
 	Exception(const std::string &func, const std::string &errstr);
-  };
+	};
 
-  class Session {
-  private:
+	class Session {
+	private:
 	CkConnector *ckc;
 	DBusError error;
 
 	const char * get_x11_device(const std::string &display);
 	dbus_bool_t ck_connector_open_graphic_session(const std::string &display,
-												  uid_t uid);
-  public:
+		uid_t uid);
+	public:
 	const char * get_xdg_session_cookie();
 	void open_session(const std::string &display, uid_t uid);
 	void close_session();
 
 	Session();
 	~Session();
-  };
+	};
 };
 
-std::ostream& operator<<( std::ostream& os, const Ck::Exception& e);
+std::ostream &operator<<(std::ostream &os, const Ck::Exception &e);
 
 #endif /* _CK_H_ */

+ 1 - 1
PAM.cpp

@@ -145,7 +145,7 @@ namespace PAM {
 			case PAM_USER_UNKNOWN:
 				_end();
 				throw Exception(pam_handle, "pam_acct_mgmt()", last_result);
-				
+
 			case PAM_AUTH_ERR:
 			case PAM_PERM_DENIED:
 				throw Auth_Exception(pam_handle, "pam_acct_mgmt()", last_result);

+ 11 - 12
app.cpp

@@ -176,7 +176,7 @@ App::App(int argc, char** argv)
 			break;
 		}
 	}
-#ifndef XNEST_DEBUG 
+#ifndef XNEST_DEBUG
 	if (getuid() != 0 && !testing) {
 		logStream << APPNAME << ": only root can run this program" << endl;
 		exit(ERR_EXIT);
@@ -316,7 +316,7 @@ void App::Run() {
 	bool firstloop = true; /* 1st time panel is shown (for automatic username) */
 	bool focuspass = cfg->getOption("focus_password")=="yes";
 	bool autologin = cfg->getOption("auto_login")=="yes";
-	
+
 	if (firstlogin && cfg->getOption("default_user") != "") {
 		LoginPanel->SetName(cfg->getOption("default_user") );
 #ifdef USE_PAM
@@ -335,7 +335,7 @@ void App::Run() {
 	} else if (numlock == "off") {
 		NumLock::setOff(Dpy);
 	}
-	
+
 	/* Start looping */
 	int panelclosed = 1;
 	Panel::ActionType Action;
@@ -369,7 +369,7 @@ void App::Run() {
 			XBell(Dpy, 100);
 			continue;
 		}
-	
+
 		firstloop = false;
 
 		Action = LoginPanel->getAction();
@@ -442,7 +442,7 @@ bool App::AuthenticateUser(bool focuspass){
 		}
 	}
 	LoginPanel->EventHandler(Panel::Get_Passwd);
-	
+
 	char *encrypted, *correct;
 	struct passwd *pw;
 
@@ -463,7 +463,7 @@ bool App::AuthenticateUser(bool focuspass){
 		return false;
 
 #ifdef HAVE_SHADOW
-	struct spwd *sp = getspnam(pw->pw_name);	
+	struct spwd *sp = getspnam(pw->pw_name);
 	endspent();
 	if(sp)
 		correct = sp->sp_pwdp;
@@ -537,7 +537,7 @@ void App::Login() {
 	maildir.append(pw->pw_name);
 	string xauthority = pw->pw_dir;
 	xauthority.append("/.Xauthority");
-	
+
 #ifdef USE_PAM
 	/* Setup the PAM environment */
 	try{
@@ -799,11 +799,11 @@ void App::RestartServer() {
 	};
 #endif
 
-	StopServer(); 
+	StopServer();
 	RemoveLock();
 	while (waitpid(-1, NULL, WNOHANG) > 0); /* Collects all dead childrens */
 	Run();
-} 
+}
 
 void App::KillAllClients(Bool top) {
 	Window dummywindow;
@@ -1077,7 +1077,7 @@ void App::setBackground(const string& themedir) {
 		XSetWindowBackgroundPixmap(Dpy, Root, p);
 	}
 	XClearWindow(Dpy, Root);
-	
+
 	XFlush(Dpy);
 	delete image;
 }
@@ -1137,8 +1137,7 @@ void App::OpenLog() {
 		RemoveLock();
 		exit(ERR_EXIT);
 	}
-	/* I should set the buffers to imediate write, but I just flush on every 
-	   << operation. */ 
+	/* I should set the buffers to imediate write, but I just flush on every << operation. */
 }
 
 /* Relases stdout/err */

+ 15 - 15
app.h

@@ -33,7 +33,7 @@
 
 class App {
 public:
-	App(int argc, char** argv);
+	App(int argc, char **argv);
 	~App();
 	void Run();
 	int GetServerPID();
@@ -59,15 +59,15 @@ private:
 	void CloseLog();
 	void HideCursor();
 	void CreateServerAuth();
-	char* StrConcat(const char* str1, const char* str2);
+	char *StrConcat(const char *str1, const char *str2);
 	void UpdatePid();
 
 	bool AuthenticateUser(bool focuspass);
- 
-	static std::string findValidRandomTheme(const std::string& set);
-	static void replaceVariables(std::string& input,
-								 const std::string& var,
-								 const std::string& value);
+
+	static std::string findValidRandomTheme(const std::string &set);
+	static void replaceVariables(std::string &input,
+								 const std::string &var,
+								 const std::string &value);
 
 	/* Server functions */
 	int StartServer();
@@ -76,11 +76,11 @@ private:
 
 	/* Private data */
 	Window Root;
-	Display* Dpy;
+	Display *Dpy;
 	int Scr;
-	Panel* LoginPanel;
+	Panel *LoginPanel;
 	int ServerPID;
-	const char* DisplayName;
+	const char *DisplayName;
 	bool serverStarted;
 
 #ifdef USE_PAM
@@ -91,23 +91,23 @@ private:
 #endif
 
 	/* Options */
-	char* DispName;
+	char *DispName;
 
 	Cfg *cfg;
 
 	Pixmap BackgroundPixmap;
 
 	void blankScreen();
-	Image* image;
-	void setBackground(const std::string& themedir);
+	Image *image;
+	void setBackground(const std::string &themedir);
 
 	bool firstlogin;
 	bool daemonmode;
 	bool force_nodaemon;
 	/* For testing themes */
-	char* testtheme;
+	char *testtheme;
 	bool testing;
-	
+
 	std::string themeName;
 	std::string mcookie;
 

+ 5 - 6
cfg.cpp

@@ -24,7 +24,7 @@ using namespace std;
 
 typedef pair<string,string> option;
 
-Cfg::Cfg() 
+Cfg::Cfg()
 	: currentSession(-1)
 {
 	/* Configuration options */
@@ -110,7 +110,6 @@ Cfg::Cfg()
 	options.insert(option("msg_shadow_xoffset", "0"));
 	options.insert(option("msg_shadow_yoffset", "0"));
 	options.insert(option("msg_shadow_color","#FFFFFF"));
-	
 
 	options.insert(option("session_color","#FFFFFF"));
 	options.insert(option("session_font","Verdana:size=16:bold"));
@@ -285,16 +284,16 @@ void Cfg::fillSessionList(){
 
 				struct stat oFileStat;
 
-				if (stat(strFile.c_str( ), &oFileStat) == 0){
-					if (S_ISREG(oFileStat.st_mode) && 
-						access(strFile.c_str(), R_OK | X_OK) == 0){
+				if (stat(strFile.c_str(), &oFileStat) == 0) {
+					if (S_ISREG(oFileStat.st_mode) &&
+						access(strFile.c_str(), R_OK | X_OK) == 0) {
 						sessions.push_back(string(pDirent->d_name));
 					}
 				}
 			}
 			closedir(pDir);
 		}
-	} 
+	}
 
 	if (sessions.empty()){
 		split(sessions, strSessionList, ',', false);

+ 5 - 5
cfg.h

@@ -27,6 +27,7 @@ class Cfg {
 public:
 	Cfg();
 	~Cfg();
+
 	bool readConf(std::string configfile);
 	std::string parseOption(std::string line, std::string option);
 	const std::string& getError() const;
@@ -34,11 +35,11 @@ public:
 	int getIntOption(std::string option);
 	std::string getWelcomeMessage();
 
-	static int absolutepos(const std::string& position, int max, int width);
-	static int string2int(const char* string, bool* ok = 0);
-	static void split(std::vector<std::string>& v, const std::string& str, 
+	static int absolutepos(const std::string &position, int max, int width);
+	static int string2int(const char *string, bool *ok = 0);
+	static void split(std::vector<std::string> &v, const std::string &str, 
 					  char c, bool useEmpty=true);
-	static std::string Trim(const std::string& s);
+	static std::string Trim(const std::string &s);
 
 	std::string nextSession(std::string current);
 
@@ -50,7 +51,6 @@ private:
 	std::vector<std::string> sessions;
 	int currentSession;
 	std::string error;
-
 };
 
 #endif /* _CFG_H_ */

+ 14 - 15
image.cpp

@@ -2,12 +2,12 @@
    Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
    Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
    Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-	  
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    The following code has been adapted and extended from
    xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
 */
@@ -69,7 +69,7 @@ Image::Read(const char *filename) {
 	fread(buf, 1, 4, file);
 	fclose(file);
 
-	if ((ubuf[0] == 0x89) && !strncmp("PNG", buf+1, 3)) 
+	if ((ubuf[0] == 0x89) && !strncmp("PNG", buf+1, 3))
 		success = readPng(filename, &width, &height, &rgb_data, &png_alpha);
 	else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8))
 		success = readJpeg(filename, &width, &height, &rgb_data);
@@ -131,7 +131,7 @@ Image::Reduce(const int factor) {
 
 void
 Image::Resize(const int w, const int h) {
-	
+
 	if (width==w && height==h){
 		return;
 	}
@@ -244,7 +244,7 @@ Image::getPixel(double x, double y, unsigned char *pixel, unsigned char *alpha)
  */
 void Image::Merge(Image* background, const int x, const int y) {
 
-	if (x + width > background->Width()|| y + height > background->Height()) 
+	if (x + width > background->Width()|| y + height > background->Height())
 		return;
 
 	if (background->Width()*background->Height() != width*height)
@@ -254,7 +254,7 @@ void Image::Merge(Image* background, const int x, const int y) {
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * width * height);
 	memset(new_rgb, 0, 3 * width * height);
 	const unsigned char *bg_rgb = background->getRGBData();
-	
+
 	int ipos = 0;
 	if (png_alpha != NULL){
 		for (int j = 0; j < height; j++) {
@@ -305,7 +305,7 @@ void Image::Tile(const int w, const int h) {
 
 	int newwidth = nx*width;
 	int newheight=ny*height;
-		
+
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * newwidth * newheight);
 	memset(new_rgb, 0, 3 * width * height * nx * ny);
 
@@ -390,18 +390,18 @@ void Image::Crop(const int x, const int y, const int w, const int h) {
 void Image::Center(const int w, const int h, const char *hex) {
 
 	unsigned long packed_rgb;
-	sscanf(hex, "%lx", &packed_rgb);  
+	sscanf(hex, "%lx", &packed_rgb);
 
 	unsigned long r = packed_rgb>>16;
 	unsigned long g = packed_rgb>>8 & 0xff;
-	unsigned long b = packed_rgb & 0xff;	
+	unsigned long b = packed_rgb & 0xff;
 
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
 	memset(new_rgb, 0, 3 * w * h);
 
 	int x = (w - width) / 2;
 	int y = (h - height) / 2;
-	
+
 	if (x<0) {
 		Crop((width - w)/2,0,w,height);
 		x = 0;
@@ -454,14 +454,14 @@ void Image::Center(const int w, const int h, const char *hex) {
 			}
 		}
 	}
-	
+
 	free(rgb_data);
 	free(png_alpha);
 	rgb_data = new_rgb;
 	png_alpha = NULL;
 	width = w;
 	height = h;
-	
+
 }
 
 /* Fill the image with the given color and adjust its dimensions
@@ -470,11 +470,11 @@ void Image::Center(const int w, const int h, const char *hex) {
 void Image::Plain(const int w, const int h, const char *hex) {
 
 	unsigned long packed_rgb;
-	sscanf(hex, "%lx", &packed_rgb);  
+	sscanf(hex, "%lx", &packed_rgb);
 
 	unsigned long r = packed_rgb>>16;
 	unsigned long g = packed_rgb>>8 & 0xff;
-	unsigned long b = packed_rgb & 0xff;	
+	unsigned long b = packed_rgb & 0xff;
 
 	unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
 	memset(new_rgb, 0, 3 * w * h);
@@ -492,7 +492,6 @@ void Image::Plain(const int w, const int h, const char *hex) {
 	png_alpha = NULL;
 	width = w;
 	height = h;
-	
 }
 
 void

+ 20 - 20
image.h

@@ -1,15 +1,15 @@
 /* SLiM - Simple Login Manager
-   Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
-   Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
-   Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-	  
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-   
-   The following code has been adapted and extended from
-   xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
+	 Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+	 Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
+	 Copyright (C) 2012	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
+
+	 This program is free software; you can redistribute it and/or modify
+	 it under the terms of the GNU General Public License as published by
+	 the Free Software Foundation; either version 2 of the License, or
+	 (at your option) any later version.
+
+	 The following code has been adapted and extended from
+	 xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
 */
 
 #ifndef _IMAGE_H_
@@ -23,22 +23,22 @@ class Image {
 public:
 	Image();
 	Image(const int w, const int h, const unsigned char *rgb,
-		  const unsigned char *alpha);
+			const unsigned char *alpha);
 
 	~Image();
 
-	const unsigned char * getPNGAlpha() const {
+	const unsigned char *getPNGAlpha() const {
 		return(png_alpha);
 	};
-	const unsigned char * getRGBData() const {
+	const unsigned char *getRGBData() const {
 		return(rgb_data);
 	};
 
 	void getPixel(double px, double py, unsigned char *pixel);
 	void getPixel(double px, double py, unsigned char *pixel,
-				  unsigned char *alpha);
+					unsigned char *alpha);
 
-	int Width() const  {
+	int Width() const {
 		return(width);
 	};
 	int Height() const {
@@ -52,16 +52,16 @@ public:
 
 	void Reduce(const int factor);
 	void Resize(const int w, const int h);
-	void Merge(Image* background, const int x, const int y);
+	void Merge(Image *background, const int x, const int y);
 	void Crop(const int x, const int y, const int w, const int h);
 	void Tile(const int w, const int h);
 	void Center(const int w, const int h, const char *hex);
 	void Plain(const int w, const int h, const char *hex);
-	
+
 	void computeShift(unsigned long mask, unsigned char &left_shift,
-					  unsigned char &right_shift);
+				unsigned char &right_shift);
 
-	Pixmap createPixmap(Display* dpy, int scr, Window win);
+	Pixmap createPixmap(Display *dpy, int scr, Window win);
 
 private:
 	int width, height, area;

+ 1 - 1
log.cpp

@@ -5,7 +5,7 @@ bool
 LogUnit::openLog(const char * filename)
 {
 	if (logFile.is_open()) {
-		cerr << APPNAME 
+		cerr << APPNAME
 			<< ": opening a new Log file, while another is already open"
 			<< endl;
 		logFile.close();

+ 8 - 8
main.cpp

@@ -1,12 +1,12 @@
 /* SLiM - Simple Login Manager
-   Copyright (C) 1997, 1998 Per Liden
-   Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
-   Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
-	  
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+	Copyright (C) 1997, 1998 Per Liden
+	Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+	Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
+
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
 */
 
 #include "app.h"

+ 3 - 3
numlock.cpp

@@ -28,7 +28,7 @@ int NumLock::xkb_init(Display* dpy) {
 		&& XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error,
 				   &xkb_lmaj, &xkb_lmin );
 }
-	
+
 unsigned int NumLock::xkb_mask_modifier( XkbDescPtr xkb, const char *name ) {
 	int i;
 	if( !xkb || !xkb->names )
@@ -59,7 +59,7 @@ unsigned int NumLock::xkb_numlock_mask(Display* dpy) {
 
 void NumLock::control_numlock(Display *dpy, bool flag) {
 	unsigned int mask;
-	
+
 	if( !xkb_init(dpy) )
 		return;
 
@@ -81,7 +81,7 @@ void NumLock::setOff(Display *dpy) {
 	control_numlock(dpy, false);
 }
 
-/* 
+/*
  Copyright (C) 2000-2001 Lubos Lunak		<l.lunak@kde.org>
  Copyright (C) 2001	  Oswald Buddenhagen <ossi@kde.org>
 

+ 14 - 14
numlock.h

@@ -1,12 +1,12 @@
 /* SLiM - Simple Login Manager
-   Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
-   Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
-   Copyright (C) 2012    Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
+	Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
+	Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
+	Copyright (C) 2012		Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
 */
 
 #ifndef _NUMLOCK_H_
@@ -19,15 +19,15 @@
 class NumLock {
 
 public:
-    NumLock();
-    static void setOn(Display *dpy);
-    static void setOff(Display *dpy);
+	NumLock();
+	static void setOn(Display *dpy);
+	static void setOff(Display *dpy);
 
 private:
-    static int xkb_init(Display* dpy);
-    static unsigned int xkb_mask_modifier( XkbDescPtr xkb, const char *name );
-    static unsigned int xkb_numlock_mask(Display* dpy);
-    static void control_numlock(Display *dpy, bool flag);
+	static int xkb_init(Display *dpy);
+	static unsigned int xkb_mask_modifier(XkbDescPtr xkb, const char *name);
+	static unsigned int xkb_numlock_mask(Display *dpy);
+	static void control_numlock(Display *dpy, bool flag);
 };
 
 #endif /* _NUMLOCK_H_ */

+ 5 - 5
panel.cpp

@@ -353,7 +353,7 @@ bool Panel::OnKeyPress(XEvent& event) {
 	int yy;
 	string text;
 	string formerString = "";
-	
+
 	XLookupString(&event.xkey, &ascii, 1, &keysym, &compstatus);
 	switch(keysym){
 		case XK_F1:
@@ -429,7 +429,7 @@ bool Panel::OnKeyPress(XEvent& event) {
 				break;
 			}
 			/* Deliberate fall-through */
-		
+
 		default:
 			if (isprint(ascii) && (keysym < XK_Shift_L || keysym > XK_Hyper_R)){
 				switch(field) {
@@ -575,9 +575,9 @@ void Panel::ShowSession() {
 	XClearWindow(Dpy, Root);
 	string currsession = cfg->getOption("session_msg") + " " + session;
 	XGlyphInfo extents;
-	
+
 	sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
-	
+
 	XftDraw *draw = XftDrawCreate(Dpy, Root,
 								  DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
 	XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
@@ -590,7 +590,7 @@ void Panel::ShowSession() {
 	int shadowYOffset = cfg->getIntOption("session_shadow_yoffset");
 
 	SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
-					currsession, 
+					currsession,
 					&sessionshadowcolor,
 					shadowXOffset, shadowYOffset);
 	XFlush(Dpy);

+ 18 - 18
panel.h

@@ -41,34 +41,35 @@ public:
 		Exit,
 		Suspend
 	};
+
 	enum FieldType {
 		Get_Name,
 		Get_Passwd
 	};
 
 
-	Panel(Display* dpy, int scr, Window root, Cfg* config,
+	Panel(Display *dpy, int scr, Window root, Cfg *config,
 		  const std::string& themed);
 	~Panel();
 	void OpenPanel();
 	void ClosePanel();
 	void ClearPanel();
-	void Message(const std::string& text);
-	void Error(const std::string& text);
-	void EventHandler(const FieldType& curfield);
+	void Message(const std::string &text);
+	void Error(const std::string &text);
+	void EventHandler(const FieldType &curfield);
 	std::string getSession();
 	ActionType getAction(void) const;
 
 	void Reset(void);
 	void ResetName(void);
 	void ResetPasswd(void);
-	void SetName(const std::string& name);
+	void SetName(const std::string &name);
 	const std::string& GetName(void) const;
 	const std::string& GetPasswd(void) const;
 private:
 	Panel();
 	void Cursor(int visible);
-	unsigned long GetColor(const char* colorname);
+	unsigned long GetColor(const char *colorname);
 	void OnExpose(void);
 	bool OnKeyPress(XEvent& event);
 	void ShowText();
@@ -76,34 +77,34 @@ private:
 	void ShowSession();
 
 	void SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
-							int x, int y, const std::string& str,
-							XftColor* shadowColor,
+							int x, int y, const std::string &str,
+							XftColor *shadowColor,
 							int xOffset, int yOffset);
 
-	Cfg* cfg;
+	Cfg *cfg;
 
 	/* Private data */
 	Window Win;
 	Window Root;
-	Display* Dpy;
+	Display *Dpy;
 	int Scr;
 	int X, Y;
 	GC TextGC;
-	XftFont* font;
+	XftFont *font;
 	XftColor inputshadowcolor;
 	XftColor inputcolor;
 	XftColor msgcolor;
 	XftColor msgshadowcolor;
-	XftFont* msgfont;
+	XftFont *msgfont;
 	XftColor introcolor;
-	XftFont* introfont;
-	XftFont* welcomefont;
+	XftFont *introfont;
+	XftFont *welcomefont;
 	XftColor welcomecolor;
-	XftFont* sessionfont;
+	XftFont *sessionfont;
 	XftColor sessioncolor;
 	XftColor sessionshadowcolor;
 	XftColor welcomeshadowcolor;
-	XftFont* enterfont;
+	XftFont *enterfont;
 	XftColor entercolor;
 	XftColor entershadowcolor;
 	ActionType action;
@@ -142,7 +143,7 @@ private:
 	/* Pixmap data */
 	Pixmap PanelPixmap;
 
-	Image* image;
+	Image *image;
 
 	/* For thesting themes */
 	bool testing;
@@ -150,7 +151,6 @@ private:
 
 	/* Session handling */
 	std::string session;
-
 };
 
 #endif /* _PANEL_H_ */

+ 28 - 26
png.c

@@ -25,7 +25,7 @@
 #include "const.h"
 
 int
-read_png(const char *filename, int *width, int *height, unsigned char **rgb, 
+read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 	 unsigned char **alpha)
 {
 	int ret = 0;
@@ -41,21 +41,22 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 
 	FILE *infile = fopen(filename, "rb");
 	if (infile == NULL) {
-		fprintf(stderr, "Can not fopen file: %s\n",filename);
+		fprintf(stderr, "Can not fopen file: %s\n", filename);
 		return ret;
 	}
 
-	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 
-									 (png_voidp) NULL, 
-									 (png_error_ptr) NULL, 
-									 (png_error_ptr) NULL);
+	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+						(png_voidp)NULL,
+						(png_error_ptr)NULL,
+						(png_error_ptr)NULL);
 	if (!png_ptr)
 		goto file_close;
-  
+
 	info_ptr = png_create_info_struct(png_ptr);
 	if (!info_ptr) {
-		png_destroy_read_struct(&png_ptr, (png_infopp) NULL, 
-								(png_infopp) NULL);
+		png_destroy_read_struct(&png_ptr,
+						(png_infopp)NULL,
+						(png_infopp)NULL);
 	}
 
 #if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
@@ -64,7 +65,7 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 	if (setjmp(png_ptr->jmpbuf))
 #endif
 		goto png_destroy;
-  
+
 	png_init_io(png_ptr, infile);
 	png_read_info(png_ptr, info_ptr);
 
@@ -72,31 +73,32 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 				 &interlace_type, (int *) NULL, (int *) NULL);
 
 	/* Prevent against integer overflow */
-	if(w >= MAX_DIMENSION || h >= MAX_DIMENSION) {
-		fprintf(stderr, "Unreasonable dimension found in file: %s\n",filename);
+	if (w >= MAX_DIMENSION || h >= MAX_DIMENSION) {
+		fprintf(stderr,
+			"Unreasonable dimension found in file: %s\n", filename);
 		goto png_destroy;
 	}
 
 	*width = (int) w;
 	*height = (int) h;
-	
+
 	if (color_type == PNG_COLOR_TYPE_RGB_ALPHA
 		|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
 		alpha[0] = malloc(*width * *height);
-		if (alpha[0] == NULL)
-		{
-			fprintf(stderr, "Can't allocate memory for alpha channel in PNG file.\n");
+		if (alpha[0] == NULL) {
+			fprintf(stderr,
+				"Can't allocate memory for alpha channel in PNG file.\n");
 			goto png_destroy;
 		}
 	}
 
 	/* Change a paletted/grayscale image to RGB */
-	if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth <= 8) 
+	if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth <= 8)
 		png_set_expand(png_ptr);
 
 	/* Change a grayscale image to RGB */
-	if (color_type == PNG_COLOR_TYPE_GRAY 
-		|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+	if (color_type == PNG_COLOR_TYPE_GRAY ||
+		color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
 		png_set_gray_to_rgb(png_ptr);
 
 	/* If the PNG file has 16 bits per channel, strip them down to 8 */
@@ -115,7 +117,8 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 	for (i = 0; i < *height; i++) {
 		row_pointers[i] = malloc(4 * *width);
 		if (row_pointers == NULL) {
-			fprintf(stderr, "Can't allocate memory for PNG line.\n");
+			fprintf(stderr,
+				"Can't allocate memory for PNG line.\n");
 			goto rows_free;
 		}
 	}
@@ -128,8 +131,7 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 		goto rows_free;
 	}
 
-	if (alpha[0] == NULL)
-	{
+	if (alpha[0] == NULL) {
 		ptr = rgb[0];
 		for (i = 0; i < *height; i++) {
 			memcpy(ptr, row_pointers[i], 3 * *width);
@@ -144,7 +146,8 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
 				*ptr++ = row_pointers[i][ipos++];
-				alpha[0][i * *width + j] = row_pointers[i][ipos++];
+				alpha[0][i * *width + j]
+					= row_pointers[i][ipos++];
 			}
 		}
 	}
@@ -153,9 +156,8 @@ read_png(const char *filename, int *width, int *height, unsigned char **rgb,
 
 rows_free:
 	for (i = 0; i < *height; i++) {
-		if (row_pointers[i] != NULL ) {
+		if (row_pointers[i] != NULL)
 			free(row_pointers[i]);
-		}
 	}
 
 	free(row_pointers);
@@ -165,5 +167,5 @@ png_destroy:
 
 file_close:
 	fclose(infile);
-	return(ret);
+	return ret;
 }