summaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc102
1 files changed, 58 insertions, 44 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 5ec6480..bd55854 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.cc,v 1.129 2003/12/07 16:39:43 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.130 2003/12/08 17:29:44 fluxgen Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -212,6 +212,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
212 scrn.name() + ".toolbar.autoHide", scrn.altName() + ".Toolbar.AutoHide"), 212 scrn.name() + ".toolbar.autoHide", scrn.altName() + ".Toolbar.AutoHide"),
213 m_rc_maximize_over(scrn.resourceManager(), false, 213 m_rc_maximize_over(scrn.resourceManager(), false,
214 scrn.name() + ".toolbar.maxOver", scrn.altName() + ".Toolbar.MaxOver"), 214 scrn.name() + ".toolbar.maxOver", scrn.altName() + ".Toolbar.MaxOver"),
215 m_rc_visible(scrn.resourceManager(), true, scrn.name() + ".toolbar.visible", scrn.altName() + ".Toolbar.Visible"),
215 m_rc_width_percent(scrn.resourceManager(), 65, 216 m_rc_width_percent(scrn.resourceManager(), 65,
216 scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"), 217 scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"),
217 m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()), 218 m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()),
@@ -352,6 +353,8 @@ void Toolbar::lower() {
352} 353}
353 354
354void Toolbar::reconfigure() { 355void Toolbar::reconfigure() {
356 updateVisibleState();
357
355 m_tool_factory.updateThemes(); 358 m_tool_factory.updateThemes();
356 359
357 // parse resource tools and determine if we need to rebuild toolbar 360 // parse resource tools and determine if we need to rebuild toolbar
@@ -714,6 +717,10 @@ void Toolbar::setPlacement(Toolbar::Placement where) {
714 } 717 }
715} 718}
716 719
720void Toolbar::updateVisibleState() {
721 *m_rc_visible ? frame.window.show() : frame.window.hide();
722}
723
717void Toolbar::toggleHidden() { 724void Toolbar::toggleHidden() {
718 m_hide_timer.fireOnce(true); 725 m_hide_timer.fireOnce(true);
719 726
@@ -732,59 +739,66 @@ void Toolbar::moveToLayer(int layernum) {
732} 739}
733 740
734void Toolbar::setupMenus() { 741void Toolbar::setupMenus() {
735 Toolbar &tbar = *this; 742 const I18n &i18n = *I18n::instance();
736 I18n *i18n = I18n::instance();
737 using namespace FBNLS; 743 using namespace FBNLS;
738 using namespace FbTk; 744 using namespace FbTk;
739 745
740 FbTk::Menu &menu = tbar.menu(); 746 typedef RefCount<Command> RefCommand;
747 typedef SimpleCommand<Toolbar> ToolbarCommand;
748
741 //!! TODO: this should be inserted by the workspace tool 749 //!! TODO: this should be inserted by the workspace tool
742 750
743 751
744 RefCount<Command> start_edit(CommandParser::instance().parseLine("setworkspacename")); 752 RefCommand start_edit(CommandParser::instance().parseLine("setworkspacename"));
745 menu.insert(i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarEditWkspcName, 753 menu().insert(i18n.getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarEditWkspcName,
746 "Edit current workspace name"), 754 "Edit current workspace name"),
747 start_edit); 755 start_edit);
748 756
749 menu.setLabel(i18n->getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarToolbarTitle, 757 menu().setLabel(i18n.getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarToolbarTitle,
750 "Toolbar")); 758 "Toolbar"));
751 759
752 FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent", 760 MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent",
753 m_rc_width_percent, 761 m_rc_width_percent,
754 0, 100); // min/max value 762 0, 100); // min/max value
755 763
756 764
757 FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk:: 765 RefCommand reconfig_toolbar(new ToolbarCommand(*this, &Toolbar::reconfigure));
758 SimpleCommand<Toolbar> 766 RefCommand save_resources(CommandParser::instance().parseLine("saverc"));
759 (tbar, &Toolbar::reconfigure)); 767 MacroCommand *toolbar_menuitem_macro = new MacroCommand();
760 FbTk::RefCount<FbTk::Command> save_resources(CommandParser::instance().parseLine("saverc"));
761 FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand();
762 toolbar_menuitem_macro->add(reconfig_toolbar); 768 toolbar_menuitem_macro->add(reconfig_toolbar);
763 toolbar_menuitem_macro->add(save_resources); 769 toolbar_menuitem_macro->add(save_resources);
764 770
765 FbTk::RefCount<FbTk::Command> reconfig_toolbar_and_save_resource(toolbar_menuitem_macro); 771 RefCommand reconfig_toolbar_and_save_resource(toolbar_menuitem_macro);
766 toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource); 772 toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource);
767 773
768 menu.insert(toolbar_menuitem); 774 menu().insert(toolbar_menuitem);
775
776 menu().insert(new BoolMenuItem(i18n.getMessage(FBNLS::CommonSet, FBNLS::CommonAutoHide,
777 "Auto hide"),
778 *m_rc_auto_hide,
779 reconfig_toolbar_and_save_resource));
769 780
770 menu.insert(new BoolMenuItem(i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonAutoHide, 781 MacroCommand *visible_macro = new MacroCommand();
771 "Auto hide"), 782 RefCommand toggle_visible(new ToolbarCommand(*this, &Toolbar::updateVisibleState));
772 *m_rc_auto_hide, 783 visible_macro->add(toggle_visible);
773 reconfig_toolbar_and_save_resource)); 784 visible_macro->add(save_resources);
774 menu.insert(new BoolMenuItem("Maximize Over", *m_rc_maximize_over, 785 RefCommand toggle_visible_cmd(visible_macro);
775 reconfig_toolbar_and_save_resource)); 786 menu().insert(new BoolMenuItem("Visible", *m_rc_visible, toggle_visible_cmd));
776 menu.insert("Layer...", &tbar.layermenu());
777 787
778 if (tbar.screen().hasXinerama()) { 788 menu().insert(new BoolMenuItem("Maximize Over", *m_rc_maximize_over,
789 reconfig_toolbar_and_save_resource));
790 menu().insert("Layer...", &layermenu());
791
792
793
794 if (screen().hasXinerama()) {
779 // TODO: nls (main label plus menu heading 795 // TODO: nls (main label plus menu heading
780 menu.insert("On Head...", new XineramaHeadMenu<Toolbar>( 796 menu().insert("On Head...", new XineramaHeadMenu<Toolbar>(*screen().menuTheme(),
781 *tbar.screen().menuTheme(), 797 screen(),
782 tbar.screen(), 798 screen().imageControl(),
783 tbar.screen().imageControl(), 799 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
784 *tbar.screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), 800 *this,
785 tbar, 801 "Toolbar on Head"));
786 "Toolbar on Head"
787 ));
788 } 802 }
789 803
790 // setup items in placement menu 804 // setup items in placement menu
@@ -814,23 +828,23 @@ void Toolbar::setupMenus() {
814 828
815 {0, 0, "Bottom Right", Toolbar::BOTTOMRIGHT} 829 {0, 0, "Bottom Right", Toolbar::BOTTOMRIGHT}
816 }; 830 };
817 tbar.placementMenu().setMinimumSublevels(3); 831 placementMenu().setMinimumSublevels(3);
818 // create items in sub menu 832 // create items in sub menu
819 for (size_t i=0; i<15; ++i) { 833 for (size_t i=0; i<15; ++i) {
820 if (place_menu[i].default_str == 0) { 834 if (place_menu[i].default_str == 0) {
821 tbar.placementMenu().insert(""); 835 placementMenu().insert("");
822 } else { 836 } else {
823 const char *i18n_str = i18n->getMessage(place_menu[i].set, 837 const char *i18n_str = i18n.getMessage(place_menu[i].set,
824 place_menu[i].base, 838 place_menu[i].base,
825 place_menu[i].default_str); 839 place_menu[i].default_str);
826 RefCount<FbTk::Command> setplace(new SetToolbarPlacementCmd(tbar, place_menu[i].placement)); 840 RefCommand setplace(new SetToolbarPlacementCmd(*this, place_menu[i].placement));
827 tbar.placementMenu().insert(i18n_str, setplace); 841 placementMenu().insert(i18n_str, setplace);
828 842
829 } 843 }
830 } 844 }
831 menu.insert("Placement", &tbar.placementMenu()); 845 menu().insert("Placement", &placementMenu());
832 tbar.placementMenu().update(); 846 placementMenu().update();
833 menu.update(); 847 menu().update();
834} 848}
835 849
836void Toolbar::saveOnHead(int head) { 850void Toolbar::saveOnHead(int head) {