Пример #1
0
function setup_yes_no_dialog()
{
    $dialog = new GtkDialog();
    $dialog->vbox->pack_start($hbox = new GtkHBox());
    $hbox->pack_start(new GtkLabel('Phone Number: '), 0);
    $hbox->pack_start($phone = new GtkEntry(), 0);
    // note 1
    $dialog->vbox->pack_start($hbox2 = new GtkHBox());
    $button_ok = GtkButton::new_from_stock(Gtk::STOCK_OK);
    $button_ok->set_size_request(87, 33);
    $hbox2->pack_start(new GtkLabel());
    $hbox2->pack_start($button_ok, 0);
    $phone->connect('activate', 'on_enter', $button_ok);
    // note 2
    $button_ok->connect('clicked', 'on_ok_button', $dialog);
    $dialog->set_has_separator(false);
    $dialog->action_area->set_size_request(-1, 1);
    $dialog->show_all();
    $dialog->run();
    $dialog->destroy();
    global $response;
    $response->set_text($phone->get_text());
}
 private function createLabelText($label, $entryVisible = true)
 {
     $labelObj = new GtkLabel($label);
     $labelObj->set_alignment(1, 0.5);
     $entryObj = new GtkEntry();
     $entryObj->set_visibility($entryVisible);
     return array($labelObj, $entryObj);
 }
Пример #3
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();
 }
Пример #4
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);
     }
 }
Пример #5
0
 /**
  * Define if the widget is editable
  * @param $boolean A boolean
  */
 public function setEditable($editable)
 {
     parent::set_sensitive($editable);
 }
Пример #6
0
 /**
  * Define options for completion
  * @param $options array of options for completion
  */
 function setCompletion($options)
 {
     $store = new GtkListStore(GObject::TYPE_STRING);
     if (is_array($options)) {
         foreach ($options as $option) {
             $store->append(array($option));
         }
     }
     $completion = new GtkEntryCompletion();
     $completion->set_model($store);
     $completion->set_text_column(0);
     parent::set_completion($completion);
 }
Пример #7
0
<?php

$window = new GtkWindow();
$window->set_size_request(400, 200);
$window->set_position(Gtk::WIN_POS_CENTER_ALWAYS);
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$window->add($vbox = new GtkVBox());
// display title
$title = new GtkLabel("Change the background color and\nset the font and color of GtkEntry");
$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);
$vbox->pack_start($title, 0, 0);
$entry = new GtkEntry();
$entry->modify_base(Gtk::STATE_NORMAL, GdkColor::parse('#ffff00'));
// note 1
$entry->modify_text(Gtk::STATE_NORMAL, GdkColor::parse('#0000ff'));
// note 2
$entry->modify_font(new PangoFontDescription("Arial Black 12"));
// note 3
$hbox = new GtkHBox();
$hbox->pack_start(new GtkLabel('Item Number: '), 0, 0);
$hbox->pack_start($entry, 0, 0);
$vbox->pack_start($hbox);
$window->show_all();
Gtk::main();
Пример #8
0
function run_gource(GtkWindow $wnd, GtkEntry $txtRepositoryPath, $options)
{
    //fetch the values from the widgets into variables
    $strRepositoryPath = $txtRepositoryPath->get_text();
    //Do some error checking
    $errors = null;
    if (strlen($strRepositoryPath) == 0) {
        $errors .= "you need some path!.\r\n";
    }
    if ($errors !== null) {
        //save setting
        $settings = new Settings();
        $settings->set("last_repo_path", $strRepositoryPath);
        //There was at least one error.
        //We show a message box with the errors
        $dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, $errors);
        $dialog->set_markup("The following errors occured:\r\n" . "<span foreground='red'>" . $errors . "</span>");
        $dialog->run();
        $dialog->destroy();
    } else {
        $dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
        $dialog->set_markup("running gource on repository...\npath: " . $txtRepositoryPath->get_text() . "\n");
        $dialog->run();
        $dialog->destroy();
        $arr_hide_options = array();
        $arr_normal_options = array();
        foreach ($options as $option_name => $option) {
            if ($option->get_active() != 1) {
                continue;
            }
            switch ($option_name) {
                case 'chkOptionHideFiles':
                    $arr_hide_options[] = "files";
                    break;
                case 'chkOptionHideFilenames':
                    $arr_hide_options[] = "filenames";
                    break;
                case 'chkOptionHideDirnames':
                    $arr_hide_options[] = "dirnames";
                    break;
                case 'chkOptionHideDates':
                    $arr_hide_options[] = "date";
                    break;
                case 'chkOptionHideProgress':
                    $arr_hide_options[] = "progress";
                    break;
                case 'chkOptionHideBloom':
                    $arr_hide_options[] = "bloom";
                    break;
                case 'chkOptionHideMouse':
                    $arr_hide_options[] = "mouse";
                    break;
                case 'chkOptionHideTree':
                    $arr_hide_options[] = "tree";
                    break;
                case 'chkOptionHideUsers':
                    $arr_hide_options[] = "users";
                    break;
                case 'chkOptionHideUsernames':
                    $arr_hide_options[] = "usernames";
                    break;
                case 'chkOptionFullscreen':
                    $arr_normal_options[] = "--fullscreen";
                    break;
                case 'chkOptionMultiSampling':
                    $arr_normal_options[] = "--multi-sampling";
                    break;
                case 'chkOptionTransparent':
                    $arr_normal_options[] = "--transparent";
                    break;
                case 'chkOptionSaveConfig':
                    $arr_normal_options[] = "--save-config default.conf";
                    break;
            }
        }
        // "&" is added to run gource in background
        if (!empty($arr_hide_options)) {
            $str_hide_options = implode(',', $arr_hide_options);
            $str_normal_options = implode(' ', $arr_normal_options);
            system('gource ' . $txtRepositoryPath->get_text() . " --hide {$str_hide_options} {$str_normal_options} &", $gource_return);
        } else {
            $str_normal_options = implode(' ', $arr_normal_options);
            system('gource ' . $txtRepositoryPath->get_text() . " {$str_normal_options}  &", $gource_return);
        }
        //No error. You would need to hide the dialog now
        //instead of destroying it (because when you destroy it,
        //Gtk::main_quit() gets called) and show the main window
        //$wnd->destroy();
    }
}
 /**
  * Método que seta o valor no campo
  * 
  * @name __setMask($text)
  * @access private
  * @author Pablo Dall'Oglio
  * @param string $text Texto da mascará a ser setado
  */
 public function __setMask($text)
 {
     // Desconectando o sinal changed
     parent::disconnect($this->__maskConnection);
     // Seta o texto do entry
     parent::set_text($text);
     // Posiciona o cursor no final do texto
     parent::select_region(-1, -1);
     // Reconecta changed
     $this->__maskConnection = parent::connect_after("changed", array($this, "__changeMask"));
 }