Diff
Modified: trunk/programs/ide/lib/ide.class.php (84 => 85)
--- trunk/programs/ide/lib/ide.class.php 2007-01-03 13:03:34 UTC (rev 84)
+++ trunk/programs/ide/lib/ide.class.php 2007-01-05 13:10:28 UTC (rev 85)
@@ -113,6 +113,7 @@
public function __construct()
{
parent::__construct();
+ $this->set_position(Gtk::WIN_POS_CENTER);
$this->set_name('ide');
$this->set_title('Callicore Development Enviroment');
CC_Wm::add_window($this);
@@ -133,7 +134,7 @@
'short-label' => '_Run',
'tooltip' => 'Run File',
'callback' => array($this, 'on_run'),
- 'image' => 'gtk-run',
+ 'image' => 'gtk-play',
)
);
$actions->add_action('file',
@@ -242,12 +243,11 @@
public function on_open(){
echo "open file\n";
- $opendialog = new CC_Ide_fileopendialog(array('PHP' => '*.php'));
+ $opendialog = new CC_Ide_fileopendialog(array('PHP' => '*.php'),$this);
if ($opendialog->run() == Gtk::RESPONSE_OK) {
$selected_file = $opendialog->get_filename(); // get the selected filename
echo "selected_file = $selected_file\n";
$this->notebook->open_file($selected_file);
- $this->notebook->show_all();
}
$opendialog->destroy();
}
Modified: trunk/programs/ide/lib/ide_fileopendialog.class.php (84 => 85)
--- trunk/programs/ide/lib/ide_fileopendialog.class.php 2007-01-03 13:03:34 UTC (rev 84)
+++ trunk/programs/ide/lib/ide_fileopendialog.class.php 2007-01-05 13:10:28 UTC (rev 85)
@@ -4,8 +4,8 @@
protected $filetypes = array();
- public function __construct($filetypes = array()){
- parent::__construct("File Open", null,
+ public function __construct($filetypes = array(),GtkWindow $window = null){
+ parent::__construct("File Open", $window,
Gtk::FILE_CHOOSER_ACTION_OPEN,
array(Gtk::STOCK_OK, Gtk::RESPONSE_OK), null);
$this->filetypes = $filetypes;
Modified: trunk/programs/ide/lib/ide_notebook.class.php (84 => 85)
--- trunk/programs/ide/lib/ide_notebook.class.php 2007-01-03 13:03:34 UTC (rev 84)
+++ trunk/programs/ide/lib/ide_notebook.class.php 2007-01-05 13:10:28 UTC (rev 85)
@@ -3,89 +3,123 @@
class CC_Ide_notebook extends GtkNotebook {
protected $buffers = array();
+ static $count = 0;
public function __construct(){
parent::__construct();
+ $this->set_scrollable(true);
+ $this->set_tab_pos(Gtk::POS_BOTTOM);
}
public function new_file(){
+ self::$count++;
$view = new GtkScrolledWindow();
$lang_mgr = new GtkSourceLanguagesManager();
# removed lang_mgr to cant seem to get it working since using new builds
//$lang = $lang_mgr->get_language_from_mime_type("text/x-php");
- $buffer = new GtkSourceBuffer(); //::new_with_language($lang);
+ //$buffer = new GtkSourceBuffer::new_with_language($lang);
+ $buffer = new GtkSourceBuffer();
$source = GtkSourceView::new_with_buffer($buffer);
$source->set_show_line_numbers(1);
$buffer->set_highlight(1);
$view->add($source);
- $eventbox = new GtkEventBox();
+ //$eventbox = new GtkEventBox();
+ $hbox = new GtkHBox();
+ $button = new GtkButton('X');
$label = new GtkLabel('untitled');
- $eventbox->add($label);
+ //$eventbox->add($label);
+ $hbox->pack_start($label);
+ $hbox->pack_start($button);
$label->show();
- $id = $this->append_page($view,$eventbox);
- $this->buffers[$id] = $buffer;
+ $button->show();
+ $id = $this->append_page($view,$hbox);
+ $view->set_data('tab_id',self::$count);
+ $button->connect('clicked', array($this,'tab_close'),$view);
+ $this->buffers[self::$count] = $buffer;
+ $this->show_all();
}
+ public function tab_close($button, $view){
+ $id = $view->get_data('tab_id');
+ $this->buffers[$id] = null;
+ unset($this->buffers[$id]);
+ $id = $this->page_num($view);
+ $this->remove_page($id);
+ }
+
public function open_file($filename){
if (file_exists($filename)) {
+ self::$count++;
echo "file exists $filename\n";
$view = new GtkScrolledWindow();
$lang_mgr = new GtkSourceLanguagesManager();
- $lang = $lang_mgr->get_language_from_mime_type("text/x-php");
- $buffer = GtkSourceBuffer::new_with_language($lang);
+ # removed lang_mgr to cant seem to get it working since using new builds
+ //$lang = $lang_mgr->get_language_from_mime_type("text/x-php");
+ //$buffer = new GtkSourceBuffer::new_with_language($lang);
+ $buffer = new GtkSourceBuffer();
$source = GtkSourceView::new_with_buffer($buffer);
$source->set_show_line_numbers(1);
$buffer->set_highlight(1);
$buffer->set_text(file_get_contents($filename));
$view->add($source);
- $eventbox = new GtkEventBox();
+ //$eventbox = new GtkEventBox();
+ $hbox = new GtkHBox();
+ $button = new GtkButton('X');
$label = new GtkLabel(basename($filename));
- $eventbox->add($label);
+ //$eventbox->add($label);
+ $hbox->pack_start($label);
+ $hbox->pack_start($button);
$label->show();
- $id = $this->append_page($view,$eventbox);
- $this->buffers[$id] = $buffer;
+ $button->show();
+ $id = $this->append_page($view,$hbox);
+ //$button->set_data('tab_id',self::$count);
+ $view->set_data('tab_id',self::$count);
+ $button->connect('clicked', array($this,'tab_close'),$view);
+ $this->buffers[self::$count] = $buffer;
}
}
public function copy(){
$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
- $id = $this->get_current_page();
+ $child = $this->get_nth_page($this->get_current_page());
+ $id = $child->get_data('tab_id');
$this->buffers[$id]->copy_clipboard($cb);
}
public function cut(){
$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
- $id = $this->get_current_page();
+ $child = $this->get_nth_page($this->get_current_page());
+ $id = $child->get_data('tab_id');
$this->buffers[$id]->cut_clipboard($cb,true);
}
public function paste(){
$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
- $id = $this->get_current_page();
+ $child = $this->get_nth_page($this->get_current_page());
+ $id = $child->get_data('tab_id');
// need to remove nasty @ error suppresion
$iter = @$this->buffers[$id]->get_iter_at_mark($this->buffers[$id]->get_mark('cursor'));
$this->buffers[$id]->paste_clipboard($cb,$iter,true);
}
public function undo(){
- $id = $this->get_current_page();
+ $child = $this->get_nth_page($this->get_current_page());
+ $id = $child->get_data('tab_id');
if ($this->buffers[$id]->can_undo()) {
$this->buffers[$id]->undo();
}
}
public function redo(){
- $id = $this->get_current_page();
+ $child = $this->get_nth_page($this->get_current_page());
+ $id = $child->get_data('tab_id');
if ($this->buffers[$id]->can_redo()) {
$this->buffers[$id]->redo();
}
}
public function run(){
- //$id = $this->get_current_page();
- //$code = $this->buffers[$id]->get_text($this->buffers[$id]->get_start_iter(),$this->buffers[$id]->get_end_iter());
- //$sandbox = new Runkit_Sandbox();
- //$sandbox->eval($code);
+ // RUN FUNCTION NOT COMPLETE YET
}
}