All pastes #393562 Raw Edit

Stuff

public text v1 · immutable
·published 2007-03-13 17:44 UTC
rendered paste body
<?php

class ide_splash extends GtkWindow {

  protected $steps = array();
  protected $step = 1;
  protected $label;
  protected $progressbar;

  public function __construct(){
    parent::__construct();
    $this->set_position(Gtk::WIN_POS_CENTER);
    $this->set_resizable(false);
    $this->set_decorated(false);
    $this->set_skip_taskbar_hint(true);
    $this->set_skip_pager_hint(true);
    $this->set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
    $this->label = new gtklabel();
    $this->label->set_text("Starting Application");
    $this->progressbar = new gtkprogressbar();
    $vbox = new gtkvbox();
    $vbox->pack_end($this->label,false);
    $vbox->pack_end($this->progressbar,false);
    $this->add($vbox);
  }

  public function set_image($location){
    $pixbuf = GdkPixbuf::new_from_file($location);
    list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask();
    list($width, $height) = $pixmap->get_size();
    $this->set_app_paintable(true);
    $this->set_size_request($width, $height);
    $this->realize();
    if($mask instanceof GdkPixmap){
      $this->shape_combine_mask($mask, 0, 0);
    }
    $this->window->set_back_pixmap($pixmap, false);
  }

  public function set_steps($steps){
    $this->steps = $steps;
  }

  public function set_step($step){
    if($step <= count($this->steps)){
      $this->step = $step;
      $this->label->set_text($this->steps[$this->step - 1]);
      $this->progressbar->set_fraction($this->step / count($this->steps));
      while(Gtk::events_pending()) Gtk::main_iteration();
    }
  }

  public function next_step(){
    if($this->step <= count($this->steps)){
      $this->step++;
      $this->label->set_text($this->steps[$this->step - 1]);
      $this->progressbar->set_fraction($this->step / count($this->steps));
      while(Gtk::events_pending()) Gtk::main_iteration();
    }
  }

  public function start_splash(){
    $this->set_image(dirname(__FILE__).'/images/phpgtk.png');
    $this->show_all();
    $this->set_steps(array('attempting to start gconfd-2', 'gconfd-2 started', 'Initilizing GtkHTML', 'GtkHTML Initilized'));
    $this->set_step(1);
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $process = proc_open('start /b gconfd-2.exe', $descriptorspec, $pipes);
    if (is_resource($process)) {
      $this->next_step();
    }else{
      die();
    }
    $this->next_step();
    $html = new GtkHTML();
    $html->destroy();
    $this->next_step();
  }

}

$splash = new ide_splash();
$splash->start_splash();

?>