From 57a53674bc402a475635db1f26bc868a0952a74a Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 12 Jan 2003 17:59:20 +0000 Subject: changed Configmenu to FbTk Menu and fix new function setupConfigmenu and removed toolbar placement resource --- src/Screen.cc | 165 +++++++++++++++++++++++++++++++++++++--------------------- src/Screen.hh | 17 +++--- 2 files changed, 113 insertions(+), 69 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index fa311cd..312354d 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.96 2003/01/10 00:35:19 fluxgen Exp $ +// $Id: Screen.cc,v 1.97 2003/01/12 17:59:20 fluxgen Exp $ #include "Screen.hh" @@ -34,7 +34,6 @@ #include "Window.hh" #include "Workspace.hh" #include "Workspacemenu.hh" -#include "Configmenu.hh" #include "StringUtil.hh" #include "Netizen.hh" #include "DirHelper.hh" @@ -42,6 +41,9 @@ #include "SimpleCommand.hh" #include "MenuTheme.hh" #include "FbCommands.hh" +#include "BoolMenuItem.hh" +#include "IntResMenuItem.hh" +#include "MacroCommand.hh" //use GNU extensions #ifndef _GNU_SOURCE @@ -294,8 +296,8 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm, tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"), tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), - toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), - toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") + toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead") + // toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") { }; @@ -422,10 +424,7 @@ BScreen::BScreen(ResourceManager &rm, } } - workspacemenu.reset(new FbTk::Menu(*m_menutheme, scrn, *image_control)); - setupWorkspacemenu(*this, *workspacemenu); - - configmenu = new Configmenu(this); + workspacemenu.reset(createMenuFromScreen(*this)); Workspace *wkspc = (Workspace *) 0; if (*resource.workspaces != 0) { @@ -441,22 +440,32 @@ BScreen::BScreen(ResourceManager &rm, } current_workspace = workspacesList.front(); - workspacemenu->setItemSelected(2, true); - - m_toolbar.reset(new Toolbar(this)); - m_toolbar->setPlacement(*resource.toolbar_placement); - m_toolbar->reconfigure(); #ifdef SLIT - m_slit.reset(new Slit(this)); + // must create this one before configure menu + m_slit.reset(new Slit(*this)); #endif // SLIT + m_toolbar.reset(new Toolbar(this)); + + setupWorkspacemenu(*this, *workspacemenu); + + m_configmenu.reset(createMenuFromScreen(*this)); + setupConfigmenu(*m_configmenu.get()); + + workspacemenu->setItemSelected(2, true); + + + // m_toolbar->setPlacement(*resource.toolbar_placement); + m_toolbar->reconfigure(); + initMenu(); // create and initiate rootmenu raiseWindows(Workspace::Stack()); //update menus m_rootmenu->update(); + m_configmenu->update(); #ifdef SLIT if (m_slit.get()) m_slit->reconfigure(); @@ -558,8 +567,6 @@ BScreen::~BScreen() { } netizenList.clear(); - delete configmenu; - delete image_control; delete theme; @@ -658,8 +665,7 @@ void BScreen::reconfigure() { //reconfigure menus workspacemenu->reconfigure(); - - configmenu->reconfigure(); + m_configmenu->reconfigure(); { int remember_sub = m_rootmenu->currentSubmenu(); @@ -669,7 +675,7 @@ void BScreen::reconfigure() { m_rootmenu->drawSubmenu(remember_sub); } - m_toolbar->setPlacement(*resource.toolbar_placement); + // m_toolbar->setPlacement(*resource.toolbar_placement); m_toolbar->reconfigure(); if (m_toolbar->theme().font().isAntialias() != *resource.antialias) m_toolbar->theme().font().setAntialias(*resource.antialias); @@ -1160,31 +1166,6 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { session_stack[i++] = workspacemenu->windowID(); - session_stack[i++] = configmenu->focusmenu().windowID(); - session_stack[i++] = configmenu->placementmenu().windowID(); - session_stack[i++] = configmenu->tabmenu().windowID(); - session_stack[i++] = configmenu->windowID(); - -#ifdef SLIT - session_stack[i++] = m_slit->menu().getDirectionmenu().windowID(); - session_stack[i++] = m_slit->menu().getPlacementmenu().windowID(); -#ifdef XINERAMA - if (hasXinerama()) { - session_stack[i++] = m_slit->menu().getHeadmenu()->windowID(); - } -#endif // XINERAMA - session_stack[i++] = m_slit->menu().windowID(); -#endif // SLIT - - session_stack[i++] = - m_toolbar->menu().placementmenu()->windowID(); -#ifdef XINERAMA - if (hasXinerama()) { - session_stack[i++] = m_toolbar->getMenu()->getHeadmenu()->windowID(); - } -#endif // XINERAMA - session_stack[i++] = m_toolbar->menu().windowID(); - Rootmenus::iterator rit = rootmenuList.begin(); Rootmenus::iterator rit_end = rootmenuList.end(); for (; rit != rit_end; ++rit) { @@ -1378,7 +1359,7 @@ void BScreen::initMenu() { while (m_rootmenu->numberOfItems()) m_rootmenu->remove(0); } else - m_rootmenu.reset(new FbTk::Menu(*m_menutheme.get(), getScreenNumber(), *getImageControl())); + m_rootmenu.reset(createMenuFromScreen(*this)); bool defaultMenu = true; Fluxbox * const fb = Fluxbox::instance(); @@ -1519,19 +1500,20 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { } } // end of style */ - /* else if (str_key == "config") { - if (! str_label.size()) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenCONFIGError, - "BScreen::parseMenufile: [config] error, " - "no label defined")); - cerr<<"Row: "< + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenCONFIGError, + "BScreen::parseMenufile: [config] error, " + "no label defined")); + cerr<<"Row: "<setLabel(str_label.c_str()); - parseMenuFile(file, *submenu, row); + parseMenuFile(file, *submenu, row); submenu->update(); menu.insert(str_label.c_str(), submenu); + // save to list so we can delete it later rootmenuList.push_back(submenu); } @@ -1661,6 +1644,70 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { return ((menu.numberOfItems() == 0) ? true : false); } +void BScreen::setupConfigmenu(FbTk::Menu &menu) { + I18n *i18n = I18n::instance(); + using namespace FBNLS; + + FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); + FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand(*Fluxbox::instance(), &Fluxbox::save_rc)); + FbTk::RefCount reconf_cmd(new FbCommands::ReconfigureFluxboxCmd()); + s_a_reconf_macro->add(saverc_cmd); + s_a_reconf_macro->add(reconf_cmd); + FbTk::RefCount save_and_reconfigure(s_a_reconf_macro); +#ifdef SLIT + if (getSlit() != 0) + menu.insert("Slit", &getSlit()->menu()); +#endif // SLIT + menu.insert(i18n->getMessage( + ToolbarSet, ToolbarToolbarTitle, + "Toolbar"), &m_toolbar->menu()); + + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuImageDithering, + "Image Dithering"), + *resource.image_dither, save_and_reconfigure)); + menu.insert(new + BoolMenuItem( + i18n->getMessage( + ConfigmenuSet, ConfigmenuOpaqueMove, + "Opaque Window Moving"), + *resource.opaque_move, save_and_reconfigure)); + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuFullMax, + "Full Maximization"), + *resource.full_max, save_and_reconfigure)); + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuFocusNew, + "Focus New Windows"), + *resource.focus_new, save_and_reconfigure)); + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuFocusLast, + "Focus Last Window on Workspace"), + *resource.focus_last, save_and_reconfigure)); + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuMaxOverSlit, + "Maximize Over Slit"), + *resource.max_over_slit, save_and_reconfigure)); + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuWorkspaceWarping, + "Workspace Warping"), + *resource.workspace_warping, save_and_reconfigure)); + menu.insert(new + BoolMenuItem(i18n->getMessage( + ConfigmenuSet, ConfigmenuDesktopWheeling, + "Desktop MouseWheel Switching"), + *resource.desktop_wheeling, save_and_reconfigure)); + menu.insert(new BoolMenuItem("antialias", *resource.antialias, save_and_reconfigure)); + // finaly update menu + menu.update(); +} + void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu, const char *label, const char *directory) { /* // perform shell style ~ home directory expansion diff --git a/src/Screen.hh b/src/Screen.hh index 0002e0d..418cb12 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.60 2003/01/10 00:34:08 fluxgen Exp $ +// $Id: Screen.hh,v 1.61 2003/01/12 17:57:46 fluxgen Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -32,7 +32,8 @@ #include "Workspace.hh" #include "Tab.hh" #include "Resource.hh" -#include "Toolbar.hh" +#include "Subject.hh" +#include "FbWinFrameTheme.hh" #include #include @@ -48,11 +49,12 @@ #include "config.h" #endif // HAVE_CONFIG_H -class Configmenu; class Workspacemenu; class Iconmenu; class Netizen; class Slit; +class Toolbar; +class FbWinFrameTheme; namespace FbTk { class MenuTheme; @@ -168,7 +170,6 @@ public: /// @return the resource value of number of workspace inline int getNumberOfWorkspaces() const { return *resource.workspaces; } - inline Toolbar::Placement getToolbarPlacement() const { return *resource.toolbar_placement; } inline int getToolbarOnHead() { return *resource.toolbar_on_head; } @@ -191,7 +192,6 @@ public: inline void saveToolbarOnTop(bool r) { *resource.toolbar_on_top = r; } inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; } inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; } - inline void saveToolbarPlacement(Toolbar::Placement p) { *resource.toolbar_placement = p; } inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; } @@ -310,6 +310,7 @@ public: }; private: + void setupConfigmenu(FbTk::Menu &menu); void createStyleMenu(FbTk::Menu &menu, bool newmenu, const char *label, const char *directory); bool parseMenuFile(std::ifstream &filestream, FbTk::Menu &menu, int &row); @@ -333,7 +334,7 @@ private: Window geom_window; FbTk::ImageControl *image_control; - Configmenu *configmenu; + std::auto_ptr m_configmenu; std::auto_ptr m_rootmenu; @@ -383,10 +384,6 @@ private: Resource tab_alignment; Resource toolbar_on_head; - - Resource toolbar_placement; - - bool slit_on_top, slit_auto_hide; int slit_placement, slit_direction; -- cgit v0.11.2