name)) { $this->set_name(strtolower(get_class($this))); } $this->connect('window-state-event', array($this, 'windowState')); $this->connect_simple('delete-event', array($this, 'saveWindowState')); $this->restoreWindowState(); return; } /** * public function set_title * * overload set_title * * @param string $name title to set * @return void */ public function set_title($title, $program = 'Callicore') { parent::set_title(CC::i18n('%s :: %s', $program, $title)); return; } //---------------------------------------------------------------- // Callbacks //---------------------------------------------------------------- /** * public function saveWindowState * * saves window state * * @return void */ 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(); $config->{$name . '_height'} = $height; $config->{$name . '_width'} = $width; // position list($x, $y) = $this->get_position(); $config->{$name . '_x'} = $x; $config->{$name . '_y'} = $y; $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(); } 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; } public function hide_all() { if (class_exists('CC_WM') && CC_WM::is_window($this->get_name()) && $this->isModal) { parent::grab_remove(); $return = parent::hide_all(); $this->isModal = false; return $return; } else { return parent::hide_all(); } } public function show_all($modal = false) { if (class_exists('CC_WM') && CC_WM::is_window($this->get_name())) { $return = parent::show_all(); parent::grab_add(); $this->isModal = true; return $return; } else { return parent::show_all(); } } } ?>