widget = &new $class($glade_file); $this->window = $this->widget->get_widget("window"); $this->btn_ok = $this->widget->get_widget("OK"); $this->btn_cancel = $this->widget->get_widget("cancel"); $this->info = $this->widget->get_widget("info"); $this->window->set_modal(TRUE); $this->window->connect("delete-event", array(&$this,"ignore_close")); $this->btn_ok->connect("clicked", array(&$this,"ok_pressed")); if ($this->btn_cancel) $this->btn_cancel->connect("clicked", array(&$this,"cancel_pressed")); } function ignore_close() { $this->cancel_pressed(); return true; } function show($message="") { debug_echo("GENERIC dialog show"); $this->__show($message); } function __show($message="") { global $application; if ($this->info && method_exists($this->info,"set_text")) $this->info->set_text($message); if ($application->window) $this->window->set_transient_for($application->window); $this->window->show(); } function hide() { $this->__hide(); } function __hide() { $this->window->hide(); } function set_callbacks($ok=NULL,$cancel=NULL) { $this->ok_pressed_callback = $ok; $this->cancel_pressed_callback = $cancel; } function ok_pressed() { if (!$this->disable_ok_hide) $this->hide(); $cb = $this->ok_pressed_callback; $this->set_callbacks(); if ($cb) call_user_func($cb); } function cancel_pressed() { $this->hide(); $cb = $this->cancel_pressed_callback; $this->set_callbacks(); if ($cb) call_user_func($cb); } } ?>