Revision
43
Author
emsmith
Date
2006-12-01 10:44:59 -0800 (Fri, 01 Dec 2006)

Log Message

another typo and a "boilerplate" splash window creator

Modified Paths

Added Paths

Diff

Modified: desktop/trunk/lib/config.class.php (42 => 43)


--- desktop/trunk/lib/config.class.php	2006-12-01 17:55:54 UTC (rev 42)
+++ desktop/trunk/lib/config.class.php	2006-12-01 18:44:59 UTC (rev 43)
@@ -70,8 +70,8 @@
 
 		$this->program = $program;
 		$folders = CC_Folders::instance();
-		$this->file = $folders->getAppdata() . strtolower($program) . 'config.ini';
-		if(file_exists($file))
+		$this->file = $folders->getAppdata() . strtolower($program) . '.config.ini';
+		if(file_exists($this->file))
 		{
 			$this->data = parse_ini_file($this->file);
 		}

Copied: desktop/trunk/lib/splash.class.php (from rev 40, desktop/trunk/programs/writer/lib/splash.class.php) (40 => 43)


--- desktop/trunk/programs/writer/lib/splash.class.php	2006-11-30 20:05:37 UTC (rev 40)
+++ desktop/trunk/lib/splash.class.php	2006-12-01 18:44:59 UTC (rev 43)
@@ -0,0 +1,209 @@
+<?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
+ */
+
+/**
+ * CC_Splash - basically a wrapper around GtkWindow
+ *
+ * Sets up a window with a pretty image backdrop and basic program info while showing
+ * basic information about what is happening during setup
+ */
+class CC_Splash extends GtkWindow
+{
+
+	/**
+	 * progressbar object reference for easy updating
+	 * @var $progressbar object instanceof GtkProgressBar
+	 */
+	protected $progressbar;
+
+	/**
+	 * total startup steps - needed for incrementing progressbar
+	 * @var $steps int
+	 */
+	protected $steps;
+
+	/**
+	 * main vbox
+	 * @var $vbox instanceof GtkVBox
+	 */
+	protected $vbox;
+
+	/**
+	 * empty hbox
+	 * @var $hbox instanceof GtkHBox
+	 */
+	protected $hbox;
+
+	/**
+	 * public function __construct
+	 *
+	 * creates and displays the splash window
+	 * and all the widgets it contains
+	 *
+	 * @return void
+	 */
+	public function __construct($steps, $program = 'Callicore')
+	{
+
+		$this->steps = (int) $steps;
+
+		// Window Features
+		parent::__construct();
+		$this->set_position(Gtk::WIN_POS_CENTER);
+		$this->set_title(CC_Main::i18n('%s :: %s', $program, '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);
+
+		// Main VBox Container
+		$vbox = $this->vbox = new GtkVbox();
+		$vbox->set_border_width(10);
+		$this->add($vbox);
+
+		// Empty top bar
+		$hbox = $this->hbox = new GtkHBox();
+		$vbox->pack_start($hbox, FALSE, FALSE);
+
+		// Progressbar on Bottom
+		$this->progressbar = new GtkProgressBar();
+		$this->progressbar->set_text(CC_Main::i18n('Loading...'));
+		$this->progressbar->set_fraction(0);
+		$vbox->pack_end($this->progressbar, FALSE, FALSE);
+
+		unset($vbox, $hbox);
+		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 setImage
+	 *
+	 * sets a background image for the splash screen
+	 *
+	 * @param string $image absolute path to splash background
+	 * @return void
+	 */
+	public function setImage($image)
+	{
+		$pixbuf = GdkPixbuf::new_from_file($image);
+		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();
+		if($mask instanceof GdkPixmap)
+		{
+			$this->shape_combine_mask($mask, 0, 0);
+		}
+		$this->window->set_back_pixmap($pixmap, FALSE);
+		unset($pixbuf, $pixmap, $mask, $width, $height, $image);
+		return;
+	}
+
+	/**
+	 * public function setLicense
+	 *
+	 * sets license information string (on bottom center of window)
+	 *
+	 * @param string $license license string to use
+	 * @return void
+	 */
+	public function setLicense($license = 'GPL License')
+	{
+		// License info just above progressbar
+		$hbox = new GtkHBox();
+		$hbox->pack_start(new GtkLabel(CC_Main::i18n($license)), FALSE, FALSE);
+		$this->vbox->pack_end($hbox, FALSE, FALSE);
+		unset($hbox, $license, $this);
+		return;
+	}
+
+	/**
+	 * public function setVersion
+	 *
+	 * sets version information string (top right)
+	 *
+	 * @param string $version string to use
+	 * @return void
+	 */
+	public function setVersion($version = NULL)
+	{
+		if(is_null($version))
+		{
+			$verion = 'version ' . CC_Main::VERSION;
+		}
+		$this->hbox->pack_end(new GtkLabel(CC_Main::i18n($version)), FALSE, FALSE);
+		unset($version ,$this);
+		return;
+	}
+
+	/**
+	 * public function setCopyright
+	 *
+	 * sets author information string (top left)
+	 *
+	 * @param string $copyright string to use
+	 * @return void
+	 */
+	public function setCopyright($copyright = 'Copyright (c) 2006')
+	{
+		$this->hbox->pack_start(new GtkLabel(CC_Main::i18n($copyright)), FALSE, FALSE);
+		unset($copyright, $this);
+		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(CC_Main::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