m ("Exit"); $fileMenu->append ($open); $open->connect_object ('activate', 'showFileSelection'); $fileMenu->append ($save); $save->connect_object ('activate', 'saveFile'); $fileMenu->append ($line); $fileMenu->append ($exit); $exit->connect_object ('activate', array ('gtk', 'main_quit'));
$file->set_submenu ($fileMenu);
$scroll = &new GtkScrolledWindow (); $scroll->set_border_width (8); $scroll->set_policy (GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); $hbox->pack_start ($scroll, true, true, 0); $vbox->pack_start ($hbox, true, true, 1);
$text = &new GtkText (); $text->set_editable (true); $text->set_word_wrap (true); $scroll->add ($text);
function showFileSelection () // 文件选择函数 { $file = &new GtkFileSelection ("File Selection"); $ok_button = $file->ok_button; $ok_button->connect ('clicked', 'openFile', $file); $ok_button->connect_object ('clicked', array ($file, 'destroy')); $cancel_button = $file->cancel_button; $cancel_button->connect_object ('clicked', array ($file, 'destroy')); $file->show (); }
$filePath = null; function openFile ($button, $f) // 打开文件的函数 { GLOBAL $text, $save, $filePath; $filePath = $f->get_filename (); if (is_file ($filePath)) &nbs上一页 [1] [2] [3] [4] [5] 下一页 |