/**
  * Cria o FFWButton
  * 
  * @name __construct($label="")
  * @param string $label Texto do botão
  * @param mixed $callback Função de callback
  * @return GtkButton
  */
 public function __construct($label = "", $callback = NULL)
 {
     // Cria o botão
     parent::__construct($label);
     // Verifica o callback
     if ($callback !== NULL) {
         parent::connect_simple("clicked", $callback);
     }
 }
Esempio n. 2
0
 /**
  * Class Constructor
  * @param $name Name of the widget
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkHBox();
     parent::add($this->widget);
     $this->mask = 'yyyy-mm-dd';
     // creates the entry field
     $this->entry = new TEntry($name);
     $this->entry->setSize(200);
     $this->setMask($this->mask);
     $this->widget->add($this->entry);
     // creates a button with a calendar image
     $button = new GtkButton();
     $button->set_relief(GTK::RELIEF_NONE);
     $imagem = GtkImage::new_from_file('lib/adianti/images/tdate-gtk.png');
     $button->set_image($imagem);
     $this->actionButton = $button;
     // define the button's callback
     $button->connect_simple('clicked', array($this, 'onCalendar'));
     $this->widget->add($button);
     // creates the calendar window
     $this->popWindow = new GtkWindow(Gtk::WINDOW_POPUP);
     // creates the calendar
     $this->calendar = new GtkCalendar();
     // define the action when the user selects a date
     $this->calendar->connect_simple('day-selected-double-click', array($this, 'onSelectDate'));
     $this->month = new TCombo('tdate-month');
     $this->month->addItems(array(TAdiantiCoreTranslator::translate('January'), TAdiantiCoreTranslator::translate('February'), TAdiantiCoreTranslator::translate('March'), TAdiantiCoreTranslator::translate('April'), TAdiantiCoreTranslator::translate('May'), TAdiantiCoreTranslator::translate('June'), TAdiantiCoreTranslator::translate('July'), TAdiantiCoreTranslator::translate('August'), TAdiantiCoreTranslator::translate('September'), TAdiantiCoreTranslator::translate('October'), TAdiantiCoreTranslator::translate('November'), TAdiantiCoreTranslator::translate('December')));
     $this->month->setCallback(array($this, 'onChangeMonth'));
     $this->month->setSize(70);
     for ($n = date('Y') - 10; $n <= date('Y') + 10; $n++) {
         $years[$n] = $n;
     }
     $this->year = new TCombo('tdate-year');
     $this->year->addItems($years);
     $this->year->setCallback(array($this, 'onChangeMonth'));
     $this->year->setSize(70);
     $hbox = new GtkHBox();
     $hbox->pack_start($this->month);
     $hbox->pack_start($this->year);
     $bt_today = new GtkButton(TAdiantiCoreTranslator::translate('Today'));
     $bt_close = new GtkButton(TAdiantiCoreTranslator::translate('Close'));
     $bt_today->connect_simple('clicked', array($this, 'selectToday'));
     $inst = $this->popWindow;
     $bt_close->connect_simple('clicked', array($inst, 'hide'));
     $hbox2 = new GtkHBox();
     $hbox2->pack_start($bt_today);
     $hbox2->pack_start($bt_close);
     $vbox = new GtkVBox();
     $vbox->pack_start($hbox, FALSE, FALSE);
     $vbox->pack_start($this->calendar);
     $vbox->pack_start($hbox2, FALSE, FALSE);
     // shows the window
     $this->popWindow->add($vbox);
 }
Esempio n. 3
0
 /**
  * Add an Action to the DataGrid
  * @param $object A TDataGridAction object
  */
 public function addAction(TDataGridAction $action)
 {
     $this->actions[] = $action;
     $button = new GtkButton($action->getLabel());
     if (file_exists('lib/adianti/images/' . $action->getImage())) {
         $button->set_image(GtkImage::new_from_file('lib/adianti/images/' . $action->getImage()));
     } else {
         $button->set_image(GtkImage::new_from_file('app/images/' . $action->getImage()));
     }
     $button->connect_simple('clicked', array($this, 'onExecute'), $action);
     $this->action_area->pack_start($button);
 }
Esempio n. 4
0
 /**
  * Define the action of the button
  * @param  $action  TAction object
  * @param  $label   Button's label
  */
 public function setAction(TAction $action, $label)
 {
     parent::set_label($label);
     parent::connect_simple('clicked', array($this, 'onExecute'), $action);
 }
Esempio n. 5
0
 function createButton($basewidget, $function, $function2)
 {
     //call the function on the base widget
     $btn = new GtkButton($function);
     $btn->connect_simple('clicked', array($basewidget, $function));
     if ($function2 === null) {
         return $btn;
     }
     $btn2 = new GtkButton($function2);
     $btn2->connect_simple('clicked', array($basewidget, $function2));
     $hbox = new GtkHBox();
     $hbox->pack_start($btn);
     $hbox->pack_end($btn2);
     return $hbox;
 }
Esempio n. 6
0
 /**
  * Define the menu based on user profile
  */
 public function configureMenu()
 {
     if ($this->scroll->get_child()) {
         $this->scroll->remove($this->scroll->get_child());
     }
     TTransaction::open('library');
     $member = User::newFromLogin(TSession::getValue('login'));
     if ($member->role->mnemonic == 'LIBRARIAN') {
         $buttons = array();
         $buttons[] = array('<b>' . _t('Cataloging') . '</b>');
         $buttons[] = array(_t('Books'), 'BookList');
         $buttons[] = array(_t('Collections'), 'CollectionFormList');
         $buttons[] = array(_t('Classifications'), 'ClassificationFormList');
         $buttons[] = array(_t('Subjects'), 'SubjectList');
         $buttons[] = array(_t('Authors'), 'AuthorList');
         $buttons[] = array(_t('Publishers'), 'PublisherList');
         $buttons[] = array(_t('Status'), 'StatusFormList');
         $buttons[] = array('<b>' . _t('Members') . '</b>');
         $buttons[] = array(_t('Members'), 'MemberList');
         $buttons[] = array(_t('Categories'), 'CategoryFormList');
         $buttons[] = array(_t('Cities'), 'CityList');
         $buttons[] = array('<b>' . _t('Circulation') . '</b>');
         $buttons[] = array(_t('Check in'), 'CheckInForm');
         $buttons[] = array(_t('Check out'), 'CheckOutForm');
         $buttons[] = array('<b>' . _t('Reports') . '</b>');
         $buttons[] = array(_t('Loans'), 'LoanReport');
         $buttons[] = array(_t('Member'), 'MemberReport');
         $buttons[] = array(_t('Books'), 'BookReport');
         $buttons[] = array('Logout', array('LoginForm', 'onLogout'));
     } else {
         if ($member->role->mnemonic == 'OPERATOR') {
             $buttons = array();
             $buttons[] = array('<b>' . _t('Members') . '</b>');
             $buttons[] = array(_t('Members'), 'MemberList');
             $buttons[] = array(_t('Categories'), 'CategoryFormList');
             $buttons[] = array(_t('Cities'), 'CityList');
             $buttons[] = array('<b>' . _t('Circulation') . '</b>');
             $buttons[] = array(_t('Check in'), 'CheckInForm');
             $buttons[] = array(_t('Check out'), 'CheckOutForm');
             $buttons[] = array('<b>' . _t('Reports') . '</b>');
             $buttons[] = array(_t('Loans'), 'LoanReport');
             $buttons[] = array(_t('Member'), 'MemberReport');
             $buttons[] = array(_t('Books'), 'BookReport');
             $buttons[] = array('Logout', array('LoginForm', 'onLogout'));
         } else {
             if ($member->role->mnemonic == 'ADMINISTRATOR') {
                 $buttons = array();
                 $buttons[] = array('<b>' . 'Admin' . '</b>');
                 $buttons[] = array(_t('Users'), 'UserList');
                 $buttons[] = array(_t('Roles'), 'RoleList');
                 $buttons[] = array('Logout', array('LoginForm', 'onLogout'));
             }
         }
     }
     TTransaction::close();
     $vbox_buttons = new GtkVBox(FALSE, 0);
     $this->scroll->add_with_viewport($vbox_buttons);
     $this->scroll->get_child()->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#EFEFEF'));
     foreach ($buttons as $button_info) {
         if (!isset($button_info[1])) {
             $button = new GtkEventBox();
             $button->add($label = new GtkLabel($button_info[0]));
             $button->set_size_request(-1, 20);
             $label->set_use_markup(TRUE);
             $button->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#C0C0C0'));
         } else {
             $button = new GtkButton($button_info[0]);
             $button->get_child()->set_alignment(0, 0);
             $button->set_property('can-focus', FALSE);
             $button->set_relief(Gtk::RELIEF_NONE);
             $button->modify_bg(Gtk::STATE_PRELIGHT, GdkColor::parse('#CFCFCF'));
             $button->modify_bg(Gtk::STATE_ACTIVE, GdkColor::parse('#CFCFCF'));
             $button->set_size_request(-1, 24);
             $button->connect_simple('clicked', array($this, 'run'), $button_info[1]);
         }
         $vbox_buttons->pack_start($button, FALSE, FALSE, 0);
     }
     $this->scroll->show_all();
 }
Esempio n. 7
0
 /**
  * Add an Action to the DataGrid
  * @param $object A TDataGridAction object
  */
 public function addAction(TDataGridAction $action)
 {
     if ($this->modelCreated) {
         throw new Exception(TAdiantiCoreTranslator::translate('You must call ^1 before ^2', __METHOD__, 'createModel'));
     } else {
         $this->actions[] = $action;
         $button = new GtkButton($action->getLabel());
         if (file_exists('lib/adianti/images/' . $action->getImage())) {
             $button->set_image(GtkImage::new_from_file('lib/adianti/images/' . $action->getImage()));
         } else {
             $button->set_image(GtkImage::new_from_file('app/images/' . $action->getImage()));
         }
         $button->connect_simple('clicked', array($this, 'onExecute'), $action);
         $this->action_area->pack_start($button);
     }
 }
// be brave, use your own tips window
$vbox->add($text = new GtkLabel('Different Tooltips Window'));
$tipswindow = new GtkWindow(Gtk::WINDOW_POPUP);
$content = new GtkLabel('I feel pretty');
$tipswindow->add($content);
$content->show();
$text->set_tooltip_window($tipswindow);
$text->connect('query-tooltip', 'redboxtip');
// trigger tooltip query for the display on button press
$vbox->add($button = new GtkButton('Trigger Tooltip passing Display'));
$button->connect_simple('clicked', array('GtkTooltip', 'trigger_tooltip_query'), GdkDisplay::get_default());
$button->set_has_tooltip(true);
$button->connect('query-tooltip', 'texttip');
// trigger tooltip query for a display where the widget is on button press
$vbox->add($button = new GtkButton('Trigger Tooltip passing Widget'));
$button->connect_simple('clicked', array($label, 'trigger_tooltip_query'));
$button->set_has_tooltip(true);
$button->connect('query-tooltip', 'texttip');
/* Generic liststore for the next tests */
$store = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_STRING, GdkPixbuf::gtype);
$store->append(array('foo', 'tip1', $window->render_icon(Gtk::STOCK_OPEN, Gtk::ICON_SIZE_DIALOG)));
$store->append(array('bar', 'tip2', $window->render_icon(Gtk::STOCK_CLOSE, Gtk::ICON_SIZE_DIALOG)));
$store->append(array('baz', 'tip3', $window->render_icon(Gtk::STOCK_SAVE, Gtk::ICON_SIZE_DIALOG)));
$store->append(array('kitty', 'tip4', $window->render_icon(Gtk::STOCK_OK, Gtk::ICON_SIZE_DIALOG)));
// callback that tells us if we have an item at the spot
function checkcontext($widget, $x, $y, $keyboard_mode, $tooltip)
{
    $list = $widget->get_tooltip_context($x, $y, $keyboard_mode);
    if (!$list) {
        return false;
    }
Esempio n. 9
0
$chkOptionFullscreen = new GtkCheckButton('Fullscreen', true);
$chkOptionMultiSampling = new GtkCheckButton('Multi Sampling', true);
$chkOptionTransparent = new GtkCheckButton('Transparent', true);
$chkOptionSaveConfig = new GtkCheckButton('Save Config File', true);
//buttons
$btnRun = new GtkButton('_Run');
$btnConfigFile = new GtkButton('_Config File');
$btnQuit = new GtkButton('_Quit');
//Which widget should be activated when the
// mnemonic (Alt+U or Alt+P) is pressed?
$lblRepositoryPath->set_mnemonic_widget($txtRepositoryPath);
//Destroy the window when the user clicks Cancel
$btnQuit->connect_simple('clicked', array($wnd, 'destroy'));
// what to do when RUN is pressed
$options = array('chkOptionHideFiles' => $chkOptionHideFiles, 'chkOptionHideFilenames' => $chkOptionHideFilenames, 'chkOptionHideDirnames' => $chkOptionHideDirnames, 'chkOptionHideDates' => $chkOptionHideDates, 'chkOptionHideProgress' => $chkOptionHideProgress, 'chkOptionHideBloom' => $chkOptionHideBloom, 'chkOptionHideMouse' => $chkOptionHideMouse, 'chkOptionHideTree' => $chkOptionHideTree, 'chkOptionHideUsers' => $chkOptionHideUsers, 'chkOptionHideUsernames' => $chkOptionHideUsernames, 'chkOptionFullscreen' => $chkOptionFullscreen, 'chkOptionMultiSampling' => $chkOptionMultiSampling, 'chkOptionTransparent' => $chkOptionTransparent, 'chkOptionSaveConfig' => $chkOptionSaveConfig);
$btnRun->connect_simple('clicked', 'run_gource', $wnd, $txtRepositoryPath, $options);
$btnConfigFile->connect_simple('clicked', 'show_file_select', $wnd);
//Lay out all the widgets in the table
$tbl = new GtkTable(3, 6);
$tbl->attach($lblRepositoryPath, 0, 1, 0, 1);
$tbl->attach($txtRepositoryPath, 1, 3, 0, 1);
//options attach to table
$tbl->attach($chkOptionHideFiles, 0, 1, 1, 2);
$tbl->attach($chkOptionHideFilenames, 0, 1, 2, 3);
$tbl->attach($chkOptionHideDirnames, 0, 1, 3, 4);
$tbl->attach($chkOptionHideDates, 0, 1, 4, 5);
$tbl->attach($chkOptionHideProgress, 0, 1, 5, 6);
$tbl->attach($chkOptionHideBloom, 1, 2, 1, 2);
$tbl->attach($chkOptionHideTree, 1, 2, 2, 3);
$tbl->attach($chkOptionHideUsers, 1, 2, 3, 4);
$tbl->attach($chkOptionHideUsernames, 1, 2, 4, 5);