Revision
28
Author
emsmith
Date
2006-11-30 07:15:17 -0800 (Thu, 30 Nov 2006)

Log Message

A whole bunch of rearranging and simplifying

Modified Paths

Added Paths

Removed Paths

Diff

Added: desktop/trunk/Writer/lib/actions.class.php (27 => 28)


--- desktop/trunk/Writer/lib/actions.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/actions.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -0,0 +1,210 @@
+<?php
+/**
+ * actions.class.php - container for gtkactions & gtkactiongroups
+ *
+ * sets up actions and actiongroups "on demand"
+ *
+ * This is released under the GPL, see license.txt for details
+ *
+ * @author       Elizabeth Smith <emsmith@callicore.net>
+ * @copyright    Elizabeth Smith (c)2006
+ * @link         http://callicore.net/writer
+ * @license      http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version      $Id$
+ * @since        Php 5.2.0
+ * @package      callicore
+ * @subpackage   writer
+ * @category     lib
+ * @filesource
+ */
+
+/**
+ * Actions - actions/actiongroups map
+ *
+ * fixes the weirdness of toolbar tooltips, adds help tooltip support
+ * and generally makes managing actions easier
+ */
+class Actions
+{
+
+	/**
+	 * list of all current created action groups
+	 * @var $groups array
+	 */
+	protected $groups = array();
+
+	/**
+	 * global accelerator container for actions
+	 * @var $accel instanceof GtkAccelGroup
+	 */
+	protected $accel;
+
+	/**
+	 * public function __construct
+	 *
+	 * sets up the global accelgroup
+	 *
+	 * @return void
+	 */
+	public function __construct()
+	{
+		$this->accel = new GtkAccelGroup();
+		return;
+	}
+
+	/**
+	 * public function get_accel
+	 *
+	 * returns GtkAccelGroup instance, use this to set it in the right window
+	 *
+	 * @return object instanceof GtkAccelGroup
+	 */
+	public function get_accel()
+	{
+		return $this->accel;
+	}
+
+	/**
+	 * public function create_menu_item
+	 *
+	 * uses get_group to fetch the action group specified
+	 * uses get_action to fetch the action specified
+	 * creates a menu item and sets a tooltip for the action
+	 *
+	 * @param string $group name of action group to get
+	 * @param string $action name of action to get
+	 * @return object instanceof GtkMenuItem
+	 */
+	public function create_menu_item($group, $action)
+	{
+		$action = $this->get_action($group, $action);
+		$widget = $action->create_menu_item();
+		Writer::$tooltips->set_tip($widget, $action->get_property('tooltip'), $action->get_data('help-tooltip'));
+		unset($action, $group);
+		return $widget;
+	}
+
+	/**
+	 * public function create_tool_item
+	 *
+	 * uses get_group to fetch the action group specified
+	 * uses get_action to fetch the action specified
+	 * creates a toolbar item and sets a tooltip for the action
+	 *
+	 * @param string $group name of action group to get
+	 * @param string $action name of action to get
+	 * @return object instanceof GtkToolItem
+	 */
+	public function create_tool_item($group, $action)
+	{
+		$action = $this->get_action($group, $action);
+		$widget = $action->create_tool_item();
+		Writer::$tooltips->set_tip($widget, $action->get_property('tooltip'), $action->get_data('help-tooltip'));
+		unset($action, $group);
+		return $widget;
+	}
+
+	/**
+	 * public function get_group
+	 *
+	 * returns action group
+	 *
+	 * @param string $group name of action group to get
+	 * @return instanceof GtkActionGroup
+	 */
+	public function get_group($group)
+	{
+		return isset($this->groups[$group]) ? $this->groups[$group] : NULL;
+	}
+
+	/**
+	 * public function get_action
+	 *
+	 * returns an action from a group (shortcut)
+	 *
+	 * @param string $group name of action group to get
+	 * @param string $action name of action to get
+	 * @return instanceof GtkAction
+	 */
+	public function get_action($group, $action)
+	{
+		return (isset($this->groups[$group]) && isset($this->groups[$group][$action])) ? $this->groups[$group][$action] : NULL;
+	}
+
+	/**
+	 * public function add_group
+	 *
+	 * adds a new group with the specific name
+	 *
+	 * @param string $group group to create
+	 * @return void
+	 */
+	public function add_group($group)
+	{
+		$this->groups[$group] = new GtkActionGroup($group);
+		unset($group);
+		return;
+	}
+
+	/**
+	 * public function add_actions
+	 *
+	 * adds actions to a specific group (shortcut)
+	 * definition is array(
+	 * 'type' => action|toggle|radio,
+	 * 'callback' => php callback,
+	 * 'accel' => accelerator string to use,
+	 * 'name' => internal name for action,
+	 * 'label' => label,
+	 * 'short-label' => shorter label (for toolbar),
+	 * 'tooltip' => tooltip for the action,
+	 * 'help-tooltip' => help tooltip for the action,
+	 * 'image' => stock id or named image),
+	 * 'value' => value for radio action,
+	 * 'radio' => for radio items, the name of the action to group with
+	 * );
+	 * 
+	 *
+	 * @param string $group group to add to
+	 * @param array $definitions array of action definitions
+	 * @return void
+	 */
+	public function add_actions($group, $definitions)
+	{
+		if(!isset($this->groups[$group]))
+		{
+			$this->add_group($group);
+		}
+		$group = $this->get_group($group);
+		foreach($definitions as $def)
+		{
+			switch($def['type'])
+			{
+				case 'radio':
+					$action = new GtkRadioAction($def['name'], Writer::i18n($def['label']), Writer::i18n($def['tooltip']),$def['image'],$def['value']);
+					$action->set_group($group->get_action($def['radio']));
+					break;
+				case 'toggle':
+					$action = new GtkToggleAction($def['name'], Writer::i18n($def['label']), Writer::i18n($def['tooltip']),$def['image']);
+					break;
+				default:
+					$action = new GtkAction($def['name'], Writer::i18n($def['label']), Writer::i18n($def['tooltip']),$def['image']);
+			}
+			$action->set_data('help-tooltip', isset($def['help-tooltip']) ? Writer::i18n($def['help-tooltip']) : NULL);
+			$action->set_property('short-label', isset($def['short-label']) ? Writer::i18n($def['short-label']) : NULL);
+			$action->connect($callback);
+			if(isset($def['accel']))
+			{
+				$action->set_accel_group($this->accel);
+				$group->add_action_with_accel($action, $def['accel']);
+			}
+			else
+			{
+				$group->add_action($action);
+			}
+		}
+		unset($def, $definitions, $group, $action, $this);
+		return;
+	}
+}
+?>
\ No newline at end of file
Property changes on: desktop/trunk/Writer/lib/actions.class.php
___________________________________________________________________
Name: tsvn:logminsize
   + 15
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Modified: desktop/trunk/Writer/lib/character/edit.class.php (27 => 28)


--- desktop/trunk/Writer/lib/character/edit.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/character/edit.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -23,7 +23,7 @@
  *
  * Simple form with save and cancel options
  */
-class CharacterEdit extends GtkDialog
+class CharacterEdit extends Window
 {
 
 	/**
@@ -39,42 +39,15 @@
 	 *
 	 * @return void
 	 */
-	public function __construct($model, $iter)
+	public function __construct()
 	{
-		// dao object to tamper with
-		$this->character = new CharacterDao();
-		$cols = $model->get_n_columns();
-		while($cols > 0)
-		{
-			$this->character->{$cols - 1} = $model->get_value($iter, $cols -1);
-			$cols--;
-		}
-		unset($data, $cols, $iter, $model);
+		parent::__construct();
+		$this->connect('show', array($this, 'parent'));
+		$this->toolbar->set_no_show_all(TRUE);
+		$this->toolbar->hide();
+		$this->menu->set_no_show_all(TRUE);
+		$this->menu->hide();
 
-		// create window
-		parent::__construct(Writer::i18n('Writer :: Characters :: Edit "')
-			. $this->character->name . '"', CharacterWindow::instance(),
-			Gtk::DIALOG_MODAL | Gtk::DIALOG_DESTROY_WITH_PARENT | Gtk::DIALOG_NO_SEPARATOR,
-			array(
-				Gtk::STOCK_APPLY, Gtk::RESPONSE_APPLY,
-				Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL
-			));
-
-		// window defaults
-		$config = Config::instance();
-		$width = isset($config->character_edit_width) ? (int) $config->character_edit_width : NULL;
-		$height = isset($config->character_edit_height) ? (int) $config->character_edit_height : NULL;
-		if(!is_null($width) && !is_null($height))
-		{
-			$this->set_default_size($height, $width);
-		}
-		$x = isset($config->character_window_x) ? (int) $config->character_window_x : NULL;
-		$y = isset($config->character_window_y) ? (int) $config->character_window_y : NULL;
-		if(!is_null($x) && !is_null($y))
-		{
-			$this->move($x, $y);
-		}
-
 		// frame for form
 		$frame = new GtkFrame(Writer::i18n('Character Information'));
 		$frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
@@ -85,81 +58,87 @@
 		$scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
 		$scroll->set_shadow_type(Gtk::SHADOW_NONE);
 		$frame->add($scroll);
-		unset($frame);
 		// viewport by hand so we can kill shadow...grrr
 		$port = new GtkViewport();
 		$port->set_shadow_type(Gtk::SHADOW_NONE);
 		$scroll->add($port);
-		unset($scroll);
 		// table into viewport
 		$table = new GtkTable();
 		$port->add($table);
-		unset($port);
+
 		// basic items
-		$table->attach($label = new GtkLabel(Writer::i18n('Id:')), 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(1, 0.5);
-		$table->attach($label = new GtkLabel($this->character->id), 1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(0, 0.5);
-		$table->attach($label =new GtkLabel(Writer::i18n('Name:')), 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(1, 0.5);
-		$table->attach(new GtkEntry($this->character->name), 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
-		$table->attach($label =new GtkLabel(Writer::i18n('Created:')), 0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(1, 0.5);
-		$table->attach($label =new GtkLabel($this->character->date_created), 1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(0, 0.5);
-		$table->attach($label =new GtkLabel(Writer::i18n('Edited:')), 0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(1, 0.5);
-		$table->attach($label =new GtkLabel($this->character->date_edited), 1, 2, 3, 4, Gtk::FILL, Gtk::SHRINK);
-		$label->set_alignment(0, 0.5);
-		$meta = CharacterDao::listMeta();
-		print_r($meta);
-		// meta data
-		
+		//$table->attach($label = new GtkLabel(Writer::i18n('Id:')), 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(1, 0.5);
+		//$table->attach($label = new GtkLabel($this->character->id), 1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(0, 0.5);
+		//$table->attach($label =new GtkLabel(Writer::i18n('Name:')), 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(1, 0.5);
+		//$table->attach(new GtkEntry($this->character->name), 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
+		//$table->attach($label =new GtkLabel(Writer::i18n('Created:')), 0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(1, 0.5);
+		//$table->attach($label =new GtkLabel($this->character->date_created), 1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(0, 0.5);
+		//$table->attach($label =new GtkLabel(Writer::i18n('Edited:')), 0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(1, 0.5);
+		//$table->attach($label =new GtkLabel($this->character->date_edited), 1, 2, 3, 4, Gtk::FILL, Gtk::SHRINK);
+		//$label->set_alignment(0, 0.5);
 
-		$this->connect_simple('delete-event', array($this, 'onDeleteEvent'));
-		$this->show_all();
+		unset($port, $table, $this, $frame, $scroll);
 		return;
 
-		//create statusbar
-		$vbox = new GtkVBox();
 
-		$vbox->pack_start($this->toolbar, FALSE, FALSE);
 
-		$scroll = new GtkScrolledWindow();
-		$scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-		$scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-		$scroll->add($this->treeview);
-		$vbox->pack_start($scroll);
 
-		$this->add($vbox);
-		$this->treeview->grab_focus();
+		$meta = CharacterDao::listMeta();
+		print_r($meta);
+		return;
+	}
 
-		$this->show_all();
-		unset($vbox, $config, $height, $width);
+	/**
+	 * public function parent
+	 *
+	 * if this is not the top window and has a parent, we link destroy to hide
+	 *
+	 * @param object instanceof GtkWindow $parent GtkWindow object parent
+	 * @return void
+	 */
+	public function parent()
+	{
+		$this->set_transient_for(Writer::$window->characters);
+		$this->connect_simple('delete-event', array($this, 'onClose'));
+		Writer::$window->connect_simple('destroy', array($this, 'onDeleteEvent'));
+		unset($this);
 		return;
 	}
 
 	/**
-	 * public function onDeleteEvent
+	 * public function getData
 	 *
-	 * callback when window is destroyed
+	 * if this is not the top window and has a parent, we link destroy to hide
 	 *
+	 * @param object instanceof GtkWindow $parent GtkWindow object parent
+	 * @return void
+	 */
+	public function getData($id)
+	{
+		// retrieve row from db
+		$row = new CharacterDao($id);
+		$this->set_title($row->name, Writer::i18n('Edit Character'));
+		return;
+	}
+
+	/**
+	 * public function removeTimeout
+	 *
+	 * description
+	 *
 	 * @param type $name about
 	 * @return type about
 	 */
-	public function onDeleteEvent()
+	public function onClose()
 	{
-		// write configuration settings for window
-		$config = Config::instance();
-		list($height, $width) = $this->get_size();
-		$config->character_edit_height = $height;
-		$config->character_edit_width = $width;
-		list($x, $y) = $this->get_position();
-		$config->character_edit_x = $x;
-		$config->character_edit_y = $y;
-		unset($config, $height, $width, $x, $y);
-		$this->destroy();
-		return;
+		$this->hide_all();
+		return TRUE;
 	}
 }
 ?>
\ No newline at end of file

Modified: desktop/trunk/Writer/lib/character/window.class.php (27 => 28)


--- desktop/trunk/Writer/lib/character/window.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/character/window.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -70,6 +70,12 @@
 	protected $timeout;
 
 	/**
+	 * character edit window
+	 * @var $editwindow object instanceof Window
+	 */
+	protected $editwindow;
+
+	/**
 	 * public function __construct
 	 *
 	 * description
@@ -92,6 +98,8 @@
 		$this->date = isset($config->date) ? (string) $config->date : 'Y-m-d H:i:s';
 		$this->timeout = isset($config->timeout) ? (int) $config->timeout : 60000;
 		unset($this, $config);
+
+		$this->editwindow = new CharacterEdit();
 		file_put_contents('C:\work\writer\\' .__CLASS__ . '.' . __FUNCTION__ . '.txt', print_r(get_defined_vars(), TRUE));
 	}
 
@@ -125,7 +133,10 @@
 			$col->set_sort_column_id($id);
 			$treeview->append_column($col);
 		}
-		$treeview->set_model($this->buildModel());
+		$model = $this->buildModel();
+		$model->set_default_sort_func(array($this, 'defaultSort'));
+		$treeview->set_model($model);
+		$treeview->set_search_column(1);
 		$selection = $treeview->get_selection();
 		$selection->set_mode(Gtk::SELECTION_BROWSE);
 		$first = $treeview->get_model()->get_iter_first();
@@ -134,7 +145,37 @@
 			$selection->select_iter($first);
 		}
 		$selection->connect('changed', array($this, 'onSelectionChanged'));
-		unset($cols, $name, $id, $render, $col, $selection, $this, $treeview, $first);
+
+		// Popup menu
+		$menu = $treeview->menu = new GtkMenu();
+		$group = $this->actions['file'];
+		$tooltips = Tooltips::instance();
+
+		$action = $group->get_action('open');
+		$item = $action->create_menu_item();
+		$tooltips->set_tip($item, $action->get_property('tooltip'));
+		$menu->append($item);
+
+		$action = $group->get_action('delete');
+		$item = $action->create_menu_item();
+		$tooltips->set_tip($item, $action->get_property('tooltip'));
+		$menu->append($item);
+
+		$action = $group->get_action('undelete');
+		$item = $action->create_menu_item();
+		$tooltips->set_tip($item, $action->get_property('tooltip'));
+		$menu->append($item);
+
+		$menu->show_all();
+
+		$treeview->set_events($treeview->get_events() | Gdk::BUTTON_PRESS_MASK);
+		$treeview->connect('button-press-event', array($this, 'doPopup'), $menu);
+
+		// double click on open
+		$treeview->connect('row-activated', array($this, 'onOpen'));
+
+		unset($cols, $name, $id, $render, $col, $selection, $this, $treeview, $first,
+			$menu, $item, $action, $group);
 		return;
 	}
 
@@ -363,6 +404,7 @@
 		$error->set_use_markup(TRUE);
 		$dialog->vbox->set_border_width(10);
 		$dialog->show_all();
+		$error->hide();
 		// evil naughty bad loop will run forever
 		while(1)
 		{
@@ -373,10 +415,12 @@
 				if(empty($name))
 				{
 					$error->set_label(Writer::i18n('<span color="#CC0000">Character name cannot be empty</span>'));
+					$error->show();
 				}
 				elseif($this->checkName($name) == TRUE)
 				{
 					$error->set_label(Writer::i18n('<span color="#CC0000">Character name must be unique</span>'));
+					$error->show();
 				}
 				else
 				{
@@ -693,5 +737,56 @@
 		}
 		return FALSE;
 	}
+
+	/**
+	 * public function onCharacters
+	 *
+	 * description
+	 *
+	 * @param type $name about
+	 * @return type about
+	 */
+	public function onOpen()
+	{
+		$selection = $this->treeview->get_selection();
+		list($model, $iter) = $selection->get_selected();
+		if(is_null($iter))
+		{
+			unset($model, $iter, $selection);
+			return;
+		}
+		$this->editwindow->getData($model->get_value($iter, 0));
+		unset($row, $model, $iter, $selection);
+		$this->editwindow->show_all();
+		unset($this);
+		return;
+	}
+
+	/**
+	 * public function defaultSort
+	 *
+	 * description
+	 *
+	 * @param type $name about
+	 * @return type about
+	 */
+	public function defaultSort($model, $iter1, $iter2)
+	{
+		$iter1 = $model->get_value($iter1, 3);
+		$iter2 = $model->get_value($iter2, 3);
+		unset($model);
+		if($iter1 > $iter2)
+		{
+			return 1;
+		}
+		elseif($iter1 < $iter2)
+		{
+			return -1;
+		}
+		else
+		{
+			return 0;
+		}
+	}
 }
 ?>
\ No newline at end of file

Modified: desktop/trunk/Writer/lib/config.class.php (27 => 28)


--- desktop/trunk/Writer/lib/config.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/config.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -27,18 +27,6 @@
 class Config
 {
 	/**
-	 * singleton instance for this class
-	 * @var $singleton instanceof Characters
-	 */
-	static protected $singleton;
-
-	/**
-	 * switches on to allow construct to occur
-	 * @var $check bool
-	 */
-	static protected $check = FALSE;
-
-	/**
 	 * multi-dim array of current configuration information
 	 * @var $data array
 	 */
@@ -53,14 +41,6 @@
 	 */
 	public function __construct()
 	{
-		if(self::$check == FALSE)
-		{
-			throw new Exception(Writer::i18n(
-			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
-			'Config'));
-		}
-		self::$singleton = $this;
-
 		if(file_exists(Writer::appdata() . 'config.ini'))
 		{
 			$this->data = parse_ini_file(Writer::appdata() . 'config.ini');
@@ -74,46 +54,13 @@
 	}
 
 	/**
-	 * public function safeSerialize
+	 * public function __get
 	 *
-	 * regular serialize adds semicolons which breaks this
-	 * this only does assoc arrays for now
+	 * gets item from data store
 	 *
-	 * @param array $array
-	 * @return string
+	 * @param string $name
+	 * @return mixed
 	 */
-	public function safeSerialize(array $array)
-	{
-		$string = array();
-		foreach($array as $name => $value)
-		{
-			$string[] = $name . ':' . $value;
-		}
-		unset($array, $name, $value);
-		return implode('#', $string);
-	}
-
-	/**
-	 * public function safeUnSerialize
-	 *
-	 * undoes safe serialize
-	 *
-	 * @param string $string
-	 * @return array
-	 */
-	public function safeUnSerialize($string)
-	{
-		$array = array();
-		$string = explode('#', $string);
-		foreach($string as $item)
-		{
-			$item = explode(':', $item, 2);
-			$array[$item[0]] = $item[1];
-		}
-		unset($string, $item);
-		return $array;
-	}
-
 	protected function __get($name)
 	{
 		if(isset($this->data[$name]))
@@ -123,25 +70,50 @@
 		return;
 	}
 
+	/**
+	 * public function __isset
+	 *
+	 * checks if item is set in data store
+	 *
+	 * @param string $name
+	 * @return mixed
+	 */
 	protected function __isset($name)
 	{
 		return isset($this->data[$name]);
 	}
 
+	/**
+	 * public function __set
+	 *
+	 * sets an item in the data store and writes out the file
+	 *
+	 * @param string $name
+	 * @param mixed $value
+	 * @return void
+	 */
 	protected function __set($name, $value)
 	{
 		$this->data[$name] = $value;
 		$this->writeFile();
 		unset($name, $value);
-		return TRUE;
+		return;
 	}
 
+	/**
+	 * public function __unset
+	 *
+	 * removes item from the data store and writes out the file
+	 *
+	 * @param string $name
+	 * @return void
+	 */
 	protected function __unset($name)
 	{
 		unset($this->data[$name]);
 		$this->writeFile();
 		unset($name);
-		return TRUE;
+		return;
 	}
 
 	protected function writeFile()
@@ -173,36 +145,5 @@
 		unset($string, $subvalue, $key, $value);
 		return;
 	}
-
-	/**
-	 * public function __clone()
-	 *
-	 * disable cloning of a singleton
-	 *
-	 * @return void
-	 */
-	public function __clone()
-	{
-		throw new Exception(Writer::i18n('Cannot clone singleton object %s', 'Config'));
-		return;
-	}
-
-	/**
-	 * static public function instance
-	 *
-	 * this is how you "construct" a Config object
-	 *
-	 * @return object instanceof Config
-	 */
-	static public function instance()
-	{
-		if(is_null(self::$singleton))
-		{
-			self::$check = TRUE;
-			self::$singleton = new Config();
-			self::$check = FALSE;
-		}
-		return self::$singleton;
-	}
 }
 ?>
\ No newline at end of file

Deleted: desktop/trunk/Writer/lib/db.class.php (27 => 28)


--- desktop/trunk/Writer/lib/db.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/db.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -1,185 +0,0 @@
-<?php
-/**
- * db.class.php - wrapper for pdo and sqlite to manage open project
- *
- * extends pdo class, forces singleton instance
- *
- * This is released under the GPL, see license.txt for details
- *
- * @author       Elizabeth Smith <emsmith@callicore.net>
- * @copyright    Elizabeth Smith (c)2006
- * @link         http://callicore.net/writer
- * @license      http://www.opensource.org/licenses/gpl-license.php GPL
- * @version      $Id$
- * @since        Php 5.2.0
- * @package      callicore
- * @subpackage   writer
- * @category     lib
- * @filesource
- */
-
-/**
- * Db - pdo wrapper class for easy pdo management
- *
- * forces pdo as a singleton
- */
-class Db extends PDO
-{
-	/**
-	 * singleton instance for this class
-	 * @var $singleton instanceof Db
-	 */
-	static protected $singleton;
-
-	/**
-	 * switches on to allow construct to occur
-	 * @var $check bool
-	 */
-	static protected $check = FALSE;
-
-	/**
-	 * sql definition
-	 * @var $sql string
-	 */
-	protected $sql =
-'CREATE TABLE "character" (
-  "id" INTEGER PRIMARY KEY,
-  "name" TEXT UNIQUE,
-  "order" INTEGER,
-  "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  "date_edited" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
-CREATE TABLE "character_meta" (
-  "id" INTEGER PRIMARY KEY,
-  "name" TEXT UNIQUE,
-  "display" TEXT,
-  "default" TEXT,
-  "order" INTEGER,
-  "character_meta_type_id_fk" INTEGER NOT NULL DEFAULT 0,
-  "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  "date_edited" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
-CREATE TABLE "character_meta_type" (
-  "id" INTEGER PRIMARY KEY,
-  "name" TEXT UNIQUE,
-  "list" TEXT
-);
-
-INSERT INTO "character_meta_type"("name", "list") VALUES (\'entry\', \'TEXT\');
-INSERT INTO "character_meta_type"("name", "list") VALUES (\'text\', NULL);
-INSERT INTO "character_meta_type"("name", "list") VALUES (\'toggle\', \'TOGGLE\');
-INSERT INTO "character_meta_type"("name", "list") VALUES (\'choice\', NULL);
-INSERT INTO "character_meta_type"("name", "list") VALUES (\'image\', \'PIXBUF\');
-
-CREATE TABLE "character_meta_option" (
-  "id" INTEGER PRIMARY KEY,
-  "name" TEXT UNIQUE,
-  "display" TEXT,
-  "value" TEXT,
-  "character_meta_id_fk" INTEGER NOT NULL DEFAULT 0
-);
-
-CREATE TABLE "character_has_character_meta" (
-  "id" INTEGER PRIMARY KEY,
-  "value" TEXT,
-  "character_id_fk" INTEGER NOT NULL DEFAULT 0,
-  "character_meta_id_fk" INTEGER NOT NULL DEFAULT 0,
-  "character_meta_option_id_fk" INTEGER
-);
-
-INSERT INTO "character"("name", "order") VALUES (\'NONE\', 1);
-';
-
-	/**
-	 * public function __construct
-	 *
-	 * constructor will throw an exception if a class already exists - use
-	 * instance to create the class
-	 *
-	 * @param string $file file to open
-	 * @return void
-	 */
-	public function __construct($file)
-	{
-		if(self::$check == FALSE)
-		{
-			throw new Exception(Writer::i18n(
-			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
-			'Db'));
-		}
-		self::$singleton = $this;
-
-		$new = file_exists($file) ? FALSE : TRUE;
-		parent::__construct('sqlite:' . $file);
-		$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-		if($new == TRUE)
-		{
-			$this->beginTransaction();
-			try
-			{
-				$create = $this->exec($this->sql);
-			}
-			catch(PDOException $e)
-			{
-				$this->rollback();
-				$info = $this->errorInfo();
-				unset($file, $new, $e);
-				throw new Exception(Writer::i18n('Creating character storage failed: "%s"', $info[2]));
-			}
-			$this->commit();
-		}
-		unset($file, $new);
-		return;
-	}
-
-	/**
-	 * public function identify
-	 *
-	 * quote identifier
-	 *
-	 * @param string $string string to quote
-	 * @return string
-	 */
-	public function identify($string)
-	{
-		return '"' . $string . '"';
-	}
-
-	/**
-	 * public function __clone()
-	 *
-	 * disable cloning of a singleton
-	 *
-	 * @return void
-	 */
-	public function __clone()
-	{
-		throw new Exception(Writer::i18n('Cannot clone singleton object %s', 'Db'));
-		return;
-	}
-
-	/**
-	 * static public function instance
-	 *
-	 * this is how you "construct" a Db object
-	 *
-	 * @return object instanceof Db
-	 */
-	static public function instance($file = NULL)
-	{
-		if(is_null(self::$singleton) && !is_null($file))
-		{
-			self::$check = TRUE;
-			self::$singleton = new Db($file);
-			self::$check = FALSE;
-		}
-		elseif(is_null(self::$singleton))
-		{
-			throw new Exception(Writer::i18n('There is no currently open project'));
-		}
-		return self::$singleton;
-	}
-}
-?>
\ No newline at end of file

Modified: desktop/trunk/Writer/lib/message.class.php (27 => 28)


--- desktop/trunk/Writer/lib/message.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/message.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -24,6 +24,8 @@
  *
  * wrapper class for any errors with handlers, can also be used
  * for generic messages
+ *
+ * TODO: add expander with treeview of trace information
  */
 class Message extends GtkMessageDialog
 {
@@ -76,7 +78,7 @@
 
 		parent::__construct(NULL, 0, $type, Gtk::BUTTONS_CLOSE);
 		$this->set_position(Gtk::WIN_POS_CENTER);
-		$this->set_title(Writer::i18n('Writer :: ' . $title));
+		$this->set_title(Writer::i18n('%s : %s', 'Writer', $title));
 		if(is_array($message))
 		{
 			$this->set_markup(Writer::i18n(array_shift($message), $message));

Modified: desktop/trunk/Writer/lib/project/window.class.php (27 => 28)


--- desktop/trunk/Writer/lib/project/window.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/project/window.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -1,10 +1,9 @@
 <?php
 /**
- * window.class.php - character window main class
+ * window.class.php - project window main class
  *
- * parent window for all character related adminitration tasks such as listing,
- * creating, deleting, editing characters and manipulating meta-data for
- * characters as well as importing, exporting, printing and saving characters
+ * main window for the application, opens up last used project or creates a new
+ * blank project if no "last" is available to use
  *
  * This is released under the GPL, see license.txt for details
  *
@@ -23,16 +22,10 @@
 /**
  * ProjectWindow - character window - list view looks a lot like main window
  *
- * Has menu bar and tool bar specific to characters and character listing with
- * drag and drop and reorderable functionality
+ * Main project window, holds project object
  */
 class ProjectWindow extends Window
 {
-	/**
-	 * about
-	 * @var $characters type
-	 */
-	public $characters;
 
 	/**
 	 * public function __construct
@@ -46,10 +39,10 @@
 
 		parent::__construct();
 
-		Db::instance('test.cwp');
-		$this->set_title('Test');
+		//Db::instance('test.cwp');
+		//$this->set_title('Test');
 
-		$this->characters = new CharacterWindow();
+		//$this->characters = new CharacterWindow();
 
 		// remove when character testing is done
 		//$this->connect_simple('show', array($this->characters, 'show_all'));
@@ -57,193 +50,5 @@
 		$this->connect_simple('destroy', array('Gtk', 'main_quit'));
 		return;
 	}
-
-	/**
-	 * public function buildMenu
-	 *
-	 * description
-	 *
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function buildMenu()
-	{
-		$menu = $this->menu = new GtkMenuBar();
-		$tooltips = Tooltips::instance();
-		$config = Config::instance();
-		$name = $this->name;
-
-		$group = $this->actions['file'];
-		$item = new GtkMenuItem(Writer::i18n('_File'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$action = $group->get_action('new');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('open');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('close');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('delete');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('undelete');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$action = $group->get_action('save');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('saveas');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('revert');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('print');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$item = new GtkMenuItem(Writer::i18n('Recent'));
-		$submenu->append($item);
-		$subitem = new GtkMenu();
-		$item->set_submenu($subitem);
-
-		$list = $config->{$name . '_recent'} ? $config->{$name . '_recent'} : array();
-		foreach($list as $id => $file)
-		{
-			if(!file_exists($file))
-			{
-				unset($list[$id]);
-				continue;
-			}
-			$child = new GtkMenuItem(basename($file));
-			$subitem->append($child);
-			$tooltips->set_tip($child, $file);
-			$child->connect_simple('activate', array($this, 'onOpen'), $file);
-		}
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$action = $group->get_action('quit');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$group = $this->actions['manage'];
-		$item = new GtkMenuItem(Writer::i18n('_Manage'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$action = $group->get_action('wizard');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('import');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('export');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('properties');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$group = $this->actions['tools'];
-		$item = new GtkMenuItem(Writer::i18n('_Tools'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$action = $this->actions['toolbar']->get_action('toggle');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$action = $group->get_action('characters');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('settings');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('editing');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('publishing');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('notes');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$action = $group->get_action('preferences');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $this->actions['toolbar']->get_action('customize');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		parent::buildMenu();
-	}
-
-	/**
-	 * public function onCharacters
-	 *
-	 * description
-	 *
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function onCharacters()
-	{
-		$this->characters->show_all();
-	}
 }
 ?>
\ No newline at end of file

Copied: desktop/trunk/Writer/lib/project.class.php (from rev 27, desktop/trunk/Writer/lib/db.class.php) (27 => 28)


--- desktop/trunk/Writer/lib/db.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/project.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -0,0 +1,138 @@
+<?php
+/**
+ * db.class.php - wrapper for pdo and sqlite to manage open project
+ *
+ * extends pdo class, forces singleton instance
+ *
+ * This is released under the GPL, see license.txt for details
+ *
+ * @author       Elizabeth Smith <emsmith@callicore.net>
+ * @copyright    Elizabeth Smith (c)2006
+ * @link         http://callicore.net/writer
+ * @license      http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version      $Id$
+ * @since        Php 5.2.0
+ * @package      callicore
+ * @subpackage   writer
+ * @category     lib
+ * @filesource
+ */
+
+/**
+ * Db - pdo wrapper class for easy pdo management
+ *
+ * forces pdo as a singleton
+ */
+class Db extends PDO
+{
+	/**
+	 * sql definition
+	 * @var $sql string
+	 */
+	protected $sql =
+'CREATE TABLE "character" (
+  "id" INTEGER PRIMARY KEY,
+  "name" TEXT UNIQUE,
+  "order" INTEGER,
+  "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  "date_edited" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE TABLE "character_meta" (
+  "id" INTEGER PRIMARY KEY,
+  "name" TEXT UNIQUE,
+  "display" TEXT,
+  "default" TEXT,
+  "order" INTEGER,
+  "character_meta_type_id_fk" INTEGER NOT NULL DEFAULT 0,
+  "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+  "date_edited" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE TABLE "character_meta_type" (
+  "id" INTEGER PRIMARY KEY,
+  "name" TEXT UNIQUE,
+  "list" TEXT
+);
+
+INSERT INTO "character_meta_type"("name", "list") VALUES (\'entry\', \'TEXT\');
+INSERT INTO "character_meta_type"("name", "list") VALUES (\'text\', NULL);
+INSERT INTO "character_meta_type"("name", "list") VALUES (\'toggle\', \'TOGGLE\');
+INSERT INTO "character_meta_type"("name", "list") VALUES (\'choice\', NULL);
+INSERT INTO "character_meta_type"("name", "list") VALUES (\'image\', \'PIXBUF\');
+
+CREATE TABLE "character_meta_option" (
+  "id" INTEGER PRIMARY KEY,
+  "name" TEXT UNIQUE,
+  "display" TEXT,
+  "value" TEXT,
+  "character_meta_id_fk" INTEGER NOT NULL DEFAULT 0
+);
+
+CREATE TABLE "character_has_character_meta" (
+  "id" INTEGER PRIMARY KEY,
+  "value" TEXT,
+  "character_id_fk" INTEGER NOT NULL DEFAULT 0,
+  "character_meta_id_fk" INTEGER NOT NULL DEFAULT 0,
+  "character_meta_option_id_fk" INTEGER
+);
+
+INSERT INTO "character"("name", "order") VALUES (\'NONE\', 1);
+';
+
+	/**
+	 * public function __construct
+	 *
+	 * constructor will throw an exception if a class already exists - use
+	 * instance to create the class
+	 *
+	 * @param string $file file to open
+	 * @return void
+	 */
+	public function __construct($file)
+	{
+		if(self::$check == FALSE)
+		{
+			throw new Exception(Writer::i18n(
+			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
+			'Db'));
+		}
+		self::$singleton = $this;
+
+		$new = file_exists($file) ? FALSE : TRUE;
+		parent::__construct('sqlite:' . $file);
+		$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+		if($new == TRUE)
+		{
+			$this->beginTransaction();
+			try
+			{
+				$create = $this->exec($this->sql);
+			}
+			catch(PDOException $e)
+			{
+				$this->rollback();
+				$info = $this->errorInfo();
+				unset($file, $new, $e);
+				throw new Exception(Writer::i18n('Creating character storage failed: "%s"', $info[2]));
+			}
+			$this->commit();
+		}
+		unset($file, $new);
+		return;
+	}
+
+	/**
+	 * public function identify
+	 *
+	 * quote identifier
+	 *
+	 * @param string $string string to quote
+	 * @return string
+	 */
+	public function identify($string)
+	{
+		return '"' . $string . '"';
+	}
+}
+?>
\ No newline at end of file

Modified: desktop/trunk/Writer/lib/splash.class.php (27 => 28)


--- desktop/trunk/Writer/lib/splash.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/splash.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -34,10 +34,10 @@
 	protected $progressbar;
 
 	/**
-	 * total startup steps - useful for incrementing progressbar
+	 * total startup steps - needed for incrementing progressbar
 	 * @var $steps int
 	 */
-	protected $steps = 6;
+	protected $steps;
 
 	/**
 	 * public function __construct
@@ -47,13 +47,14 @@
 	 *
 	 * @return void
 	 */
-	public function __construct()
+	public function __construct($steps)
 	{
 
+		$this->steps = (int) $steps;
 		// Window Features
 		parent::__construct();
 		$this->set_position(Gtk::WIN_POS_CENTER);
-		$this->set_title(_('Writer :: Loading'));
+		$this->set_title(Writer::i18n('%s :: %s', 'Writer', 'Loading'));
 		$this->set_resizable(FALSE);
 		$this->set_decorated(FALSE);
 		$this->set_skip_taskbar_hint(TRUE);

Modified: desktop/trunk/Writer/lib/tooltips.class.php (27 => 28)


--- desktop/trunk/Writer/lib/tooltips.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/tooltips.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -2,7 +2,7 @@
 /**
  * tooltips.class.php - wrapper for gtktooltips
  *
- * handles forcing a tooltip singleton
+ * fixes tooltips for toolbar
  *
  * This is released under the GPL, see license.txt for details
  *
@@ -21,44 +21,22 @@
 /**
  * Tooltips - tooltips wrapper
  *
- * fixes the weirdness of toolbar tooltips, and forces a tooltip singleton
+ * fixes the weirdness of toolbar tooltips
  */
 class Tooltips extends GtkTooltips
 {
 
 	/**
-	 * singleton instance for this class
-	 * @var $singleton instanceof Tooltips
-	 */
-	static protected $singleton;
-
-	/**
-	 * switches on to allow construct to occur
-	 * @var $check bool
-	 */
-	static protected $check = FALSE;
-
-	/**
 	 * public function __construct
 	 *
-	 * registers two new icon sizes, parses the hicolor override rc file and the
-	 * application specific rc file, also sets default window icon
+	 * sets delay and enables tooltips
 	 *
 	 * @return void
 	 */
 	public function __construct()
 	{
-		if(self::$check == FALSE)
-		{
-			throw new Exception(Writer::i18n(
-			'%1$s is a singleton class - use %1$s::instance() to retrieve the current object',
-			'Tooltips'));
-		}
-		self::$singleton = $this;
 
 		parent::__construct();
-		self::$singleton = $this;
-		$this->set_delay(100);
 		$this->enable();
 		return;
 	}
@@ -66,55 +44,23 @@
 	/**
 	 * public function set_tip
 	 *
-	 * overrides original function and does gettext, also
-	 * fixes tooltips for GtkToolItem stuff
+	 * overrides original function for GtkToolItem fix
 	 *
 	 * @param object $wiget instanceof GtkObject
 	 * @return void
 	 */
-	public function set_tip($widget, $tooltip)
+	public function set_tip($widget, $tooltip, $help = NULL)
 	{
 		if($widget instanceof GtkToolItem)
 		{
-			$widget->set_tooltip($this, $tooltip);
+			$widget->set_tooltip($this, $tooltip, $help);
 		}
 		else
 		{
-			parent::set_tip($widget, $tooltip);
+			parent::set_tip($widget, $tooltip, $help);
 		}
-		unset($widget, $tooltip);
+		unset($widget, $tooltip, $help);
 		return;
 	}
-
-	/**
-	 * static public function instance
-	 *
-	 * this is how you "construct" a Tooltips object
-	 *
-	 * @return object instanceof Tooltips
-	 */
-	static public function instance()
-	{
-		if(is_null(self::$singleton))
-		{
-			self::$check = TRUE;
-			self::$singleton = new Tooltips();
-			self::$check = FALSE;
-		}
-		return self::$singleton;
-	}
-
-	/**
-	 * public function __clone()
-	 *
-	 * disable cloning of a singleton
-	 *
-	 * @return void
-	 */
-	public function __clone()
-	{
-		throw new Exception(Writer::i18n('Cannot clone singleton object %s', 'Tooltips'));
-		return;
-	}
 }
 ?>
\ No newline at end of file

Modified: desktop/trunk/Writer/lib/window.class.php (27 => 28)


--- desktop/trunk/Writer/lib/window.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/window.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -2,7 +2,8 @@
 /**
  * window.class.php - window abstract class
  *
- * extend this to get basic window functionality that is 
+ * writer general purpose window code, handles menubar, toolbar and statusbar
+ * setup as well as general actions and other items
  *
  * This is released under the GPL, see license.txt for details
  *
@@ -27,53 +28,17 @@
 {
 
 	/**
-	 * array of gtk action groups
-	 * @var $actions type
+	 * main vbox for window
+	 * @var $vbox object instanceof GtkVBox
 	 */
-	public $actions = array();
+	public $vbox;
 
 	/**
-	 * main menu for the window
-	 * @var $menu object instanceof GtkMenu
-	 */
-	public $menu;
-
-	/**
-	 * main toolbar for the window
-	 * @var $toolbar object instanceof GtkToolbar
-	 */
-	public $toolbar;
-
-	/**
 	 * status bar for window
 	 * @var $statusbar object instanceof GtkStatusBar
 	 */
 	public $statusbar;
 
-	/**
-	 * array of all actions available to put on a toolbar
-	 * @var $toolbuttons 
-	 */
-	protected $toolbuttons = array(
-		'separator', 'new', 'open', 'close', 'delete', 'undelete', 'save', 'saveas',
-		'revert', 'print', 'quit', 'wizard', 'import', 'export', 'properties',
-		'characters', 'settings', 'editing', 'publishing', 'notes',
-		'preferences','help', 'website', 'about',);
-
-	/**
-	 * array of items for the current toolbar
-	 * @var $toolcurrent array
-	 */
-	protected $toolcurrent = array();
-
-	/**
-	 * default items for window
-	 * @var $tooldefault array
-	 */
-	protected $tooldefault = array('new', 'delete', 'save', 'separator', 'import',
-		'export', 'separator', 'print', 'properties');
-
-
 	//----------------------------------------------------------------
 	//             Overrides
 	//----------------------------------------------------------------
@@ -90,11 +55,11 @@
 
 		parent::__construct();
 
-		$this->set_name(strtolower(get_class($this)));
+		$config = Writer::$config;
 
-		$config = Config::instance();
-
+		$this->set_name(strtolower(get_class($this)));
 		$name = $this->name;
+
 		// default size and location
 		$width = isset($config->{$name . '_height'}) ? (int) $config->{$name . '_height'} : 800;
 		$height = isset($config->{$name . '_width'}) ? (int) $config->{$name . '_width'} : 600;
@@ -107,14 +72,14 @@
 			$this->move($x, $y);
 		}
 
-		$this->buildActions();
-		$this->buildMenu();
-		$this->buildToolbar();
+		//$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_start($this->menu, 0, 0);
+		//$vbox->pack_start($this->toolbar, 0, 0);
 		$vbox->pack_end($this->statusbar, 0, 0);
 		$this->add($vbox);
 
@@ -130,9 +95,12 @@
 	 * @param string $name title to set
 	 * @return void
 	 */
-	public function set_title($title)
+	public function set_title($title, $class = NULL)
 	{
-		$class = ucfirst(str_replace('window', '', $this->name));
+		if(is_null($class))
+		{
+			$class = ucfirst(str_replace('window', '', $this->name));
+		}
 		parent::set_title(Writer::i18n('%s :: %s :: %s', 'Writer', $class, $title));
 		unset($title, $class);
 		return;
@@ -143,387 +111,6 @@
 	//----------------------------------------------------------------
 
 	/**
-	 * protected function buildActions
-	 *
-	 * creates all actions for the window
-	 *
-	 * @todo add additional generic actions
-	 * @return void
-	 */
-	protected function buildActions($name = '')
-	{
-		$acc = new GtkAccelGroup();
-		$this->add_accel_group($acc);
-
-		// file related actions
-		$group = $this->actions['file'] = new GtkActionGroup('file');
-
-		$action = new GtkAction('new', Writer::i18n('_New...'), Writer::i18n('Create new blank %s', $name),
-			'gtk-new');
-		$action->connect('activate', array($this, 'onNew'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, '<Ctrl>n');
-
-		$action = new GtkAction('open', Writer::i18n('_Open...'), Writer::i18n('Open existing %s', $name),
-			'gtk-open');
-		$action->connect('activate', array($this, 'onOpen'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, '<Ctrl>o');
-
-		$action = new GtkAction('close', Writer::i18n('_Close'), Writer::i18n('Close current %s', $name),
-			'gtk-close');
-		$action->connect('activate', array($this, 'onClose'));
-		$group->add_action($action);
-
-		$action = new GtkAction('delete', Writer::i18n('_Delete'), Writer::i18n('Delete current %s', $name),
-			'gtk-delete');
-		$action->connect('activate', array($this, 'onDelete'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'Delete');
-
-		$action = new GtkAction('undelete', Writer::i18n('_Undelete'), Writer::i18n('Undelete current %s', $name),
-			'gtk-undelete');
-		$action->connect('activate', array($this, 'onUndelete'));
-		$group->add_action($action);
-
-		$action = new GtkAction('save', Writer::i18n('_Save'), Writer::i18n('Save %s', $name),
-			'gtk-save');
-		$action->connect('activate', array($this, 'onSave'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, '<Ctrl>s');
-
-		$action = new GtkAction('saveas', Writer::i18n('Save _As...'), Writer::i18n('Save %s under new name', $name),
-			'gtk-save-as');
-		$action->connect('activate', array($this, 'onSaveAs'));
-		$group->add_action($action);
-
-		$action = new GtkAction('revert', Writer::i18n('Re_vert'), Writer::i18n('Revert %s to last save', $name),
-			'revert');
-		$action->connect('activate', array($this, 'onRevert'));
-		$group->add_action($action);
-
-		$action = new GtkAction('print', Writer::i18n('_Print'), Writer::i18n('Print'),
-			'gtk-print');
-		$action->connect('activate', array($this, 'onPrint'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, '<Ctrl>p');
-
-		$action = new GtkAction('quit', Writer::i18n('_Quit'), Writer::i18n('Exit'),
-			'gtk-quit');
-		$action->connect('activate', array($this, 'onQuit'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, '<Ctrl>q');
-
-		// management related actions
-		$group = $this->actions['manage'] = new GtkActionGroup('manage');
-
-		$action = new GtkAction('wizard', Writer::i18n('_Wizard...'), Writer::i18n('Create %s using wizard', $name),
-			'wizard');
-		$action->connect('activate', array($this, 'onWizard'));
-		$group->add_action($action);
-
-		$action = new GtkAction('import', Writer::i18n('_Import...'), Writer::i18n('Import %s from another format', $name),
-			'gtk-convert');
-		$action->connect('activate', array($this, 'onImport'));
-		$group->add_action($action);
-
-		$action = new GtkAction('export', Writer::i18n('_Export...'), Writer::i18n('Export %s to another format', $name),
-			'save-all');
-		$action->connect('activate', array($this, 'onExport'));
-		$group->add_action($action);
-
-		$action = new GtkAction('properties', Writer::i18n('_Properties...'), Writer::i18n('View and edit %s properties', $name),
-			'gtk-execute');
-		$action->connect('activate', array($this, 'onProperties'));
-		$group->add_action($action);
-
-		// tools related actions
-		$group = $this->actions['tools'] = new GtkActionGroup('tools');
-
-		$action = new GtkAction('characters', Writer::i18n('_Characters...'), Writer::i18n('Characters management'),
-			'users');
-		$action->connect('activate', array($this, 'onCharacters'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'F2');
-
-		$action = new GtkAction('settings', Writer::i18n('_Settings...'), Writer::i18n('Settings management'),
-			'folder-home');
-		$action->connect('activate', array($this, 'onSettings'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'F3');
-
-		$action = new GtkAction('editing', Writer::i18n('_Editing...'), Writer::i18n('Editing projects'),
-			'editor');
-		$action->connect('activate', array($this, 'onEditing'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'F5');
-
-		$action = new GtkAction('publishing', Writer::i18n('_Publishing...'), Writer::i18n('Publishing projects'),
-			'ftp');
-		$action->connect('activate', array($this, 'onPublishing'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'F6');
-
-		$action = new GtkAction('notes', Writer::i18n('_Notes...'), Writer::i18n('Project notes'),
-			'notes');
-		$action->connect('activate', array($this, 'onNotes'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'F7');
-
-		$action = new GtkAction('preferences', Writer::i18n('_Preferences...'), Writer::i18n('Writer preferences'),
-			'gtk-preferences');
-		$action->connect('activate', array($this, 'onPreferences'));
-		$group->add_action($action);
-
-		// help related actions
-		$group = $this->actions['help'] = new GtkActionGroup('help');
-
-		$action = new GtkAction('help', Writer::i18n('_Help'), Writer::i18n('Help'),
-			'gtk-help');
-		$action->connect('activate', array($this, 'onHelp'));
-		$action->set_accel_group($acc);
-		$group->add_action_with_accel($action, 'F1');
-
-		$action = new GtkAction('website', Writer::i18n('_Website'), Writer::i18n('Visit writer website'),
-			'browser');
-		$action->connect('activate', array($this, 'onWebsite'));
-		$group->add_action($action);
-
-		$action = new GtkAction('about', Writer::i18n('_About'), Writer::i18n('About Writer'),
-			'gtk-about');
-		$action->connect('activate', array($this, 'onAbout'));
-		$group->add_action($action);
-
-		// toolbar related actions
-		$group = $this->actions['toolbar'] = new GtkActionGroup('toolbar');
-
-		$action = new GtkToggleAction('toggle', Writer::i18n('_Show Toolbar'),
-			Writer::i18n('Show and hide the toolbar'), NULL);
-		$config = Config::instance();
-		$state = isset($config->{$name . '_show_toolbar'}) ? (bool) $config->{$name . '_show_toolbar'} : TRUE;
-		$action->set_active($state);
-		$action->connect_simple('toggled', array($this, 'toggleToolbar'));
-		$group->add_action($action);
-
-		$radio = $action = new GtkRadioAction('small', Writer::i18n('_Small'),
-			Writer::i18n('Display small icons on the toolbar'), NULL, 1);
-		$action->connect_simple('toggled', array($this, 'sizeToolbar'), 'small');
-		$action->set_group($radio);
-		$group->add_action($action);
-
-		$action = new GtkRadioAction('medium', Writer::i18n('_Medium'),
-			Writer::i18n('Display medium icons on the toolbar'), NULL, 2);
-		$action->connect_simple('toggled', array($this, 'sizeToolbar'), 'medium');
-		$action->set_group($radio);
-		$group->add_action($action);
-
-		$action = new GtkRadioAction('large', Writer::i18n('_Large'),
-			Writer::i18n('Display large icons on the toolbar'), NULL, 3);
-		$action->connect_simple('toggled', array($this, 'sizeToolbar'), 'large');
-		$action->set_group($radio);
-		$group->add_action($action);
-
-		$radio = $action = new GtkRadioAction('icon', Writer::i18n('_Icons'),
-			Writer::i18n('Display only icons on the toolbar'), NULL, 1);
-		$action->connect_simple('toggled', array($this, 'styleToolbar'), 'icon');
-		$action->set_group($radio);
-		$group->add_action($action);
-
-		$action = new GtkRadioAction('text', Writer::i18n('_Text'),
-			Writer::i18n('Display only text on the toolbar'), NULL, 2);
-		$action->connect_simple('toggled', array($this, 'styleToolbar'), 'text');
-		$action->set_group($radio);
-		$group->add_action($action);
-
-		$action = new GtkRadioAction('both', Writer::i18n('_Both'),
-			Writer::i18n('Display icons and text on the toolbar'), NULL, 3);
-		$action->connect_simple('toggled', array($this, 'styleToolbar'), 'both');
-		$action->set_group($radio);
-		$group->add_action($action);
-
-		$action = new GtkAction('customize', '_Customize...', 'Customize toolbar',
-			'gtk-properties');
-		$action->connect('activate', array($this, 'onCustomize'));
-		$group->add_action($action);
-
-		unset($group, $action, $radio, $this, $state, $config, $name, $acc);
-		return;
-	}
-
-	/**
-	 * protected function buildMenu
-	 *
-	 * build a default menubar
-	 * file quit, view options
-	 *
-	 * @todo finish menu creation
-	 * @return void
-	 */
-	protected function buildMenu()
-	{
-
-		$this->menu = $menu = is_null($this->menu) ? new GtkMenuBar() : $this->menu;
-		$tooltips = Tooltips::instance();
-		$config = Config::instance();
-		$name = $this->name;
-
-		$group = $this->actions['help'];
-		$item = new GtkMenuItem(Writer::i18n('_Help'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$action = $group->get_action('help');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('website');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$submenu->append(new GtkSeparatorMenuItem());
-
-		$action = $group->get_action('about');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		unset($this, $menu, $action, $item, $tooltips, $config, $name, $group,
-			$submenu, $subitem, $child, $id, $file, $list);
-		return;
-	}
-
-	/**
-	 * protected function buildToolbar
-	 *
-	 * build toolbar
-	 *
-	 * @todo set up toolbar with chosen customization
-	 * @return void
-	 */
-	protected function buildToolbar()
-	{
-		$name = $this->name;
-		$config = Config::instance();
-		$tooltips = Tooltips::instance();
-
-		$toolbar = $this->toolbar = new GtkToolbar();
-		$size = isset($config->{$this->name . '_toolbar_size'}) ? (string) $config->{$this->name . '_toolbar_size'} : 'small';
-		$style = isset($config->{$name . '_toolbar_style'}) ? (string) $config->{$name . '_toolbar_style'} : 'icon';
-		$toolitems = $this->toolcurrent = isset($config->{$name . 'toolbar_items'}) ? $config->{$name . 'toolbar_items'} : $this->tooldefault;
-
-		// populate toolbar
-		foreach($toolitems as $name)
-		{
-			if($name === 'separator')
-			{
-				$toolbar->insert(new GtkSeparatorToolItem(), -1);
-			}
-			else
-			{
-				$action = $this->getAction($name);
-				if(!is_null($action))
-				{
-					$item = $action->create_tool_item();
-					$item->set_tooltip($tooltips, $action->get_property('tooltip'));
-					$toolbar->insert($item, -1);
-				}
-			}
-		}
-
-		// Popup menu
-		$menu = $toolbar->menu = new GtkMenu();
-		$group = $this->actions['toolbar'];
-
-		$action = $group->get_action('toggle');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$menu->append($item);
-
-		$item = new GtkMenuItem(Writer::i18n('Toolbar S_tyle'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$action = $group->get_action('icon');
-		$item = $action->create_menu_item();
-		if($style === 'icon')
-		{
-			$item->set_active(TRUE);
-		}
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('text');
-		$item = $action->create_menu_item();
-		if($style === 'text')
-		{
-			$item->set_active(TRUE);
-		}
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('both');
-		$item = $action->create_menu_item();
-		if($style === 'both')
-		{
-			$item->set_active(TRUE);
-		}
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$item = new GtkMenuItem(Writer::i18n('Toolbar Si_ze'));
-		$menu->add($item);
-		$submenu = new GtkMenu();
-		$item->set_submenu($submenu);
-
-		$action = $group->get_action('small');
-		$item = $action->create_menu_item();
-		if($size === 'small')
-		{
-			$item->set_active(TRUE);
-		}
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('medium');
-		$item = $action->create_menu_item();
-		if($size === 'medium')
-		{
-			$item->set_active(TRUE);
-		}
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$action = $group->get_action('large');
-		$item = $action->create_menu_item();
-		if($size === 'large')
-		{
-			$item->set_active(TRUE);
-		}
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$submenu->append($item);
-
-		$menu->append(new GtkSeparatorMenuItem());
-
-		$action = $group->get_action('customize');
-		$item = $action->create_menu_item();
-		$tooltips->set_tip($item, $action->get_property('tooltip'));
-		$menu->append($item);
-
-		$menu->show_all();
-
-		$toolbar->set_events($toolbar->get_events() | Gdk::BUTTON_PRESS_MASK);
-		$toolbar->connect('button-press-event', array($this, 'doPopup'), $menu);
-
-		unset($this, $menu, $toolbar, $submenu, $tooltips, $config, $name, $state,
-			$style, $size, $toolitems, $action, $group, $item);
-		return;
-	}
-
-	/**
 	 * protected function buildStatusbar
 	 *
 	 * build statusbar
@@ -536,7 +123,7 @@
 		$children = $status->get_children();
 		$status->label = $children[0]->child;
 		$status->label->set_padding(3, 0);
-		$status->label->set_label(Writer::i18n('<i>Ready</i>'));
+		$status->label->set_label(Writer::i18n('Ready'));
 		$status->label->set_use_markup(TRUE);
 		unset($status, $children);
 		return;
@@ -556,7 +143,7 @@
 	public function onDeleteEvent()
 	{
 		$name = $this->name;
-		$config = Config::instance();
+		$config = Writer::$config;
 
 		list($height, $width) = $this->get_size();
 		$config->{$name . '_height'} = $height;
@@ -570,584 +157,5 @@
 		$this->destroy();
 		return;
 	}
-
-	/**
-	 * public function toggleToolbar
-	 *
-	 * show-hide toolbar callback
-	 *
-	 * @return void
-	 */
-	public function toggleToolbar()
-	{
-		$state = !$this->toolbar->is_visible();
-		$this->toolbar->set_visible($state);
-		Config::instance()->{$this->name . '_show_toolbar'} = $state;
-		if(!is_null($this->statusbar))
-		{
-			$this->statusbar->label->set_label(Writer::i18n('<b>Toolbar visibility changed</b>'));
-		}
-		unset($state);
-		return;
-	}
-
-	/**
-	 * public function styleToolbar
-	 *
-	 * change toolbar display type
-	 *
-	 * @param string $style text|icon|both
-	 * @return void
-	 */
-	public function styleToolbar($style)
-	{
-		$config = Config::instance();
-		switch($style)
-		{
-			case 'both':
-			{
-				$config->{$this->name . '_toolbar_style'} = 'both';
-				$this->toolbar->set_style(Gtk::TOOLBAR_BOTH);
-				break;
-			}
-			case 'text':
-			{
-				$config->{$this->name . '_toolbar_style'} = 'text';
-				$this->toolbar->set_style(Gtk::TOOLBAR_TEXT);
-				break;
-			}
-			default:
-			{
-				$config->{$this->name . '_toolbar_style'} = 'icon';
-				$this->toolbar->set_style(Gtk::TOOLBAR_ICONS);
-			}
-		}
-		if(!is_null($this->statusbar))
-		{
-			$this->statusbar->label->set_label(Writer::i18n('<b>Toolbar style changed</b>'));
-		}
-		unset($config, $style);
-		return;
-	}
-
-	/**
-	 * public function sizeToolbar
-	 *
-	 * change toolbar icon display size
-	 *
-	 * @param int $size icon size to change toolbar to
-	 * @return void
-	 */
-	public function sizeToolbar($size)
-	{
-		$config = Config::instance();
-		switch($size)
-		{
-			case 'large':
-			{
-				$config->{$this->name . '_toolbar_size'} = 'large';
-				$this->toolbar->set_icon_size(Writer::$DND);
-				break;
-			}
-			case 'medium':
-			{
-				$config->{$this->name . '_toolbar_size'} = 'medium';
-				$this->toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
-				break;
-			}
-			default:
-			{
-				$config->{$this->name . '_toolbar_size'} = 'small';
-				$this->toolbar->set_icon_size(Writer::$BUTTON);
-			}
-		}
-		if(!is_null($this->statusbar))
-		{
-			$this->statusbar->label->set_label(Writer::i18n('<b>Toolbar icon size changed</b>'));
-		}
-		unset($config, $size);
-		return;
-	}
-
-	/**
-	 * public function doPopup
-	 *
-	 * pops up a popup menu on right click
-	 *
-	 * @param object $window GtkWindow
-	 * @param object $event GdkEvent
-	 * @param object $menu GtkMenu
-	 * @return void
-	 */
-	public function doPopup($window, $event, $menu)
-	{
-		if($event->button == 3)
-		{
-			$menu->popup();
-		}
-		unset($window, $event, $menu);
-		return;
-	}
-
-	/**
-	 * public function deleteRow
-	 *
-	 * press delete to remove a treeview row
-	 *
-	 * @param object $window GtkWindow
-	 * @param object $event GdkEvent
-	 * @return void
-	 */
-	public function deleteRow($window, $event, $treeview)
-	{
-		if($event->keyval == Gdk::KEY_Delete)
-		{
-			$selection = $treeview->get_selection();
-			list($model, $iter) = $selection->get_selected();
-			$next = $model->iter_next($iter);
-			if(!is_null($next))
-			{
-				$selection->select_iter($next);
-			}
-			if(!is_null($iter))
-			{
-				$model->remove($iter);
-			}
-			unset($selection, $model, $iter);
-		}
-		unset($window, $event, $treeview, $next);
-		return;
-	}
-
-	/**
-	 * public function getAction
-	 *
-	 * loops through all action groups and finds the first one matching an
-	 * action name
-	 *
-	 * @param string $name action to grab
-	 * @return object instanceof GtkAction
-	 */
-	public function getAction($name)
-	{
-		foreach($this->actions as $group)
-		{
-			$action = $group->get_action($name);
-			if(!is_null($action))
-			{
-				break;
-			}
-		}
-		unset($group);
-		return $action;
-	}
-
-	/**
-	 * public function onCustomize
-	 *
-	 * description
-	 *
-	 * @todo right now the drag and drop for this is ugly as sin because the enable_drag stuff
-	 * for the higher level treeview dnd stuff doesn't exist yet, this should be moved
-	 * over when that stuff is completed.
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function onCustomize()
-	{
-		$options = array();
-		$actions = array();
-		$window = new GtkDialog(
-			Writer::i18n('%s :: Customize', $this->get_title()),
-			$this, Gtk::DIALOG_MODAL | Gtk::DIALOG_DESTROY_WITH_PARENT | Gtk::DIALOG_NO_SEPARATOR,
-			array(Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL, Gtk::STOCK_APPLY, Gtk::RESPONSE_APPLY));
-		$window->set_position(Gtk::WIN_POS_CENTER);
-		$window->vbox->add($notebook = new GtkNotebook());
-
-		// show or hide toobar, pick icon size (with images) and types (with images)
-		$table = new GtkTable();
-		$group = $this->actions['toolbar'];
-
-		$toggle = $button = new GtkCheckButton();
-		$actions['toggle'] = $action = $group->get_action('toggle');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 0, 4, 0, 1);
-
-		$table->attach(new GtkHSeparator(), 0, 4, 1, 2);
-
-		$options['icon'] = $button = new GtkRadioButton();
-		$actions['icon'] = $action = $group->get_action('icon');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 0, 1, 2, 3);
-
-		$toolbar = new GtkToolbar();
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
-		$toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
-		$toolbar->set_style(Gtk::TOOLBAR_ICONS);
-		$toolbar->set_show_arrow(FALSE);
-		$table->attach($toolbar, 1, 2, 2, 3);
-
-		$options['text'] = $button = new GtkRadioButton($button);
-		$actions['text'] = $action = $group->get_action('text');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 0, 1, 3, 4);
-
-		$toolbar = new GtkToolbar();
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
-		$toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
-		$toolbar->set_style(Gtk::TOOLBAR_TEXT);
-		$toolbar->set_show_arrow(FALSE);
-		$table->attach($toolbar, 1, 2, 3, 4);
-
-		$options['both'] = $button = new GtkRadioButton($button);
-		$actions['both'] = $action = $group->get_action('both');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 0, 1, 4, 5);
-
-		$toolbar = new GtkToolbar();
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
-		$toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
-		$toolbar->set_style(Gtk::TOOLBAR_BOTH);
-		$toolbar->set_show_arrow(FALSE);
-		$table->attach($toolbar, 1, 2, 4, 5);
-
-		$options['small'] = $button = new GtkRadioButton();
-		$actions['small'] = $action = $group->get_action('small');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 2, 3, 2, 3);
-
-		$toolbar = new GtkToolbar();
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
-		$toolbar->set_icon_size(Writer::$BUTTON);
-		$toolbar->set_style(Gtk::TOOLBAR_ICONS);
-		$toolbar->set_show_arrow(FALSE);
-		$table->attach($toolbar, 3, 4, 2, 3);
-
-		$options['medium'] = $button = new GtkRadioButton($button);
-		$actions['medium'] = $action = $group->get_action('medium');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 2, 3, 3, 4);
-
-		$toolbar = new GtkToolbar();
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
-		$toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
-		$toolbar->set_style(Gtk::TOOLBAR_ICONS);
-		$toolbar->set_show_arrow(FALSE);
-		$table->attach($toolbar, 3, 4, 3, 4);
-
-		$options['large'] = $button = new GtkRadioButton($button);
-		$actions['large'] = $action = $group->get_action('large');
-		$action->connect_proxy($button);
-		$action->block_activate_from($button);
-		$table->attach($button, 2, 3, 4, 5);
-
-		$toolbar = new GtkToolbar();
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
-		$toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
-		$toolbar->set_icon_size(Writer::$DND);
-		$toolbar->set_style(Gtk::TOOLBAR_ICONS);
-		$toolbar->set_show_arrow(FALSE);
-		$table->attach($toolbar, 3, 4, 4, 5);
-
-		$table->attach(new GtkHSeparator(), 0, 4, 5, 6);
-
-		$table->attach($all = new GtkCheckButton(Writer::i18n('_Apply options to all windows'), TRUE), 0, 4, 6, 7);
-
-		$notebook->append_page($table, $label = new GtkLabel(Writer::i18n('_Options')));
-		$label->set_use_underline(TRUE);
-		unset($table, $toolbar, $label, $button, $group, $action);
-
-		$vbox = new GtkVBox();
-		$hbox = new GtkHBox();
-		$vbox->pack_start($hbox);
-
-		// Set up treeview for available commands
-		$scrolled = new GtkScrolledWindow();
-		$scrolled->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-		$treeview = new GtkTreeView();
-		$treeview->set_headers_visible(FALSE);
-		$selection = $treeview->get_selection();
-		$selection->set_mode(Gtk::SELECTION_SINGLE);
-		$scrolled->add($treeview);
-
-		$col = new GtkTreeViewColumn('image', new GtkCellRendererPixbuf(), 'pixbuf', 0);
-		$treeview->append_column($col);
-
-		$col = new GtkTreeViewColumn('name', new GtkCellRendererText(), 'text', 1);
-		$col->set_expand(TRUE);
-		$treeview->append_column($col);
-
-		$hbox->pack_start($scrolled);
-
-		$current = new GtkListStore(GdkPixbuf::gtype, Gtk::TYPE_STRING, Gtk::TYPE_STRING);
-		foreach($this->toolbuttons as $name)
-		{
-			if($name == 'separator')
-			{
-				$current->append(array(NULL, Writer::i18n('Separator'), NULL));
-				continue;
-			}
-			$action = $this->getAction($name);
-			$current->append(array($window->render_icon($action->get_property('stock_id'), Writer::$LARGE_TOOLBAR),
-				str_replace(array('...', '_'), '', $action->get_property('label')), $name));
-		}
-		$treeview->set_model($current);
-		$treeview->drag_source_set(Gdk::BUTTON1_MASK, array(array('text/plain', 0, 0)), Gdk::ACTION_COPY);
-		$treeview->connect('drag-begin', array($this, 'setRowDragIcon'));
-		$treeview->connect('drag-data-get', array($this, 'treeviewDragStart')); 
-
-		// Set up treeview for available commands
-		$scrolled = new GtkScrolledWindow();
-		$scrolled->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-		$treeview = new GtkTreeView();
-		$treeview->set_headers_visible(FALSE);
-		$selection = $treeview->get_selection();
-		$selection->set_mode(Gtk::SELECTION_SINGLE);
-		$scrolled->add($treeview);
-
-		$col = new GtkTreeViewColumn('image', new GtkCellRendererPixbuf(), 'pixbuf', 0);
-		$treeview->append_column($col);
-
-		$col = new GtkTreeViewColumn('name', new GtkCellRendererText(), 'text', 1);
-		$col->set_expand(TRUE);
-		$treeview->append_column($col);
-
-		$hbox->pack_start($scrolled);
-
-		$current = new GtkListStore(GdkPixbuf::gtype, Gtk::TYPE_STRING, Gtk::TYPE_STRING);
-		foreach($this->toolcurrent as $name)
-		{
-			if($name == 'separator')
-			{
-				$current->append(array(NULL, Writer::i18n('Separator'), 'separator'));
-				continue;
-			}
-			$action = $this->getAction($name);
-			$current->append(array($window->render_icon($action->get_property('stock_id'), Writer::$LARGE_TOOLBAR),
-				str_replace(array('...', '_'), '', $action->get_property('label')), $name));
-		}
-		Tooltips::instance()->set_tip($treeview, Writer::i18n('Press delete to remove an item'));
-		$treeview->set_model($current);
-		$treeview->drag_dest_set(Gtk::DEST_DEFAULT_ALL, array( array( 'text/plain', 0, 0)), Gdk::ACTION_COPY);
-		$treeview->connect('drag-data-received', array($this, 'treeviewDragEnd'));
-		$treeview->set_events($treeview->get_events() | Gdk::KEY_PRESS_MASK);
-		$treeview->connect('key-press-event', array($this, 'deleteRow'), $treeview);
-		$treeview->drag_source_set(Gdk::BUTTON1_MASK, array(array('text/plain', 0, 0)), Gdk::ACTION_COPY);
-		$treeview->connect('drag-begin', array($this, 'setRowDragIcon'));
-		$treeview->connect('drag-data-get', array($this, 'treeviewDragStart'), TRUE);
-
-		$vbox->pack_start($default = new GtkCheckButton(Writer::i18n('_Reset to default toolbar'), TRUE), 0, 0);
-
-		$notebook->append_page($vbox, $label = new GtkLabel(Writer::i18n('_Commands')));
-		$label->set_use_underline(TRUE);
-		$window->show_all();
-		$response = $window->run();
-		if($response == Gtk::RESPONSE_APPLY)
-		{
-			if($all->get_active() == TRUE)
-			{
-				$this->recurseWindowOptions(Writer::$window, $toggle->get_active(), $options);
-			}
-			else
-			{
-				$actions['toggle']->set_active($toggle->get_active());
-				foreach($options as $name => $button)
-				{
-					if($button->get_active() == TRUE)
-					{
-						$actions[$name]->set_active(TRUE);
-					}
-				}
-			}
-
-			$this->toolcurrent = array();
-			if($default->get_active() == TRUE)
-			{
-				$this->toolcurrent = $this->tooldefault;
-			}
-			else
-			{
-				$current->foreach(array($this, 'setButtons'));
-			}
-			$this->rebuildToolbar();
-		}
-		$window->destroy();
-
-		unset($all, $window, $notebook, $response, $this, $options, $actions,
-			$toggle, $vbox, $hbox, $scrolled, $treeview, $selection, $col, $current,
-			$name, $action, $default, $label, $button);
-			}
-
-	/**
-	 * public function recurseWindows
-	 *
-	 * description
-	 *
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function recurseWindowOptions($window, $toggle, $options)
-	{
-		$window->actions['toolbar']->get_action('toggle')->set_active($toggle);
-		foreach($options as $name => $button)
-		{
-			if($button->get_active() == TRUE)
-			{
-				$window->actions['toolbar']->get_action($name)->set_active(TRUE);
-			}
-		}
-		foreach($window as $name => $item)
-		{
-			if($name != 'transient_parent' && is_object($item) && $item instanceof Window)
-			{
-				$this->recurseWindowOptions($item, $toggle, $options);
-			}
-		}
-		unset($window, $options, $toggle, $item, $name, $button);
-		return;
-	}
-
-	/**
-	 * public function setRowDragIcon
-	 *
-	 * creates a drag icon from a treeview row
-	 *
-	 * @param object $treeview instanceof GtkTreeview
-	 * @return void
-	 */
-	public function setRowDragIcon(GtkTreeview $treeview)
-	{
-		$selection = $treeview->get_selection();
-		list($model, $iter) = $selection->get_selected();
-		$pixmap = $treeview->create_row_drag_icon($model->get_path($iter));
-		$treeview->drag_source_set_icon($pixmap->get_colormap(), $pixmap);
-		unset($selection, $model, $iter, $treeview, $pixmap);
-		return;
-	}
-
-	/**
-	 * public function treeviewDragStart
-	 *
-	 * description
-	 *
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function treeviewDragStart(GtkTreeview $treeview, $context, $data, $x, $y, $bool = FALSE)
-	{
-		$selection = $treeview->get_selection();
-		list($model, $iter) = $selection->get_selected();
-		$data->set_text($model->get_value($iter, 2));
-		if($bool == TRUE)
-		{
-			$model->remove($iter);
-		}
-		unset($treeview, $context, $selection, $model, $iter, $x, $y, $bool);
-		return;
-	}
-
-	public function treeviewDragEnd(GtkTreeview $treeview, $context, $x, $y, $data)
-	{
-		list($x, $y) = $treeview->widget_to_tree_coords($x, $y);
-		$iter = $treeview->get_path_at_pos($x, $y);
-		$model = $treeview->get_model();
-		if(is_null($iter[0]))
-		{
-			$total = $model->iter_n_children(NULL);
-			if($total > 0)
-			$total--;
-			$iter = $model->iter_nth_child(NULL, $total);
-		}
-		else
-		{
-			$iter = $model->get_iter($iter[0]);
-		}
-		$action = $this->getAction($data->data);
-		if(is_null($action))
-		{
-			$newiter = $model->append(array(NULL, Writer::i18n('Separator'), 'separator'));
-		}
-		else
-		{
-			// insert before/after are broken
-			$newiter = $model->append(array($treeview->render_icon($action->get_property('stock_id'), Writer::$LARGE_TOOLBAR),
-				str_replace(array('...', '_'), '', $action->get_property('label')), $data->data));
-		}
-		$model->move_after($newiter, $iter);
-		unset($treeview, $context, $x, $y, $data, $iter, $model, $action, $newiter, $total);
-		return;
-	}
-
-	/**
-	 * public function setButtons
-	 *
-	 * description
-	 *
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function setButtons($store, $path, $iter)
-	{
-		$this->toolcurrent[] = $store->get_value($iter, 2);
-		unset($store, $path, $iter);
-		return;
-	}
-
-	/**
-	 * public function rebuildToolbar
-	 *
-	 * description
-	 *
-	 * @param type $name about
-	 * @return type about
-	 */
-	public function rebuildToolbar()
-	{
-		$toolbar = $this->toolbar;
-		$tooltips = Tooltips::instance();
-		$list = $toolbar->get_children();
-		foreach($list as $widget)
-		{
-			$toolbar->remove($widget);
-		}
-		// populate toolbar
-		foreach($this->toolcurrent as $name)
-		{
-			if($name == 'separator')
-			{
-				$toolbar->insert($sep = new GtkSeparatorToolItem(), -1);
-				$sep->show();
-			}
-			else
-			{
-				$action = $this->getAction($name);
-				if(!is_null($action))
-				{
-					$item = $action->create_tool_item();
-					$item->set_tooltip($tooltips, $action->get_property('tooltip'));
-					$toolbar->insert($item, -1);
-				}
-			}
-		}
-		Config::instance()->{$this->name . 'toolbar_items'} = $this->toolcurrent;
-		if(!is_null($this->statusbar))
-		{
-			$this->statusbar->label->set_label(Writer::i18n('<b>Toolbar items rebuilt</b>'));
-		}
-		unset($toolbar, $list, $widget, $name, $action, $item, $tooltips);
-		return;
-	}
-
 }
 ?>
\ No newline at end of file

Modified: desktop/trunk/Writer/lib/writer.class.php (27 => 28)


--- desktop/trunk/Writer/lib/writer.class.php	2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/writer.class.php	2006-11-30 15:15:17 UTC (rev 28)
@@ -33,11 +33,29 @@
 
 	/**
 	 * you can grab and manipulate everything from here
-	 * @var $window instanceof GtkWindow
+	 * @var $window instanceof ProjectWindow (GtkWindow)
 	 */
 	static public $window;
 
 	/**
+	 * you can grab and manipulate everything from here
+	 * @var $window instanceof Tooltips (GtkTooltips)
+	 */
+	static public $tooltips;
+
+	/**
+	 * all actions for application are stored here
+	 * @var $window instanceof Actions
+	 */
+	static public $actions;
+
+	/**
+	 * application configuration
+	 * @var $config instanceof Config
+	 */
+	static public $config;
+
+	/**
 	 * Icon sizes - these SHOULD be constants - but
 	 * you can't set class constants after the class is defined
 	 * so they're static vars instead - annoying
@@ -68,23 +86,29 @@
 	{
 		$this->checkRequirements();
 
-		$splash = new Splash();
-		$splash->update('Starting');
+		$splash = new Splash(7);
 		$splash->update('Checking Requirements');
 
 		$splash->update('Initializing Messages');
 		set_error_handler(array('Message', 'error'));
 		set_exception_handler(array('Message', 'exception'));
 
-		$splash->update('Loading Theme');
+		$splash->update('Initializing Theme');
 		$this->theme();
 
+		$splash->update('Initializing Configuration');
+		self::$config = new Config();
+
+		$splash->update('Initializing Environment');
+		self::$tooltips = new Tooltips();
+		self::$actions = new Actions();
+
 		$splash->update('Loading Project');
 		self::$window = $window = new ProjectWindow();
 		$splash->parent($window);
 		$window->show_all();
 
-		$splash->update('Setup Complete');
+		$splash->update('Loaded');
 		$splash->destroy();
 		unset($splash, $window);
 
@@ -111,7 +135,19 @@
 		{
 			$args = $args[0];
 		}
-		return gettext(vsprintf($string, $args));
+		if(function_exists('gettext'))
+		{
+			// if we have args, the first item is format only and not translated
+			if(is_array($args) && !empty($args))
+			{
+				$args = array_map('gettext', $args);
+			}
+			else
+			{
+				$string = gettext($string);
+			}
+		}
+		return vsprintf($string, $args);
 	}
 
 	/**
@@ -141,11 +177,13 @@
 		{
 			$shell = new COM('WScript.Shell');
 			$shell->Run('cmd /c start "" "' . $file . '"', 0, FALSE);
+			unset($shell, $file);
 		}
 		elseif(stristr(PHP_OS, 'win32'))
 		{
 			$shell = new COM('WScript.Shell');
 			$shell->Run('command /c start "" "' . $file . '"', 0, FALSE);
+			unset($shell, $file);
 		}
 		elseif(stristr(PHP_OS, 'darwin') || stristr(PHP_OS, 'mac'))
 		{
@@ -174,16 +212,16 @@
 			// check environment variables for appdir or use home/.projects
 			if(isset($_ENV['APPDATA']))
 			{
-				$appdata = $_ENV['APPDATA'] . DS . 'callicore' . DS;
+				$appdata = $_ENV['APPDATA'] . DS . 'Callicore' . DS;
 			}
 			elseif(stristr(PHP_OS, 'darwin'))
 			{
 				$appdata = DIR . 'Library' . DS . 'Application Support'
-					. DS . 'callicore' . DS;
+					. DS . 'Callicore' . DS;
 			}
 			elseif(stristr(PHP_OS, 'linux') || stristr(PHP_OS, 'freebsd') || stristr(PHP_OS, 'unix'))
 			{
-				$appdata = DIR . 'callicore' . DS;
+				$appdata = DIR . 'Callicore' . DS;
 			}
 			else
 			{
@@ -193,7 +231,7 @@
 			{
 				mkdir($appdata);
 			}
-			$appdata .= 'writer' . DS;
+			$appdata .= 'Writer' . DS;
 			if(!file_exists($appdata))
 			{
 				mkdir($appdata);
@@ -223,24 +261,16 @@
 			bindtextdomain('Writer', DIR . 'locale');
 			textdomain('Writer');
 		}
-		else
+		if(version_compare(PHP_VERSION, '5.2.0', '<'))
 		{
-			function gettext($string)
-			{
-				return $string;
-			}
+			trigger_error(self::i18n('You must use php 5.2.0 or higher'), E_USER_ERROR);
 		}
-		if(version_compare(PHP_VERSION, '5.1.0', '<'))
-		{
-			trigger_error(self::i18n('You must use php 5.1.0 or higher'), E_USER_ERROR);
-		}
 		$have = get_loaded_extensions();
 		$needed = array('standard', 'pcre', 'date', 'PDO', 'pdo_sqlite', 'php-gtk');
 		$diff = array_diff($needed, $have);
 		if(!empty($diff))
 		{
-			trigger_error(self::i18n('The following extensions must be loaded in your php.ini for Writer to function: %s',
-				implode(', ', $diff)), E_USER_ERROR);
+			trigger_error(self::i18n('%s : %s', 'The following extensions must be loaded in your php.ini for Writer to function', implode(', ', $diff)), E_USER_ERROR);
 		}
 		unset($have, $needed, $diff);
 		return;