aboutsummaryrefslogtreecommitdiff
path: root/src/Slit.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-06-07 11:46:05 (GMT)
committerrathnor <rathnor>2004-06-07 11:46:05 (GMT)
commitfff4456dee29e675d7f2ed3490db39bcb7e10e53 (patch)
tree2d2dbf386551773cbdc8231b2a93b493187bd733 /src/Slit.cc
parent073065ac56b388db1169108d44f37d32f1d19c67 (diff)
downloadfluxbox-fff4456dee29e675d7f2ed3490db39bcb7e10e53.zip
fluxbox-fff4456dee29e675d7f2ed3490db39bcb7e10e53.tar.bz2
update NLS string handling...
Diffstat (limited to 'src/Slit.cc')
-rw-r--r--src/Slit.cc146
1 files changed, 73 insertions, 73 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index c5a74a4..4157178 100644
--- a/src/Slit.cc
+++ b/src/Slit.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: Slit.cc,v 1.94 2004/05/17 15:20:32 rathnor Exp $ 25// $Id: Slit.cc,v 1.95 2004/06/07 11:46:04 rathnor Exp $
26 26
27#include "Slit.hh" 27#include "Slit.hh"
28 28
@@ -35,7 +35,6 @@
35#include "config.h" 35#include "config.h"
36#endif // HAVE_CONFIG_H 36#endif // HAVE_CONFIG_H
37 37
38#include "I18n.hh"
39#include "Screen.hh" 38#include "Screen.hh"
40#include "ImageControl.hh" 39#include "ImageControl.hh"
41#include "RefCount.hh" 40#include "RefCount.hh"
@@ -58,6 +57,7 @@
58#include "Xutil.hh" 57#include "Xutil.hh"
59#include "FbAtoms.hh" 58#include "FbAtoms.hh"
60#include "FbTk/StringUtil.hh" 59#include "FbTk/StringUtil.hh"
60#include "FbTk/I18n.hh"
61 61
62#include <algorithm> 62#include <algorithm>
63#include <iostream> 63#include <iostream>
@@ -79,8 +79,9 @@ template<>
79void FbTk::Resource<Slit::Placement>::setFromString(const char *strval) { 79void FbTk::Resource<Slit::Placement>::setFromString(const char *strval) {
80 if (strcasecmp(strval, "TopLeft")==0) 80 if (strcasecmp(strval, "TopLeft")==0)
81 m_value = Slit::TOPLEFT; 81 m_value = Slit::TOPLEFT;
82 else if (strcasecmp(strval, "CenterLeft")==0) 82 else if (strcasecmp(strval, "LeftCenter")==0
83 m_value = Slit::CENTERLEFT; 83 || strcasecmp(strval, "CenterLeft")==0)
84 m_value = Slit::LEFTCENTER;
84 else if (strcasecmp(strval, "BottomLeft")==0) 85 else if (strcasecmp(strval, "BottomLeft")==0)
85 m_value = Slit::BOTTOMLEFT; 86 m_value = Slit::BOTTOMLEFT;
86 else if (strcasecmp(strval, "TopCenter")==0) 87 else if (strcasecmp(strval, "TopCenter")==0)
@@ -89,8 +90,9 @@ void FbTk::Resource<Slit::Placement>::setFromString(const char *strval) {
89 m_value = Slit::BOTTOMCENTER; 90 m_value = Slit::BOTTOMCENTER;
90 else if (strcasecmp(strval, "TopRight")==0) 91 else if (strcasecmp(strval, "TopRight")==0)
91 m_value = Slit::TOPRIGHT; 92 m_value = Slit::TOPRIGHT;
92 else if (strcasecmp(strval, "CenterRight")==0) 93 else if (strcasecmp(strval, "RightCenter")==0
93 m_value = Slit::CENTERRIGHT; 94 || strcasecmp(strval, "CenterRight")==0)
95 m_value = Slit::RIGHTCENTER;
94 else if (strcasecmp(strval, "BottomRight")==0) 96 else if (strcasecmp(strval, "BottomRight")==0)
95 m_value = Slit::BOTTOMRIGHT; 97 m_value = Slit::BOTTOMRIGHT;
96 else 98 else
@@ -113,8 +115,8 @@ string FbTk::Resource<Slit::Placement>::getString() {
113 case Slit::TOPLEFT: 115 case Slit::TOPLEFT:
114 return string("TopLeft"); 116 return string("TopLeft");
115 break; 117 break;
116 case Slit::CENTERLEFT: 118 case Slit::LEFTCENTER:
117 return string("CenterLeft"); 119 return string("LeftCenter");
118 break; 120 break;
119 case Slit::BOTTOMLEFT: 121 case Slit::BOTTOMLEFT:
120 return string("BottomLeft"); 122 return string("BottomLeft");
@@ -128,8 +130,8 @@ string FbTk::Resource<Slit::Placement>::getString() {
128 case Slit::TOPRIGHT: 130 case Slit::TOPRIGHT:
129 return string("TopRight"); 131 return string("TopRight");
130 break; 132 break;
131 case Slit::CENTERRIGHT: 133 case Slit::RIGHTCENTER:
132 return string("CenterRight"); 134 return string("RightCenter");
133 break; 135 break;
134 case Slit::BOTTOMRIGHT: 136 case Slit::BOTTOMRIGHT:
135 return string("BottomRight"); 137 return string("BottomRight");
@@ -198,14 +200,13 @@ public:
198 } 200 }
199 201
200 void setLabel(const char *label) { 202 void setLabel(const char *label) {
201 I18n *i18n = I18n::instance(); 203 _FB_USES_NLS;
202 m_label = (label ? label : ""); 204 m_label = (label ? label : "");
203 std::string reallabel = m_label + " " + 205 std::string reallabel = m_label + " " +
204 ( m_slit.direction() == Slit::HORIZONTAL ? 206 ( m_slit.direction() == Slit::HORIZONTAL ?
205 i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonDirectionHoriz, 207
206 "Horizontal") : 208 _FBTEXT(Align, Horizontal, "Horizontal", "Horizontal"):
207 i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonDirectionVert, 209 _FBTEXT(Align, Vertical, "Vertical", "Vertical"));
208 "Vertical") );
209 FbTk::MenuItem::setLabel(reallabel.c_str()); 210 FbTk::MenuItem::setLabel(reallabel.c_str());
210 } 211 }
211private: 212private:
@@ -278,6 +279,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
278 m_rc_layernum(scr.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDockLayer()), 279 m_rc_layernum(scr.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDockLayer()),
279 scr.name() + ".slit.layer", scr.altName() + ".Slit.Layer") { 280 scr.name() + ".slit.layer", scr.altName() + ".Slit.Layer") {
280 281
282 _FB_USES_NLS;
283
281 // attach to theme and root window change signal 284 // attach to theme and root window change signal
282 m_slit_theme->reconfigSig().attach(this); 285 m_slit_theme->reconfigSig().attach(this);
283 scr.resizeSig().attach(this); 286 scr.resizeSig().attach(this);
@@ -315,9 +318,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
315 m_layeritem.reset(new FbTk::XLayerItem(frame.window, layer)); 318 m_layeritem.reset(new FbTk::XLayerItem(frame.window, layer));
316 moveToLayer((*m_rc_layernum).getNum()); 319 moveToLayer((*m_rc_layernum).getNum());
317 320
318 // TODO: nls
319 if (m_layermenu.get()) 321 if (m_layermenu.get())
320 m_layermenu->setLabel("Slit Layer"); 322 m_layermenu->setLabel(_FBTEXT(Slit, Layer, "Slit Layer", "Title of Slit Layer Menu"));
321 323
322 // Get client list for sorting purposes 324 // Get client list for sorting purposes
323 loadClientList(filename); 325 loadClientList(filename);
@@ -391,11 +393,11 @@ void Slit::updateStrut() {
391 else 393 else
392 right = width(); 394 right = width();
393 break; 395 break;
394 case CENTERLEFT: 396 case LEFTCENTER:
395 if (direction() == VERTICAL) 397 if (direction() == VERTICAL)
396 left = width(); 398 left = width();
397 break; 399 break;
398 case CENTERRIGHT: 400 case RIGHTCENTER:
399 if (direction() == VERTICAL) 401 if (direction() == VERTICAL)
400 right = width(); 402 right = width();
401 break; 403 break;
@@ -804,7 +806,7 @@ void Slit::reposition() {
804 } 806 }
805 break; 807 break;
806 808
807 case CENTERLEFT: 809 case LEFTCENTER:
808 frame.x = head_x; 810 frame.x = head_x;
809 frame.y = head_y + (head_h - frame.height) / 2; 811 frame.y = head_y + (head_h - frame.height) / 2;
810 frame.x_hidden = head_x + bevel_width - 812 frame.x_hidden = head_x + bevel_width -
@@ -856,7 +858,7 @@ void Slit::reposition() {
856 } 858 }
857 break; 859 break;
858 860
859 case CENTERRIGHT: 861 case RIGHTCENTER:
860 default: 862 default:
861 frame.x = head_x + head_w - frame.width - border_width*2; 863 frame.x = head_x + head_w - frame.width - border_width*2;
862 frame.y = head_y + ((head_h - frame.height) / 2); 864 frame.y = head_y + ((head_h - frame.height) / 2);
@@ -1096,15 +1098,16 @@ void Slit::loadClientList(const char *filename) {
1096void Slit::updateClientmenu() { 1098void Slit::updateClientmenu() {
1097 if (screen().isShuttingdown()) 1099 if (screen().isShuttingdown())
1098 return; 1100 return;
1101 _FB_USES_NLS;
1099 1102
1100 // clear old items 1103 // clear old items
1101 m_clientlist_menu.removeAll(); 1104 m_clientlist_menu.removeAll();
1102 m_clientlist_menu.setLabel("Clients"); 1105 m_clientlist_menu.setLabel(_FBTEXT(Slit, ClientsMenu, "Clients", "Slit client menu"));
1103 1106
1104 FbTk::RefCount<FbTk::Command> cycle_up(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsUp)); 1107 FbTk::RefCount<FbTk::Command> cycle_up(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsUp));
1105 FbTk::RefCount<FbTk::Command> cycle_down(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsDown)); 1108 FbTk::RefCount<FbTk::Command> cycle_down(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsDown));
1106 m_clientlist_menu.insert("Cycle Up", cycle_up); 1109 m_clientlist_menu.insert(_FBTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up);
1107 m_clientlist_menu.insert("Cycle Down", cycle_down); 1110 m_clientlist_menu.insert(_FBTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down);
1108 1111
1109 FbTk::MenuItem *separator = new FbTk::MenuItem("---"); 1112 FbTk::MenuItem *separator = new FbTk::MenuItem("---");
1110 separator->setEnabled(false); 1113 separator->setEnabled(false);
@@ -1148,8 +1151,7 @@ void Slit::setAutoHide(bool val) {
1148} 1151}
1149 1152
1150void Slit::setupMenu() { 1153void Slit::setupMenu() {
1151 I18n *i18n = I18n::instance(); 1154 _FB_USES_NLS;
1152 using namespace FBNLS;
1153 using namespace FbTk; 1155 using namespace FbTk;
1154 1156
1155 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); 1157 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
@@ -1168,40 +1170,39 @@ void Slit::setupMenu() {
1168 FbTk::RefCount<FbTk::Command> save_and_reconfigure_slit(s_a_reconf_slit_macro); 1170 FbTk::RefCount<FbTk::Command> save_and_reconfigure_slit(s_a_reconf_slit_macro);
1169 1171
1170 // setup base menu 1172 // setup base menu
1171 m_slitmenu.setLabel("Slit"); 1173 m_slitmenu.setLabel(_FBTEXT(Slit, Slit, "Slit", "The Slit"));
1172 m_slitmenu.insert(i18n->getMessage(CommonSet, CommonPlacementTitle, 1174 m_slitmenu.insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"),
1173 "Placement"),
1174 &m_placement_menu); 1175 &m_placement_menu);
1175 1176
1176 m_slitmenu.insert("Layer...", m_layermenu.get()); 1177 m_slitmenu.insert(_FBTEXT(Menu, Layer, "Layer...", "Title of Layer menu"), m_layermenu.get());
1177 1178
1178#ifdef XINERAMA 1179#ifdef XINERAMA
1179 if (screen().hasXinerama()) { 1180 if (screen().hasXinerama()) {
1180 // TODO: nls (main label, plus menu heading) 1181 m_slitmenu.insert(_FBTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"),
1181 m_slitmenu.insert("On Head...", new XineramaHeadMenu<Slit>( 1182 new XineramaHeadMenu<Slit>(
1182 screen().menuTheme(), 1183 screen().menuTheme(),
1183 screen(), 1184 screen(),
1184 screen().imageControl(), 1185 screen().imageControl(),
1185 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), 1186 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
1186 *this, 1187 *this,
1187 "Slit on Head" 1188 _FBTEXT(Slit, OnHead, "Slit on Head", "Title of Slits On Head menu")
1188 )); 1189 ));
1189 } 1190 }
1190 1191
1191#endif //XINERAMA 1192#endif //XINERAMA
1192 m_slitmenu.insert(new BoolMenuItem(i18n->getMessage(CommonSet, CommonAutoHide, 1193 m_slitmenu.insert(new BoolMenuItem(_FBTEXT(Common, AutoHide, "Auto hide", "This thing automatically hides when not close by"),
1193 "Auto hide"),
1194 *m_rc_auto_hide, 1194 *m_rc_auto_hide,
1195 save_and_reconfigure_slit)); 1195 save_and_reconfigure_slit));
1196 1196
1197 m_slitmenu.insert(new BoolMenuItem("Maximize Over", 1197 m_slitmenu.insert(new BoolMenuItem(_FBTEXT(Common, MaximizeOver,"Maximize Over", "Maximize over this thing when maximizing"),
1198 *m_rc_maximize_over, 1198 *m_rc_maximize_over,
1199 save_and_reconfigure_slit)); 1199 save_and_reconfigure_slit));
1200 1200
1201 // this saves resources and clears the slit window to update alpha value 1201 // this saves resources and clears the slit window to update alpha value
1202 FbTk::MenuItem *alpha_menuitem = new IntResMenuItem("Alpha", 1202 FbTk::MenuItem *alpha_menuitem =
1203 m_rc_alpha, 1203 new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"),
1204 0, 255); 1204 m_rc_alpha,
1205 0, 255);
1205 // setup command for alpha value 1206 // setup command for alpha value
1206 MacroCommand *alpha_macrocmd = new MacroCommand(); 1207 MacroCommand *alpha_macrocmd = new MacroCommand();
1207 RefCount<Command> clear_cmd(new SimpleCommand<Slit>(*this, &Slit::clearWindow)); 1208 RefCount<Command> clear_cmd(new SimpleCommand<Slit>(*this, &Slit::clearWindow));
@@ -1212,51 +1213,50 @@ void Slit::setupMenu() {
1212 1213
1213 m_slitmenu.insert(alpha_menuitem); 1214 m_slitmenu.insert(alpha_menuitem);
1214 1215
1215 m_slitmenu.insert(new SlitDirMenuItem(i18n->getMessage(SlitSet, SlitSlitDirection, 1216 m_slitmenu.insert(new SlitDirMenuItem(_FBTEXT(Slit, Direction, "Slit Direction", "Orientation of slit"),
1216 "Slit Direction"),
1217 *this, 1217 *this,
1218 save_and_reconfigure)); 1218 save_and_reconfigure));
1219 m_slitmenu.insert("Clients", &m_clientlist_menu); 1219 m_slitmenu.insert(_FBTEXT(Slit, ClientsMenu, "Clients", "Slit client menu"), &m_clientlist_menu);
1220 m_slitmenu.update(); 1220 m_slitmenu.update();
1221 1221
1222 // setup sub menu 1222 // setup sub menu
1223 m_placement_menu.setLabel(i18n->getMessage(SlitSet, SlitSlitPlacement, 1223 m_placement_menu.setLabel(_FBTEXT(Slit, Placement, "Slit Placement", "Slit Placement"));
1224 "Slit Placement"));
1225 m_placement_menu.setMinimumSublevels(3); 1224 m_placement_menu.setMinimumSublevels(3);
1226 m_layermenu->setInternalMenu(); 1225 m_layermenu->setInternalMenu();
1227 m_clientlist_menu.setInternalMenu(); 1226 m_clientlist_menu.setInternalMenu();
1228 1227
1228 typedef list<pair<const char *, Slit::Placement> > Placements;
1229 Placements place_menu;
1230
1231 // menu is 3 wide, 5 down
1232 place_menu.push_back(make_pair(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), Slit::TOPLEFT));
1233 place_menu.push_back(make_pair(_FBTEXT(Align, LeftCenter, "Left Center", "Left Center"), Slit::LEFTCENTER));
1234 place_menu.push_back(make_pair(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), Slit::BOTTOMLEFT));
1235 place_menu.push_back(make_pair(_FBTEXT(Align, TopCenter, "Top Center", "Top Center"), Slit::TOPCENTER));
1236 place_menu.push_back(make_pair((const char *)0, Slit::TOPLEFT));
1237 place_menu.push_back(make_pair(_FBTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), Slit::BOTTOMCENTER));
1238 place_menu.push_back(make_pair(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), Slit::TOPRIGHT));
1239 place_menu.push_back(make_pair(_FBTEXT(Align, RightCenter, "Right Center", "Right Center"), Slit::RIGHTCENTER));
1240 place_menu.push_back(make_pair(_FBTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), Slit::BOTTOMRIGHT));
1241
1229 1242
1230 // setup items in sub menu
1231 struct {
1232 int set;
1233 int base;
1234 const char *default_str;
1235 Placement slit_placement;
1236 } place_menu[] = {
1237 {CommonSet, CommonPlacementTopLeft, "Top Left", Slit::TOPLEFT},
1238 {CommonSet, CommonPlacementCenterLeft, "Center Left", Slit::CENTERLEFT},
1239 {CommonSet, CommonPlacementBottomLeft, "Bottom Left", Slit::BOTTOMLEFT},
1240 {CommonSet, CommonPlacementTopCenter, "Top Center", Slit::TOPCENTER},
1241 {0, 0, 0, Slit::TOPLEFT}, // middle item, empty
1242 {CommonSet, CommonPlacementBottomCenter, "Bottom Center", Slit::BOTTOMCENTER},
1243 {CommonSet, CommonPlacementTopRight, "Top Right", Slit::TOPRIGHT},
1244 {CommonSet, CommonPlacementCenterRight, "Center Right", Slit::CENTERRIGHT},
1245 {CommonSet, CommonPlacementBottomRight, "Bottom Right", Slit::BOTTOMRIGHT}
1246 };
1247 // create items in sub menu 1243 // create items in sub menu
1248 for (size_t i=0; i<9; ++i) { 1244 for (size_t i=0; i<9; ++i) {
1249 if (place_menu[i].default_str == 0) { 1245 const char *str = place_menu.front().first;
1246 Slit::Placement placement = place_menu.front().second;
1247
1248 if (str == 0) {
1250 m_placement_menu.insert(""); 1249 m_placement_menu.insert("");
1250 m_placement_menu.setItemEnabled(i, false);
1251 } else { 1251 } else {
1252 const char *i18n_str = i18n->getMessage(place_menu[i].set, 1252 m_placement_menu.insert(new PlaceSlitMenuItem(str, *this,
1253 place_menu[i].base, 1253 placement,
1254 place_menu[i].default_str);
1255 m_placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this,
1256 place_menu[i].slit_placement,
1257 save_and_reconfigure)); 1254 save_and_reconfigure));
1255
1258 } 1256 }
1257 place_menu.pop_front();
1259 } 1258 }
1259
1260 // finaly update sub menu 1260 // finaly update sub menu
1261 m_placement_menu.update(); 1261 m_placement_menu.update();
1262} 1262}