Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
function setup_yes_no_dialog()
{
    $dialog = new GtkDialog();
    $dialog->set_title('Yes/No Dialog');
    $label = new GtkLabel("Do you like PHP-Gtk2?");
    $dialog->vbox->pack_start($label);
    $button_yes = GtkButton::new_from_stock(Gtk::STOCK_YES);
    // note 1
    $button_no = GtkButton::new_from_stock(Gtk::STOCK_NO);
    // note 2
    $button_yes->connect('clicked', 'on_ok_button', $dialog, 100);
    // note 3
    $button_no->connect('clicked', 'on_ok_button', $dialog, 200);
    $hbox = new GtkHBox();
    // note 4
    $dialog->vbox->pack_start($hbox);
    $hbox->pack_start($button_yes);
    $hbox->pack_start($button_no);
    $dialog->set_has_separator(false);
    $dialog->action_area->set_size_request(-1, 1);
    $dialog->show_all();
    $response_id = $dialog->run();
    $dialog->destroy();
    global $response;
    $response->set_text($response_id);
    // note 6
}
Ejemplo n.º 3
0
 function prop_clicked($button, $ptr_entry)
 {
     $dialog = new GtkDialog('Escolha uma data ...');
     $pixbuf = $dialog->render_icon(Gtk::STOCK_PROPERTIES, Gtk::ICON_SIZE_BUTTON);
     $dialog->set_icon($pixbuf);
     $dialog->vbox->pack_start($calendar = new GtkCalendar());
     $calendar->connect('day-selected-double-click', array($this, 'calendar_double_click'), $dialog, $ptr_entry);
     $calendar->show();
     $dialog->run();
     $dialog->destroy();
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
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.
}
Ejemplo n.º 6
0
function setup_yes_no_dialog()
{
    $dialog = new GtkDialog();
    // note 1
    $dialog->set_title('Yes/No Dialog');
    $label = new GtkLabel("Do you like PHP-Gtk2?");
    $dialog->vbox->pack_start($label);
    // note 2
    $dialog->add_buttons(array(Gtk::STOCK_YES, Gtk::RESPONSE_YES, Gtk::STOCK_NO, Gtk::RESPONSE_NO));
    //
    $dialog->show_all();
    $response_id = $dialog->run();
    // note 4
    $dialog->destroy();
    // note 5
    global $response;
    switch ($response_id) {
        // note 6
        case Gtk::RESPONSE_YES:
            $response->set_text("{$response_id} (Yes)");
            // note 7
            break;
        case Gtk::RESPONSE_NO:
            $response->set_text("{$response_id} (No)");
            break;
    }
}
Ejemplo n.º 7
0
 /**
  * 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();
         }
     }
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     parent::__construct();
     $this->strings = KioskClient::getStrings();
     $this->set_default_size(200, 100);
     $this->set_resizable(false);
     $this->set_modal(true);
     $label = new GtkLabel($this->strings["logoutWarningLabel"]);
     $this->vbox->pack_start($label);
     $this->vbox->show_all();
     $this->add_button(Gtk::STOCK_NO, Gtk::RESPONSE_NO);
     $this->add_button(GtK::STOCK_YES, Gtk::RESPONSE_YES);
 }
Ejemplo n.º 9
0
 function run()
 {
     $db = new Database($this, true);
     if (!$db->link) {
         exit(1);
     }
     while (true) {
         $this->username->grab_focus();
         $response = parent::run();
         $username = $this->username->get_text();
         $password = $this->password->get_text();
         if ($response != Gtk::RESPONSE_OK) {
             exit(1);
         }
         if (!$username || !$password) {
             new Message($this, latin1('Usuário e senha devem ser informados!'), Gtk::MESSAGE_ERROR);
             continue;
         }
         $sql = 'SELECT Cod_S_Usuario FROM Tb_Usuarios WHERE Ativo = 1 AND Senha LIKE ' . String(md5($username . '@' . $password));
         if (!$db->multi_query($sql)) {
             continue;
         }
         if (!($line = $db->line())) {
             new Message($this, latin1('Usuário ou senha incorreta!', Gtk::MESSAGE_ERROR));
             continue;
         } else {
             $CodUsuario = $line['Cod_S_Usuario'];
             putenv('XMONEY_UID=' . $CodUsuario);
         }
         $sql = 'SELECT * FROM Vw_Usuario_Filial WHERE CodUsuario = ' . $CodUsuario;
         if (!$db->multi_query($sql)) {
             continue;
         }
         if (!($line = $db->line())) {
             new Message($this, latin1('Usuário não encontrado!', Gtk::MESSAGE_ERROR));
             continue;
         } else {
             $GLOBALS['CodUsuario'] = $CodUsuario;
             $GLOBALS['Usuario'] = $line['Usuario'];
             $GLOBALS['Nome'] = $line['Nome'];
             $GLOBALS['CodFilial'] = $line['CodFilial'];
             $GLOBALS['Filial'] = $line['Filial'];
             $GLOBALS['CodPerfil'] = $line['CodPerfil'];
             $GLOBALS['Perfil'] = $line['Perfil'];
             break;
         }
     }
 }
Ejemplo n.º 10
0
 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();
 }
Ejemplo n.º 11
0
 /**
  * Executed when the user hits any key
  * @param $widget Source widget of the event
  * @param $event  GdkEvent associated
  * @ignore-autocomplete on
  */
 public function onClose($widget, $event)
 {
     if ($event->keyval == Gdk::KEY_Escape) {
         parent::hide();
     }
 }
 public function autocomplete_window_destroy()
 {
     parent::hide();
     return TRUE;
 }
Ejemplo n.º 13
0
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();
}
Ejemplo n.º 14
0
function create_event_watcher()
{
    static $dialog = null;
    static $event_watcher_enter_id = 0;
    static $event_watcher_leave_id = 0;
    if (!$dialog) {
        $dialog = new GtkDialog();
        $dialog->connect_object('destroy', 'event_watcher_down', &$event_watcher_enter_id, &$event_watcher_leave_id);
        $dialog->connect_object('destroy', create_function('$w', '$w = null;'), &$dialog);
        $dialog->set_title('Event Watcher');
        $dialog->set_border_width(0);
        $dialog->set_usize(200, 110);
        $vbox = $dialog->vbox;
        $action_area = $dialog->action_area;
        $button =& new GtkToggleButton('Activate Watch');
        $button->connect_object('clicked', 'event_watcher_toggle', &$event_watcher_enter_id, &$event_watcher_leave_id);
        $button->set_border_width(10);
        $vbox->pack_start($button);
        $button->show();
        $button =& new GtkButton('Close');
        $button->connect_object('clicked', 'event_watcher_down', &$event_watcher_enter_id, &$event_watcher_leave_id);
        $button->connect_object('clicked', array($dialog, 'destroy'));
        $button->set_flags(GTK_CAN_DEFAULT);
        $action_area->pack_start($button);
        $button->grab_default();
        $button->show();
    }
    if (!($dialog->flags() & GTK_VISIBLE)) {
        $dialog->show();
    } else {
        $dialog->destroy();
    }
}
Ejemplo n.º 15
0
<?php

$dialog = new GtkDialog();
$dialog->connect_simple('destroy', array('Gtk', 'main_quit'));
$dialog->set_size_request(400, 150);
// display title
$title = new GtkLabel("Set Default Button - Part 1\n" . "using set_default_response");
$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, 0, 0);
$alignment->add($title);
$dialog->vbox->pack_start($alignment, 0, 0);
$dialog->vbox->pack_start(new GtkLabel(), 0, 0);
$dialog->add_buttons(array('button 1', 100, 'button 2', 101, 'button 3', 102));
$dialog->set_default_response(101);
// note 2
$dialog->set_has_separator(0);
$dialog->show_all();
$response = $dialog->run();
echo "response = {$response}\n";
Ejemplo n.º 16
0
 function enter_text()
 {
     $dialog = new GtkDialog('Enter text', $this, 0, array(Gtk::STOCK_OK, Gtk::RESPONSE_OK, Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL));
     $hbox = new GtkHBox(false);
     $dialog->vbox->pack_start($hbox, false, false, 0);
     $label = new GtkLabel('String :');
     $entry = new GtkEntry();
     $hbox->pack_start($label);
     $hbox->pack_start($entry);
     $dialog->show_all();
     $response = $dialog->run();
     if ($response == Gtk::RESPONSE_OK) {
         $this->hash_label->set_text($entry->get_text());
         $this->selected_file = $entry->get_text();
     }
     $dialog->destroy();
 }
Ejemplo n.º 17
0
 function GetDate()
 {
     $dialog = new GtkDialog('Get Date', null, Gtk::DIALOG_MODAL);
     $dialog->set_position(Gtk::WIN_POS_CENTER_ALWAYS);
     $top_area = $dialog->vbox;
     //setlocale(LC_ALL, 'english');
     $top_area->pack_start($hbox = new GtkHBox());
     // set up the calendar
     $this->calendar = new GtkCalendar();
     $top_area->pack_start($this->calendar, 0, 0);
     // add an OK button
     $dialog->add_button(Gtk::STOCK_OK, Gtk::RESPONSE_OK);
     $this->dialog = $dialog;
     $dialog->set_has_separator(false);
     $dialog->show_all();
     $dialog->run();
     $dialog->destroy();
 }
Ejemplo n.º 18
0
 /**
  * Método ao tirar o foco do calendario
  * 
  * @name __onlostfocusCalendar($widget, $event, $dialog)
  * @access private
  * @param GtkCalendar $widget Calendario passado pelo sinal
  * @param GtkEvents $event Eventos disparados externamente
  * @param GtkDialog $dialog Container onde está o calendario
  * @return bool
  */
 public function __onlostfocusCalendar($widget, $event, $dialog)
 {
     // Fecha a janela do calendario
     $dialog->destroy();
     return FALSE;
 }