Revision
78
Author
leonpegg
Date
2006-12-20 07:47:33 -0800 (Wed, 20 Dec 2006)

Log Message

Ide program added

Added Paths

Diff

Added: desktop/trunk/programs/ide/lib/ide.class.php (77 => 78)


--- desktop/trunk/programs/ide/lib/ide.class.php	2006-12-20 15:45:25 UTC (rev 77)
+++ desktop/trunk/programs/ide/lib/ide.class.php	2006-12-20 15:47:33 UTC (rev 78)
@@ -0,0 +1,266 @@
+<?php
+/**
+ * writer.class.php - Main window for the writer program
+ *
+ * main window for the application, opens up last used project or creates a new
+ * blank project if no "last" is available to use
+ *
+ * This is released under the GPL, see docs/gpl.txt for details
+ *
+ * @author       Leon Pegg <leon@btarchives.com>
+ * @copyright    Leon Pegg (c)2006
+ * @link         http://callicore.net/desktop/programs/writer
+ * @license      http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version      $Id: writer.class.php 66 2006-12-10 22:02:36Z emsmith $
+ * @since        Php 5.2.0
+ * @package      callicore
+ * @subpackage   dev_ide
+ * @category     lib
+ * @filesource
+ */
+
+/**
+ * CC_Dev_ide - checks settings and manages common properties
+ *
+ * Basically a wrapper class for the application
+ */
+class CC_Ide extends CC_Main
+{
+	
+	protected $notebook;
+	
+	protected $menubar = array(
+		'_File' => array(
+			'file:new',
+			'file:open',
+			'file:save',
+			'file:quit',
+		),
+		'_Edit' => array(
+			'edit:copy',
+			'edit:cut',
+			'edit:paste',
+			'edit:undo',
+			'edit:redo',
+		),
+		'_View' => array(
+			//'toolbar:toggle',
+			'view:fullscreen',
+		),
+		'_Help' => array(
+			'help:help',
+			'help:website',
+			'separator',
+			'help:about',
+		),
+	);
+
+	/**
+	 * options available for toolbar
+	 * @var $tooloptions array
+	 */
+	protected $tooloptions = array(
+		'file:new',
+		'file:open',
+		'file:save',
+		'file:quit',
+		'edit:copy',
+		'edit:cut',
+		'edit:paste',
+		'edit:undo',
+		'edit:redo',
+		'view:fullscreen',
+		'help:help',
+		'help:website',
+		'help:about'
+	);
+
+	/**
+	 * default toolbar layout
+	 * @var $tooldefault array
+	 */
+	protected $tooldefault = array(
+		'file:new',
+		'file:open',
+		'file:save',
+		'separator',
+		'edit:copy',
+		'edit:cut',
+		'edit:paste',
+		'edit:undo',
+		'edit:redo',
+		'separator',
+		'view:fullscreen',
+		'separator',
+		'file:quit',
+		'expander',
+		'help:website',
+		'help:help',
+		'help:about'
+	);
+	
+	/**
+	 * public function __construct
+	 *
+	 * description
+	 *
+	 * @param type $name about
+	 * @return type about
+	 */
+	public function __construct()
+	{
+		parent::__construct();
+		$this->set_name('ide');
+		$this->set_title('Callicore Development Enviroment');
+		CC_Wm::add_window($this);
+		$this->notebook = new CC_Ide_notebook();
+		$this->notebook->new_file();
+ 		$this->vbox->pack_start($this->notebook);
+		$this->show_all();
+	}
+
+	protected function register_actions(){
+		$actions = CC_Actions::instance();
+
+		$actions->add_action('file',
+				array(
+					'type' => 'action',
+					'name' => 'open',
+					'label' => '_Open',
+					'short-label' => '_Open',
+					'tooltip' => 'Open File',
+					'callback' => array($this, 'on_open'),
+					'image' => 'gtk-open',
+				)
+		);
+		$actions->add_action('file',
+				array(
+					'type' => 'action',
+					'name' => 'save',
+					'label' => '_Save',
+					'short-label' => '_Save',
+					'tooltip' => 'Save File',
+					'callback' => array($this, 'on_save'),
+					'image' => 'gtk-save',
+				)
+		);
+		$actions->add_action('file',
+				array(
+					'type' => 'action',
+					'name' => 'new',
+					'label' => '_New',
+					'short-label' => '_New',
+					'tooltip' => 'New File',
+					'callback' => array($this, 'on_new'),
+					'image' => 'gtk-new',
+				)
+		);
+		$actions->add_action('edit',
+				array(
+					'type' => 'action',
+					'name' => 'copy',
+					'label' => 'Copy',
+					'short-label' => 'Copy',
+					'tooltip' => 'Copy',
+					'callback' => array($this, 'on_copy'),
+					'image' => 'gtk-copy',
+				)
+		);	
+		$actions->add_action('edit',
+				array(
+					'type' => 'action',
+					'name' => 'cut',
+					'label' => 'Cut',
+					'short-label' => 'Cut',
+					'tooltip' => 'Cut',
+					'callback' => array($this, 'on_cut'),
+					'image' => 'gtk-cut',
+				)
+		);	
+		$actions->add_action('edit',
+				array(
+					'type' => 'action',
+					'name' => 'paste',
+					'label' => 'Paste',
+					'short-label' => 'Paste',
+					'tooltip' => 'Paste',
+					'callback' => array($this, 'on_paste'),
+					'image' => 'gtk-paste',
+				)
+		);	
+		$actions->add_action('edit',
+				array(
+					'type' => 'action',
+					'name' => 'undo',
+					'label' => 'Undo',
+					'short-label' => 'Undo',
+					'tooltip' => 'Undo',
+					'callback' => array($this, 'on_undo'),
+					'image' => 'gtk-undo',
+				)
+		);	
+		$actions->add_action('edit',
+				array(
+					'type' => 'action',
+					'name' => 'redo',
+					'label' => 'Redo',
+					'short-label' => 'Redo',
+					'tooltip' => 'Redo',
+					'callback' => array($this, 'on_redo'),
+					'image' => 'gtk-redo',
+				)
+		);
+		return parent::register_actions();
+	}
+	
+	public function on_about(){
+		echo "show_about\n";
+	}
+	
+	public function on_new(){
+		$this->notebook->new_file();
+		$this->notebook->show_all();
+	}
+	
+	public function on_open(){
+		echo "open file\n";
+	}
+	
+	public function on_save(){
+		echo "save file\n";
+	}
+	
+	public function on_help(){
+		echo "show help\n";
+	}
+	
+	public function on_copy(){
+		$this->notebook->copy();
+	}
+	
+	public function on_cut(){
+		$this->notebook->cut();
+	}
+	
+	public function on_paste(){
+		$this->notebook->paste();
+	}
+	
+	public function on_undo(){
+		$this->notebook->undo();
+		//echo "undo change\n";
+	}
+	
+	public function on_redo(){
+		$this->notebook->redo();
+		//echo "redo change\n";
+	}
+
+}
+
+# ToDo
+# Add Callicore Project template
+# Add code completion
+# Add Debug function
+
+?>
\ No newline at end of file

Added: desktop/trunk/programs/ide/lib/ide_notebook.class.php (77 => 78)


--- desktop/trunk/programs/ide/lib/ide_notebook.class.php	2006-12-20 15:45:25 UTC (rev 77)
+++ desktop/trunk/programs/ide/lib/ide_notebook.class.php	2006-12-20 15:47:33 UTC (rev 78)
@@ -0,0 +1,84 @@
+<?php
+
+class CC_Ide_notebook extends GtkNotebook {
+
+	protected $buffers = array();
+
+	public function __construct(){
+		parent::__construct();
+	}
+
+	public function new_file(){
+		$view = new GtkScrolledWindow();
+		$lang_mgr = new GtkSourceLanguagesManager();
+		$lang = $lang_mgr->get_language_from_mime_type("text/x-php");
+		$buffer = GtkSourceBuffer::new_with_language($lang);
+		$source = GtkSourceView::new_with_buffer($buffer);
+		$source->set_show_line_numbers(1);
+		$buffer->set_highlight(1);
+		$view->add($source);
+		$eventbox = new GtkEventBox();
+		$label = new GtkLabel('untitled');
+		$eventbox->add($label);
+		$label->show();
+		$id = $this->append_page($view,$eventbox);
+		$this->buffers[$id] = $buffer;
+	}
+
+	public function open_file($filename){
+		if (file_exists($filename)) {
+			$view = new GtkScrolledWindow();
+			$lang_mgr = new GtkSourceLanguagesManager();
+			$lang = $lang_mgr->get_language_from_mime_type("text/x-php");
+			$buffer = GtkSourceBuffer::new_with_language($lang);
+			$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();
+			$label = new GtkLabel(basename($filename));
+			$eventbox->add($label);
+			$label->show();
+			$id = $this->append_page($view,$eventbox);
+			$this->buffers[$id] = $buffer;
+		}
+	}
+	
+	public function copy(){
+		$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
+		$id = $this->get_current_page();
+		$this->buffers[$id]->copy_clipboard($cb);
+	}
+	
+	public function cut(){
+		$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
+		$id = $this->get_current_page();
+		$this->buffers[$id]->cut_clipboard($cb,true);
+	}
+	
+	public function paste(){
+		$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
+		$id = $this->get_current_page();
+		// 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();
+		if ($this->buffers[$id]->can_undo()) {
+			$this->buffers[$id]->undo();
+		}
+	}
+	
+	public function redo(){
+		$id = $this->get_current_page();
+		if ($this->buffers[$id]->can_redo()) {
+			$this->buffers[$id]->redo();
+		}
+	}
+
+}
+
+?>
\ No newline at end of file