mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Merging new panel in the trunk.
This commit is contained in:
71
ede-panel/applets/clock/Clock.cpp
Normal file
71
ede-panel/applets/clock/Clock.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "Applet.h"
|
||||
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl.H>
|
||||
#include <time.h>
|
||||
|
||||
#include <edelib/Debug.h>
|
||||
#include <edelib/Run.h>
|
||||
|
||||
EDELIB_NS_USING(run_async)
|
||||
|
||||
static void clock_refresh(void *o);
|
||||
|
||||
class Clock : public Fl_Box {
|
||||
private:
|
||||
char buf[64];
|
||||
public:
|
||||
Clock() : Fl_Box(450, 0, 80, 25, NULL) {
|
||||
box(FL_THIN_DOWN_BOX);
|
||||
}
|
||||
|
||||
~Clock() {
|
||||
Fl::remove_timeout(clock_refresh);
|
||||
}
|
||||
|
||||
int handle(int e);
|
||||
void update_time(void);
|
||||
};
|
||||
|
||||
static void clock_refresh(void *o) {
|
||||
Clock *c = (Clock *)o;
|
||||
c->update_time();
|
||||
|
||||
Fl::repeat_timeout(1.0, clock_refresh, o);
|
||||
}
|
||||
|
||||
void Clock::update_time(void) {
|
||||
time_t t;
|
||||
struct tm *tmp;
|
||||
|
||||
t = time(NULL);
|
||||
tmp = localtime(&t);
|
||||
if(!tmp)
|
||||
return;
|
||||
|
||||
strftime(buf, sizeof(buf), "%H:%M:%S", tmp);
|
||||
label(buf);
|
||||
}
|
||||
|
||||
int Clock::handle(int e) {
|
||||
switch(e) {
|
||||
case FL_SHOW:
|
||||
Fl::add_timeout(0, clock_refresh, this);
|
||||
break;
|
||||
|
||||
case FL_RELEASE:
|
||||
run_async("ede-timedate");
|
||||
break;
|
||||
}
|
||||
|
||||
return Fl_Box::handle(e);
|
||||
}
|
||||
|
||||
EDE_PANEL_APPLET_EXPORT (
|
||||
Clock,
|
||||
EDE_PANEL_APPLET_OPTION_ALIGN_RIGHT,
|
||||
"Clock applet",
|
||||
"0.1",
|
||||
"empty",
|
||||
"Sanel Zukan"
|
||||
)
|
13
ede-panel/applets/clock/Jamfile
Normal file
13
ede-panel/applets/clock/Jamfile
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Part of Equinox Desktop Environment (EDE).
|
||||
# Copyright (c) 2009 EDE Authors.
|
||||
#
|
||||
# This program is licensed under terms of the
|
||||
# GNU General Public License version 2 or newer.
|
||||
# See COPYING for details.
|
||||
|
||||
SubDir TOP ede-panel-new applets clock ;
|
||||
|
||||
PanelApplet clock : Clock.cpp ;
|
Reference in New Issue
Block a user