Revision
56
Author
emsmith
Date
2006-12-02 17:08:46 -0800 (Sat, 02 Dec 2006)

Log Message

Painfully implemented minimize, maximize and fullscreen window remembering - need to research show/hide to see if I need to implement it there as well

Modified Paths

Diff

Modified: desktop/trunk/lib/actions.class.php (55 => 56)


--- desktop/trunk/lib/actions.class.php	2006-12-02 04:14:32 UTC (rev 55)
+++ desktop/trunk/lib/actions.class.php	2006-12-03 01:08:46 UTC (rev 56)
@@ -120,6 +120,38 @@
 	}
 
 	/**
+	 * public function create_button_item
+	 *
+	 * creates a gtkbutton, gtkcheckbutton or gtkradiobutton
+	 * and hooks it to the action you specify
+	 *
+	 * @param string $group name of action group to get
+	 * @param string $action name of action to get
+	 * @return object instanceof GtkButton
+	 */
+	public function create_button_item($group, $action)
+	{
+		$tips = CC_Tooltips::instance();
+		$action = $this->get_action($group, $action);
+		if($action instanceof GtkRadioAction)
+		{
+			$button = new GtkRadioButton();
+		}
+		elseif($action instanceof GtkToggleAction)
+		{
+			$button = new GtkCheckButton();
+		}
+		else
+		{
+			$button = new GtkButton();
+		}
+		$tips->set_tip($button, $action->get_property('tooltip'));
+		$action->connect_proxy($button);
+		unset($action, $group, $tips);
+		return $button;
+	}
+
+	/**
 	 * public function get_group
 	 *
 	 * returns action group

Modified: desktop/trunk/lib/toolbar.class.php (55 => 56)


--- desktop/trunk/lib/toolbar.class.php	2006-12-02 04:14:32 UTC (rev 55)
+++ desktop/trunk/lib/toolbar.class.php	2006-12-03 01:08:46 UTC (rev 56)
@@ -298,7 +298,7 @@
 	 */
 	public function onCustomize()
 	{
-		$window = new CC_Tooldialog($this);
+		$window = new CC_Tooldialog($this->parent->parent);
 		$response = $window->run();
 		return;
 	}

Modified: desktop/trunk/lib/window.class.php (55 => 56)


--- desktop/trunk/lib/window.class.php	2006-12-02 04:14:32 UTC (rev 55)
+++ desktop/trunk/lib/window.class.php	2006-12-03 01:08:46 UTC (rev 56)
@@ -14,7 +14,7 @@
  * @version      $Id$
  * @since        Php 5.2.0
  * @package      callicore
- * @subpackage   writer
+ * @subpackage   desktop
  * @category     lib
  * @filesource
  */
@@ -52,6 +52,24 @@
 	 */
 	public $statusbar;
 
+	/**
+	 * windows can be minimized, maximized and fullscreened
+	 * @var $minimized bool
+	 */
+	protected $minimized = FALSE;
+
+	/**
+	 * windows can be minimized, maximized and fullscreened
+	 * @var $maximized bool
+	 */
+	protected $maximized = FALSE;
+
+	/**
+	 * windows can be minimized, maximized and fullscreened
+	 * @var $fullscreen bool
+	 */
+	protected $fullscreen = FALSE;
+
 	//----------------------------------------------------------------
 	//             Setup
 	//----------------------------------------------------------------
@@ -70,19 +88,9 @@
 
 		$config = CC_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;
-		$this->set_default_size($width, $height);
-
-		$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(empty($this->name))
 		{
-			$this->move($x, $y);
+			$this->set_name(strtolower(get_class($this)));
 		}
 
 		$this->toolbar = new CC_Toolbar($this->name);
@@ -97,8 +105,12 @@
 		$vbox->pack_end($this->statusbar, 0, 0);
 		$this->add($vbox);
 
-		$this->connect_simple('delete-event', array($this, 'onDeleteEvent'));
+		$this->connect('window-state-event', array($this, 'windowState'));
+		$this->connect_simple('delete-event', array($this, 'saveWindowState'));
+		//$this->connect_simple('hide', array($this, 'saveWindowState'));
+		//$this->connect_simple('show', array($this, 'restoreWindowState'));
 		unset($config, $height, $width, $x, $y, $name, $vbox, $this);
+		$this->restoreWindowState();
 		return;
 	}
 
@@ -360,22 +372,46 @@
 	//----------------------------------------------------------------
 
 	/**
-	 * public function onDeleteEvent
+	 * public function saveWindowState
 	 *
-	 * callback for delete-event, saves window size and position
+	 * saves window state
 	 *
 	 * @return void
 	 */
-	public function onDeleteEvent()
+	public function saveWindowState()
 	{
 		$name = $this->name;
 		$config = CC_Config::instance();
 
+		// unmax/min/fullscreen
+		$config->{$name . '_fullscreen'} = $this->fullscreen;
+		$config->{$name . '_maximized'} = $this->maximized;
+		$config->{$name . '_minimized'} = $this->minimized;
+
+		if($this->minimized)
+		{
+			$this->deiconify();
+		}
+		if($this->maximized)
+		{
+			$this->unmaximize();
+		}
+		elseif($this->fullscreen)
+		{
+			$this->unfullscreen();
+		}
+
+		// size
 		list($height, $width) = $this->get_size();
+		echo "height is $height\n";
+		echo "width is $width\n";
 		$config->{$name . '_height'} = $height;
 		$config->{$name . '_width'} = $width;
 
+		// position
 		list($x, $y) = $this->get_position();
+		echo "x is $x\n";
+		echo "y is $y\n";
 		$config->{$name . '_x'} = $x;
 		$config->{$name . '_y'} = $y;
 
@@ -383,5 +419,64 @@
 		$this->destroy();
 		return;
 	}
+
+	/**
+	 * public function restoreWindowState
+	 *
+	 * restores a window state
+	 *
+	 * @return void
+	 */
+	public function restoreWindowState()
+	{
+		$name = $this->name;
+		$config = CC_Config::instance();
+
+		// default size and location
+		$width = isset($config->{$name . '_height'}) ? (int) $config->{$name . '_height'} : 800;
+		$height = isset($config->{$name . '_width'}) ? (int) $config->{$name . '_width'} : 600;
+		$this->set_default_size($width, $height);
+
+		$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))
+		{
+			$this->move($x, $y);
+		}
+
+		$fullscreen = isset($config->{$name . '_fullscreen'}) ? (bool) $config->{$name . '_fullscreen'} : FALSE;
+		$maximized = isset($config->{$name . '_maximized'}) ? (bool) $config->{$name . '_maximized'} : FALSE;
+		$minimized = isset($config->{$name . '_minimized'}) ? (bool) $config->{$name . '_minimized'} : FALSE;
+
+		if($fullscreen)
+		{
+			$this->fullscreen();
+		}
+		if($maximized)
+		{
+			$this->maximize();
+		}
+		if($minimized)
+		{
+			$this->iconify();
+		}
+		unset($name, $config, $width, $height, $x, $y, $state);
+		return;
+	}
+
+	/**
+	 * public function saveWindow
+	 *
+	 * keeps track of minimized/maximized/fullscreen or normal windows states
+	 *
+	 * @return void
+	 */
+	public function windowState($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;
+	}
+
 }
 ?>
\ No newline at end of file