aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-01-12 17:59:20 (GMT)
committerfluxgen <fluxgen>2003-01-12 17:59:20 (GMT)
commit57a53674bc402a475635db1f26bc868a0952a74a (patch)
tree8371e60d60ed7796c9548a1dedd966f9f696e662 /src
parentfcf431100c1729c8301aa48a884c3b0feef495cb (diff)
downloadfluxbox-57a53674bc402a475635db1f26bc868a0952a74a.zip
fluxbox-57a53674bc402a475635db1f26bc868a0952a74a.tar.bz2
changed Configmenu to FbTk Menu and fix new function setupConfigmenu and removed toolbar placement resource
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc165
-rw-r--r--src/Screen.hh17
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 @@
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: Screen.cc,v 1.96 2003/01/10 00:35:19 fluxgen Exp $ 25// $Id: Screen.cc,v 1.97 2003/01/12 17:59:20 fluxgen Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -34,7 +34,6 @@
34#include "Window.hh" 34#include "Window.hh"
35#include "Workspace.hh" 35#include "Workspace.hh"
36#include "Workspacemenu.hh" 36#include "Workspacemenu.hh"
37#include "Configmenu.hh"
38#include "StringUtil.hh" 37#include "StringUtil.hh"
39#include "Netizen.hh" 38#include "Netizen.hh"
40#include "DirHelper.hh" 39#include "DirHelper.hh"
@@ -42,6 +41,9 @@
42#include "SimpleCommand.hh" 41#include "SimpleCommand.hh"
43#include "MenuTheme.hh" 42#include "MenuTheme.hh"
44#include "FbCommands.hh" 43#include "FbCommands.hh"
44#include "BoolMenuItem.hh"
45#include "IntResMenuItem.hh"
46#include "MacroCommand.hh"
45 47
46//use GNU extensions 48//use GNU extensions
47#ifndef _GNU_SOURCE 49#ifndef _GNU_SOURCE
@@ -294,8 +296,8 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
294 tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"), 296 tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"),
295 tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), 297 tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"),
296 tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), 298 tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"),
297 toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), 299 toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead")
298 toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") 300 // toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement")
299{ 301{
300 302
301}; 303};
@@ -422,10 +424,7 @@ BScreen::BScreen(ResourceManager &rm,
422 } 424 }
423 } 425 }
424 426
425 workspacemenu.reset(new FbTk::Menu(*m_menutheme, scrn, *image_control)); 427 workspacemenu.reset(createMenuFromScreen(*this));
426 setupWorkspacemenu(*this, *workspacemenu);
427
428 configmenu = new Configmenu(this);
429 428
430 Workspace *wkspc = (Workspace *) 0; 429 Workspace *wkspc = (Workspace *) 0;
431 if (*resource.workspaces != 0) { 430 if (*resource.workspaces != 0) {
@@ -441,22 +440,32 @@ BScreen::BScreen(ResourceManager &rm,
441 } 440 }
442 441
443 current_workspace = workspacesList.front(); 442 current_workspace = workspacesList.front();
444 workspacemenu->setItemSelected(2, true);
445
446 m_toolbar.reset(new Toolbar(this));
447 m_toolbar->setPlacement(*resource.toolbar_placement);
448 m_toolbar->reconfigure();
449 443
450#ifdef SLIT 444#ifdef SLIT
451 m_slit.reset(new Slit(this)); 445 // must create this one before configure menu
446 m_slit.reset(new Slit(*this));
452#endif // SLIT 447#endif // SLIT
453 448
449 m_toolbar.reset(new Toolbar(this));
450
451 setupWorkspacemenu(*this, *workspacemenu);
452
453 m_configmenu.reset(createMenuFromScreen(*this));
454 setupConfigmenu(*m_configmenu.get());
455
456 workspacemenu->setItemSelected(2, true);
457
458
459 // m_toolbar->setPlacement(*resource.toolbar_placement);
460 m_toolbar->reconfigure();
461
454 initMenu(); // create and initiate rootmenu 462 initMenu(); // create and initiate rootmenu
455 463
456 raiseWindows(Workspace::Stack()); 464 raiseWindows(Workspace::Stack());
457 465
458 //update menus 466 //update menus
459 m_rootmenu->update(); 467 m_rootmenu->update();
468 m_configmenu->update();
460#ifdef SLIT 469#ifdef SLIT
461 if (m_slit.get()) 470 if (m_slit.get())
462 m_slit->reconfigure(); 471 m_slit->reconfigure();
@@ -558,8 +567,6 @@ BScreen::~BScreen() {
558 } 567 }
559 netizenList.clear(); 568 netizenList.clear();
560 569
561 delete configmenu;
562
563 delete image_control; 570 delete image_control;
564 571
565 delete theme; 572 delete theme;
@@ -658,8 +665,7 @@ void BScreen::reconfigure() {
658 665
659 //reconfigure menus 666 //reconfigure menus
660 workspacemenu->reconfigure(); 667 workspacemenu->reconfigure();
661 668 m_configmenu->reconfigure();
662 configmenu->reconfigure();
663 669
664 { 670 {
665 int remember_sub = m_rootmenu->currentSubmenu(); 671 int remember_sub = m_rootmenu->currentSubmenu();
@@ -669,7 +675,7 @@ void BScreen::reconfigure() {
669 m_rootmenu->drawSubmenu(remember_sub); 675 m_rootmenu->drawSubmenu(remember_sub);
670 } 676 }
671 677
672 m_toolbar->setPlacement(*resource.toolbar_placement); 678 // m_toolbar->setPlacement(*resource.toolbar_placement);
673 m_toolbar->reconfigure(); 679 m_toolbar->reconfigure();
674 if (m_toolbar->theme().font().isAntialias() != *resource.antialias) 680 if (m_toolbar->theme().font().isAntialias() != *resource.antialias)
675 m_toolbar->theme().font().setAntialias(*resource.antialias); 681 m_toolbar->theme().font().setAntialias(*resource.antialias);
@@ -1160,31 +1166,6 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) {
1160 1166
1161 session_stack[i++] = workspacemenu->windowID(); 1167 session_stack[i++] = workspacemenu->windowID();
1162 1168
1163 session_stack[i++] = configmenu->focusmenu().windowID();
1164 session_stack[i++] = configmenu->placementmenu().windowID();
1165 session_stack[i++] = configmenu->tabmenu().windowID();
1166 session_stack[i++] = configmenu->windowID();
1167
1168#ifdef SLIT
1169 session_stack[i++] = m_slit->menu().getDirectionmenu().windowID();
1170 session_stack[i++] = m_slit->menu().getPlacementmenu().windowID();
1171#ifdef XINERAMA
1172 if (hasXinerama()) {
1173 session_stack[i++] = m_slit->menu().getHeadmenu()->windowID();
1174 }
1175#endif // XINERAMA
1176 session_stack[i++] = m_slit->menu().windowID();
1177#endif // SLIT
1178
1179 session_stack[i++] =
1180 m_toolbar->menu().placementmenu()->windowID();
1181#ifdef XINERAMA
1182 if (hasXinerama()) {
1183 session_stack[i++] = m_toolbar->getMenu()->getHeadmenu()->windowID();
1184 }
1185#endif // XINERAMA
1186 session_stack[i++] = m_toolbar->menu().windowID();
1187
1188 Rootmenus::iterator rit = rootmenuList.begin(); 1169 Rootmenus::iterator rit = rootmenuList.begin();
1189 Rootmenus::iterator rit_end = rootmenuList.end(); 1170 Rootmenus::iterator rit_end = rootmenuList.end();
1190 for (; rit != rit_end; ++rit) { 1171 for (; rit != rit_end; ++rit) {
@@ -1378,7 +1359,7 @@ void BScreen::initMenu() {
1378 while (m_rootmenu->numberOfItems()) 1359 while (m_rootmenu->numberOfItems())
1379 m_rootmenu->remove(0); 1360 m_rootmenu->remove(0);
1380 } else 1361 } else
1381 m_rootmenu.reset(new FbTk::Menu(*m_menutheme.get(), getScreenNumber(), *getImageControl())); 1362 m_rootmenu.reset(createMenuFromScreen(*this));
1382 1363
1383 bool defaultMenu = true; 1364 bool defaultMenu = true;
1384 Fluxbox * const fb = Fluxbox::instance(); 1365 Fluxbox * const fb = Fluxbox::instance();
@@ -1519,19 +1500,20 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1519 } 1500 }
1520 } // end of style 1501 } // end of style
1521 */ 1502 */
1522 /* else if (str_key == "config") { 1503 else if (str_key == "config") {
1523 if (! str_label.size()) { 1504 if (! str_label.size()) {
1524 fprintf(stderr, 1505 fprintf(stderr,
1525 i18n-> 1506 i18n->
1526 getMessage( 1507 getMessage(
1527 FBNLS::ScreenSet, FBNLS::ScreenCONFIGError, 1508 FBNLS::ScreenSet, FBNLS::ScreenCONFIGError,
1528 "BScreen::parseMenufile: [config] error, " 1509 "BScreen::parseMenufile: [config] error, "
1529 "no label defined")); 1510 "no label defined"));
1530 cerr<<"Row: "<<row<<endl; 1511 cerr<<"Row: "<<row<<endl;
1531 } else 1512 } else {
1532 menu.insert(str_label.c_str(), configmenu); 1513 cerr<<"inserts configmenu: "<<m_configmenu.get()<<endl;
1533 } // end of config 1514 menu.insert(str_label.c_str(), m_configmenu.get());
1534 */ 1515 }
1516 } // end of config
1535 else if ( str_key == "include") { // include 1517 else if ( str_key == "include") { // include
1536 if (!str_label.size()) { 1518 if (!str_label.size()) {
1537 fprintf(stderr, 1519 fprintf(stderr,
@@ -1589,9 +1571,10 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1589 else 1571 else
1590 submenu->setLabel(str_label.c_str()); 1572 submenu->setLabel(str_label.c_str());
1591 1573
1592 parseMenuFile(file, *submenu, row); 1574 parseMenuFile(file, *submenu, row);
1593 submenu->update(); 1575 submenu->update();
1594 menu.insert(str_label.c_str(), submenu); 1576 menu.insert(str_label.c_str(), submenu);
1577 // save to list so we can delete it later
1595 rootmenuList.push_back(submenu); 1578 rootmenuList.push_back(submenu);
1596 1579
1597 } 1580 }
@@ -1661,6 +1644,70 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1661 return ((menu.numberOfItems() == 0) ? true : false); 1644 return ((menu.numberOfItems() == 0) ? true : false);
1662} 1645}
1663 1646
1647void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1648 I18n *i18n = I18n::instance();
1649 using namespace FBNLS;
1650
1651 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
1652 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), &Fluxbox::save_rc));
1653 FbTk::RefCount<FbTk::Command> reconf_cmd(new FbCommands::ReconfigureFluxboxCmd());
1654 s_a_reconf_macro->add(saverc_cmd);
1655 s_a_reconf_macro->add(reconf_cmd);
1656 FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro);
1657#ifdef SLIT
1658 if (getSlit() != 0)
1659 menu.insert("Slit", &getSlit()->menu());
1660#endif // SLIT
1661 menu.insert(i18n->getMessage(
1662 ToolbarSet, ToolbarToolbarTitle,
1663 "Toolbar"), &m_toolbar->menu());
1664
1665 menu.insert(new
1666 BoolMenuItem(i18n->getMessage(
1667 ConfigmenuSet, ConfigmenuImageDithering,
1668 "Image Dithering"),
1669 *resource.image_dither, save_and_reconfigure));
1670 menu.insert(new
1671 BoolMenuItem(
1672 i18n->getMessage(
1673 ConfigmenuSet, ConfigmenuOpaqueMove,
1674 "Opaque Window Moving"),
1675 *resource.opaque_move, save_and_reconfigure));
1676 menu.insert(new
1677 BoolMenuItem(i18n->getMessage(
1678 ConfigmenuSet, ConfigmenuFullMax,
1679 "Full Maximization"),
1680 *resource.full_max, save_and_reconfigure));
1681 menu.insert(new
1682 BoolMenuItem(i18n->getMessage(
1683 ConfigmenuSet, ConfigmenuFocusNew,
1684 "Focus New Windows"),
1685 *resource.focus_new, save_and_reconfigure));
1686 menu.insert(new
1687 BoolMenuItem(i18n->getMessage(
1688 ConfigmenuSet, ConfigmenuFocusLast,
1689 "Focus Last Window on Workspace"),
1690 *resource.focus_last, save_and_reconfigure));
1691 menu.insert(new
1692 BoolMenuItem(i18n->getMessage(
1693 ConfigmenuSet, ConfigmenuMaxOverSlit,
1694 "Maximize Over Slit"),
1695 *resource.max_over_slit, save_and_reconfigure));
1696 menu.insert(new
1697 BoolMenuItem(i18n->getMessage(
1698 ConfigmenuSet, ConfigmenuWorkspaceWarping,
1699 "Workspace Warping"),
1700 *resource.workspace_warping, save_and_reconfigure));
1701 menu.insert(new
1702 BoolMenuItem(i18n->getMessage(
1703 ConfigmenuSet, ConfigmenuDesktopWheeling,
1704 "Desktop MouseWheel Switching"),
1705 *resource.desktop_wheeling, save_and_reconfigure));
1706 menu.insert(new BoolMenuItem("antialias", *resource.antialias, save_and_reconfigure));
1707 // finaly update menu
1708 menu.update();
1709}
1710
1664void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu, const char *label, const char *directory) { 1711void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu, const char *label, const char *directory) {
1665 /* 1712 /*
1666 // perform shell style ~ home directory expansion 1713 // 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 @@
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: Screen.hh,v 1.60 2003/01/10 00:34:08 fluxgen Exp $ 25// $Id: Screen.hh,v 1.61 2003/01/12 17:57:46 fluxgen Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -32,7 +32,8 @@
32#include "Workspace.hh" 32#include "Workspace.hh"
33#include "Tab.hh" 33#include "Tab.hh"
34#include "Resource.hh" 34#include "Resource.hh"
35#include "Toolbar.hh" 35#include "Subject.hh"
36#include "FbWinFrameTheme.hh"
36 37
37#include <X11/Xlib.h> 38#include <X11/Xlib.h>
38#include <X11/Xresource.h> 39#include <X11/Xresource.h>
@@ -48,11 +49,12 @@
48#include "config.h" 49#include "config.h"
49#endif // HAVE_CONFIG_H 50#endif // HAVE_CONFIG_H
50 51
51class Configmenu;
52class Workspacemenu; 52class Workspacemenu;
53class Iconmenu; 53class Iconmenu;
54class Netizen; 54class Netizen;
55class Slit; 55class Slit;
56class Toolbar;
57class FbWinFrameTheme;
56 58
57namespace FbTk { 59namespace FbTk {
58class MenuTheme; 60class MenuTheme;
@@ -168,7 +170,6 @@ public:
168 170
169 /// @return the resource value of number of workspace 171 /// @return the resource value of number of workspace
170 inline int getNumberOfWorkspaces() const { return *resource.workspaces; } 172 inline int getNumberOfWorkspaces() const { return *resource.workspaces; }
171 inline Toolbar::Placement getToolbarPlacement() const { return *resource.toolbar_placement; }
172 173
173 inline int getToolbarOnHead() { return *resource.toolbar_on_head; } 174 inline int getToolbarOnHead() { return *resource.toolbar_on_head; }
174 175
@@ -191,7 +192,6 @@ public:
191 inline void saveToolbarOnTop(bool r) { *resource.toolbar_on_top = r; } 192 inline void saveToolbarOnTop(bool r) { *resource.toolbar_on_top = r; }
192 inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; } 193 inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; }
193 inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; } 194 inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; }
194 inline void saveToolbarPlacement(Toolbar::Placement p) { *resource.toolbar_placement = p; }
195 195
196 inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; } 196 inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; }
197 197
@@ -310,6 +310,7 @@ public:
310 }; 310 };
311 311
312private: 312private:
313 void setupConfigmenu(FbTk::Menu &menu);
313 void createStyleMenu(FbTk::Menu &menu, bool newmenu, const char *label, const char *directory); 314 void createStyleMenu(FbTk::Menu &menu, bool newmenu, const char *label, const char *directory);
314 315
315 bool parseMenuFile(std::ifstream &filestream, FbTk::Menu &menu, int &row); 316 bool parseMenuFile(std::ifstream &filestream, FbTk::Menu &menu, int &row);
@@ -333,7 +334,7 @@ private:
333 Window geom_window; 334 Window geom_window;
334 335
335 FbTk::ImageControl *image_control; 336 FbTk::ImageControl *image_control;
336 Configmenu *configmenu; 337 std::auto_ptr<FbTk::Menu> m_configmenu;
337 338
338 std::auto_ptr<FbTk::Menu> m_rootmenu; 339 std::auto_ptr<FbTk::Menu> m_rootmenu;
339 340
@@ -383,10 +384,6 @@ private:
383 Resource<Tab::Alignment> tab_alignment; 384 Resource<Tab::Alignment> tab_alignment;
384 Resource<int> toolbar_on_head; 385 Resource<int> toolbar_on_head;
385 386
386
387 Resource<Toolbar::Placement> toolbar_placement;
388
389
390 bool slit_on_top, slit_auto_hide; 387 bool slit_on_top, slit_auto_hide;
391 int slit_placement, slit_direction; 388 int slit_placement, slit_direction;
392 389