Revision
62
Author
emsmith
Date
2006-12-08 12:08:34 -0800 (Fri, 08 Dec 2006)

Log Message

CC::run now requires a program name (run.php will get it from argv if available), changed naming convention to meet new standard (underscore naming, spaces after language constructs, no closing ?>, lowercase null, true, false), added CC_Exception, added CC_WM(window manager) - thanks leon, CC_Window is more basic now - there will be a CC_Main added that handles menu, toolbar, statusbar and main canvas area - writer is broken as of this commit...

Modified Paths

Added Paths

Diff

Modified: desktop/trunk/lib/cc.class.php (61 => 62)


--- desktop/trunk/lib/cc.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/cc.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -13,7 +13,7 @@
  * @link         http://callicore.net/desktop
  * @license      http://www.opensource.org/licenses/gpl-license.php GPL
  * @version      $Id$
- * @since        Php 5.2.0
+ * @since        Php 5.1.0
  * @package      callicore
  * @subpackage   desktop
  * @category     lib
@@ -57,6 +57,11 @@
 	static protected $program;
 
 	/**
+	 * @var string root callicore dir
+	 */
+	static public $dir;
+
+	/**
 	 * public function __construct
 	 *
 	 * forces only static calls
@@ -65,8 +70,7 @@
 	 */
 	public function __construct()
 	{
-		throw new Exception(CC::i18n(
-			'CC contains only static methods can cannot be constructed'));
+		throw new CC_Exception('CC contains only static methods and cannot be constructed');
 	}
 
 	/**
@@ -78,43 +82,38 @@
 	 * @param string $program 
 	 * @return void
 	 */
-	static public function run($program = NULL)
+	static public function run($program)
 	{
+		// global defines for the duration of the program
+		// I got tired of typing DIRECTORY_SEPARATOR all the time
+		define('DS', DIRECTORY_SEPARATOR, true);
+		define('EOL', PHP_EOL, true);
+		// CC root - whack off one dir
+		self::$dir = dirname((dirname(__FILE__))) . DS;
 		// set up translation
-		if(extension_loaded('gettext'))
+		if (extension_loaded('gettext'))
 		{
 			// we use system locale
-			bindtextdomain('Callicore', DIR . 'locale');
+			bindtextdomain('Callicore', self::$dir . 'locale');
 			textdomain('Callicore');
 		}
-		if(version_compare(PHP_VERSION, '5.1.0', '<'))
+		if (version_compare(PHP_VERSION, '5.1.0', '<'))
 		{
-			trigger_error(self::i18n('You must use php 5.1.0 or higher'), E_USER_ERROR);
+			throw new CC_Exception('You must use php 5.1.0 or higher');
 		}
 		$have = get_loaded_extensions();
 		$needed = array('standard', 'pcre', 'date', 'PDO', 'pdo_sqlite', 'php-gtk');
 		$diff = array_diff($needed, $have);
-		if(!empty($diff))
+		if (!empty($diff))
 		{
-			trigger_error(self::i18n('%s : %s', 'The following extensions must be loaded in your php.ini for Callicore to function', implode(', ', $diff)), E_USER_ERROR);
+			throw new CC_Exception('%s : %s', 'The following extensions must be loaded in your php.ini for Callicore to function', implode(', ', $diff));
 		}
 
 		self::$LARGE = Gtk::icon_size_register('gtk-large',64, 64);
 		self::$IMAGE = Gtk::icon_size_register('gtk-image',128, 128);
-		Gtk::rc_parse(DIR . 'stock_icons' . DS . 'stock.rc');
-		Gtk::rc_parse(DIR . 'cc_icons' . DS . 'callicore.rc');
+		Gtk::rc_parse(self::$dir . 'stock_icons' . DS . 'stock.rc');
+		Gtk::rc_parse(self::$dir . 'cc_icons' . DS . 'callicore.rc');
 
-		if(is_null($program))
-		{
-			if(isset($_SERVER['argv']) && isset($_SERVER['argv'][1]))
-			{
-				$program = (string) $_SERVER['argv'][1];
-			}
-		}
-		if(is_null($program))
-		{
-			trigger_error(self::i18n('You must supply a program to run'), E_USER_ERROR);
-		}
 		self::$program = $program;
 		spl_autoload_register(array(__CLASS__, 'autoload'));
 
@@ -139,14 +138,14 @@
 	{
 		$args = func_get_args();
 		array_shift($args);
-		if(!empty($args) && count($args) == 1 && is_array($args[0]))
+		if (!empty($args) && count($args) == 1 && is_array($args[0]))
 		{
 			$args = $args[0];
 		}
-		if(function_exists('gettext'))
+		if (function_exists('gettext'))
 		{
 			// if we have args, the first item is format only and not translated
-			if(is_array($args) && !empty($args))
+			if (is_array($args) && !empty($args))
 			{
 				$args = array_map('gettext', $args);
 			}
@@ -159,14 +158,14 @@
 	}
 
 	/**
-	 * public static function setDefaultIcon
+	 * public static function icon
 	 *
 	 * uses add_builtin_icon and render_icon to make set_default_icon_name work
 	 *
 	 * @param string $icon icon name to use as default
 	 * @return void
 	 */
-	public static function setDefaultIcon($icon)
+	public static function icon($icon)
 	{
 		$theme = GtkIconTheme::get_for_screen(GdkScreen::get_default());
 		$window = new GtkWindow();
@@ -207,29 +206,52 @@
 		preg_match_all('/[A-Z][a-z0-9_]*/', str_replace('CC_', '', $class), $matches);
 		$array = array_map('strtolower', $matches[0]);
 		$file = array_pop($array) . '.class.php';
-		if(!empty($array))
+		if (!empty($array))
 		{
 			$array[] = '';
 		}
 
-		$program = DIR . 'programs' . DS . self::$program . DS . 'lib' . DS . implode(DS, $array) . $file;
-		$lib = DIR . 'lib' . DS . implode(DS, $array) . $file;
+		$program = self::$dir . 'programs' . DS . self::$program . DS . 'lib' . DS . implode(DS, $array) . $file;
+		$lib = self::$dir . 'lib' . DS . implode(DS, $array) . $file;
 
-		if(file_exists($program))
+		if (file_exists($program))
 		{
 			include $program;
-			$return = TRUE;
+			$return = true;
 		}
-		elseif(file_exists($lib))
+		elseif (file_exists($lib))
 		{
 			include $lib;
-			$return = TRUE;
+			$return = true;
 		}
 		else
 		{
-			$return = FALSE;
+			echo $program;
+			$return = false;
 		}
 		return $return;
 	}
 }
-?>
\ No newline at end of file
+
+/**
+ * CC_Exception - exception class that handles translating messages
+ *
+ * Included with CC because these are the only two required classes
+ */
+class CC_Exception extends Exception
+{
+	/**
+	 * public function __construct
+	 *
+	 * wraps php exception class to do translation of the message
+	 * using CC::i18n
+	 *
+	 * @return void
+	 */
+	public function __construct($message = null, $code = 0)
+	{
+		$args = func_get_args();
+		parent::__construct(call_user_func_array(array('CC', 'i18n'), $args));
+		return;
+	}
+}
\ No newline at end of file

Modified: desktop/trunk/lib/config.class.php (61 => 62)


--- desktop/trunk/lib/config.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/config.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -11,7 +11,7 @@
  * @link         http://callicore.net/desktop
  * @license      http://www.opensource.org/licenses/gpl-license.php GPL
  * @version      $Id$
- * @since        Php 5.2.0
+ * @since        Php 5.1.0
  * @package      callicore
  * @subpackage   desktop
  * @category     lib
@@ -60,25 +60,25 @@
 	 */
 	public function __construct($program = 'Callicore')
 	{
-		if(!is_null(self::$singleton))
+		if (!is_null(self::$singleton))
 		{
-			throw new Exception(CC::i18n(
+			throw new CC_Exception(
 			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
-			'CC_Config'));
+			'CC_Config');
 		}
 		self::$singleton = $this;
 
 		$this->program = $program;
 		$folders = CC_Folders::instance();
-		$this->file = $folders->getAppdata() . strtolower($program) . '.config.ini';
-		if(file_exists($this->file))
+		$this->file = $folders->get_appdata() . strtolower($program) . '.config.ini';
+		if (file_exists($this->file))
 		{
 			$this->data = parse_ini_file($this->file);
 		}
 		else
 		{
 			$this->data = array();
-			$this->writeFile();
+			$this->write();
 		}
 		return;
 	}
@@ -93,7 +93,7 @@
 	 */
 	protected function __get($name)
 	{
-		if(isset($this->data[$name]))
+		if (isset($this->data[$name]))
 		{
 			return $this->data[$name];
 		}
@@ -125,7 +125,7 @@
 	protected function __set($name, $value)
 	{
 		$this->data[$name] = $value;
-		$this->writeFile();
+		$this->write();
 		return;
 	}
 
@@ -139,29 +139,36 @@
 	 */
 	protected function __unset($name)
 	{
-		unset($this->data[$name]);
-		$this->writeFile();
+		unset ($this->data[$name]);
+		$this->write();
 		return;
 	}
 
-	protected function writeFile()
+	/**
+	 * public function write
+	 *
+	 * actually writes the file out
+	 *
+	 * @return void
+	 */
+	protected function write()
 	{
-		$string = ';Preferences and Configuration for Callicore ' . $this->program
-			. EOL . '; Saved ' . date('Y-m-d H:i:s') . EOL . EOL;
-		foreach($this->data as $key => $value)
+		$string = CC::i18n(';Preferences and Configuration for Callicore ') . $this->program
+			. EOL . CC::i18n('; Saved ') . date('Y-m-d H:i:s') . EOL . EOL;
+		foreach ($this->data as $key => $value)
 		{
-			if(is_array($value))
+			if (is_array($value))
 			{
 				$key = preg_replace('/[' . preg_quote('{}|&~![()"') . ']/', '', $key) . '[]';
-				foreach($value as $subvalue)
+				foreach ($value as $subvalue)
 				{
 					$string .= $key . ' = "' . str_replace('"', '', $subvalue) . '"' . EOL;
 				}
 			}
-			elseif(is_bool($value))
+			elseif (is_bool($value))
 			{
 				$string .= preg_replace('/[' . preg_quote('{}|&~![()"') . ']/', '', $key)
-					. ' = ' . (($value == TRUE) ? 'TRUE' : 'FALSE') . EOL;
+					. ' = ' . (($value == true) ? 'TRUE' : 'FALSE') . EOL;
 			}
 			else
 			{
@@ -182,7 +189,7 @@
 	 */
 	static public function instance()
 	{
-		if(is_null(self::$singleton))
+		if (is_null(self::$singleton))
 		{
 			self::$singleton = new CC_Config();
 		}
@@ -198,8 +205,7 @@
 	 */
 	public function __clone()
 	{
-		throw new Exception(CC::i18n('Cannot clone singleton object %s', 'CC_Config'));
+		throw new CC_Exception('Cannot clone singleton object %s', 'CC_Config');
 		return;
 	}
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: desktop/trunk/lib/folders.class.php (61 => 62)


--- desktop/trunk/lib/folders.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/folders.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -12,7 +12,7 @@
  * @link         http://callicore.net/desktop
  * @license      http://www.opensource.org/licenses/gpl-license.php GPL
  * @version      $Id$
- * @since        Php 5.2.0
+ * @since        Php 5.1.0
  * @package      callicore
  * @subpackage   desktop
  * @category     lib
@@ -118,31 +118,31 @@
 	 */
 	public function __construct()
 	{
-		if(!is_null(self::$singleton))
+		if (!is_null(self::$singleton))
 		{
-			throw new Exception(CC::i18n(
+			throw new CC_Exception(
 			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
-			'CC_Folders'));
+			'CC_Folders');
 		}
 		self::$singleton = $this;
 
-		if(stristr(PHP_OS, 'winnt'))
+		if (stristr(PHP_OS, 'winnt'))
 		{
 			$this->os = self::WINNT;
 		}
-		elseif(stristr(PHP_OS, 'win32'))
+		elseif (stristr(PHP_OS, 'win32'))
 		{
 			$this->os = self::WIN32;
 		}
-		elseif(stristr(PHP_OS, 'darwin') || stristr(PHP_OS, 'mac'))
+		elseif (stristr(PHP_OS, 'darwin') || stristr(PHP_OS, 'mac'))
 		{
 			$this->os = self::MAC;
 		}
-		elseif(stristr(PHP_OS, 'linux'))
+		elseif (stristr(PHP_OS, 'linux'))
 		{
 			$this->os = self::LINUX;
 		}
-		elseif(stristr(PHP_OS, 'freebsd') || stristr(PHP_OS, 'aix') || stristr(PHP_OS, 'unix'))
+		elseif (stristr(PHP_OS, 'freebsd') || stristr(PHP_OS, 'aix') || stristr(PHP_OS, 'unix'))
 		{
 			$this->os = self::UNIX;
 		}
@@ -150,12 +150,12 @@
 		{
 			$this->os = self::UNKNOWN;
 		}
-		if((isset($_ENV['KDE_FULL_SESSION']) && $_ENV['KDE_FULL_SESSION'] == 'true') ||
+		if ((isset($_ENV['KDE_FULL_SESSION']) && $_ENV['KDE_FULL_SESSION'] == 'true') ||
 			(isset($_ENV['KDE_MULTIHEAD']) && $_ENV['KDE_MULTIHEAD'] == 'true'))
 		{
 			$this->desktop = self::KDE;
 		}
-		elseif(isset($_ENV['GNOME_DESKTOP_SESSION_ID']) || isset($_ENV['GNOME_KEYRING_SOCKET']))
+		elseif (isset($_ENV['GNOME_DESKTOP_SESSION_ID']) || isset($_ENV['GNOME_KEYRING_SOCKET']))
 		{
 			$this->desktop = self::GNOME;
 		}
@@ -173,49 +173,49 @@
 	 *
 	 * @return int
 	 */
-	public function getOS()
+	public function get_os()
 	{
 		return $this->os;
 	}
 
 	/**
-	 * public function getAppdata
+	 * public function get_appdata
 	 *
 	 * finds appdata dependent on env variables and OS, adds callicore specific
 	 * dir if needed
 	 *
 	 * @return void
 	 */
-	public function getAppdata()
+	public function get_appdata()
 	{
-		if(is_null($this->appdata))
+		if (is_null($this->appdata))
 		{
 			// check environment variables for appdata
-			if(isset($_ENV['APPDATA']))
+			if (isset($_ENV['APPDATA']))
 			{
 				$this->appdata = $_ENV['APPDATA'] . DS . 'Callicore' . DS;
 			}
 			// if win doesn't have appdata, we force the issue in the user profile
-			elseif($this->os == self::WIN32 || $this->os == self::WINNT)
+			elseif ($this->os == self::WIN32 || $this->os == self::WINNT)
 			{
-				$path = $this->getProfile() . 'Application Data' . DS;
-				if(!file_exists($path))
+				$path = $this->get_profile() . 'Application Data' . DS;
+				if (!file_exists($path))
 				{
 					mkdir($path);
 				}
 				$this->appdata = $path . 'Callicore' . DS;
 			}
 			// darwin puts things in $HOME/Library/Application Support/Callicore/
-			elseif($this->os == self::MAC)
+			elseif ($this->os == self::MAC)
 			{
-				$this->appdata = $this->getProfile() . 'Library/Application Support/Callicore' . DS;
+				$this->appdata = $this->get_profile() . 'Library/Application Support/Callicore' . DS;
 			}
 			// most *nix want ~/.callicore
 			else
 			{
-				$this->appdata = $this->getProfile() . '.callicore' . DS;
+				$this->appdata = $this->get_profile() . '.callicore' . DS;
 			}
-			if(!file_exists($this->appdata))
+			if (!file_exists($this->appdata))
 			{
 				mkdir($this->appdata);
 			}
@@ -224,55 +224,55 @@
 	}
 
 	/**
-	 * public function getProfile
+	 * public function get_profile
 	 *
 	 * finds windows user profile and *nix users "home" location
 	 *
 	 * @return void
 	 */
-	public function getProfile()
+	public function get_profile()
 	{
-		if(is_null($this->profile))
+		if (is_null($this->profile))
 		{
-			if($this->os == self::WINNT || $this->os == self::WIN32)
+			if ($this->os == self::WINNT || $this->os == self::WIN32)
 			{
 				$env = $_ENV + $_SERVER;
-				if(isset($env['USERPROFILE']))
+				if (isset($env['USERPROFILE']))
 				{
 					$this->profile = $env['USERPROFILE'] . DS;
 				}
-				elseif(isset($env['HOMEPATH']) && isset($env['HOMEDRIVE']))
+				elseif (isset($env['HOMEPATH']) && isset($env['HOMEDRIVE']))
 				{
 					$this->profile = $env['HOMEPATH'] . $env['HOMEDRIVE'] . DS;
 				}
-				elseif(isset($env['USERNAME']) && file_exists('C:\Documents and Settings\\' . $env['USERNAME']))
+				elseif (isset($env['USERNAME']) && file_exists('C:\Documents and Settings\\' . $env['USERNAME']))
 				{
 					$this->profile = 'C:\Documents and Settings\\' . $env['USERNAME'] . DS;
 				}
 				else
 				{
-					$this->profile = DIR;
+					$this->profile = CC::$dir;
 				}
 			}
 			else
 			{
-				if(isset($_ENV['HOME']))
+				if (isset($_ENV['HOME']))
 				{
 					$this->profile = $_ENV['HOME'] . DS;
 				}
-				elseif($this->os == self::MAC && isset($_ENV['USER']) &&
+				elseif ($this->os == self::MAC && isset($_ENV['USER']) &&
 					file_exists('/Users/' . $_ENV['USER']))
 				{
 					$this->profile = '/Users/' . $_ENV['USER'] . DS;
 				}
-				elseif(isset($_ENV['USER']) &&
+				elseif (isset($_ENV['USER']) &&
 					file_exists('/home/' . $_ENV['USER']))
 				{
 					$this->profile = '/home/' . $_ENV['USER'] . DS;
 				}
 				else
 				{
-					$this->profile = DIR;
+					$this->profile = CC::$dir;
 				}
 			}
 		}
@@ -280,27 +280,27 @@
 	}
 
 	/**
-	 * public function documents
+	 * public function get_documents
 	 *
 	 * finds documents folder dependent on env variables and OS
 	 *
 	 * @return void
 	 */
-	public function getDocuments()
+	public function get_documents()
 	{
 		// we always use wscript and com on windows because we want "my documents"
-		if(is_null($this->documents))
+		if (is_null($this->documents))
 		{
-			if($this->os == self::WINNT || $this->os == self::WIN32)
+			if ($this->os == self::WINNT || $this->os == self::WIN32)
 			{
 				$shell = new COM('WScript.Shell');
 				$this->documents = $shell->SpecialFolders('MyDocuments');
-				unset($shell);
+				unset ($shell);
 			}
 			else
 			{
-				$home = $this->getProfile();
-				if(file_exists($home . 'Documents'))
+				$home = $this->get_profile();
+				if (file_exists($home . 'Documents'))
 				{
 					$this->documents = $home . 'Documents' . DS;
 				}
@@ -314,39 +314,39 @@
 	}
 
 	/**
-	 * public function getTemp
+	 * public function get_temp
 	 *
 	 * finds temp directory using best guesses per OS
 	 *
 	 * @return string
 	 */
-	public function getTemp()
+	public function get_temp()
 	{
-		if(is_null($this->temp))
+		if (is_null($this->temp))
 		{
 			$env = $_SERVER + $_ENV;
-			if(isset($env['TEMP']) && file_exists($env['TEMP']) && is_dir($env['TEMP']))
+			if (isset($env['TEMP']) && file_exists($env['TEMP']) && is_dir($env['TEMP']))
 			{
 				$this->temp = $env['TEMP'];
 			}
-			if(isset($env['TMP']) && file_exists($env['TMP']) && is_dir($env['TMP']))
+			elseif (isset($env['TMP']) && file_exists($env['TMP']) && is_dir($env['TMP']))
 			{
 				$this->temp = $env['TMP'];
 			}
-			elseif(file_exists('/tmp/') && is_dir('/tmp/'))
+			elseif (file_exists('/tmp/') && is_dir('/tmp/'))
 			{
 				$this->temp = '/tmp/';
 			}
 			else
 			{
-				$this->temp = $this->getProfile();
+				$this->temp = $this->get_profile();
 			}
 		}
 		return $this->temp;
 	}
 
 	/**
-	 * public function launchFile
+	 * public function open_file
 	 *
 	 * creates command string and pipes it to exec to open a file with an external
 	 * app dependent on OS and desktop Windows uses com to avoid the extra dos window
@@ -354,47 +354,47 @@
 	 * @param string $file file to open
 	 * @return bool
 	 */
-	public function launchFile($file)
+	public function open_file($file)
 	{
-		if($this->os == self::LINUX || $this->os == self::UNIX)
+		if ($this->os == self::LINUX || $this->os == self::UNIX)
 		{
 			// try to use desktop launch standard
-			if(isset($_ENV['DESKTOP_LAUNCH']))
+			if (isset($_ENV['DESKTOP_LAUNCH']))
 			{
 				$file = $_ENV['DESKTOP_LAUNCH'] . '"' . $file . '"';
 			}
-			elseif($this->desktop == self::KDE)
+			elseif ($this->desktop == self::KDE)
 			{
 				$file = 'kfmclient exec "' . $file . '"';
 			}
-			elseif($this->desktop == self::GNOME)
+			elseif ($this->desktop == self::GNOME)
 			{
 				$file = 'gnome-open "' . $file . '"';
 			}
 			return exec($file);
 		}
-		elseif($this->os == self::WINNT)
+		elseif ($this->os == self::WINNT)
 		{
 			$shell = new COM('WScript.Shell');
-			$return = $shell->Run('cmd /c start "" "' . $file . '"', 0, FALSE);
-			unset($shell);
+			$return = $shell->Run('cmd /c start "" "' . $file . '"', 0, false);
+			unset ($shell);
 			return (bool) $return;
 		}
-		elseif($this->os == self::WIN32)
+		elseif ($this->os == self::WIN32)
 		{
 			$shell = new COM('WScript.Shell');
-			$return = $shell->Run('command /c start "" "' . $file . '"', 0, FALSE);
-			unset($shell);
+			$return = $shell->Run('command /c start "" "' . $file . '"', 0, false);
+			unset ($shell);
 			return (bool) $return;
 		}
-		elseif($this->os == self::MAC)
+		elseif ($this->os == self::MAC)
 		{
 			$file = 'open "' . $file . '"';
 			return exec($file);
 		}
 		else
 		{
-			return FALSE;
+			return false;
 		}
 		return;
 	}
@@ -408,7 +408,7 @@
 	 */
 	static public function instance()
 	{
-		if(is_null(self::$singleton))
+		if (is_null(self::$singleton))
 		{
 			self::$singleton = new CC_Folders();
 		}
@@ -424,9 +424,8 @@
 	 */
 	public function __clone()
 	{
-		throw new Exception(CC::i18n('Cannot clone singleton object %s', 'CC_Folders'));
+		throw new CC_Exception('Cannot clone singleton object %s', 'CC_Folders');
 		return;
 	}
 
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: desktop/trunk/lib/message.class.php (61 => 62)


--- desktop/trunk/lib/message.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/message.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -12,7 +12,7 @@
  * @link         http://callicore.net/desktop
  * @license      http://www.opensource.org/licenses/gpl-license.php GPL
  * @version      $Id$
- * @since        Php 5.2.0
+ * @since        Php 5.1.0
  * @package      callicore
  * @subpackage   desktop
  * @category     lib
@@ -69,15 +69,15 @@
 	 */
 	public function __construct($message, $title = 'Default Message', $type = self::INFO, $program = 'Callicore')
 	{
-		if($type !== self::ERROR && $type !== self::WARNING && $type !== self::QUESTION)
+		if ($type !== self::ERROR && $type !== self::WARNING && $type !== self::QUESTION)
 		{
 			$type = self::INFO;
 		}
 
-		parent::__construct(NULL, 0, $type, Gtk::BUTTONS_CLOSE);
+		parent::__construct(null, 0, $type, Gtk::BUTTONS_CLOSE);
 		$this->set_position(Gtk::WIN_POS_CENTER);
 		$this->set_title(CC::i18n('%s : %s', $program, $title));
-		if(is_array($message))
+		if (is_array($message))
 		{
 			$this->set_markup(CC::i18n(array_shift($message), $message));
 		}
@@ -90,7 +90,7 @@
 	}
 
 	/**
-	 * public function parent
+	 * public function set_parent
 	 *
 	 * although the message may be triggered by an error handler
 	 * manual messages may wish to set a parent window
@@ -98,10 +98,10 @@
 	 * @param object instanceof GtkWindow $parent GtkWindow object parent
 	 * @return void
 	 */
-	public function parent($parent)
+	public function set_parent($parent)
 	{
 		$this->set_transient_for($parent);
-		$this->set_destroy_with_parent(TRUE);
+		$this->set_destroy_with_parent(true);
 		return;
 	}
 
@@ -118,11 +118,11 @@
 	 */
 	static public function error($code, $message, $file, $line)
 	{
-		switch($code)
+		switch ($code)
 		{
-			case(E_STRICT):
-			case(E_NOTICE):
-			case(E_USER_NOTICE):
+			case (E_STRICT):
+			case (E_NOTICE):
+			case (E_USER_NOTICE):
 			{
 				$level = self::INFO;
 				$title = 'Information';
@@ -131,8 +131,8 @@
 					. "\n$message\n" . 'The application will now continue.';
 				break;
 			}
-			case(E_WARNING):
-			case(E_USER_WARNING):
+			case (E_WARNING):
+			case (E_USER_WARNING):
 			{
 				$level = self::WARNING;
 				$title = 'Warning';
@@ -154,7 +154,7 @@
 		$win = new CC_Message($text, $title, $level);
 		$win->run();
 		$win->destroy();
-		if($level == self::ERROR)
+		if ($level == self::ERROR)
 		{
 			exit;
 		}
@@ -188,14 +188,13 @@
 	static protected function log($level, $message)
 	{
 		$folders = CC_Folders::instance();
-		$log = $folders->getAppdata() . 'error.log';
-		if(file_exists($log) && filesize($log) > 536870912)
+		$log = $folders->get_appdata() . 'error.log';
+		if (file_exists($log) && filesize($log) > 536870912)
 		{
-			rename($log, $folders->getAppdata() . date('Y-m-d') . 'error.log.bak');
+			rename($log, $folders->get_appdata() . date('Y-m-d') . 'error.log.bak');
 		}
 		file_put_contents($log, self::$messages[$level] . ' ' . date('Y-m-d H:i:s')
 			. ' --> ' . $message . EOL, FILE_APPEND);
 		return;
 	}
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: desktop/trunk/lib/splash.class.php (61 => 62)


--- desktop/trunk/lib/splash.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/splash.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -11,7 +11,7 @@
  * @link         http://callicore.net/desktop
  * @license      http://www.opensource.org/licenses/gpl-license.php GPL
  * @version      $Id$
- * @since        Php 5.2.0
+ * @since        Php 5.1.0
  * @package      callicore
  * @subpackage   desktop
  * @category     lib
@@ -59,7 +59,7 @@
 	 *
 	 * @return void
 	 */
-	public function __construct($steps, $program = 'Callicore')
+	public function __construct($steps, $program)
 	{
 
 		$this->steps = (int) $steps;
@@ -68,10 +68,10 @@
 		parent::__construct();
 		$this->set_position(Gtk::WIN_POS_CENTER);
 		$this->set_title(CC::i18n('%s :: %s', $program, 'Loading'));
-		$this->set_resizable(FALSE);
-		$this->set_decorated(FALSE);
-		$this->set_skip_taskbar_hint(TRUE);
-		$this->set_skip_pager_hint(TRUE);
+		$this->set_resizable(false);
+		$this->set_decorated(false);
+		$this->set_skip_taskbar_hint(true);
+		$this->set_skip_pager_hint(true);
 		$this->set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
 
 		// Main VBox Container
@@ -81,18 +81,18 @@
 
 		// Empty top bar
 		$hbox = $this->hbox = new GtkHBox();
-		$vbox->pack_start($hbox, FALSE, FALSE);
+		$vbox->pack_start($hbox, false, false);
 
 		// Progressbar on Bottom
 		$this->progressbar = new GtkProgressBar();
 		$this->progressbar->set_text(CC::i18n('Loading...'));
 		$this->progressbar->set_fraction(0);
-		$vbox->pack_end($this->progressbar, FALSE, FALSE);
+		$vbox->pack_end($this->progressbar, false, false);
 		return;
 	}
 
 	/**
-	 * public function parent
+	 * public function set_parent
 	 *
 	 * although the splashscreen is created first,
 	 * it changes to a transient for the main window
@@ -101,83 +101,83 @@
 	 * @param object instanceof GtkWindow $parent GtkWindow object parent
 	 * @return void
 	 */
-	public function parent($parent)
+	public function set_parent($parent)
 	{
 		$this->set_transient_for($parent);
-		$this->set_destroy_with_parent(TRUE);
+		$this->set_destroy_with_parent(true);
 		return;
 	}
 
 	/**
-	 * public function setImage
+	 * public function set_image
 	 *
 	 * sets a background image for the splash screen
 	 *
 	 * @param string $image absolute path to splash background
 	 * @return void
 	 */
-	public function setImage($image)
+	public function set_image($image)
 	{
 		$pixbuf = GdkPixbuf::new_from_file($image);
 		list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask();
 		list($width, $height) = $pixmap->get_size();
-		$this->set_app_paintable(TRUE);
+		$this->set_app_paintable(true);
 		$this->set_size_request($width, $height);
 		$this->realize();
 		if($mask instanceof GdkPixmap)
 		{
 			$this->shape_combine_mask($mask, 0, 0);
 		}
-		$this->window->set_back_pixmap($pixmap, FALSE);
+		$this->window->set_back_pixmap($pixmap, false);
 		return;
 	}
 
 	/**
-	 * public function setLicense
+	 * public function set_license
 	 *
 	 * sets license information string (on bottom center of window)
 	 *
 	 * @param string $license license string to use
 	 * @return void
 	 */
-	public function setLicense($license = 'GPL License')
+	public function set_license($license = 'GPL License')
 	{
 		// License info just above progressbar
 		$hbox = new GtkHBox();
-		$hbox->pack_start(new GtkLabel(CC::i18n($license)), FALSE, FALSE);
-		$this->vbox->pack_end($hbox, FALSE, FALSE);
+		$hbox->pack_start(new GtkLabel(CC::i18n($license)), false, false);
+		$this->vbox->pack_end($hbox, false, false);
 		return;
 	}
 
 	/**
-	 * public function setVersion
+	 * public function set_version
 	 *
 	 * sets version information string (top right)
 	 *
 	 * @param string $version string to use
 	 * @return void
 	 */
-	public function setVersion($version = NULL)
+	public function set_version($version = null)
 	{
 		if(is_null($version))
 		{
-			$verion = 'version ' . CC::VERSION;
+			$version = 'version ' . CC::VERSION;
 		}
-		$this->hbox->pack_end(new GtkLabel(CC::i18n($version)), FALSE, FALSE);
+		$this->hbox->pack_end(new GtkLabel(CC::i18n($version)), false, false);
 		return;
 	}
 
 	/**
-	 * public function setCopyright
+	 * public function set_copyright
 	 *
 	 * sets author information string (top left)
 	 *
 	 * @param string $copyright string to use
 	 * @return void
 	 */
-	public function setCopyright($copyright = 'Copyright (c) 2006')
+	public function set_copyright($copyright = 'Copyright (c) 2006')
 	{
-		$this->hbox->pack_start(new GtkLabel(CC::i18n($copyright)), FALSE, FALSE);
+		$this->hbox->pack_start(new GtkLabel(CC::i18n($copyright)), false, false);
 		return;
 	}
 
@@ -192,10 +192,10 @@
 	public function update($text)
 	{
 		$this->progressbar->set_text(CC::i18n($text));
-		$this->progressbar->set_fraction($this->progressbar->get_fraction() + (1 / $this->steps));
+		$this->progressbar->set_fraction($this->progressbar->get_fraction() +
+			(1 / $this->steps));
 		while (Gtk::events_pending())
 		Gtk::main_iteration();
 		return;
 	}
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: desktop/trunk/lib/tooltips.class.php (61 => 62)


--- desktop/trunk/lib/tooltips.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/tooltips.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -11,7 +11,7 @@
  * @link         http://callicore.net/desktop
  * @license      http://www.opensource.org/licenses/gpl-license.php GPL
  * @version      $Id$
- * @since        Php 5.2.0
+ * @since        Php 5.1.0
  * @package      callicore
  * @subpackage   desktop
  * @category     lib
@@ -21,7 +21,7 @@
 /**
  * CC_Tooltips - tooltips wrapper
  *
- * fixes the weirdness of toolbar tooltips
+ * fixes the weirdness of toolbar tooltips and forces a singleton instance
  */
 class CC_Tooltips extends GtkTooltips
 {
@@ -41,11 +41,11 @@
 	 */
 	public function __construct()
 	{
-		if(!is_null(self::$singleton))
+		if (!is_null(self::$singleton))
 		{
-			throw new Exception(CC::i18n(
-			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
-			'CC_Tooltips'));
+			throw new CC_Exception(
+				'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
+			'CC_Tooltips');
 		}
 		self::$singleton = $this;
 
@@ -64,7 +64,7 @@
 	 */
 	public function set_tip($widget, $tooltip)
 	{
-		if($widget instanceof GtkToolItem)
+		if ($widget instanceof GtkToolItem)
 		{
 			$widget->set_tooltip($this, $tooltip);
 		}
@@ -84,7 +84,7 @@
 	 */
 	static public function instance()
 	{
-		if(is_null(self::$singleton))
+		if (is_null(self::$singleton))
 		{
 			self::$singleton = new CC_Tooltips();
 		}
@@ -100,7 +100,7 @@
 	 */
 	public function __clone()
 	{
-		throw new Exception(CC::i18n('Cannot clone singleton object %s', 'CC_Tooltips'));
+		throw new CC_Exception('Cannot clone singleton object %s', 'CC_Tooltips');
 		return;
 	}
 }

Modified: desktop/trunk/lib/window.class.php (61 => 62)


--- desktop/trunk/lib/window.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/window.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -20,45 +20,14 @@
  */
 
 /**
- * CC_Window - basic window with menu, toolbar, status bar automagically created
+ * CC_Window - basic window items taken care of
  *
  * Streamlines creation of similiar windows and callbacks - handles automatic
  * saving and returning x and y position, as well as height and width on windows
  */
 abstract class CC_Window extends GtkWindow
 {
-
 	/**
-	 * program name for app
-	 * @var $program string
-	 */
-	public $program;
-
-	/**
-	 * main vbox for window
-	 * @var $vbox object instanceof GtkVBox
-	 */
-	public $vbox;
-
-	/**
-	 * main menu for the window
-	 * @var $menu object instanceof GtkMenu
-	 */
-	public $menu;
-
-	/**
-	 * toolbar for the window
-	 * @var $toolbar object instanceof CC_Toolbar
-	 */
-	public $toolbar;
-
-	/**
-	 * status bar for window
-	 * @var $statusbar object instanceof GtkStatusBar
-	 */
-	public $statusbar;
-
-	/**
 	 * windows can be minimized, maximized and fullscreened
 	 * @var $minimized bool
 	 */
@@ -92,28 +61,14 @@
 
 		parent::__construct();
 
-		$config = CC_Config::instance();
-
-		if(empty($this->name))
+		if (empty($this->name))
 		{
 			$this->set_name(strtolower(get_class($this)));
 		}
 
-		$this->toolbar = new CC_Toolbar($this->name);
-		$this->buildActions();
-		$this->buildMenu();
-		$this->buildToolbar();
-		$this->buildStatusbar();
-
-		$vbox = $this->vbox = new GtkVBox();
-		$vbox->pack_start($this->menu, 0, 0);
-		$vbox->pack_start($this->toolbar, 0, 0);
-		$vbox->pack_end($this->statusbar, 0, 0);
-		$this->add($vbox);
-
-		$this->connect('window-state-event', array($this, 'windowState'));
-		$this->connect_simple('delete-event', array($this, 'saveWindowState'));
-		$this->restoreWindowState();
+		$this->connect('window-state-event', array($this, 'on_state_event'));
+		$this->connect_simple('delete-event', array($this, 'on_state_save'));
+		$this->on_state_restore();
 		return;
 	}
 
@@ -125,9 +80,9 @@
 	 * @param string $name title to set
 	 * @return void
 	 */
-	public function set_title($title, $program = 'Callicore')
+	public function set_title($title, $program = null)
 	{
-		if(empty($this->program))
+		if (empty($this->program))
 		{
 			$this->program = $program;
 		}
@@ -136,251 +91,66 @@
 	}
 
 	//----------------------------------------------------------------
-	//             Building Items
+	//             Overrides for window manager class
 	//----------------------------------------------------------------
 
 	/**
-	 * protected function buildActions
+	 * public function hide_all
 	 *
-	 * creates generic window actions
+	 * overrides hide_all for windows manager integration
 	 *
-	 * @todo add additional generic actions
 	 * @return void
 	 */
-	protected function buildActions()
+	public function hide_all()
 	{
-		$actions = CC_Actions::instance();
-		$this->add_accel_group($actions->get_accel());
-
-		$actions->add_actions('file', array(
-		array(
-			'type' => 'action',
-			'name' => 'quit',
-			'label' => '_Quit',
-			'short-label' => '_Quit',
-			'tooltip' => 'Exit program',
-			'accel' => '<Ctrl>q',
-			'callback' => array($this, 'onQuit'),
-			'image' => 'gtk-quit',
-			),
-		));
-
-		$actions->add_actions('help', array(
-		array(
-			'type' => 'action',
-			'name' => 'help',
-			'label' => '_Help',
-			'short-label' => '_Help',
-			'tooltip' => 'Open help',
-			'accel' => 'F1',
-			'callback' => array($this, 'onHelp'),
-			'image' => 'gtk-help',
-			),
-		array(
-			'type' => 'action',
-			'name' => 'website',
-			'label' => '_Website',
-			'short-label' => '_Website',
-			'tooltip' => 'Visit Callicore website',
-			'callback' => array($this, 'onWebsite'),
-			'image' => 'cc-browser',
-			),
-		array(
-			'type' => 'action',
-			'name' => 'about',
-			'label' => '_About',
-			'short-label' => '_About',
-			'tooltip' => 'About Callicore',
-			'callback' => array($this, 'onAbout'),
-			'image' => 'gtk-about',
-			),
-		));
-
-		$actions->add_actions('toolbar', array(
-		array(
-			'type' => 'toggle',
-			'name' => 'toggle',
-			'label' => '_Show/Hide Toolbar',
-			'short-label' => '_Toolbar',
-			'tooltip' => 'Show and hide the toolbar',
-			'callback' => array($this->toolbar, 'onToggleToolbar'),
-			),
-		array(
-			'type' => 'radio',
-			'name' => 'small',
-			'label' => '_Small Icons',
-			'short-label' => '_Small',
-			'tooltip' => 'Display small icons on the toolbar',
-			'callback' => array($this->toolbar, 'onSizeToolbar'),
-			'value' => 1,
-			'radio' => 'small',
-			),
-		array(
-			'type' => 'radio',
-			'name' => 'medium',
-			'label' => '_Medium Icons',
-			'short-label' => '_Medium',
-			'tooltip' => 'Display medium icons on the toolbar',
-			'callback' => array($this->toolbar, 'onSizeToolbar'),
-			'value' => 2,
-			'radio' => 'small',
-			),
-		array(
-			'type' => 'radio',
-			'name' => 'large',
-			'label' => '_Large Icons',
-			'short-label' => '_Large',
-			'tooltip' => 'Display large icons on the toolbar',
-			'callback' => array($this->toolbar, 'onSizeToolbar'),
-			'value' => 3,
-			'radio' => 'small',
-			),
-		array(
-			'type' => 'radio',
-			'name' => 'icon',
-			'label' => '_Icons',
-			'short-label' => '_Icons',
-			'tooltip' => 'Display only icons on the toolbar',
-			'callback' => array($this->toolbar, 'onStyleToolbar'),
-			'value' => 1,
-			'radio' => 'icon',
-			),
-		array(
-			'type' => 'radio',
-			'name' => 'text',
-			'label' => '_Text',
-			'short-label' => '_Text',
-			'tooltip' => 'Display only text on the toolbar',
-			'callback' => array($this->toolbar, 'onStyleToolbar'),
-			'value' => 2,
-			'radio' => 'icon',
-			),
-		array(
-			'type' => 'radio',
-			'name' => 'both',
-			'label' => '_Both',
-			'short-label' => '_Both',
-			'tooltip' => 'Display icons and text on the toolbar',
-			'callback' => array($this->toolbar, 'onStyleToolbar'),
-			'value' => 3,
-			'radio' => 'icon',
-			),
-		array(
-			'type' => 'action',
-			'name' => 'customize',
-			'label' => '_Customize...',
-			'short-label' => '_Customize',
-			'tooltip' => 'Customize toolbar',
-			'callback' => array($this->toolbar, 'onCustomize'),
-			'image' => 'gtk-properties',
-			),
-		));
-
-		return;
+		if (class_exists('CC_WM') && CC_WM::is_window($this->get_name()) &&
+			$this->modal)
+		{
+			parent::grab_remove();
+			$return = parent::hide_all();
+			$this->modal = false;
+			return $return;
+		}
+		else
+		{
+			return parent::hide_all();
+		}
 	}
 
-	//----------------------------------------------------------------
-	//             Gui Creation
-	//----------------------------------------------------------------
-
 	/**
-	 * protected function buildMenu
+	 * public function show_all
 	 *
-	 * build a default menubar
-	 * file quit, view options
+	 * overrides show_all for windows manager integration
 	 *
-	 * @todo finish menu creation
 	 * @return void
 	 */
-	protected function buildMenu()
+	public function show_all($modal = false)
 	{
-
-		$this->menu = $menu = is_null($this->menu) ? new GtkMenuBar() : $this->menu;
-		$actions = CC_Actions::instance();
-
-		$item = new GtkMenuItem(CC::i18n('_File'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$submenu->append($actions->create_menu_item('file', 'quit'));
-
-		$item = new GtkMenuItem(CC::i18n('_View'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$submenu->append($actions->create_menu_item('toolbar', 'toggle'));
-		$submenu->append($actions->create_menu_item('toolbar', 'customize'));
-
-		$item = new GtkMenuItem(CC::i18n('_Help'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$submenu->append($actions->create_menu_item('help', 'help'));
-		$submenu->append($actions->create_menu_item('help', 'website'));
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$submenu->append($actions->create_menu_item('help', 'about'));
-		return;
+		if (class_exists('CC_WM') && CC_WM::is_window($this->get_name()))
+		{
+			$return = parent::show_all();
+			parent::grab_add();
+			$this->modal = true;
+			return $return;
+		}
+		else
+		{
+			return parent::show_all();
+		}
 	}
 
-	/**
-	 * protected function buildToolbar
-	 *
-	 * set up default and possible actions, and set name for toolbar
-	 *
-	 * @return void
-	 */
-	protected function buildToolbar()
-	{
-		$this->toolbar->default = array('file:quit', 'separator', 'toolbar:toggle',
-			'toolbar:customize');
-
-		$this->toolbar->options = array('separator', 'file:quit', 'help:about',
-			'help:website', 'help:help', 'toolbar:customize', 'toolbar:toggle',
-			'toolbar:icon', 'toolbar:text', 'toolbar: both', 'toolbar:large',
-			'toolbar:medium', 'toolbar:small');
-
-		$this->toolbar->buildToolbar();
-
-		return;
-	}
-
-	/**
-	 * protected function buildStatusbar
-	 *
-	 * build statusbar - gets the label inside and pads it gently (because
-	 * windows is stupid, has little effect on other systems), and sets a label
-	 * property for easy statusbar manipulation
-	 *
-	 * @return void
-	 */
-	protected function buildStatusbar()
-	{
-		$status = $this->statusbar = new GtkStatusBar();
-		$children = $status->get_children();
-		$status->label = $children[0]->child;
-		$status->label->set_padding(3, 0);
-		$status->label->set_label(CC::i18n('Ready'));
-		$status->label->set_use_markup(TRUE);
-		return;
-	}
-
 	//----------------------------------------------------------------
 	//             Callbacks
 	//----------------------------------------------------------------
 
 	/**
-	 * public function saveWindowState
+	 * public function on_state_save
 	 *
 	 * saves window state
 	 *
 	 * @return void
 	 */
-	public function saveWindowState()
+	public function on_state_save()
 	{
 		$name = $this->name;
 		$config = CC_Config::instance();
@@ -390,15 +160,15 @@
 		$config->{$name . '_maximized'} = $this->maximized;
 		$config->{$name . '_minimized'} = $this->minimized;
 
-		if($this->minimized)
+		if ($this->minimized)
 		{
 			$this->deiconify();
 		}
-		if($this->maximized)
+		if ($this->maximized)
 		{
 			$this->unmaximize();
 		}
-		elseif($this->fullscreen)
+		elseif ($this->fullscreen)
 		{
 			$this->unfullscreen();
 		}
@@ -418,13 +188,13 @@
 	}
 
 	/**
-	 * public function restoreWindowState
+	 * public function on_state_restore
 	 *
 	 * restores a window state
 	 *
 	 * @return void
 	 */
-	public function restoreWindowState()
+	public function on_state_restore()
 	{
 		$name = $this->name;
 		$config = CC_Config::instance();
@@ -436,7 +206,7 @@
 
 		$x = isset($config->{$name . '_x'}) ? (int) $config->{$name . '_x'} : NULL;
 		$y = isset($config->{$name . '_y'}) ? (int) $config->{$name . '_y'} : NULL;
-		if(!is_null($x) && !is_null($y))
+		if (!is_null($x) && !is_null($y))
 		{
 			$this->move($x, $y);
 		}
@@ -445,15 +215,15 @@
 		$maximized = isset($config->{$name . '_maximized'}) ? (bool) $config->{$name . '_maximized'} : FALSE;
 		$minimized = isset($config->{$name . '_minimized'}) ? (bool) $config->{$name . '_minimized'} : FALSE;
 
-		if($fullscreen)
+		if ($fullscreen)
 		{
 			$this->fullscreen();
 		}
-		if($maximized)
+		if ($maximized)
 		{
 			$this->maximize();
 		}
-		if($minimized)
+		if ($minimized)
 		{
 			$this->iconify();
 		}
@@ -461,18 +231,17 @@
 	}
 
 	/**
-	 * public function saveWindow
+	 * public function on_state_event
 	 *
 	 * keeps track of minimized/maximized/fullscreen or normal windows states
 	 *
 	 * @return void
 	 */
-	public function windowState($widget, $event)
+	public function on_state_event($widget, $event)
 	{
-		$this->minimized = ($event->new_window_state & Gdk::WINDOW_STATE_ICONIFIED) ? TRUE : FALSE;
-		$this->maximized = ($event->new_window_state & Gdk::WINDOW_STATE_MAXIMIZED) ? TRUE : FALSE;
-		$this->fullscreen = ($event->new_window_state & Gdk::WINDOW_STATE_FULLSCREEN) ? TRUE : FALSE;
+		$this->minimized = ($event->new_window_state & Gdk::WINDOW_STATE_ICONIFIED) ? true : false;
+		$this->maximized = ($event->new_window_state & Gdk::WINDOW_STATE_MAXIMIZED) ? true : false;
+		$this->fullscreen = ($event->new_window_state & Gdk::WINDOW_STATE_FULLSCREEN) ? true : false;
 	}
-
 }
 ?>
\ No newline at end of file

Added: desktop/trunk/lib/wm.class.php (61 => 62)


--- desktop/trunk/lib/wm.class.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/lib/wm.class.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -0,0 +1,167 @@
+<?php
+/**
+ * wm.class.php - window manager
+ *
+ * handles window groups and multiple gtkwindow object easily
+ *
+ * This is released under the GPL, see docs/gpl.txt for details
+ *
+ * @author       Leon Pegg <leon.pegg@gmail.com>
+ * @author       Elizabeth Smith <emsmith@callicore.net>
+ * @copyright    Leon Pegg (c)2006
+ * @link         http://callicore.net/desktop
+ * @license      http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version      $Id$
+ * @since        Php 5.1.0
+ * @package      callicore
+ * @subpackage   desktop
+ * @category     lib
+ * @filesource
+ */
+
+/**
+* Class for handling multiple GtkWindow objects
+*
+* contains all static methods
+*/
+class CC_WM
+{
+	/**
+	 * GtkWindow object array
+	 *      [string GtkWindow_Name]
+	 *          array(
+	 *            GtkWindow - Store GtkWindow object
+	 *          )
+	 *
+	 * @var array
+	 */
+	protected static $windows = array();
+
+	/**
+	 * GtkWindowGroup - for making grabs work properly (see GtkWidget::grab_add)
+	 *
+	 * @var object instanceof GtkWindowGroup
+	 */
+	protected static $window_group;
+
+	/**
+	 * public function __construct
+	 *
+	 * forces only static calls
+	 *
+	 * @return void
+	 */
+	public function __construct()
+	{
+		throw new CC_Exception('CC_WM contains only static methods and cannot be constructed');
+	}
+
+	/**
+	 * Adds a GtkWindow object to CC_WM::$windows
+	 *
+	 * @param object $window instanceof GtkWindow
+	 * @return bool
+	 */
+	public static function add_window(GtkWindow $window)
+	{
+		$name = $window->get_name();
+		if ($name !== '' && !array_key_exists($name, self::$windows))
+		{
+			if (!is_object(self::$window_group))
+			{
+				self::$window_group = new GtkWindowGroup();
+			}
+			self::$window_group->add_window($window);
+			self::$windows[$name] = $window;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Removes a GtkWindow object from CC_WM::$windows
+	 *
+	 * @param string $name
+	 * @return object instanceof GtkWindow
+	 */
+	public static function remove_window($name)
+	{
+		if ($name !== '' && array_key_exists($name, self::$windows))
+		{
+			$window = self::$windows[$$name];
+			unset(self::$windows[$name]);
+			self::$window_group->remove_window($window);
+			return $window;
+		}
+		return false;
+	}
+
+	/**
+	 * Retrives GtkWindow object from CC_WM::$windows
+	 *
+	 * @param string $name
+	 * @return object instanceof GtkWindow
+	 */
+	public static function get_window($name)
+	{
+		if ($name !== '' && array_key_exists($name, self::$$windows))
+		{
+			return self::$windows[$name];
+		}
+		return false;
+	}
+
+	/**
+	 * Retrives CC_WM::$windows infomation array
+	 *   Structure:
+	 *      [int window_id]
+	 *          array(
+	 *            name   - Name of GtkWindow
+	 *            class  - Name of GtkWindow class
+	 *          )
+	 *
+	 * @return array
+	 */
+	public static function list_windows()
+	{
+		$list = array();
+		foreach (self::$windows as $name => $class)
+		{
+			$list[] = array('name' => $name, 'class' => $get_class($class));
+		}
+		return $list;
+	}
+
+	/**
+	 * Shows all windows in the manager
+	 */
+	public static function show_all_windows()
+	{
+		foreach (self::$windows as $window)
+		{
+			$window->show_all();
+		}
+	}
+
+	/**
+	 * hides all the windows in the manager
+	 */
+	public static function hide_all_windows()
+	{
+		foreach (self::$windows as $window)
+		{
+			$window->hide_all();
+		}
+	}
+
+	/**
+	 * See if a specific window exists
+	 *
+	 * @param string $name name of window to check for
+	 * @return bool
+	 */
+	public static function is_window($name)
+	{
+		return array_key_exists($name, self::$windows);
+	}
+}
\ No newline at end of file
Property changes on: desktop/trunk/lib/wm.class.php
___________________________________________________________________
Name: tsvn:logminsize
   + 15
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Modified: desktop/trunk/run.php (61 => 62)


--- desktop/trunk/run.php	2006-12-06 23:28:23 UTC (rev 61)
+++ desktop/trunk/run.php	2006-12-08 20:08:34 UTC (rev 62)
@@ -1,15 +1,18 @@
 #!/usr/bin/php
 <?php
 /**
- * run.php - sets up the callicore environment
+ * run.php - this is a simple script to run callicore
  *
- * can be run via the shebang line on *nix systems - windows users can either
+ * this can be run via the shebang line on *nix systems - windows users can either
  * associate the file extension with the php cli or create a shortcut
  * C:\WINDOWS\system32\cmd.exe /k "C:\Program Files\php-gtk\php.exe"  run.php (for dos window)
  * or "C:\Program Files\php-gtk\php-win.exe" run.php (your php cli locations may vary)
  * you should pass an arg that is the name of the callicore program you want to run
  * e.g. run.php writer
  *
+ * You do not have to use this script to run a callicore program, you can write
+ * your own, just use CC::run('name of program'); to start callicore
+ *
  * This is released under the GPL, see docs/gpl.txt for details
  *
  * @author       Elizabeth Smith <emsmith@callicore.net>
@@ -24,17 +27,14 @@
  * @filesource
  */
 
-/**
- * global defines for the duration of the program
- * I got tired of typing DIRECTORY_SEPARATOR all the time
- * also finds the callicore program files root directory because cwd may vary
- */
-define('DS', DIRECTORY_SEPARATOR, TRUE);
-define('EOL', PHP_EOL, TRUE);
-define('DIR', dirname(__FILE__) . DS, TRUE);
+include (dirname(__FILE__) . '/lib/cc.class.php');
 
-include(DIR . 'lib' . DS . 'cc.class.php');
+// This particular script checks argv for a program name
+if (isset($argv) && isset($argv[1]))
+{
+	$program = (string) $argv[1];
+}
 
-CC::run();
+CC::run($program);
 Gtk::main();
 ?>
\ No newline at end of file