From 57a320ec85e39885707a6cabe2ab36f69e948ea9 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 13 Jul 2011 10:33:14 +0200 Subject: Emit the "modified" signal when a resource value is changed through C++ code --- src/FbTk/Resource.hh | 8 ++++++-- src/IconbarTool.cc | 3 +-- src/IconbarTool.hh | 2 +- src/Screen.cc | 5 +++-- src/Window.cc | 2 +- util/fluxbox-update_configs.cc | 26 +++++++++++++------------- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index 37a7ed3..7a797a1 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh @@ -224,7 +224,11 @@ public: setDefaultValue(); } } - Accessor &operator =(const T& newvalue) { m_value = newvalue; return *this;} + Accessor &operator =(const T& newvalue) { + m_value = newvalue; + m_modified_sig.emit(m_value); + return *this; + } /// specialized, must be implemented /// @return string value of resource std::string getString() const { return Traits::toString(m_value); } @@ -243,7 +247,7 @@ public: operator T() const { return m_value; } T& get() { return m_value; } - T& operator*() { return m_value; } + Accessor& operator*() { return *this; } const T& operator*() const { return m_value; } T *operator->() { return &m_value; } const T *operator->() const { return &m_value; } diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 070e45b..73f0003 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -242,7 +242,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, screen.name() + ".iconbar.mode"), m_rc_alignment(screen.resourceManager(), FbTk::Container::RELATIVE, screen.name() + ".iconbar.alignment"), - m_rc_client_width(screen.resourceManager(), 128, screen.name() + ".iconbar.iconWidth"), + m_rc_client_width(screen.resourceManager(), 128, screen.name() + ".iconbar.iconWidth", FbTk::RangedIntTraits(10, 400)), m_rc_client_padding(screen.resourceManager(), 10, screen.name() + ".iconbar.iconTextPadding"), m_rc_use_pixmap(screen.resourceManager(), true, screen.name() + ".iconbar.usePixmap"), @@ -380,7 +380,6 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) { m_icon_container.setAlignment(*m_rc_alignment); - *m_rc_client_width = FbTk::Util::clamp(*m_rc_client_width, 10, 400); m_icon_container.setMaxSizePerClient(*m_rc_client_width); // lock graphic update diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 754cd50..9091a91 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -113,7 +113,7 @@ private: FbTk::StringResource m_rc_mode; /// alignment of buttons FbTk::Resource > m_rc_alignment; - FbTk::IntResource m_rc_client_width; ///< size of client button in LEFT/RIGHT mode + FbTk::RangedIntResource m_rc_client_width; ///< size of client button in LEFT/RIGHT mode FbTk::UIntResource m_rc_client_padding; ///< padding of the text FbTk::BoolResource m_rc_use_pixmap; ///< if iconbar should use win pixmap or not FbTk::RefCount m_menu; diff --git a/src/Screen.cc b/src/Screen.cc index 37381cd..fa8df19 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -822,7 +822,7 @@ void BScreen::reconfigure() { // and update their names for(size_t i = 0; i < std::min(m_workspaces_list.size(), resource.workspace_names->size()); ++i) - m_workspaces_list[i]->setName( (*resource.workspace_names)[i] ); + m_workspaces_list[i]->setName( resource.workspace_names.get()[i] ); // update menu filenames m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename()); @@ -862,7 +862,8 @@ void BScreen::reconfigureTabs() { void BScreen::updateWorkspaceName(unsigned int w) { Workspace *space = getWorkspace(w); if (space) { - (*resource.workspace_names)[w] = space->name(); + resource.workspace_names.get()[w] = space->name(); + // XXX use resource.workspace_names.modifiedSig() instead m_workspacenames_sig.emit(*this); Fluxbox::instance()->save_rc(); } diff --git a/src/Window.cc b/src/Window.cc index 771ac7c..0081e75 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -3506,7 +3506,7 @@ void FluxboxWindow::updateButtons() { need_update = true; else { for (size_t j=0; j < new_size && !need_update; j++) { - if ((*(*titlebar_side[i]))[j] != m_titlebar_buttons[i][j]) + if ((*titlebar_side[i]).get()[j] != m_titlebar_buttons[i][j]) need_update = true; } } diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc index 069b112..9062b57 100644 --- a/util/fluxbox-update_configs.cc +++ b/util/fluxbox-update_configs.cc @@ -167,8 +167,8 @@ void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager& rm, FbTk::BoolResource rc_reverse(rm, false, "screen0.reversewheeling", "Screen0.ReverseWheeling"); - if (strcasecmp((*rc_wheeling).c_str(), "On") == 0 || - (strcasecmp((*rc_wheeling).c_str(), "Screen") == 0 && *rc_screen)) { + if (strcasecmp(rc_wheeling->c_str(), "On") == 0 || + (strcasecmp(rc_wheeling->c_str(), "Screen") == 0 && *rc_screen)) { keep_changes = true; if (*rc_reverse) { // if you ask me, this should have been default new_keyfile += "OnToolbar Mouse4 :PrevWorkspace\n"; @@ -202,13 +202,13 @@ void update_move_modkey_to_keys_file(FbTk::ResourceManager& rm, "modKey", "ModKey"); - new_keyfile += "OnWindow " + *rc_modkey + + new_keyfile += "OnWindow " + rc_modkey.get() + " Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}\n"; - new_keyfile += "OnWindow " + *rc_modkey + + new_keyfile += "OnWindow " + rc_modkey.get() + " Mouse3 :MacroCmd {Raise} {Focus} {StartResizing "; - if (strcasecmp((*rc_mode).c_str(), "Quadrant") == 0) { + if (strcasecmp(rc_mode->c_str(), "Quadrant") == 0) { new_keyfile += "NearestCorner}\n"; - } else if (strcasecmp((*rc_mode).c_str(), "Center") == 0) { + } else if (strcasecmp(rc_mode->c_str(), "Center") == 0) { new_keyfile += "Center}\n"; } else { new_keyfile += "BottomRight}\n"; @@ -262,7 +262,7 @@ void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager& rm, FbTk::BoolResource rc_reverse(rm, false,"screen0.reversewheeling", "Screen0.ReverseWheeling"); FbTk::StringResource scroll_action(rm, "", "screen0.windowScrollAction", "Screen0.WindowScrollAction"); - if (strcasecmp((*scroll_action).c_str(), "shade") == 0) { + if (strcasecmp(scroll_action->c_str(), "shade") == 0) { if (*rc_reverse) { new_keyfile += "OnTitlebar Mouse5 :ShadeOn\n"; new_keyfile += "OnTitlebar Mouse4 :ShadeOff\n"; @@ -270,7 +270,7 @@ void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager& rm, new_keyfile += "OnTitlebar Mouse4 :ShadeOn\n"; new_keyfile += "OnTitlebar Mouse5 :ShadeOff\n"; } - } else if (strcasecmp((*scroll_action).c_str(), "nexttab") == 0) { + } else if (strcasecmp(scroll_action->c_str(), "nexttab") == 0) { if (*rc_reverse) { new_keyfile += "OnTitlebar Mouse5 :PrevTab\n"; new_keyfile += "OnTitlebar Mouse4 :NextTab\n"; @@ -329,14 +329,14 @@ void update_change_format_of_split_placement_menu(FbTk::ResourceManager& rm, "screen0.slit.direction", "Screen0.Slit.Direction"); - if (strcasecmp((**direction).c_str(), "vertical") == 0) { - if (strcasecmp((**placement).c_str(), "BottomRight") == 0) + if (strcasecmp((*direction)->c_str(), "vertical") == 0) { + if (strcasecmp((*placement)->c_str(), "BottomRight") == 0) *placement = "RightBottom"; - else if (strcasecmp((**placement).c_str(), "BottomLeft") == 0) + else if (strcasecmp((*placement)->c_str(), "BottomLeft") == 0) *placement = "LeftBottom"; - else if (strcasecmp((**placement).c_str(), "TopRight") == 0) + else if (strcasecmp((*placement)->c_str(), "TopRight") == 0) *placement = "RightTop"; - else if (strcasecmp((**placement).c_str(), "TopLeft") == 0) + else if (strcasecmp((*placement)->c_str(), "TopLeft") == 0) *placement = "LeftTop"; } } -- cgit v0.11.2