Modified: desktop/trunk/Writer/lib/character/edit.class.php (27 => 28)
--- desktop/trunk/Writer/lib/character/edit.class.php 2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/character/edit.class.php 2006-11-30 15:15:17 UTC (rev 28)
@@ -23,7 +23,7 @@
*
* Simple form with save and cancel options
*/
-class CharacterEdit extends GtkDialog
+class CharacterEdit extends Window
{
/**
@@ -39,42 +39,15 @@
*
* @return void
*/
- public function __construct($model, $iter)
+ public function __construct()
{
- // dao object to tamper with
- $this->character = new CharacterDao();
- $cols = $model->get_n_columns();
- while($cols > 0)
- {
- $this->character->{$cols - 1} = $model->get_value($iter, $cols -1);
- $cols--;
- }
- unset($data, $cols, $iter, $model);
+ parent::__construct();
+ $this->connect('show', array($this, 'parent'));
+ $this->toolbar->set_no_show_all(TRUE);
+ $this->toolbar->hide();
+ $this->menu->set_no_show_all(TRUE);
+ $this->menu->hide();
- // create window
- parent::__construct(Writer::i18n('Writer :: Characters :: Edit "')
- . $this->character->name . '"', CharacterWindow::instance(),
- Gtk::DIALOG_MODAL | Gtk::DIALOG_DESTROY_WITH_PARENT | Gtk::DIALOG_NO_SEPARATOR,
- array(
- Gtk::STOCK_APPLY, Gtk::RESPONSE_APPLY,
- Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL
- ));
-
- // window defaults
- $config = Config::instance();
- $width = isset($config->character_edit_width) ? (int) $config->character_edit_width : NULL;
- $height = isset($config->character_edit_height) ? (int) $config->character_edit_height : NULL;
- if(!is_null($width) && !is_null($height))
- {
- $this->set_default_size($height, $width);
- }
- $x = isset($config->character_window_x) ? (int) $config->character_window_x : NULL;
- $y = isset($config->character_window_y) ? (int) $config->character_window_y : NULL;
- if(!is_null($x) && !is_null($y))
- {
- $this->move($x, $y);
- }
-
// frame for form
$frame = new GtkFrame(Writer::i18n('Character Information'));
$frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
@@ -85,81 +58,87 @@
$scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
$scroll->set_shadow_type(Gtk::SHADOW_NONE);
$frame->add($scroll);
- unset($frame);
// viewport by hand so we can kill shadow...grrr
$port = new GtkViewport();
$port->set_shadow_type(Gtk::SHADOW_NONE);
$scroll->add($port);
- unset($scroll);
// table into viewport
$table = new GtkTable();
$port->add($table);
- unset($port);
+
// basic items
- $table->attach($label = new GtkLabel(Writer::i18n('Id:')), 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(1, 0.5);
- $table->attach($label = new GtkLabel($this->character->id), 1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(0, 0.5);
- $table->attach($label =new GtkLabel(Writer::i18n('Name:')), 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(1, 0.5);
- $table->attach(new GtkEntry($this->character->name), 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
- $table->attach($label =new GtkLabel(Writer::i18n('Created:')), 0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(1, 0.5);
- $table->attach($label =new GtkLabel($this->character->date_created), 1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(0, 0.5);
- $table->attach($label =new GtkLabel(Writer::i18n('Edited:')), 0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(1, 0.5);
- $table->attach($label =new GtkLabel($this->character->date_edited), 1, 2, 3, 4, Gtk::FILL, Gtk::SHRINK);
- $label->set_alignment(0, 0.5);
- $meta = CharacterDao::listMeta();
- print_r($meta);
- // meta data
-
+ //$table->attach($label = new GtkLabel(Writer::i18n('Id:')), 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(1, 0.5);
+ //$table->attach($label = new GtkLabel($this->character->id), 1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(0, 0.5);
+ //$table->attach($label =new GtkLabel(Writer::i18n('Name:')), 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(1, 0.5);
+ //$table->attach(new GtkEntry($this->character->name), 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
+ //$table->attach($label =new GtkLabel(Writer::i18n('Created:')), 0, 1, 2, 3, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(1, 0.5);
+ //$table->attach($label =new GtkLabel($this->character->date_created), 1, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(0, 0.5);
+ //$table->attach($label =new GtkLabel(Writer::i18n('Edited:')), 0, 1, 3, 4, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(1, 0.5);
+ //$table->attach($label =new GtkLabel($this->character->date_edited), 1, 2, 3, 4, Gtk::FILL, Gtk::SHRINK);
+ //$label->set_alignment(0, 0.5);
- $this->connect_simple('delete-event', array($this, 'onDeleteEvent'));
- $this->show_all();
+ unset($port, $table, $this, $frame, $scroll);
return;
- //create statusbar
- $vbox = new GtkVBox();
- $vbox->pack_start($this->toolbar, FALSE, FALSE);
- $scroll = new GtkScrolledWindow();
- $scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- $scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
- $scroll->add($this->treeview);
- $vbox->pack_start($scroll);
- $this->add($vbox);
- $this->treeview->grab_focus();
+ $meta = CharacterDao::listMeta();
+ print_r($meta);
+ return;
+ }
- $this->show_all();
- unset($vbox, $config, $height, $width);
+ /**
+ * public function parent
+ *
+ * if this is not the top window and has a parent, we link destroy to hide
+ *
+ * @param object instanceof GtkWindow $parent GtkWindow object parent
+ * @return void
+ */
+ public function parent()
+ {
+ $this->set_transient_for(Writer::$window->characters);
+ $this->connect_simple('delete-event', array($this, 'onClose'));
+ Writer::$window->connect_simple('destroy', array($this, 'onDeleteEvent'));
+ unset($this);
return;
}
/**
- * public function onDeleteEvent
+ * public function getData
*
- * callback when window is destroyed
+ * if this is not the top window and has a parent, we link destroy to hide
*
+ * @param object instanceof GtkWindow $parent GtkWindow object parent
+ * @return void
+ */
+ public function getData($id)
+ {
+ // retrieve row from db
+ $row = new CharacterDao($id);
+ $this->set_title($row->name, Writer::i18n('Edit Character'));
+ return;
+ }
+
+ /**
+ * public function removeTimeout
+ *
+ * description
+ *
* @param type $name about
* @return type about
*/
- public function onDeleteEvent()
+ public function onClose()
{
- // write configuration settings for window
- $config = Config::instance();
- list($height, $width) = $this->get_size();
- $config->character_edit_height = $height;
- $config->character_edit_width = $width;
- list($x, $y) = $this->get_position();
- $config->character_edit_x = $x;
- $config->character_edit_y = $y;
- unset($config, $height, $width, $x, $y);
- $this->destroy();
- return;
+ $this->hide_all();
+ return TRUE;
}
}
?>
\ No newline at end of file
Modified: desktop/trunk/Writer/lib/window.class.php (27 => 28)
--- desktop/trunk/Writer/lib/window.class.php 2006-11-02 19:21:50 UTC (rev 27)
+++ desktop/trunk/Writer/lib/window.class.php 2006-11-30 15:15:17 UTC (rev 28)
@@ -2,7 +2,8 @@
/**
* window.class.php - window abstract class
*
- * extend this to get basic window functionality that is
+ * writer general purpose window code, handles menubar, toolbar and statusbar
+ * setup as well as general actions and other items
*
* This is released under the GPL, see license.txt for details
*
@@ -27,53 +28,17 @@
{
/**
- * array of gtk action groups
- * @var $actions type
+ * main vbox for window
+ * @var $vbox object instanceof GtkVBox
*/
- public $actions = array();
+ public $vbox;
/**
- * main menu for the window
- * @var $menu object instanceof GtkMenu
- */
- public $menu;
-
- /**
- * main toolbar for the window
- * @var $toolbar object instanceof GtkToolbar
- */
- public $toolbar;
-
- /**
* status bar for window
* @var $statusbar object instanceof GtkStatusBar
*/
public $statusbar;
- /**
- * array of all actions available to put on a toolbar
- * @var $toolbuttons
- */
- protected $toolbuttons = array(
- 'separator', 'new', 'open', 'close', 'delete', 'undelete', 'save', 'saveas',
- 'revert', 'print', 'quit', 'wizard', 'import', 'export', 'properties',
- 'characters', 'settings', 'editing', 'publishing', 'notes',
- 'preferences','help', 'website', 'about',);
-
- /**
- * array of items for the current toolbar
- * @var $toolcurrent array
- */
- protected $toolcurrent = array();
-
- /**
- * default items for window
- * @var $tooldefault array
- */
- protected $tooldefault = array('new', 'delete', 'save', 'separator', 'import',
- 'export', 'separator', 'print', 'properties');
-
-
//----------------------------------------------------------------
// Overrides
//----------------------------------------------------------------
@@ -90,11 +55,11 @@
parent::__construct();
- $this->set_name(strtolower(get_class($this)));
+ $config = Writer::$config;
- $config = Config::instance();
-
+ $this->set_name(strtolower(get_class($this)));
$name = $this->name;
+
// default size and location
$width = isset($config->{$name . '_height'}) ? (int) $config->{$name . '_height'} : 800;
$height = isset($config->{$name . '_width'}) ? (int) $config->{$name . '_width'} : 600;
@@ -107,14 +72,14 @@
$this->move($x, $y);
}
- $this->buildActions();
- $this->buildMenu();
- $this->buildToolbar();
+ //$this->buildActions();
+ //$this->buildMenu();
+ //$this->buildToolbar();
$this->buildStatusbar();
$vbox = $this->vbox = new GtkVBox();
- $vbox->pack_start($this->menu, 0, 0);
- $vbox->pack_start($this->toolbar, 0, 0);
+ //$vbox->pack_start($this->menu, 0, 0);
+ //$vbox->pack_start($this->toolbar, 0, 0);
$vbox->pack_end($this->statusbar, 0, 0);
$this->add($vbox);
@@ -130,9 +95,12 @@
* @param string $name title to set
* @return void
*/
- public function set_title($title)
+ public function set_title($title, $class = NULL)
{
- $class = ucfirst(str_replace('window', '', $this->name));
+ if(is_null($class))
+ {
+ $class = ucfirst(str_replace('window', '', $this->name));
+ }
parent::set_title(Writer::i18n('%s :: %s :: %s', 'Writer', $class, $title));
unset($title, $class);
return;
@@ -143,387 +111,6 @@
//----------------------------------------------------------------
/**
- * protected function buildActions
- *
- * creates all actions for the window
- *
- * @todo add additional generic actions
- * @return void
- */
- protected function buildActions($name = '')
- {
- $acc = new GtkAccelGroup();
- $this->add_accel_group($acc);
-
- // file related actions
- $group = $this->actions['file'] = new GtkActionGroup('file');
-
- $action = new GtkAction('new', Writer::i18n('_New...'), Writer::i18n('Create new blank %s', $name),
- 'gtk-new');
- $action->connect('activate', array($this, 'onNew'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, '<Ctrl>n');
-
- $action = new GtkAction('open', Writer::i18n('_Open...'), Writer::i18n('Open existing %s', $name),
- 'gtk-open');
- $action->connect('activate', array($this, 'onOpen'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, '<Ctrl>o');
-
- $action = new GtkAction('close', Writer::i18n('_Close'), Writer::i18n('Close current %s', $name),
- 'gtk-close');
- $action->connect('activate', array($this, 'onClose'));
- $group->add_action($action);
-
- $action = new GtkAction('delete', Writer::i18n('_Delete'), Writer::i18n('Delete current %s', $name),
- 'gtk-delete');
- $action->connect('activate', array($this, 'onDelete'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'Delete');
-
- $action = new GtkAction('undelete', Writer::i18n('_Undelete'), Writer::i18n('Undelete current %s', $name),
- 'gtk-undelete');
- $action->connect('activate', array($this, 'onUndelete'));
- $group->add_action($action);
-
- $action = new GtkAction('save', Writer::i18n('_Save'), Writer::i18n('Save %s', $name),
- 'gtk-save');
- $action->connect('activate', array($this, 'onSave'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, '<Ctrl>s');
-
- $action = new GtkAction('saveas', Writer::i18n('Save _As...'), Writer::i18n('Save %s under new name', $name),
- 'gtk-save-as');
- $action->connect('activate', array($this, 'onSaveAs'));
- $group->add_action($action);
-
- $action = new GtkAction('revert', Writer::i18n('Re_vert'), Writer::i18n('Revert %s to last save', $name),
- 'revert');
- $action->connect('activate', array($this, 'onRevert'));
- $group->add_action($action);
-
- $action = new GtkAction('print', Writer::i18n('_Print'), Writer::i18n('Print'),
- 'gtk-print');
- $action->connect('activate', array($this, 'onPrint'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, '<Ctrl>p');
-
- $action = new GtkAction('quit', Writer::i18n('_Quit'), Writer::i18n('Exit'),
- 'gtk-quit');
- $action->connect('activate', array($this, 'onQuit'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, '<Ctrl>q');
-
- // management related actions
- $group = $this->actions['manage'] = new GtkActionGroup('manage');
-
- $action = new GtkAction('wizard', Writer::i18n('_Wizard...'), Writer::i18n('Create %s using wizard', $name),
- 'wizard');
- $action->connect('activate', array($this, 'onWizard'));
- $group->add_action($action);
-
- $action = new GtkAction('import', Writer::i18n('_Import...'), Writer::i18n('Import %s from another format', $name),
- 'gtk-convert');
- $action->connect('activate', array($this, 'onImport'));
- $group->add_action($action);
-
- $action = new GtkAction('export', Writer::i18n('_Export...'), Writer::i18n('Export %s to another format', $name),
- 'save-all');
- $action->connect('activate', array($this, 'onExport'));
- $group->add_action($action);
-
- $action = new GtkAction('properties', Writer::i18n('_Properties...'), Writer::i18n('View and edit %s properties', $name),
- 'gtk-execute');
- $action->connect('activate', array($this, 'onProperties'));
- $group->add_action($action);
-
- // tools related actions
- $group = $this->actions['tools'] = new GtkActionGroup('tools');
-
- $action = new GtkAction('characters', Writer::i18n('_Characters...'), Writer::i18n('Characters management'),
- 'users');
- $action->connect('activate', array($this, 'onCharacters'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'F2');
-
- $action = new GtkAction('settings', Writer::i18n('_Settings...'), Writer::i18n('Settings management'),
- 'folder-home');
- $action->connect('activate', array($this, 'onSettings'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'F3');
-
- $action = new GtkAction('editing', Writer::i18n('_Editing...'), Writer::i18n('Editing projects'),
- 'editor');
- $action->connect('activate', array($this, 'onEditing'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'F5');
-
- $action = new GtkAction('publishing', Writer::i18n('_Publishing...'), Writer::i18n('Publishing projects'),
- 'ftp');
- $action->connect('activate', array($this, 'onPublishing'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'F6');
-
- $action = new GtkAction('notes', Writer::i18n('_Notes...'), Writer::i18n('Project notes'),
- 'notes');
- $action->connect('activate', array($this, 'onNotes'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'F7');
-
- $action = new GtkAction('preferences', Writer::i18n('_Preferences...'), Writer::i18n('Writer preferences'),
- 'gtk-preferences');
- $action->connect('activate', array($this, 'onPreferences'));
- $group->add_action($action);
-
- // help related actions
- $group = $this->actions['help'] = new GtkActionGroup('help');
-
- $action = new GtkAction('help', Writer::i18n('_Help'), Writer::i18n('Help'),
- 'gtk-help');
- $action->connect('activate', array($this, 'onHelp'));
- $action->set_accel_group($acc);
- $group->add_action_with_accel($action, 'F1');
-
- $action = new GtkAction('website', Writer::i18n('_Website'), Writer::i18n('Visit writer website'),
- 'browser');
- $action->connect('activate', array($this, 'onWebsite'));
- $group->add_action($action);
-
- $action = new GtkAction('about', Writer::i18n('_About'), Writer::i18n('About Writer'),
- 'gtk-about');
- $action->connect('activate', array($this, 'onAbout'));
- $group->add_action($action);
-
- // toolbar related actions
- $group = $this->actions['toolbar'] = new GtkActionGroup('toolbar');
-
- $action = new GtkToggleAction('toggle', Writer::i18n('_Show Toolbar'),
- Writer::i18n('Show and hide the toolbar'), NULL);
- $config = Config::instance();
- $state = isset($config->{$name . '_show_toolbar'}) ? (bool) $config->{$name . '_show_toolbar'} : TRUE;
- $action->set_active($state);
- $action->connect_simple('toggled', array($this, 'toggleToolbar'));
- $group->add_action($action);
-
- $radio = $action = new GtkRadioAction('small', Writer::i18n('_Small'),
- Writer::i18n('Display small icons on the toolbar'), NULL, 1);
- $action->connect_simple('toggled', array($this, 'sizeToolbar'), 'small');
- $action->set_group($radio);
- $group->add_action($action);
-
- $action = new GtkRadioAction('medium', Writer::i18n('_Medium'),
- Writer::i18n('Display medium icons on the toolbar'), NULL, 2);
- $action->connect_simple('toggled', array($this, 'sizeToolbar'), 'medium');
- $action->set_group($radio);
- $group->add_action($action);
-
- $action = new GtkRadioAction('large', Writer::i18n('_Large'),
- Writer::i18n('Display large icons on the toolbar'), NULL, 3);
- $action->connect_simple('toggled', array($this, 'sizeToolbar'), 'large');
- $action->set_group($radio);
- $group->add_action($action);
-
- $radio = $action = new GtkRadioAction('icon', Writer::i18n('_Icons'),
- Writer::i18n('Display only icons on the toolbar'), NULL, 1);
- $action->connect_simple('toggled', array($this, 'styleToolbar'), 'icon');
- $action->set_group($radio);
- $group->add_action($action);
-
- $action = new GtkRadioAction('text', Writer::i18n('_Text'),
- Writer::i18n('Display only text on the toolbar'), NULL, 2);
- $action->connect_simple('toggled', array($this, 'styleToolbar'), 'text');
- $action->set_group($radio);
- $group->add_action($action);
-
- $action = new GtkRadioAction('both', Writer::i18n('_Both'),
- Writer::i18n('Display icons and text on the toolbar'), NULL, 3);
- $action->connect_simple('toggled', array($this, 'styleToolbar'), 'both');
- $action->set_group($radio);
- $group->add_action($action);
-
- $action = new GtkAction('customize', '_Customize...', 'Customize toolbar',
- 'gtk-properties');
- $action->connect('activate', array($this, 'onCustomize'));
- $group->add_action($action);
-
- unset($group, $action, $radio, $this, $state, $config, $name, $acc);
- return;
- }
-
- /**
- * protected function buildMenu
- *
- * build a default menubar
- * file quit, view options
- *
- * @todo finish menu creation
- * @return void
- */
- protected function buildMenu()
- {
-
- $this->menu = $menu = is_null($this->menu) ? new GtkMenuBar() : $this->menu;
- $tooltips = Tooltips::instance();
- $config = Config::instance();
- $name = $this->name;
-
- $group = $this->actions['help'];
- $item = new GtkMenuItem(Writer::i18n('_Help'));
- $menu->add($item);
- $submenu = new GtkMenu();
- $item->set_submenu($submenu);
-
- $action = $group->get_action('help');
- $item = $action->create_menu_item();
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $action = $group->get_action('website');
- $item = $action->create_menu_item();
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $submenu->append(new GtkSeparatorMenuItem());
-
- $action = $group->get_action('about');
- $item = $action->create_menu_item();
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- unset($this, $menu, $action, $item, $tooltips, $config, $name, $group,
- $submenu, $subitem, $child, $id, $file, $list);
- return;
- }
-
- /**
- * protected function buildToolbar
- *
- * build toolbar
- *
- * @todo set up toolbar with chosen customization
- * @return void
- */
- protected function buildToolbar()
- {
- $name = $this->name;
- $config = Config::instance();
- $tooltips = Tooltips::instance();
-
- $toolbar = $this->toolbar = new GtkToolbar();
- $size = isset($config->{$this->name . '_toolbar_size'}) ? (string) $config->{$this->name . '_toolbar_size'} : 'small';
- $style = isset($config->{$name . '_toolbar_style'}) ? (string) $config->{$name . '_toolbar_style'} : 'icon';
- $toolitems = $this->toolcurrent = isset($config->{$name . 'toolbar_items'}) ? $config->{$name . 'toolbar_items'} : $this->tooldefault;
-
- // populate toolbar
- foreach($toolitems as $name)
- {
- if($name === 'separator')
- {
- $toolbar->insert(new GtkSeparatorToolItem(), -1);
- }
- else
- {
- $action = $this->getAction($name);
- if(!is_null($action))
- {
- $item = $action->create_tool_item();
- $item->set_tooltip($tooltips, $action->get_property('tooltip'));
- $toolbar->insert($item, -1);
- }
- }
- }
-
- // Popup menu
- $menu = $toolbar->menu = new GtkMenu();
- $group = $this->actions['toolbar'];
-
- $action = $group->get_action('toggle');
- $item = $action->create_menu_item();
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $menu->append($item);
-
- $item = new GtkMenuItem(Writer::i18n('Toolbar S_tyle'));
- $menu->add($item);
- $submenu = new GtkMenu();
- $item->set_submenu($submenu);
-
- $action = $group->get_action('icon');
- $item = $action->create_menu_item();
- if($style === 'icon')
- {
- $item->set_active(TRUE);
- }
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $action = $group->get_action('text');
- $item = $action->create_menu_item();
- if($style === 'text')
- {
- $item->set_active(TRUE);
- }
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $action = $group->get_action('both');
- $item = $action->create_menu_item();
- if($style === 'both')
- {
- $item->set_active(TRUE);
- }
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $item = new GtkMenuItem(Writer::i18n('Toolbar Si_ze'));
- $menu->add($item);
- $submenu = new GtkMenu();
- $item->set_submenu($submenu);
-
- $action = $group->get_action('small');
- $item = $action->create_menu_item();
- if($size === 'small')
- {
- $item->set_active(TRUE);
- }
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $action = $group->get_action('medium');
- $item = $action->create_menu_item();
- if($size === 'medium')
- {
- $item->set_active(TRUE);
- }
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $action = $group->get_action('large');
- $item = $action->create_menu_item();
- if($size === 'large')
- {
- $item->set_active(TRUE);
- }
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $submenu->append($item);
-
- $menu->append(new GtkSeparatorMenuItem());
-
- $action = $group->get_action('customize');
- $item = $action->create_menu_item();
- $tooltips->set_tip($item, $action->get_property('tooltip'));
- $menu->append($item);
-
- $menu->show_all();
-
- $toolbar->set_events($toolbar->get_events() | Gdk::BUTTON_PRESS_MASK);
- $toolbar->connect('button-press-event', array($this, 'doPopup'), $menu);
-
- unset($this, $menu, $toolbar, $submenu, $tooltips, $config, $name, $state,
- $style, $size, $toolitems, $action, $group, $item);
- return;
- }
-
- /**
* protected function buildStatusbar
*
* build statusbar
@@ -536,7 +123,7 @@
$children = $status->get_children();
$status->label = $children[0]->child;
$status->label->set_padding(3, 0);
- $status->label->set_label(Writer::i18n('<i>Ready</i>'));
+ $status->label->set_label(Writer::i18n('Ready'));
$status->label->set_use_markup(TRUE);
unset($status, $children);
return;
@@ -556,7 +143,7 @@
public function onDeleteEvent()
{
$name = $this->name;
- $config = Config::instance();
+ $config = Writer::$config;
list($height, $width) = $this->get_size();
$config->{$name . '_height'} = $height;
@@ -570,584 +157,5 @@
$this->destroy();
return;
}
-
- /**
- * public function toggleToolbar
- *
- * show-hide toolbar callback
- *
- * @return void
- */
- public function toggleToolbar()
- {
- $state = !$this->toolbar->is_visible();
- $this->toolbar->set_visible($state);
- Config::instance()->{$this->name . '_show_toolbar'} = $state;
- if(!is_null($this->statusbar))
- {
- $this->statusbar->label->set_label(Writer::i18n('<b>Toolbar visibility changed</b>'));
- }
- unset($state);
- return;
- }
-
- /**
- * public function styleToolbar
- *
- * change toolbar display type
- *
- * @param string $style text|icon|both
- * @return void
- */
- public function styleToolbar($style)
- {
- $config = Config::instance();
- switch($style)
- {
- case 'both':
- {
- $config->{$this->name . '_toolbar_style'} = 'both';
- $this->toolbar->set_style(Gtk::TOOLBAR_BOTH);
- break;
- }
- case 'text':
- {
- $config->{$this->name . '_toolbar_style'} = 'text';
- $this->toolbar->set_style(Gtk::TOOLBAR_TEXT);
- break;
- }
- default:
- {
- $config->{$this->name . '_toolbar_style'} = 'icon';
- $this->toolbar->set_style(Gtk::TOOLBAR_ICONS);
- }
- }
- if(!is_null($this->statusbar))
- {
- $this->statusbar->label->set_label(Writer::i18n('<b>Toolbar style changed</b>'));
- }
- unset($config, $style);
- return;
- }
-
- /**
- * public function sizeToolbar
- *
- * change toolbar icon display size
- *
- * @param int $size icon size to change toolbar to
- * @return void
- */
- public function sizeToolbar($size)
- {
- $config = Config::instance();
- switch($size)
- {
- case 'large':
- {
- $config->{$this->name . '_toolbar_size'} = 'large';
- $this->toolbar->set_icon_size(Writer::$DND);
- break;
- }
- case 'medium':
- {
- $config->{$this->name . '_toolbar_size'} = 'medium';
- $this->toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
- break;
- }
- default:
- {
- $config->{$this->name . '_toolbar_size'} = 'small';
- $this->toolbar->set_icon_size(Writer::$BUTTON);
- }
- }
- if(!is_null($this->statusbar))
- {
- $this->statusbar->label->set_label(Writer::i18n('<b>Toolbar icon size changed</b>'));
- }
- unset($config, $size);
- return;
- }
-
- /**
- * public function doPopup
- *
- * pops up a popup menu on right click
- *
- * @param object $window GtkWindow
- * @param object $event GdkEvent
- * @param object $menu GtkMenu
- * @return void
- */
- public function doPopup($window, $event, $menu)
- {
- if($event->button == 3)
- {
- $menu->popup();
- }
- unset($window, $event, $menu);
- return;
- }
-
- /**
- * public function deleteRow
- *
- * press delete to remove a treeview row
- *
- * @param object $window GtkWindow
- * @param object $event GdkEvent
- * @return void
- */
- public function deleteRow($window, $event, $treeview)
- {
- if($event->keyval == Gdk::KEY_Delete)
- {
- $selection = $treeview->get_selection();
- list($model, $iter) = $selection->get_selected();
- $next = $model->iter_next($iter);
- if(!is_null($next))
- {
- $selection->select_iter($next);
- }
- if(!is_null($iter))
- {
- $model->remove($iter);
- }
- unset($selection, $model, $iter);
- }
- unset($window, $event, $treeview, $next);
- return;
- }
-
- /**
- * public function getAction
- *
- * loops through all action groups and finds the first one matching an
- * action name
- *
- * @param string $name action to grab
- * @return object instanceof GtkAction
- */
- public function getAction($name)
- {
- foreach($this->actions as $group)
- {
- $action = $group->get_action($name);
- if(!is_null($action))
- {
- break;
- }
- }
- unset($group);
- return $action;
- }
-
- /**
- * public function onCustomize
- *
- * description
- *
- * @todo right now the drag and drop for this is ugly as sin because the enable_drag stuff
- * for the higher level treeview dnd stuff doesn't exist yet, this should be moved
- * over when that stuff is completed.
- * @param type $name about
- * @return type about
- */
- public function onCustomize()
- {
- $options = array();
- $actions = array();
- $window = new GtkDialog(
- Writer::i18n('%s :: Customize', $this->get_title()),
- $this, Gtk::DIALOG_MODAL | Gtk::DIALOG_DESTROY_WITH_PARENT | Gtk::DIALOG_NO_SEPARATOR,
- array(Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL, Gtk::STOCK_APPLY, Gtk::RESPONSE_APPLY));
- $window->set_position(Gtk::WIN_POS_CENTER);
- $window->vbox->add($notebook = new GtkNotebook());
-
- // show or hide toobar, pick icon size (with images) and types (with images)
- $table = new GtkTable();
- $group = $this->actions['toolbar'];
-
- $toggle = $button = new GtkCheckButton();
- $actions['toggle'] = $action = $group->get_action('toggle');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 0, 4, 0, 1);
-
- $table->attach(new GtkHSeparator(), 0, 4, 1, 2);
-
- $options['icon'] = $button = new GtkRadioButton();
- $actions['icon'] = $action = $group->get_action('icon');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 0, 1, 2, 3);
-
- $toolbar = new GtkToolbar();
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
- $toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
- $toolbar->set_style(Gtk::TOOLBAR_ICONS);
- $toolbar->set_show_arrow(FALSE);
- $table->attach($toolbar, 1, 2, 2, 3);
-
- $options['text'] = $button = new GtkRadioButton($button);
- $actions['text'] = $action = $group->get_action('text');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 0, 1, 3, 4);
-
- $toolbar = new GtkToolbar();
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
- $toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
- $toolbar->set_style(Gtk::TOOLBAR_TEXT);
- $toolbar->set_show_arrow(FALSE);
- $table->attach($toolbar, 1, 2, 3, 4);
-
- $options['both'] = $button = new GtkRadioButton($button);
- $actions['both'] = $action = $group->get_action('both');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 0, 1, 4, 5);
-
- $toolbar = new GtkToolbar();
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
- $toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
- $toolbar->set_style(Gtk::TOOLBAR_BOTH);
- $toolbar->set_show_arrow(FALSE);
- $table->attach($toolbar, 1, 2, 4, 5);
-
- $options['small'] = $button = new GtkRadioButton();
- $actions['small'] = $action = $group->get_action('small');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 2, 3, 2, 3);
-
- $toolbar = new GtkToolbar();
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
- $toolbar->set_icon_size(Writer::$BUTTON);
- $toolbar->set_style(Gtk::TOOLBAR_ICONS);
- $toolbar->set_show_arrow(FALSE);
- $table->attach($toolbar, 3, 4, 2, 3);
-
- $options['medium'] = $button = new GtkRadioButton($button);
- $actions['medium'] = $action = $group->get_action('medium');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 2, 3, 3, 4);
-
- $toolbar = new GtkToolbar();
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
- $toolbar->set_icon_size(Writer::$LARGE_TOOLBAR);
- $toolbar->set_style(Gtk::TOOLBAR_ICONS);
- $toolbar->set_show_arrow(FALSE);
- $table->attach($toolbar, 3, 4, 3, 4);
-
- $options['large'] = $button = new GtkRadioButton($button);
- $actions['large'] = $action = $group->get_action('large');
- $action->connect_proxy($button);
- $action->block_activate_from($button);
- $table->attach($button, 2, 3, 4, 5);
-
- $toolbar = new GtkToolbar();
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-new'), 0);
- $toolbar->insert(GtkToolButton::new_from_stock('gtk-save'), 0);
- $toolbar->set_icon_size(Writer::$DND);
- $toolbar->set_style(Gtk::TOOLBAR_ICONS);
- $toolbar->set_show_arrow(FALSE);
- $table->attach($toolbar, 3, 4, 4, 5);
-
- $table->attach(new GtkHSeparator(), 0, 4, 5, 6);
-
- $table->attach($all = new GtkCheckButton(Writer::i18n('_Apply options to all windows'), TRUE), 0, 4, 6, 7);
-
- $notebook->append_page($table, $label = new GtkLabel(Writer::i18n('_Options')));
- $label->set_use_underline(TRUE);
- unset($table, $toolbar, $label, $button, $group, $action);
-
- $vbox = new GtkVBox();
- $hbox = new GtkHBox();
- $vbox->pack_start($hbox);
-
- // Set up treeview for available commands
- $scrolled = new GtkScrolledWindow();
- $scrolled->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- $treeview = new GtkTreeView();
- $treeview->set_headers_visible(FALSE);
- $selection = $treeview->get_selection();
- $selection->set_mode(Gtk::SELECTION_SINGLE);
- $scrolled->add($treeview);
-
- $col = new GtkTreeViewColumn('image', new GtkCellRendererPixbuf(), 'pixbuf', 0);
- $treeview->append_column($col);
-
- $col = new GtkTreeViewColumn('name', new GtkCellRendererText(), 'text', 1);
- $col->set_expand(TRUE);
- $treeview->append_column($col);
-
- $hbox->pack_start($scrolled);
-
- $current = new GtkListStore(GdkPixbuf::gtype, Gtk::TYPE_STRING, Gtk::TYPE_STRING);
- foreach($this->toolbuttons as $name)
- {
- if($name == 'separator')
- {
- $current->append(array(NULL, Writer::i18n('Separator'), NULL));
- continue;
- }
- $action = $this->getAction($name);
- $current->append(array($window->render_icon($action->get_property('stock_id'), Writer::$LARGE_TOOLBAR),
- str_replace(array('...', '_'), '', $action->get_property('label')), $name));
- }
- $treeview->set_model($current);
- $treeview->drag_source_set(Gdk::BUTTON1_MASK, array(array('text/plain', 0, 0)), Gdk::ACTION_COPY);
- $treeview->connect('drag-begin', array($this, 'setRowDragIcon'));
- $treeview->connect('drag-data-get', array($this, 'treeviewDragStart'));
-
- // Set up treeview for available commands
- $scrolled = new GtkScrolledWindow();
- $scrolled->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- $treeview = new GtkTreeView();
- $treeview->set_headers_visible(FALSE);
- $selection = $treeview->get_selection();
- $selection->set_mode(Gtk::SELECTION_SINGLE);
- $scrolled->add($treeview);
-
- $col = new GtkTreeViewColumn('image', new GtkCellRendererPixbuf(), 'pixbuf', 0);
- $treeview->append_column($col);
-
- $col = new GtkTreeViewColumn('name', new GtkCellRendererText(), 'text', 1);
- $col->set_expand(TRUE);
- $treeview->append_column($col);
-
- $hbox->pack_start($scrolled);
-
- $current = new GtkListStore(GdkPixbuf::gtype, Gtk::TYPE_STRING, Gtk::TYPE_STRING);
- foreach($this->toolcurrent as $name)
- {
- if($name == 'separator')
- {
- $current->append(array(NULL, Writer::i18n('Separator'), 'separator'));
- continue;
- }
- $action = $this->getAction($name);
- $current->append(array($window->render_icon($action->get_property('stock_id'), Writer::$LARGE_TOOLBAR),
- str_replace(array('...', '_'), '', $action->get_property('label')), $name));
- }
- Tooltips::instance()->set_tip($treeview, Writer::i18n('Press delete to remove an item'));
- $treeview->set_model($current);
- $treeview->drag_dest_set(Gtk::DEST_DEFAULT_ALL, array( array( 'text/plain', 0, 0)), Gdk::ACTION_COPY);
- $treeview->connect('drag-data-received', array($this, 'treeviewDragEnd'));
- $treeview->set_events($treeview->get_events() | Gdk::KEY_PRESS_MASK);
- $treeview->connect('key-press-event', array($this, 'deleteRow'), $treeview);
- $treeview->drag_source_set(Gdk::BUTTON1_MASK, array(array('text/plain', 0, 0)), Gdk::ACTION_COPY);
- $treeview->connect('drag-begin', array($this, 'setRowDragIcon'));
- $treeview->connect('drag-data-get', array($this, 'treeviewDragStart'), TRUE);
-
- $vbox->pack_start($default = new GtkCheckButton(Writer::i18n('_Reset to default toolbar'), TRUE), 0, 0);
-
- $notebook->append_page($vbox, $label = new GtkLabel(Writer::i18n('_Commands')));
- $label->set_use_underline(TRUE);
- $window->show_all();
- $response = $window->run();
- if($response == Gtk::RESPONSE_APPLY)
- {
- if($all->get_active() == TRUE)
- {
- $this->recurseWindowOptions(Writer::$window, $toggle->get_active(), $options);
- }
- else
- {
- $actions['toggle']->set_active($toggle->get_active());
- foreach($options as $name => $button)
- {
- if($button->get_active() == TRUE)
- {
- $actions[$name]->set_active(TRUE);
- }
- }
- }
-
- $this->toolcurrent = array();
- if($default->get_active() == TRUE)
- {
- $this->toolcurrent = $this->tooldefault;
- }
- else
- {
- $current->foreach(array($this, 'setButtons'));
- }
- $this->rebuildToolbar();
- }
- $window->destroy();
-
- unset($all, $window, $notebook, $response, $this, $options, $actions,
- $toggle, $vbox, $hbox, $scrolled, $treeview, $selection, $col, $current,
- $name, $action, $default, $label, $button);
- }
-
- /**
- * public function recurseWindows
- *
- * description
- *
- * @param type $name about
- * @return type about
- */
- public function recurseWindowOptions($window, $toggle, $options)
- {
- $window->actions['toolbar']->get_action('toggle')->set_active($toggle);
- foreach($options as $name => $button)
- {
- if($button->get_active() == TRUE)
- {
- $window->actions['toolbar']->get_action($name)->set_active(TRUE);
- }
- }
- foreach($window as $name => $item)
- {
- if($name != 'transient_parent' && is_object($item) && $item instanceof Window)
- {
- $this->recurseWindowOptions($item, $toggle, $options);
- }
- }
- unset($window, $options, $toggle, $item, $name, $button);
- return;
- }
-
- /**
- * public function setRowDragIcon
- *
- * creates a drag icon from a treeview row
- *
- * @param object $treeview instanceof GtkTreeview
- * @return void
- */
- public function setRowDragIcon(GtkTreeview $treeview)
- {
- $selection = $treeview->get_selection();
- list($model, $iter) = $selection->get_selected();
- $pixmap = $treeview->create_row_drag_icon($model->get_path($iter));
- $treeview->drag_source_set_icon($pixmap->get_colormap(), $pixmap);
- unset($selection, $model, $iter, $treeview, $pixmap);
- return;
- }
-
- /**
- * public function treeviewDragStart
- *
- * description
- *
- * @param type $name about
- * @return type about
- */
- public function treeviewDragStart(GtkTreeview $treeview, $context, $data, $x, $y, $bool = FALSE)
- {
- $selection = $treeview->get_selection();
- list($model, $iter) = $selection->get_selected();
- $data->set_text($model->get_value($iter, 2));
- if($bool == TRUE)
- {
- $model->remove($iter);
- }
- unset($treeview, $context, $selection, $model, $iter, $x, $y, $bool);
- return;
- }
-
- public function treeviewDragEnd(GtkTreeview $treeview, $context, $x, $y, $data)
- {
- list($x, $y) = $treeview->widget_to_tree_coords($x, $y);
- $iter = $treeview->get_path_at_pos($x, $y);
- $model = $treeview->get_model();
- if(is_null($iter[0]))
- {
- $total = $model->iter_n_children(NULL);
- if($total > 0)
- $total--;
- $iter = $model->iter_nth_child(NULL, $total);
- }
- else
- {
- $iter = $model->get_iter($iter[0]);
- }
- $action = $this->getAction($data->data);
- if(is_null($action))
- {
- $newiter = $model->append(array(NULL, Writer::i18n('Separator'), 'separator'));
- }
- else
- {
- // insert before/after are broken
- $newiter = $model->append(array($treeview->render_icon($action->get_property('stock_id'), Writer::$LARGE_TOOLBAR),
- str_replace(array('...', '_'), '', $action->get_property('label')), $data->data));
- }
- $model->move_after($newiter, $iter);
- unset($treeview, $context, $x, $y, $data, $iter, $model, $action, $newiter, $total);
- return;
- }
-
- /**
- * public function setButtons
- *
- * description
- *
- * @param type $name about
- * @return type about
- */
- public function setButtons($store, $path, $iter)
- {
- $this->toolcurrent[] = $store->get_value($iter, 2);
- unset($store, $path, $iter);
- return;
- }
-
- /**
- * public function rebuildToolbar
- *
- * description
- *
- * @param type $name about
- * @return type about
- */
- public function rebuildToolbar()
- {
- $toolbar = $this->toolbar;
- $tooltips = Tooltips::instance();
- $list = $toolbar->get_children();
- foreach($list as $widget)
- {
- $toolbar->remove($widget);
- }
- // populate toolbar
- foreach($this->toolcurrent as $name)
- {
- if($name == 'separator')
- {
- $toolbar->insert($sep = new GtkSeparatorToolItem(), -1);
- $sep->show();
- }
- else
- {
- $action = $this->getAction($name);
- if(!is_null($action))
- {
- $item = $action->create_tool_item();
- $item->set_tooltip($tooltips, $action->get_property('tooltip'));
- $toolbar->insert($item, -1);
- }
- }
- }
- Config::instance()->{$this->name . 'toolbar_items'} = $this->toolcurrent;
- if(!is_null($this->statusbar))
- {
- $this->statusbar->label->set_label(Writer::i18n('<b>Toolbar items rebuilt</b>'));
- }
- unset($toolbar, $list, $widget, $name, $action, $item, $tooltips);
- return;
- }
-
}
?>
\ No newline at end of file