Diff
Deleted: desktop/trunk/Writer/lib/aboutdialog.class.php (25 => 26)
--- desktop/trunk/Writer/lib/aboutdialog.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/aboutdialog.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -1,125 +0,0 @@
-<?php
-/**
- * aboutdialog.class.php - About dialog box creation
- *
- * wraps gtkaboutdialog and sets it up properly
- *
- * This is released under the GPL, see license.txt for details
- *
- * @author Elizabeth Smith <emsmith@callicore.net>
- * @copyright Elizabeth Smith (c)2006
- * @link http://callicore.net/writer
- * @license http://www.opensource.org/licenses/gpl-license.php GPL
- * @version $Id$
- * @since Php 5.2.0
- * @package callicore
- * @subpackage writer
- * @category lib
- * @filesource
- */
-
-/**
- * AboutDialog - information about writer
- *
- * uses stuff from docs to function
- */
-class AboutDialog extends GtkAboutDialog
-{
-
- /**
- * public function __construct
- *
- * Creates a new about dialog window and fills it
- *
- * @return void
- */
- public function __construct()
- {
- GtkAboutDialog::set_url_hook(array($this, 'urlhook'));
- GtkAboutDialog::set_email_hook(array($this, 'emailhook'));
-
- parent::__construct();
- $this->set_position(Gtk::WIN_POS_CENTER);
- $this->set_title(_('Writer >> About'));
-
- $this->set_name(_('Writer'));
- $this->set_logo($this->render_icon('writer-icon', THEME::$IMAGE));
- $this->set_website_label('Callicore');
- $this->set_website('http://callicore.net');
- $this->set_version(Writer::VERSION);
- $this->set_copyright(_('Copyright (c) 2006 Elizabeth Marie Smith, All Rights Reserved'));
- $this->set_comments(_('Novel creation and organization software'));
-
- $this->set_artists(file(DIR . 'docs' . DS . 'artists.txt'));
- $this->set_authors(file(DIR . 'docs' . DS . 'authors.txt'));
- $this->set_documenters(file(DIR . 'docs' . DS . 'documentors.txt'));
-
- $this->set_translator_credits(file_get_contents(DIR . 'docs' . DS . 'translators.txt'));
- $this->set_license(file_get_contents(DIR . 'docs' . DS . 'license.txt'));
- $this->show_all();
- }
-
- /**
- * public function parent
- *
- * the about dialog should be parented after it is created
- * so it doesn't try to hang around
- *
- * @param object instanceof GtkWindow $parent GtkWindow object parent
- * @return void
- */
- public function parent($parent)
- {
- $this->set_transient_for($parent);
- $this->set_destroy_with_parent(TRUE);
- unset($parent);
- return;
- }
-
- /**
- * public function urlhook
- *
- * Uses exec to open system default browser
- *
- * @param object $window instanceof GtkWindow
- * @param string $url http address to launch
- * @return void
- */
- public function urlhook($window, $url)
- {
- Writer::launchFile($url);
- unset($url, $window);
- return;
- }
-
- /**
- * public function emailhook
- *
- * Uses exec to open system default mail client
- *
- * @param object $window instanceof GtkWindow
- * @param string $email email address to launch
- * @return void
- */
- public function emailhook($window, $email)
- {
- Writer::launchFile('mailto:' . $email);
- unset($email, $window);
- return;
- }
-
- /**
- * public function __destruct
- *
- * This is fixed in next version of php-gtk and can be removed, until then
- * make sure we clean up to avoid memory leak
- *
- * @return void
- */
- public function __destruct()
- {
- GtkAboutDialog::set_url_hook(NULL);
- GtkAboutDialog::set_email_hook(NULL);
- }
-}
-?>
\ No newline at end of file
Deleted: desktop/trunk/Writer/lib/action.class.php (25 => 26)
--- desktop/trunk/Writer/lib/action.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/action.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -1,75 +0,0 @@
-<?php
-/**
- * action.class.php - Extends gtkaction
- *
- * gets the tooltips set right when fetching a toolbar/menu item and adds additional
- * properties (set by constructor) for quick creation
- *
- * This is released under the GPL, see license.txt for details
- *
- * @author Elizabeth Smith <emsmith@callicore.net>
- * @copyright Elizabeth Smith (c)2006
- * @link http://callicore.net/writer
- * @license http://www.opensource.org/licenses/gpl-license.php GPL
- * @version $Id$
- * @since Php 5.2.0
- * @package callicore
- * @subpackage writer
- * @category lib
- * @filesource
- */
-
-/**
- * Action - subclasses GtkAction
- *
- * fixes the menu and toolbar item fetching to have working tooltips and
- * automatically registers callbacks
- */
-class Action extends GtkAction
-{
- /**
- * public function __construct
- *
- * creates tooltips, accelerator group, and assigns the singleton variable
- *
- * @return void
- */
- public function __construct($name, $label, $shortlabel, $tooltip, $image, $callback)
- {
- parent::__construct($name, Writer::i18n($label), Writer::i18n($tooltip), $image);
- $this->set_property('short-label', Writer::i18n($shortlabel));
- $this->connect('activate', $callback);
- unset($name, $label, $shortlabel, $tooltip, $image, $callback);
- return;
- }
-
- /**
- * public function create_tool_item
- *
- * override so we can do the tooltip properly
- *
- * @return instanceof GtkToolItem
- */
- public function create_tool_item()
- {
- $widget = parent::create_tool_item();
- $widget->set_tooltip(Tooltips::instance(), $this->get_property('tooltip'));
- return $widget;
- }
-
- /**
- * public function create_menu_item
- *
- * description
- *
- * @param type $name about
- * @return type about
- */
- public function create_menu_item()
- {
- $widget = parent::create_menu_item();
- Tooltips::instance()->set_tip($widget, $this->get_property('tooltip'));
- return $widget;
- }
-}
-?>
\ No newline at end of file
Modified: desktop/trunk/Writer/lib/db.class.php (25 => 26)
--- desktop/trunk/Writer/lib/db.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/db.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -55,7 +55,10 @@
"name" TEXT UNIQUE,
"display" TEXT,
"default" TEXT,
- "character_meta_type_id_fk" INTEGER NOT NULL DEFAULT 0
+ "order" INTEGER UNIQUE,
+ "character_meta_type_id_fk" INTEGER NOT NULL DEFAULT 0,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_edited" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE "character_meta_type" (
Modified: desktop/trunk/Writer/lib/message.class.php (25 => 26)
--- desktop/trunk/Writer/lib/message.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/message.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -76,14 +76,14 @@
parent::__construct(NULL, 0, $type, Gtk::BUTTONS_CLOSE);
$this->set_position(Gtk::WIN_POS_CENTER);
- $this->set_title(_('Writer >> ' . $title));
+ $this->set_title(Writer::i18n('Writer :: ' . $title));
if(is_array($message))
{
- $this->set_markup(vsprintf(_(array_shift($message)), $message));
+ $this->set_markup(Writer::i18n(array_shift($message), $message));
}
else
{
- $this->set_markup(_($message));
+ $this->set_markup(Writer::i18n($message));
}
unset($message, $title, $type);
@@ -191,10 +191,10 @@
*/
static protected function log($level, $message)
{
- $log = Writer::$appdata . 'error.log';
+ $log = Writer::appdata() . 'error.log';
if(file_exists($log) && filesize($log) > 536870912)
{
- rename($log, Writer::$appdata . date('Y-m-d') . 'error.log.bak');
+ rename($log, Writer::appdata() . date('Y-m-d') . 'error.log.bak');
}
file_put_contents($log, self::$messages[$level] . ' ' . date('Y-m-d H:i:s')
. " --> $message\n", FILE_APPEND);
Modified: desktop/trunk/Writer/lib/project/window.class.php (25 => 26)
--- desktop/trunk/Writer/lib/project/window.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/project/window.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -60,6 +60,10 @@
parent::__construct();
+ Db::instance('test.cwp');
+ CharacterWindow::instance();
+ $this->connect_simple('destroy', array('Gtk', 'main_quit'));
+ $this->show_all();
return;
}
Copied: desktop/trunk/Writer/lib/splash.class.php (from rev 21, desktop/trunk/Writer/lib/splashscreen.class.php) (21 => 26)
--- desktop/trunk/Writer/lib/splashscreen.class.php 2006-09-24 01:07:26 UTC (rev 21)
+++ desktop/trunk/Writer/lib/splash.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -0,0 +1,137 @@
+<?php
+/**
+ * splash.class.php - Splash screen display window
+ *
+ * creates, displays, updates progress bar on splash screen during startup
+ *
+ * This is released under the GPL, see license.txt for details
+ *
+ * @author Elizabeth Smith <emsmith@callicore.net>
+ * @copyright Elizabeth Smith (c)2006
+ * @link http://callicore.net/writer
+ * @license http://www.opensource.org/licenses/gpl-license.php GPL
+ * @version $Id$
+ * @since Php 5.2.0
+ * @package callicore
+ * @subpackage writer
+ * @category lib
+ * @filesource
+ */
+
+/**
+ * Splash - basically a wrapper around GtkWindow
+ *
+ * Sets up a window with a pretty image backdrop and
+ * basic information about what is happening during setup
+ */
+class Splash extends GtkWindow
+{
+
+ /**
+ * progressbar object reference for easy updating
+ * @var $progressbar object instanceof GtkProgressBar
+ */
+ protected $progressbar;
+
+ /**
+ * total startup steps - useful for incrementing progressbar
+ * @var $steps int
+ */
+ protected $steps = 6;
+
+ /**
+ * public function __construct
+ *
+ * creates and displays the splash window
+ * and all the widgets it contains
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+
+ // Window Features
+ parent::__construct();
+ $this->set_position(Gtk::WIN_POS_CENTER);
+ $this->set_title(_('Writer :: Loading'));
+ $this->set_resizable(FALSE);
+ $this->set_decorated(FALSE);
+ $this->set_skip_taskbar_hint(TRUE);
+ $this->set_skip_pager_hint(TRUE);
+ $this->set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
+
+ // Pixbuf for Back
+ $pixbuf = GdkPixbuf::new_from_file(DIR . 'images' . DS . 'splash.png');
+ list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask();
+ list($width, $height) = $pixmap->get_size();
+ $this->set_app_paintable(TRUE);
+ $this->set_size_request($width, $height);
+ $this->realize();
+ $this->window->set_back_pixmap($pixmap, FALSE);
+ unset($pixbuf, $pixmap, $mask, $width, $height);
+
+ // Main VBox Container
+ $vbox = new GtkVbox();
+ $vbox->set_border_width(10);
+ $this->add($vbox);
+
+ // Top Bar with Copyright and Version information
+ $hbox = new GtkHBox();
+ $hbox->pack_start(new GtkLabel(Writer::i18n('Copyright (c) E. M. Smith 2006')), FALSE, FALSE);
+ $hbox->pack_end(new GtkLabel(Writer::i18n('version ' . WRITER::VERSION)), FALSE, FALSE);
+ $vbox->pack_start($hbox, FALSE, FALSE);
+
+ // Progressbar on Bottom
+ $this->progressbar = new GtkProgressBar();
+ $this->progressbar->set_text(Writer::i18n('Loading...'));
+ $this->progressbar->set_fraction(0);
+ $vbox->pack_end($this->progressbar, FALSE, FALSE);
+
+ // License info just above progressbar
+ $hbox = new GtkHBox();
+ $hbox->pack_start(new GtkLabel(Writer::i18n('Released under GPL License')), FALSE, FALSE);
+ $vbox->pack_end($hbox, FALSE, FALSE);
+
+ unset($vbox, $hbox);
+
+ $this->show_all();
+ return;
+ }
+
+ /**
+ * public function parent
+ *
+ * although the splashscreen is created first,
+ * it changes to a transient for the main window
+ * so we use this to set that relationship
+ *
+ * @param object instanceof GtkWindow $parent GtkWindow object parent
+ * @return void
+ */
+ public function parent($parent)
+ {
+ $this->set_transient_for($parent);
+ $this->set_destroy_with_parent(TRUE);
+ unset($parent);
+ return;
+ }
+
+ /**
+ * public function update
+ *
+ * update the progressbar text and position
+ *
+ * @param string $text text to fill
+ * @return type about
+ */
+ public function update($text)
+ {
+ $this->progressbar->set_text(Writer::i18n($text));
+ $this->progressbar->set_fraction($this->progressbar->get_fraction() + (1 / $this->steps));
+ unset($text);
+ while (Gtk::events_pending())
+ Gtk::main_iteration();
+ return;
+ }
+}
+?>
\ No newline at end of file
Deleted: desktop/trunk/Writer/lib/splashscreen.class.php (25 => 26)
--- desktop/trunk/Writer/lib/splashscreen.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/splashscreen.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -1,138 +0,0 @@
-<?php
-/**
- * splashscreen.class.php - Splash screen display window
- *
- * creates, displays, updates progress bar on splash screen duringloading
- *
- * This is released under the GPL, see license.txt for details
- *
- * @author Elizabeth Smith <emsmith@callicore.net>
- * @copyright Elizabeth Smith (c)2006
- * @link http://callicore.net/writer
- * @license http://www.opensource.org/licenses/gpl-license.php GPL
- * @version $Id$
- * @since Php 5.2.0
- * @package callicore
- * @subpackage writer
- * @category lib
- * @filesource
- */
-
-/**
- * SplashScreen - basically a wrapper around GtkWindow
- *
- * Sets up a window with a pretty image backdrop and
- * basic information about what is happening during setup
- */
-class SplashScreen extends GtkWindow
-{
-
- /**
- * progressbar object reference for easy updating
- * @var $progressbar object instanceof GtkProgressBar
- */
- protected $progressbar;
-
- /**
- * total startup steps - useful for incrementing progressbar
- * @var $steps int
- */
- protected $steps = 7;
-
-
- /**
- * public function __construct
- *
- * creates and displays the splash window
- * and all the widgets it contains
- *
- * @return void
- */
- public function __construct()
- {
-
- // Window Features
- parent::__construct();
- $this->set_position(Gtk::WIN_POS_CENTER);
- $this->set_title(_('Writer >> Loading'));
- $this->set_resizable(FALSE);
- $this->set_decorated(FALSE);
- $this->set_skip_taskbar_hint(TRUE);
- $this->set_skip_pager_hint(TRUE);
- $this->set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
-
- // Pixbuf for Back
- $pixbuf = GdkPixbuf::new_from_file(DIR . 'images' . DS . 'splash.png');
- list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask();
- list($width, $height) = $pixmap->get_size();
- $this->set_app_paintable(TRUE);
- $this->set_size_request($width, $height);
- $this->realize();
- $this->window->set_back_pixmap($pixmap, FALSE);
- unset($pixbuf, $pixmap, $mask, $width, $height);
-
- // Main VBox Container
- $vbox = new GtkVbox();
- $vbox->set_border_width(10);
- $this->add($vbox);
-
- // Top Bar with Copyright and Version information
- $hbox = new GtkHBox();
- $hbox->pack_start(new GtkLabel(_('Copyright (c) E. M. Smith 2006')), FALSE, FALSE);
- $hbox->pack_end(new GtkLabel(_('version ' . WRITER::VERSION)), FALSE, FALSE);
- $vbox->pack_start($hbox, FALSE, FALSE);
-
- // Progressbar on Bottom
- $this->progressbar = new GtkProgressBar();
- $this->progressbar->set_text(_('Loading...'));
- $this->progressbar->set_fraction(0);
- $vbox->pack_end($this->progressbar, FALSE, FALSE);
-
- // License info just above progressbar
- $hbox = new GtkHBox();
- $hbox->pack_start(new GtkLabel(_('Released under GPL License')), FALSE, FALSE);
- $vbox->pack_end($hbox, FALSE, FALSE);
-
- unset($vbox, $hbox);
-
- $this->show_all();
- return;
- }
-
- /**
- * public function parent
- *
- * although the splashscreen is created first,
- * it changes to a transient for the main window
- * so we use this to set that relationship
- *
- * @param object instanceof GtkWindow $parent GtkWindow object parent
- * @return void
- */
- public function parent($parent)
- {
- $this->set_transient_for($parent);
- $this->set_destroy_with_parent(TRUE);
- unset($parent);
- return;
- }
-
- /**
- * public function update
- *
- * update the progressbar text and position
- *
- * @param string $text text to fill
- * @return type about
- */
- public function update($text)
- {
- $this->progressbar->set_text(_($text));
- $this->progressbar->set_fraction($this->progressbar->get_fraction() + (1 / $this->steps));
- unset($text);
- while (Gtk::events_pending())
- Gtk::main_iteration();
- return;
- }
-}
-?>
\ No newline at end of file
Modified: desktop/trunk/Writer/lib/writer.class.php (25 => 26)
--- desktop/trunk/Writer/lib/writer.class.php 2006-10-18 18:02:14 UTC (rev 25)
+++ desktop/trunk/Writer/lib/writer.class.php 2006-10-18 20:40:00 UTC (rev 26)
@@ -67,38 +67,21 @@
public function __construct()
{
$this->checkRequirements();
- $this->findFolders();
- $this->theme();
-Db::instance('test.cwp');
-CharacterWindow::instance();
-return;
- $splash = new SplashScreen();
+ $splash = new Splash();
+ $splash->update('Starting');
+ $splash->update('Checking Requirements');
$splash->update('Initializing Messages');
set_error_handler(array('Message', 'error'));
set_exception_handler(array('Message', 'exception'));
$splash->update('Loading Theme');
- new Theme();
+ $this->theme();
- $splash->update('Loading Configuration');
- $this->findFolders();
+ $splash->update('Loading Project');
+ $splash->parent(ProjectWindow::instance());
- $splash->update('Reading Configuration');
- new Config();
-
- $splash->update('Loading Interface');
- new Tooltips();
- new Action();
- new Edit();
-
- $splash->update('Starting Interface');
- new Project();
- $window = new ProjectView();
-
- $splash->parent($window);
-
$splash->update('Setup Complete');
$splash->destroy();
unset($splash, $window);
@@ -106,7 +89,30 @@
return;
}
+ //----------------------------------------------------------------
+ // static helper functions
+ //----------------------------------------------------------------
+
/**
+ * public static function i18n
+ *
+ * wrapper for gettext + sprintf/vsprintf
+ *
+ * @param string $string string to translate
+ * @return string translated string
+ */
+ public static function i18n($string)
+ {
+ $args = func_get_args();
+ array_shift($args);
+ if(!empty($args) && count($args) == 1 && is_array($args[0]))
+ {
+ $args = $args[0];
+ }
+ return gettext(vsprintf($string, $args));
+ }
+
+ /**
* public static function launchFile
*
* creates command string and pipes it to exec to open a file with an external
@@ -129,10 +135,16 @@
}
return exec($file);
}
- elseif(stristr(PHP_OS, 'win'))
+ elseif(stristr(PHP_OS, 'winnt'))
{
- return win_shell_execute($file, 'open');
+ $shell = new COM('WScript.Shell');
+ $shell->Run('cmd /c start "" "' . $file . '"', 0, FALSE);
}
+ elseif(stristr(PHP_OS, 'win32'))
+ {
+ $shell = new COM('WScript.Shell');
+ $shell->Run('command /c start "" "' . $file . '"', 0, FALSE);
+ }
elseif(stristr(PHP_OS, 'darwin') || stristr(PHP_OS, 'mac'))
{
$file = 'open "' . $file . '"';
@@ -146,24 +158,52 @@
}
/**
- * public static function i18n
+ * static public function appdata
*
- * wrapper for gettext + sprintf/vsprintf
+ * finds appdata dependent on env variables and OS
*
- * @param string $string string to translate
- * @return string translated string
+ * @return void
*/
- public static function i18n($string)
+ static public function appdata()
{
- $args = func_get_args();
- array_shift($args);
- if(!empty($args) && count($args) == 1 && is_array($args[0]))
+ static $appdata;
+ if(is_null($appdata))
{
- $args = $args[0];
+ // check environment variables for appdir or use home/.projects
+ if(isset($_ENV['APPDATA']))
+ {
+ $appdata = $_ENV['APPDATA'] . DS . 'callicore' . DS;
+ }
+ elseif(stristr(PHP_OS, 'darwin'))
+ {
+ $appdata = DIR . 'Library' . DS . 'Application Support'
+ . DS . 'callicore' . DS;
+ }
+ elseif(stristr(PHP_OS, 'linux') || stristr(PHP_OS, 'freebsd') || stristr(PHP_OS, 'unix'))
+ {
+ $appdata = DIR . 'callicore' . DS;
+ }
+ else
+ {
+ $appdata = DIR;
+ }
+ if(!file_exists($appdata))
+ {
+ mkdir($appdata);
+ }
+ $appdata .= 'writer' . DS;
+ if(!file_exists($appdata))
+ {
+ mkdir($appdata);
+ }
}
- return gettext(vsprintf($string, $args));
+ return $appdata;
}
+ //----------------------------------------------------------------
+ // Startup Items
+ //----------------------------------------------------------------
+
/**
* protected function checkRequirements
*
@@ -174,6 +214,7 @@
*/
protected function checkRequirements()
{
+ // set up translation
if(extension_loaded('gettext'))
{
// we use system locale
@@ -192,12 +233,7 @@
trigger_error(self::i18n('You must use php 5.1.0 or higher'), E_USER_ERROR);
}
$have = get_loaded_extensions();
- $needed = array('standard', 'pcre', 'date', 'PDO', 'pdo_sqlite',
- 'pspell', 'stem', 'php-gtk', 'gd', 'fileinfo');
- if(stristr(PHP_OS, 'win'))
- {
- $needed[] = 'win32std';
- }
+ $needed = array('standard', 'pcre', 'date', 'PDO', 'pdo_sqlite', 'php-gtk');
$diff = array_diff($needed, $have);
if(!empty($diff))
{
@@ -209,50 +245,6 @@
}
/**
- * protected function findFolders
- *
- * finds appdata dependent on env variables and OS
- *
- * @return void
- */
- protected function findFolders()
- {
-
- // check environment variables for appdir or use home/.projects
- if(isset($_ENV['APPDATA']))
- {
- self::$appdata = $_ENV['APPDATA'] . DS . 'callicore' . DS;
- }
- elseif(stristr(PHP_OS, 'darwin'))
- {
- self::$appdata = self::$home . 'Library' . DS . 'Application Support'
- . DS . 'callicore' . DS;
- }
- elseif(stristr(PHP_OS, 'linux') || stristr(PHP_OS, 'freebsd') || stristr(PHP_OS, 'unix'))
- {
- self::$appdata = self::$home . 'callicore' . DS;
- }
- else
- {
- self::$appdata = DIR;
- }
-
- if(!file_exists(self::$appdata))
- {
- mkdir(self::$appdata);
- }
-
- self::$appdata .= 'writer' . DS;
-
- if(!file_exists(self::$appdata))
- {
- mkdir(self::$appdata);
- }
-
- return;
- }
-
- /**
* public function theme
*
* registers two new icon sizes, parses the hicolor override rc file and the