Esempio n. 1
0
 function createScale($basewidget, $basefunction, $from, $to)
 {
     $scale = GtkHScale::new_with_range($from, $to, 1);
     $function = 'get_' . $basefunction;
     $scale->set_value($basewidget->{$function}());
     $scale->connect('change-value', array($this, 'set_scale'), $basewidget, 'set_' . $basefunction);
     return $scale;
 }
Esempio n. 2
0
 /**
  * @name __construct()
  * @return Demo
  */
 public function __construct()
 {
     // Cria a janela
     $this->widgets['frmDemo'] = new GtkWindow();
     $this->widgets['frmDemo']->set_size_request(200, 200);
     $this->widgets['frmDemo']->set_position(Gtk::WIN_POS_CENTER_ALWAYS);
     $this->widgets['frmDemo']->connect("destroy", array($this, "frmDemo_unload"));
     $box = new GtkVBox();
     // Cria o video
     $this->widgets['vdoDemo'] = Fabula::GtkVideo();
     $this->widgets['vdoDemo']->set_auto_scalable(TRUE);
     $this->widgets['vdoDemo']->connect("button-press-event", array($this, "vdoDemo_button_pressed"));
     $this->widgets['vdoDemo']->connect("video-changed", array($this, "vdoDemo_onchange"));
     $this->widgets['vdoDemo']->connect("video-closed", array($this, "vdoDemo_onclose"));
     $box->pack_start($this->widgets['vdoDemo'], TRUE, TRUE);
     // Cria o progressbar
     $this->widgets['sclDemo'] = GtkHScale::new_with_range(0, 100, 1);
     $this->widgets['sclDemo']->set_draw_value(FALSE);
     $this->widgets['sclDemo']->connect("button-release-event", array($this, "sclDemo_button_pressed"));
     $box->pack_start($this->widgets['sclDemo'], FALSE, FALSE);
     // Cria o box dos botões
     $this->widgets['hbox'] = new GtkHBox();
     $box->pack_start($this->widgets['hbox'], FALSE, FALSE);
     // Cria o label do tempo
     $this->widgets['lblTime'] = Fabula::GtkLabel("");
     $this->widgets['lblTime']->set_alignment(1, 0.5);
     $this->widgets['hbox']->pack_end($this->widgets['lblTime']);
     // Adiciona os botões
     $this->widgets['btnOpen'] = Fabula::GtkButton(NULL, array($this, "btnOpen_click"));
     $this->widgets['btnOpen']->set_image(GtkImage::new_from_stock(Gtk::STOCK_OPEN, Gtk::ICON_SIZE_BUTTON));
     $this->widgets['hbox']->pack_start($this->widgets['btnOpen'], FALSE, FALSE);
     $this->widgets['btnPlay'] = Fabula::GtkButton(NULL, array($this, "btnPlay_click"));
     $this->widgets['btnPlay']->set_image(GtkImage::new_from_stock(Gtk::STOCK_MEDIA_PLAY, Gtk::ICON_SIZE_BUTTON));
     $this->widgets['hbox']->pack_start($this->widgets['btnPlay'], FALSE, FALSE);
     $this->widgets['btnPause'] = Fabula::GtkButton(NULL, array($this, "btnPause_click"));
     $this->widgets['btnPause']->set_image(GtkImage::new_from_stock(Gtk::STOCK_MEDIA_PAUSE, Gtk::ICON_SIZE_BUTTON));
     $this->widgets['hbox']->pack_start($this->widgets['btnPause'], FALSE, FALSE);
     $this->widgets['btnStop'] = Fabula::GtkButton(NULL, array($this, "btnStop_click"));
     $this->widgets['btnStop']->set_image(GtkImage::new_from_stock(Gtk::STOCK_MEDIA_STOP, Gtk::ICON_SIZE_BUTTON));
     $this->widgets['hbox']->pack_start($this->widgets['btnStop'], FALSE, FALSE);
     // Inicia a aplicação
     $this->widgets['frmDemo']->add($box);
     $this->frmDemo_onload();
 }
Esempio n. 3
0
 /**
  * Define widget properties
  * @param  $property Property's name
  * @param  $value    Property's value
  */
 public function setProperty($property, $value)
 {
     if ($property == 'readonly') {
         parent::set_editable(false);
     }
 }
Esempio n. 4
0
$window = new GtkWindow();
$window->set_size_request(400, 100);
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$window->add($vbox = new GtkVBox());
// display title
$title = new GtkLabel("Set up Volume Control\n" . "Part 2 - using GtkHScale");
$title->modify_font(new PangoFontDescription("Times New Roman Italic 10"));
$title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff"));
$title->set_size_request(-1, 40);
$title->set_justify(Gtk::JUSTIFY_CENTER);
$alignment = new GtkAlignment(0.5, 0.5, 0, 0);
$alignment->add($title);
$vbox->pack_start($alignment, 0);
$vbox->pack_start(new GtkLabel(), 0);
$vbox->pack_start($hbox = new GtkHBox(), 0);
$hbox->pack_start(new GtkLabel('Volume: '), 0);
$vol_adj = GtkHScale::new_with_range(-100, 80, 1);
// note 1
$hbox->pack_start($vol_adj);
$vol_adj->set_value_pos(Gtk::POS_RIGHT);
// note 2
$vol_adj->connect('format-value', 'on_format_value');
// note 3
$window->show_all();
Gtk::main();
function on_format_value($scale, $value)
{
    return $value . "dB";
    // note 4
}