aboutsummaryrefslogtreecommitdiff
path: root/src/ClockTool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r--src/ClockTool.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 0f4695b..5abfffa 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -46,13 +46,12 @@
46 #include <time.h> 46 #include <time.h>
47#endif 47#endif
48#include <sys/time.h> 48#include <sys/time.h>
49#include <string>
50#include <typeinfo> 49#include <typeinfo>
51 50
52class ClockMenuItem: public FbTk::MenuItem { 51class ClockMenuItem: public FbTk::MenuItem {
53public: 52public:
54 explicit ClockMenuItem(ClockTool &tool): 53 explicit ClockMenuItem(ClockTool &tool):
55 FbTk::MenuItem(""), m_tool(tool) { 54 FbTk::MenuItem(""), m_tool(tool) {
56 // determine 12/24 hour format 55 // determine 12/24 hour format
57 _FB_USES_NLS; 56 _FB_USES_NLS;
58 if (m_tool.timeFormat().find("%k") != std::string::npos || 57 if (m_tool.timeFormat().find("%k") != std::string::npos ||
@@ -78,7 +77,7 @@ public:
78 newstr = "%I"; 77 newstr = "%I";
79 else if ((pos = newformat.find("%T")) != std::string::npos) 78 else if ((pos = newformat.find("%T")) != std::string::npos)
80 newstr = "%r"; 79 newstr = "%r";
81 80
82 // 12 hour 81 // 12 hour
83 if (newstr.empty()) { 82 if (newstr.empty()) {
84 clock24hour = false; 83 clock24hour = false;
@@ -88,9 +87,9 @@ public:
88 newstr = "%H"; 87 newstr = "%H";
89 else if ((pos = newformat.find("%r")) != std::string::npos) 88 else if ((pos = newformat.find("%r")) != std::string::npos)
90 newstr = "%T"; 89 newstr = "%T";
91 90
92 } 91 }
93 92
94 if (!newstr.empty()) { 93 if (!newstr.empty()) {
95 94
96 newformat.replace(pos, 2, newstr); 95 newformat.replace(pos, 2, newstr);
@@ -102,7 +101,7 @@ public:
102 newformat.erase(pos, 2); 101 newformat.erase(pos, 2);
103 } 102 }
104 103
105 104
106 m_tool.setTimeFormat(newformat); 105 m_tool.setTimeFormat(newformat);
107 106
108 if (m_tool.timeFormat().find("%k") != std::string::npos || 107 if (m_tool.timeFormat().find("%k") != std::string::npos ||
@@ -111,7 +110,7 @@ public:
111 setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); 110 setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") );
112 else 111 else
113 setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); 112 setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") );
114 113
115 } // else some other strange format...so we don't do anything 114 } // else some other strange format...so we don't do anything
116 FbTk::MenuItem::click(button, time, mods); 115 FbTk::MenuItem::click(button, time, mods);
117 } 116 }
@@ -127,7 +126,7 @@ public:
127 return; 126 return;
128 std::string resourcename = screen->name() + ".strftimeFormat"; 127 std::string resourcename = screen->name() + ".strftimeFormat";
129 128
130 CommandDialog *dialog = new CommandDialog(*screen, "Edit Clock Format", 129 CommandDialog *dialog = new CommandDialog(*screen, "Edit Clock Format",
131 "SetResourceValue " + resourcename + " "); 130 "SetResourceValue " + resourcename + " ");
132 FbTk::RefCount<FbTk::Command> cmd(FbTk::ObjectRegistry<FbTk::Command>::instance().parse("reconfigure")); 131 FbTk::RefCount<FbTk::Command> cmd(FbTk::ObjectRegistry<FbTk::Command>::instance().parse("reconfigure"));
133 dialog->setPostCommand(cmd); 132 dialog->setPostCommand(cmd);
@@ -143,7 +142,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
143 m_theme(theme), 142 m_theme(theme),
144 m_screen(screen), 143 m_screen(screen),
145 m_pixmap(0), 144 m_pixmap(0),
146 m_timeformat(screen.resourceManager(), std::string("%k:%M"), 145 m_timeformat(screen.resourceManager(), std::string("%k:%M"),
147 screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat"), 146 screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat"),
148 m_stringconvertor(FbTk::StringConvertor::ToFbString) { 147 m_stringconvertor(FbTk::StringConvertor::ToFbString) {
149 // attach signals 148 // attach signals
@@ -162,7 +161,7 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
162 // if nothing has changed, it wont update the graphics 161 // if nothing has changed, it wont update the graphics
163 m_timer.setInterval(1); 162 m_timer.setInterval(1);
164 // m_timer.setTimeout(delay); // don't need to set timeout on interval timer 163 // m_timer.setTimeout(delay); // don't need to set timeout on interval timer
165 FbTk::RefCount<FbTk::Command> update_graphic(new FbTk::SimpleCommand<ClockTool>(*this, 164 FbTk::RefCount<FbTk::Command> update_graphic(new FbTk::SimpleCommand<ClockTool>(*this,
166 &ClockTool::updateTime)); 165 &ClockTool::updateTime));
167 m_timer.setCommand(update_graphic); 166 m_timer.setCommand(update_graphic);
168 m_timer.start(); 167 m_timer.start();
@@ -248,7 +247,7 @@ void ClockTool::update(FbTk::Subject *subj) {
248 247
249} 248}
250 249
251unsigned int ClockTool::borderWidth() const { 250unsigned int ClockTool::borderWidth() const {
252 return m_button.borderWidth(); 251 return m_button.borderWidth();
253} 252}
254 253
@@ -297,12 +296,12 @@ void ClockTool::updateTime() {
297// Just change things that affect the size 296// Just change things that affect the size
298void ClockTool::updateSizing() { 297void ClockTool::updateSizing() {
299 m_button.setBorderWidth(m_theme.border().width()); 298 m_button.setBorderWidth(m_theme.border().width());
300 // resizes if new timeformat 299 // resizes if new timeformat
301 update(0); 300 update(0);
302} 301}
303 302
304void ClockTool::reRender() { 303void ClockTool::reRender() {
305 if (m_pixmap) 304 if (m_pixmap)
306 m_screen.imageControl().removeImage(m_pixmap); 305 m_screen.imageControl().removeImage(m_pixmap);
307 306
308 if (m_theme.texture().usePixmap()) { 307 if (m_theme.texture().usePixmap()) {