Revision
116
Author
leonpegg
Date
2007-01-12 03:21:56 -0800 (Fri, 12 Jan 2007)

Log Message

Updated classes added preferences

Modified Paths

Added Paths

Diff

Modified: trunk/programs/ide/lib/ide.class.php (115 => 116)


--- trunk/programs/ide/lib/ide.class.php	2007-01-12 01:25:44 UTC (rev 115)
+++ trunk/programs/ide/lib/ide.class.php	2007-01-12 11:21:56 UTC (rev 116)
@@ -9,6 +9,7 @@
 	protected $pane_right;
 	
 	protected $website = 'http://callicore.net/desktop/ide';
+	protected $name = 'ide';
 	
 	protected $menubar = array(
 		'_File' => array(
@@ -84,7 +85,6 @@
 	{
 		parent::__construct();
 		$this->set_position(Gtk::WIN_POS_CENTER);
-		$this->set_name('ide');
 		CC_Wm::add_window($this);
 		$this->set_title('Callicore Development Enviroment');
 		$this->editor = new CC_Ide_editor();
@@ -126,7 +126,7 @@
 					'label' => 'Preferences',
 					'short-label' => 'Preferences',
 					'tooltip' => 'Preferences',
-					//'callback' => array($this, 'on_run'),
+					'callback' => array($this, 'on_preferences'),
 					'image' => 'gtk-properties',
 				)
 		);
@@ -192,7 +192,7 @@
 					'label' => '_Open',
 					'short-label' => '_Open',
 					'tooltip' => 'Open File',
-					//'callback' => array($this, 'on_open'),
+					'callback' => array($this, 'on_open'),
 					'image' => 'gtk-open',
 				)
 		);
@@ -225,7 +225,7 @@
 					'label' => 'Copy',
 					'short-label' => 'Copy',
 					'tooltip' => 'Copy',
-					//'callback' => array($this, 'on_copy'),
+					'callback' => array($this, 'on_copy'),
 					'image' => 'gtk-copy',
 				)
 		);	
@@ -236,7 +236,7 @@
 					'label' => 'Cut',
 					'short-label' => 'Cut',
 					'tooltip' => 'Cut',
-					//'callback' => array($this, 'on_cut'),
+					'callback' => array($this, 'on_cut'),
 					'image' => 'gtk-cut',
 				)
 		);	
@@ -247,7 +247,7 @@
 					'label' => 'Paste',
 					'short-label' => 'Paste',
 					'tooltip' => 'Paste',
-					//'callback' => array($this, 'on_paste'),
+					'callback' => array($this, 'on_paste'),
 					'image' => 'gtk-paste',
 				)
 		);	
@@ -258,7 +258,7 @@
 					'label' => 'Undo',
 					'short-label' => 'Undo',
 					'tooltip' => 'Undo',
-					//'callback' => array($this, 'on_undo'),
+					'callback' => array($this, 'on_undo'),
 					'image' => 'gtk-undo',
 				)
 		);	
@@ -269,7 +269,7 @@
 					'label' => 'Redo',
 					'short-label' => 'Redo',
 					'tooltip' => 'Redo',
-					//'callback' => array($this, 'on_redo'),
+					'callback' => array($this, 'on_redo'),
 					'image' => 'gtk-redo',
 				)
 		);
@@ -284,6 +284,35 @@
 		
 	}
 	
+	public function on_open(){
+		$opendialog = new CC_Ide_fileopendialog(array('PHP' => '*.php'),$this);
+		if ($opendialog->run() == Gtk::RESPONSE_OK) {
+       		$selected_file = $opendialog->get_filename();
+       		$this->editor->open_document($selected_file);
+    	}
+    	$opendialog->destroy();
+	}
+	
+	public function on_copy(){
+		$this->editor->on_copy();
+	}
+	
+	public function on_cut(){
+		$this->editor->on_cut();
+	}
+	
+	public function on_paste(){
+		$this->editor->on_paste();
+	}
+	
+	public function on_undo(){
+		$this->editor->on_undo();
+	}
+	
+	public function on_redo(){
+		$this->editor->on_redo();
+	}
+	
 	public function on_new(){
 		$this->editor->new_document();
 	}
@@ -320,6 +349,11 @@
 		}
 	}
 	
+	public function on_preferences(){
+		$preferences = new CC_Ide_preferences();
+		$preferences->show_all(true);
+	}
+	
 }
 
 ?>
\ No newline at end of file

Modified: trunk/programs/ide/lib/ide_editor.class.php (115 => 116)


--- trunk/programs/ide/lib/ide_editor.class.php	2007-01-12 01:25:44 UTC (rev 115)
+++ trunk/programs/ide/lib/ide_editor.class.php	2007-01-12 11:21:56 UTC (rev 116)
@@ -16,10 +16,81 @@
 		$sourceView->set_show_line_markers(true);
 		$sourceView->set_auto_indent(true);
 		$sourceView->set_smart_home_end(true);
-		parent::append_page($sourceView,new GtkLabel('Untitled-'.$count));
+		$sourceView->set_data('filename',null);
+		$scroll = new GtkScrolledWindow();
+		$scroll->add($sourceView);
+		$id = $this->append_page($scroll, new GtkLabel('Untitled-'.$count));
 		$this->show_all();
+		$this->set_current_page($id);
 	}
 	
+	public function open_document($filename){
+		if (file_exists($filename)) {
+			$sourceView = new CC_Ide_source();
+			$sourceView->set_text(file_get_contents($filename));
+			$sourceView->set_modified(false);
+			$sourceView->set_show_line_numbers(true);
+			$sourceView->set_check_brackets(true);
+			$sourceView->set_show_line_markers(true);
+			$sourceView->set_auto_indent(true);
+			$sourceView->set_smart_home_end(true);
+			$sourceView->set_data('filename',$filename);
+			$scroll = new GtkScrolledWindow();
+			$scroll->add($sourceView);
+			$id = $this->append_page($scroll,new GtkLabel(basename($filename)));
+			$this->show_all();
+			$this->set_current_page($id);
+		}
+	}
+	
+	public function save_document($filename, $id){
+		$scroll = $this->$this->get_nth_page($id);
+		if ($scroll !== null) {
+			$sourceView = $scroll->get_child();
+			$document = $sourceView->get_text();
+			file_put_contents($filename,$document);
+		}
+	}
+	
+	public function get_current_page(){
+		$scroll = parent::get_current_page();
+		return $scroll->get_child();
+	}
+	
+	public function on_copy(){
+		$sourceView = $this->get_current_page();
+		if ($sourceView !== null){
+			$sourceView->copy();
+		}
+	}
+	
+	public function on_cut(){
+		$sourceView = $this->get_current_page();
+		if ($sourceView !== null){
+			$sourceView->cut();
+		}
+	}
+	
+	public function on_paste(){
+		$sourceView = $this->get_current_page();
+		if ($sourceView !== null){
+			$sourceView->paste();
+		}
+	}
+	
+	public function on_undo(){
+		$sourceView = $this->get_current_page();
+		if ($sourceView !== null){
+			$sourceView->undo();
+		}
+	}
+	
+	public function on_redo(){
+		$sourceView = $this->get_current_page();
+		if ($sourceView !== null){
+			$sourceView->redo();
+		}
+	}
 }
 
 ?>
\ No newline at end of file

Modified: trunk/programs/ide/lib/ide_plugins.class.php (115 => 116)


--- trunk/programs/ide/lib/ide_plugins.class.php	2007-01-12 01:25:44 UTC (rev 115)
+++ trunk/programs/ide/lib/ide_plugins.class.php	2007-01-12 11:21:56 UTC (rev 116)
@@ -1,6 +1,6 @@
 <?php
 
-class CC_Ide_plugin {
+class CC_Plugin {
 
 	
 

Added: trunk/programs/ide/lib/ide_preferences.class.php (115 => 116)


--- trunk/programs/ide/lib/ide_preferences.class.php	2007-01-12 01:25:44 UTC (rev 115)
+++ trunk/programs/ide/lib/ide_preferences.class.php	2007-01-12 11:21:56 UTC (rev 116)
@@ -0,0 +1,14 @@
+<?php
+
+class CC_Ide_preferences extends CC_Window {
+	
+	protected $name = 'preferences';
+	
+	public function __construct(){
+		parent::__construct();
+		CC_Wm::add_window($this);
+	}
+	
+}
+
+?>
\ No newline at end of file