function alert($msg) { // note 1 $dialog = new GtkDialog('Alert', null, Gtk::DIALOG_MODAL); // create a new dialog $dialog->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $top_area = $dialog->vbox; // note 2 $top_area->pack_start($hbox = new GtkHBox()); // note 3 $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG); // note 4 $hbox->pack_start($stock, 0, 0); // stuff in the icon $hbox->pack_start(new GtkLabel($msg)); // and the msg $dialog->add_button(Gtk::STOCK_OK, Gtk::RESPONSE_OK); // note 5 $dialog->set_has_separator(false); // don't display the set_has_separator $dialog->show_all(); // show the dialog $dialog->run(); // the dialog in action $dialog->destroy(); // done. close the dialog box. }
function __construct($Parent, $CodId) { parent::__construct('Estornar Conta a Receber', 400, -1, 'contas_receber.png'); $this->Parent = $Parent; $this->CodId = $CodId; // Id. $this->pack_start($hbox = new GtkHBox()); $hbox->pack_start(GtkImage::new_from_stock(Gtk::STOCK_CANCEL, Gtk::ICON_SIZE_DIALOG), false); $hbox->pack_start($label = new GtkLabel(), false); $label->set_markup(' Cod. Id.: <b>' . $CodId . '</b>'); // anotacoes $this->pack_start($hbox = new GtkHBox(), false); $hbox->pack_start(new GtkLabel(latin1(' Anotações: ')), false); $hbox->pack_start($this->anotacoes = new AEntry(true)); // ok $this->pack_start($hbbox = new GtkHButtonBox(), false); $hbbox->set_layout(Gtk::BUTTONBOX_END); $hbbox->pack_start($this->ok = GtkButton::new_from_stock('gtk-ok'), false); $this->anotacoes->focus_widget = $this->ok; $this->ok->connect('clicked', array($this, 'ok_clicked')); // cancelar $hbbox->pack_start($this->cancelar = GtkButton::new_from_stock('gtk-cancel'), false); $this->cancelar->connect('clicked', array($this, 'cancelar_clicked')); $this->cancelar->add_accelerator('clicked', $this->accel_group, Gdk::KEY_Escape, 0, 0); $this->children_show_all(); $this->anotacoes->grab_focus(); }
function on_interactive_dialog_clicked($button) { $dialog = new GtkDialog('Interactive Dialog', $this, 0, array(Gtk::STOCK_OK, Gtk::RESPONSE_OK, '_Non-stock button', Gtk::RESPONSE_CANCEL)); $hbox = new GtkHBox(false, 8); $hbox->set_border_width(8); $dialog->vbox->pack_start($hbox, false, false, 0); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, false, false, 0); $table = new GtkTable(2, 2); $table->set_row_spacings(4); $table->set_col_spacings(4); $hbox->pack_start($table, true, true, 0); $label = new GtkLabel('Entry _1'); $label->set_use_underline(true); $table->attach($label, 0, 1, 0, 1); $local_entry1 = new GtkEntry(); $local_entry1->set_text($this->entry1->get_text()); $table->attach($local_entry1, 1, 2, 0, 1); $label->set_mnemonic_widget($local_entry1); $label = new GtkLabel('Entry _2'); $label->set_use_underline(true); $table->attach($label, 0, 1, 1, 2); $local_entry2 = new GtkEntry(); $local_entry2->set_text($this->entry2->get_text()); $table->attach($local_entry2, 1, 2, 1, 2); $label->set_mnemonic_widget($local_entry2); $dialog->show_all(); $response = $dialog->run(); if ($response == Gtk::RESPONSE_OK) { $this->entry1->set_text($local_entry1->get_text()); $this->entry2->set_text($local_entry2->get_text()); } $dialog->destroy(); }
/** * Constructor Method */ function __construct() { parent::__construct(); parent::set_size_request(840, 640); parent::set_position(GTK::WIN_POS_CENTER); parent::connect_simple('delete-event', array($this, 'onClose')); parent::connect_simple('destroy', array('Gtk', 'main_quit')); parent::set_title(self::APP_TITLE); parent::set_icon(GdkPixbuf::new_from_file('favicon.png')); $gtk = GtkSettings::get_default(); $gtk->set_long_property("gtk-button-images", TRUE, 0); $gtk->set_long_property("gtk-menu-images", TRUE, 0); self::$inst = $this; $ini = parse_ini_file('application.ini'); $lang = $ini['language']; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); date_default_timezone_set($ini['timezone']); $this->content = new GtkFixed(); $vbox = new GtkVBox(); parent::add($vbox); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false); $MenuBar = TMenuBar::newFromXML('menu.xml'); $vbox->pack_start($MenuBar, false, false); $vbox->pack_start($this->content, true, true); parent::show_all(); }
function on_delete_confirm() { $dialog = new GtkDialog('CAUTION!', $this, 0, array(Gtk::STOCK_OK, Gtk::RESPONSE_OK, Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL)); $hbox = new GtkHBox(false, 8); $hbox->set_border_width(8); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $confirm_text1 = new GtkLabel('Are you sure you want to proceed ?'); $confirm_text2 = new GtkLabel('Note: This process is irreversible.'); $confirm_text3 = new GtkLabel($this->selected_file); $confirm_text3->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#ff0000")); $vbox2 = new GtkVBox(); $vbox2->pack_start($confirm_text1); $vbox2->pack_start($confirm_text2); $vbox2->pack_start($confirm_text3); $hbox->pack_start($stock, false, false, 0); $hbox->pack_start($vbox2, false, false, 0); $dialog->vbox->pack_start($hbox, false, false, 0); $dialog->show_all(); $response = $dialog->run(); if ($response == Gtk::RESPONSE_OK) { $resp = $this->delete_file(); if ($resp) { $this->on_delete_successful(); $this->selected_file = ""; $this->file_label->set_text($this->file_label_default); } else { $this->selected_file = ""; $this->file_label->set_text('Unable to delete the specified file.'); } } $dialog->destroy(); }
public function menuCreate($xml, $mainObject) { // Cria o menu // @since rev 1 $menu = new GtkMenu(); // Cria o vetor // @since rev 1 $obj = array(); $obj['object'] = new GtkMenuItem((string) $xml['title']); $obj['object']->set_submenu($menu); // Percorre os itens // @since rev 1 foreach ($xml as $xmlItem) { // Guarda o nome do item // @since rev 1 $name = (string) $xmlItem['name']; $title = (string) $xmlItem['title']; $onclick = (string) $xmlItem['onclick']; // Verifica se é um submenu, um item, um separador // @since rev 1 if ($xmlItem->getName() == "menu") { // Cria o submenu // @since rev 1 $subObj = FMenus::menuCreate($xmlItem, $mainObject); $menu->append($subObj['object']); $obj[$name] = $subObj; } elseif ($xmlItem->getName() == "separator") { $menu->append(new GtkSeparatorMenuItem()); } else { // Verifica se possui sock icon // @since rev 1 $stockicon = (string) $xmlItem['stockicon']; if (defined($stockicon)) { $obj[$name] = new GtkImageMenuItem($title); $obj[$name]->set_image(GtkImage::new_from_stock(constant($stockicon), Gtk::ICON_SIZE_MENU)); } else { $obj[$name] = new GtkMenuItem($title); } // Verifica se existe evento // @since rev 1 if (strlen($onclick) > 0) { // Verifica se é orientado à objeto // @since rev 1 if ($mainObject != NULL) { $function = array($mainObject, $onclick); } else { $function = $onclick; } $obj[$name]->connect_simple("activate", $function); } // Adiciona o item // @since rev 1 $menu->append($obj[$name]); } } // Retorna o objeto // @since rev 1 return $obj; }
/** * Define the icon of the button * @param $image image path */ public function setImage($image) { if (file_exists('lib/adianti/images/' . $image)) { $imagem = GtkImage::new_from_file('lib/adianti/images/' . $image); } else { $imagem = GtkImage::new_from_file('app/images/' . $image); } $this->widget->set_image($imagem); }
/** * Define the icon of the button * @param $image image path */ public function setImage($image) { if (file_exists('lib/adianti/images/' . $image)) { $imagem = GtkImage::new_from_file('lib/adianti/images/' . $image); } else { $imagem = GtkImage::new_from_file('app/images/' . $image); } parent::set_image($imagem); }
/** * 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); }
function append($icon, $label, $index, $callback = null) { $button = new GtkToolButton(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . $icon), $label); $this->add($button); $button->set_visible_horizontal(true); $button->set_visible_vertical(true); if ($callback) { $button->connect('clicked', $callback); } return $button; }
/** * Class Constructor * @param $message A string containint the question * @param $action_yes Action taken for YES response * @param $action_no Action taken for NO response */ public function __construct($message, TAction $action_yes, TAction $action_no = NULL) { $buttons = array(Gtk::STOCK_YES, Gtk::RESPONSE_YES); if ($action_no instanceof TAction) { $buttons[] = Gtk::STOCK_NO; $buttons[] = Gtk::RESPONSE_NO; } $buttons[] = Gtk::STOCK_CANCEL; $buttons[] = Gtk::RESPONSE_CANCEL; parent::__construct('', NULL, Gtk::DIALOG_MODAL, $buttons); parent::set_position(Gtk::WIN_POS_CENTER); parent::set_size_request(500, 300); $textview = new GtkTextView(); $textview->set_wrap_mode(Gtk::WRAP_WORD); $textview->set_border_width(12); $textbuffer = $textview->get_buffer(); $tagtable = $textbuffer->get_tag_table(); $customTag = new GtkTextTag(); $tagtable->add($customTag); $customTag->set_property('foreground', '#525252'); $tagBegin = $textbuffer->create_mark('tagBegin', $textbuffer->get_end_iter(), true); $textbuffer->insert_at_cursor("\n " . $message); $tagEnd = $textbuffer->create_mark('tagEnd', $textbuffer->get_end_iter(), true); $start = $textbuffer->get_iter_at_mark($tagBegin); $end = $textbuffer->get_iter_at_mark($tagEnd); $textbuffer->apply_tag($customTag, $start, $end); $textview->set_editable(FALSE); $textview->set_cursor_visible(FALSE); $pango = new PangoFontDescription('Sans 14'); $textview->modify_font($pango); $image = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $scroll = new GtkScrolledWindow(); $scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); $scroll->add($textview); $hbox = new GtkHBox(); $this->vbox->pack_start($hbox); $hbox->pack_start($image, FALSE, FALSE); $hbox->pack_start($scroll, TRUE, TRUE); $this->show_all(); $result = parent::run(); if ($result == Gtk::RESPONSE_YES) { parent::destroy(); call_user_func_array($action_yes->getAction(), array($action_yes->getParameters())); } else { if ($result == Gtk::RESPONSE_NO) { parent::destroy(); call_user_func_array($action_no->getAction(), array($action_no->getParameters())); } else { parent::destroy(); } } }
function __construct() { parent::__construct(); parent::set_title('Adianti Framework :: Samples'); $this->content = new GtkFixed(); $vbox = new GtkVBox(); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false); $MenuBar = TMenuBar::newFromXML('menu.xml'); $vbox->pack_start($MenuBar, false, false); $vbox->pack_start($this->content, true, true); parent::add($vbox); parent::show_all(); }
function __construct($required = false, $duplicated = false, $table = null, $field = null) { parent::__construct($required, $duplicated, $table, $field); $this->label->set_text(' Data: '); $this->entry->set_editable(false); $this->entry->set_max_length(10); /* max 99/99/9999 */ $this->entry->set_width_chars(10); $this->entry->connect('changed', array($this, 'data_changed')); $this->eventbox->add($button = new GtkButton()); $button->add(GtkImage::new_from_stock(Gtk::STOCK_PROPERTIES, Gtk::ICON_SIZE_BUTTON)); $button->connect('clicked', array($this, 'prop_clicked'), $this->entry); $this->extra_key = 47; /* / */ }
function __construct() { parent::__construct(); parent::set_title('Adianti Framework :: Samples'); $this->content = new GtkFixed(); $vbox = new GtkVBox(); $scroll = new GtkScrolledWindow(); $scroll->set_policy(GTK::POLICY_AUTOMATIC, GTK::POLICY_ALWAYS); $scroll->set_size_request(200, -1); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader.png'), false, false); $MenuBar = TMenuBar::newFromXML('menu.xml'); $vbox->pack_start($MenuBar, false, false); $vbox->pack_start($this->content, true, true); parent::add($vbox); parent::show_all(); }
/** * Class Constructor * @param $label The menu label * @param $action The menu action * @param $image The menu image */ public function __construct($label, $action, $image = NULL) { parent::__construct(utf8_decode($label)); // converts into ISO parent::set_image(null); if (OS == 'WIN') { parent::set_border_width(3); } $this->label = $label; $this->action = $action; $this->image = $image; if (file_exists($image)) { parent::set_image(GtkImage::new_from_file($image)); } $inst = TApplication::getInstance(); if ($inst instanceof TApplication) { parent::connect_simple('activate', array($inst, 'run'), $action); } }
public function __construct($message) { parent::__construct(); $this->strings = KioskClient::getStrings(); $this->set_default_size(300, 200); $this->set_resizable(false); $this->set_keep_above(true); $this->set_title("Message: {$message}"); $this->messageLabel = new GtkLabel(); $this->messageLabel->set_use_markup(true); $this->messageLabel->set_markup($this->strings["message_begin"] . $message . $this->strings["message_end"]); $this->set_title($message); $hbox = new GtkHBox(); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, 0, 0); $hbox->pack_start($this->messageLabel); $this->add($hbox); $this->show_all(); }
/** * Class Constructor * @param $type Type of the message (info, error) * @param $message Message to be shown * @param $action Action to be processed when closing the dialog */ public function __construct($type, $message, TAction $action = NULL) { parent::__construct('', NULL, Gtk::DIALOG_MODAL, array(Gtk::STOCK_OK, Gtk::RESPONSE_OK)); parent::set_position(Gtk::WIN_POS_CENTER); parent::set_size_request(500, 300); $textview = new GtkTextView(); $textview->set_wrap_mode(Gtk::WRAP_WORD); $textview->set_border_width(12); $textbuffer = $textview->get_buffer(); $tagtable = $textbuffer->get_tag_table(); $customTag = new GtkTextTag(); $tagtable->add($customTag); $customTag->set_property('foreground', '#525252'); $message = "\n " . str_replace('<br>', "\n ", $message); $tagBegin = $textbuffer->create_mark('tagBegin', $textbuffer->get_end_iter(), true); $textbuffer->insert_at_cursor(strip_tags($message)); $tagEnd = $textbuffer->create_mark('tagEnd', $textbuffer->get_end_iter(), true); $start = $textbuffer->get_iter_at_mark($tagBegin); $end = $textbuffer->get_iter_at_mark($tagEnd); $textbuffer->apply_tag($customTag, $start, $end); $textview->set_editable(FALSE); $textview->set_cursor_visible(FALSE); $pango = new PangoFontDescription('Sans 14'); $textview->modify_font($pango); $image = $type == 'info' ? GtkImage::new_from_stock(Gtk::STOCK_DIALOG_INFO, Gtk::ICON_SIZE_DIALOG) : GtkImage::new_from_stock(Gtk::STOCK_DIALOG_ERROR, Gtk::ICON_SIZE_DIALOG); $scroll = new GtkScrolledWindow(); $scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); $scroll->add($textview); $hbox = new GtkHBox(); $this->vbox->pack_start($hbox); $hbox->pack_start($image, FALSE, FALSE); $hbox->pack_start($scroll, TRUE, TRUE); $this->show_all(); parent::connect('key_press_event', array($this, 'onClose')); $result = parent::run(); if ($result == Gtk::RESPONSE_OK) { if ($action) { $parameters = $action->getParameters(); call_user_func_array($action->getAction(), array($parameters)); } } parent::destroy(); }
function __construct($required = false, $duplicated = false, $table = null, $field = null) { parent::__construct(); $this->pack_start($this->label = new GtkLabel(), false); $this->pack_start($this->entry = new GtkEntry()); $this->pack_start($this->eventbox = new GtkEventBox(), false); $this->pack_start($this->status = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_BUTTON), false); $this->required = $required; $this->duplicated = $duplicated; $this->table = $table; $this->field = $field; $entry_next_focus = $GLOBALS['ENTRY_NEXT_FOCUS']; if ($entry_next_focus instanceof GtkWidget) { EntrySetNextFocus($entry_next_focus, $this->entry); } $this->entry->connect('changed', array($this, '__tentry_changed')); $this->entry->connect('focus_in_event', array($this, '__tentry_focus_in_event')); $this->entry->connect('focus_out_event', array($this, '__tentry_focus_out_event')); $GLOBALS['ENTRY_NEXT_FOCUS'] = $this->entry; }
function __construct() { parent::__construct(); parent::set_title('Adianti Framework :: Library'); $this->content = new GtkFixed(); $vbox = new GtkVBox(); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false); $hbox = new GtkHBox(); $vbox->pack_start($hbox, true, true); $frame = new GtkFrame(); $frame->add($this->content); $this->scroll = new GtkScrolledWindow(); $this->scroll->set_policy(GTK::POLICY_AUTOMATIC, GTK::POLICY_ALWAYS); $this->scroll->set_size_request(200, -1); $hbox->pack_start($this->scroll, false, false); $hbox->pack_start($frame, true, true); parent::add($vbox); parent::show_all(); $this->run('LoginForm'); }
/** * Class Constructor * @param $name = Name of the column in the database * @param $label = Text label that will be shown in the header * @param $align = Column align (left, center, right) * @param $width = Column Width (pixels) */ public function __construct($name, $label, $align, $width = NULL) { $this->name = $name; $this->label = $label; $this->align = $align; $this->width = (int) $width; if ($align == 'left') { $alignment = 0.0; } else { if ($align == 'center') { $alignment = 0.5; } else { if ($align == 'right') { $alignment = 1.0; } } } parent::__construct(); $this->renderer = new GtkCellRendererText(); if ($width) { $this->renderer->set_property('width', $width); parent::set_fixed_width($width); } $this->renderer->set_property('xalign', $alignment); parent::pack_start($this->renderer, true); parent::set_alignment($alignment); parent::set_title($label); $header_hbox = new GtkHBox(); $header_label = new GtkLabel($this->label); $header_hbox->pack_start($header_label); $this->sort_up = GtkImage::new_from_stock(GTK::STOCK_GO_UP, Gtk::ICON_SIZE_MENU); $this->sort_down = GtkImage::new_from_stock(GTK::STOCK_GO_DOWN, Gtk::ICON_SIZE_MENU); $header_hbox->pack_start($this->sort_up); $header_hbox->pack_start($this->sort_down); $header_hbox->show_all(); // hide the ordering images $this->sort_up->hide(); $this->sort_down->hide(); parent::set_widget($header_hbox); }
public function __construct($message) { parent::__construct(); $this->strings = KioskClient::getStrings(); $this->set_position(GtK::WIN_POS_CENTER_ALWAYS); $this->set_default_size(200, 100); $this->set_resizable(false); $this->set_modal(false); $alertMessage = new GtkLabel(); $alertMessage->set_use_markup(true); $alertMessage->set_markup($message); $this->vbox->pack_start($hbox = new GtkHBox()); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, 0, 0); $hbox->pack_start($alertMessage); $this->add_button(Gtk::STOCK_OK, Gtk::RESPONSE_OK); $this->action_area->set_layout(Gtk::BUTTONBOX_SPREAD); $this->set_has_separator(false); $this->show_all(); $this->run(); $this->destroy(); }
function __construct() { parent::__construct(); $this->set_border_width(10); $this->set_title('X-Money - Login'); $this->set_icon_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'logo.png'); $this->vbox->pack_start($hbox = new GtkHBox()); $hbox->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'logo.png')); $hbox->pack_start($vbox = new GtkVBox()); $vbox->pack_start($frame = new GtkFrame(latin1(' Digite suas informações para acessar o sistema: '))); $frame->set_border_width(10); $frame->add($table = new GtkTable()); $table->attach(new GtkLabel('Usuario:'), 0, 1, 0, 1); $table->attach($this->username = new GtkEntry(), 1, 2, 0, 1); $table->attach(new GtkLabel('Senha:'), 0, 1, 1, 2); $table->attach($this->password = new GtkEntry(), 1, 2, 1, 2); $this->password->set_visibility(false); $this->ok = $this->add_button('_Ok', Gtk::RESPONSE_OK); $this->add_button('_Cancelar', Gtk::RESPONSE_CANCEL); EntrySetNextFocus($this->username, $this->password); EntrySetNextFocus($this->password, $this->ok); $this->vbox->show_all(); }
/** * Cria um novo item * * @name append_item($title, $callback=NULL) * @param string $title Texto do item * @param mixed $callback Função de callback * @param GtkStockItem StockID do icone para aparecer * @return GtkMenuItem */ public function append_item($title, $callback = NULL, $stock = NULL) { // Verifica o stock if ($stock == NULL) { // Cria o item $menuitem = Fabula::GtkMenuItem($title); } else { // Cria o item com imagem $menuitem = new GtkImageMenuItem($title); $image = GtkImage::new_from_stock($stock, Gtk::ICON_SIZE_MENU); $menuitem->set_image($image); } // Adiciona o item ao menu $this->append($menuitem); // Atualiza o widget $this->show_all(); // Verifica o callback if ($callback !== NULL) { $menuitem->connect("activate", $callback); } // Retorna o menuitem return $menuitem; }
function alert($msg) { $dialog = new GtkDialog('Alert', null, Gtk::DIALOG_MODAL); $dialog->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $top_area = $dialog->vbox; $top_area->pack_start($hbox = new GtkHBox()); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, 0, 0); $hbox->pack_start(new GtkLabel($msg)); $dialog->add_button(Gtk::STOCK_OK, Gtk::RESPONSE_OK); $dialog->set_has_separator(false); $dialog->show_all(); $dialog->run(); $dialog->destroy(); }
function evt__mostrar_opciones() { $objeto_cmd = $this->get_objeto_comando($this->seleccion); $this->opciones = $objeto_cmd->inspeccionar_opciones(); $this->comp['label_info']->set_markup($objeto_cmd->get_info_extra()); //------ Cambia algunas cosas de lugar if ($objeto_cmd instanceof comando_base) { $opciones_a_sacar = array('listar', 'registrar'); $hay_que_sacar = $objeto_cmd->tiene_definido_base(); foreach (array_keys($this->opciones) as $id) { $existe = in_array($id, $opciones_a_sacar); if ($existe && $hay_que_sacar) { unset($this->opciones[$id]); } if (!$existe && !$hay_que_sacar) { unset($this->opciones[$id]); } } } //----------------------------------- $i = 0; foreach ($this->opciones as $opcion => $atributos) { if (!isset($atributos['tags']['gtk_no_mostrar'])) { $nombre = ucwords(str_replace('_', ' ', $opcion)); $boton = new GtkToolButton(); $boton->set_label($nombre); if (isset($atributos['tags']['gtk_icono'])) { $archivo = $atributos['tags']['gtk_icono']; $img = GtkImage::new_from_file(toba_dir() . '/www/img/' . $archivo); $boton->set_property('icon-widget', $img); } $boton->set_tooltip($this->tooltips, $atributos['ayuda']); $boton->connect('clicked', array($this, 'evt__ejecutar'), $opcion, $atributos); $this->comp['caja_opciones']->insert($boton, $i); //--- Desactivar algunos if ($objeto_cmd instanceof comando_instalacion && ($opcion == 'instalar' || $opcion == 'crear') && toba_modelo_instalacion::existe_info_basica()) { $boton->set_sensitive(false); } //---- $i++; } if (isset($atributos['tags']['gtk_separador'])) { $boton = new GtkSeparatorToolItem(); $this->comp['caja_opciones']->insert($boton, $i); $i++; } } $this->comp['caja_opciones']->show_all(); }
/** * Método que tira o snapshot e mostra no image * * @name make_snapshot() * @return bool */ public function make_snapshot() { // Executa o snapshot usando a aplicação externa exec("streamer -q -c " . $this->device . " -s " . $this->frameSize . " -j " . $this->frameQuality . " -o " . $this->tmpDir . "/" . $this->currentFrame . ".jpeg"); // Atualiza a imagem no GtkImage parent::set_from_file($this->tmpDir . "/" . $this->currentFrame . ".jpeg"); // Verifica se existe imagem para remover if ($this->currentFrame > 0) { unlink($this->tmpDir . "/" . ($this->currentFrame - 1) . ".jpeg"); } // Soma o contador $this->currentFrame++; // Continua return TRUE; }
public function onClickButton($linha, $coluna, $matrizBotao, $jogo) { if ($this->ativarClick) { //Desativa a tela para o usuário não click junto com a IA $buttonImg = $this->matrizBotao[$linha][$coluna]->get_image(); if ($this->ehBandeira($buttonImg)) { //caso o usuário click em uma casa com bandeira $this->jogo->numeroBandeiras++; //essa bandeira não será perdida $this->campoXML->get_widget("labelBandeira")->set_label($this->jogo->numeroBandeiras); } //vai reniciar a contagem do tempo toda vez que um botão //for clicado $this->tempo->zerarTempo(); $this->matrizBotao[$linha][$coluna]->set_sensitive(false); //desativa o botão clicado $campo = $jogo->campo; if ($campo->matriz[$linha][$coluna] > 0) { //Coloca o número no botão $matrizBotao[$linha][$coluna]->set_label($campo->matriz[$linha][$coluna]); //Caso o usuário click em uma bomba. } else { if ($campo->matriz[$linha][$coluna] == -1) { $this->acharBombas(); $buttonImg = $this->matrizBotao[$linha][$coluna]->get_image(); //Marca as bombas que o usuário achou if ($buttonImg != null && $buttonImg->get_name() == "bandeira") { $img = GtkImage::new_from_file("imagens/bomb2.png"); } else { $img = GtkImage::new_from_file("imagens/bomb.png"); } //Coloca a imagem na casa onde tem bomba. $matrizBotao[$linha][$coluna]->set_image($img); if ($this->controle == 0) { if (!$this->jogo->turno) { $this->vencer(); } else { $this->perder(); } } } else { if ($campo->matriz[$linha][$coluna] == 0) { //Caso clique em uma casa com 0 $matrizBotao[$linha][$coluna]->set_label(""); foreach (range($linha - 1, $linha + 1) as $i) { foreach (range($coluna - 1, $coluna + 1) as $j) { if ($campo->verificarIndice($i, $j)) { if (!$matrizBotao[$i][$j]->get_active()) { $matrizBotao[$i][$j]->clicked(); //chamada de recurso para todos os botões adjacentes. } } } } } } } } }
/** * @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(); }
function preenche_itens() { $db = new Database($this, true); if (!$db->link) { return; } /* * Itens disponiveis */ if (!$db->multi_query('SELECT * FROM Vw_Itens')) { return; } while ($line = $db->line()) { $id = $line['id']; $descricao = $line['Descricao']; $cod_menu = $line['CodMenu']; $menu = $line['Menu']; $imagem = $line['Imagem']; $cod_secao = $line['CodSecao']; $secao = latin1($line['Secao']); // Secao if ($this->secoes[$cod_secao] == null) { $this->lista->pack_start($ptr_secao = $this->secoes[$cod_secao] = new GtkExpander(' ' . $secao . ' '), false); $ptr_secao->add(new GtkHBox()); } // Menu if ($this->menus[$cod_menu] == null) { $ptr = $this->menus[$cod_menu] = new GtkFrame(' ' . $menu . ' '); $ptr->set_border_width(5); $ptr->add($children = new GtkVBox()); $children->pack_start(GtkImage::new_from_file('/usr/share/xmoney/images' . DIRECTORY_SEPARATOR . $imagem)); $this->secoes[$cod_secao]->child->pack_start($ptr, false); } // Item if ($this->itens[$id] == null) { $ptr = $this->itens[$id] = new GtkCheckButton(' ' . $descricao . ' '); $this->menus[$cod_menu]->child->pack_start($ptr); } } $this->lista->show_all(); $this->expandir->set_active(true); return true; }
/** * Cria um botão por uma imagem * * @name newButtonFromImage($image, $label=NULL) * @param $image (string): String com caminho do arquivo de imagem * @param $label (string): String com o nome do botão * @return $button (GtkButton): Retorna o botão criado * @deprecated */ public function newButtonFromImage($image, $label = NULL) { // Criação do botão $button = new GtkButton(); // Cria o container interno do botão $button_hbox = new GtkVBox(); $button->add($button_hbox); // Carrega a imagem $img = GtkImage::new_from_file($image); $button_hbox->pack_start($img, 0, 0); // Verifica se possui label if ($label != NULL) { $button_hbox->pack_start(new GtkLabel($label), 0, 0); } // Retorna o botão return $button; }