New config file format

Config updated to the existing programs
ede-conf will read config from XDG paths
This commit is contained in:
Sanel Zukan 2009-02-23 15:05:24 +00:00
parent 421a09304f
commit 345807d172
3 changed files with 55 additions and 75 deletions

View File

@ -14,3 +14,5 @@ SOURCE = ede-conf.cpp ;
EdeProgram ede-conf : $(SOURCE) ;
TranslationStrings locale : $(SOURCE) ;
InstallEdeConfigFiles ede-conf.conf ;

View File

@ -2,56 +2,30 @@
# This is a default data for ede-conf
#
[edeconf]
# main items
Items = edewmconf,ekeyconf,esvrconf,einstall,evolume, edatetime,etipconf
[EdeConf]
# main items
items = edewmconf,ede-desktop-conf,ede-screensaver-conf,ede-timedate
[edewmconf]
Name = Window manager
Tip = This item will run window manager configuration
Exec = ewmconf
Icon = preferences-system-windows
IconPathAbsolute = false
name = Window manager
tip = This item will run window manager configuration
exec = ewmconf
icon = preferences-system-windows
[ekeyconf]
Name = Keyboard configuration
Tip = This item will run keyboard configuration
Exec = konqueror
#Icon = preferences-desktop-font
Icon = accessories-character-map
IconPathAbsolute = false
[ede-desktop-conf]
name = Configure background and icons
tip = This item will configure desktop background and icons
exec = ede-desktop-conf
icon = preferences-desktop-wallpaper
[esvrconf]
Name = Screensaver configuration
Tip = This item will configure screensaver
Exec = esvrconf
Icon = preferences-desktop-screensaver
IconPathAbsolute = false
[ede-screensaver-conf]
name = Configure screensaver
tip = This item will setup screensaver settings
exec = ede-screensaver-conf
icon = preferences-desktop-screensaver
[einstall]
Name = Install new software
Tip = This item will run installer
Exec = einstall
Icon = system-installer
IconPathAbsolute = false
[evolume]
Name = Sound preferences
Tip = This item will set sound preferences
Exec = evolume
Icon = multimedia-volume-control
IconPathAbsolute = false
[edatetime]
Name = Date and time
Tip = This item will configure date and time
Exec = edatetime
Icon = preferences-date-time
IconPathAbsolute = false
[etipconf]
Name = Tips
Tip = This item will configure tips
Exec = etipconf
Icon = preferences-user-information
IconPathAbsolute = false
[ede-timedate]
name = Configure time and date
tip = This item will configure system date and time
exec = ede-timedate
icon = preferences-date-time

View File

@ -17,6 +17,7 @@
#include <FL/fl_draw.H>
#include <edelib/Config.h>
#include <edelib/Resource.h>
#include <edelib/StrUtil.h>
#include <edelib/Debug.h>
#include <edelib/ExpandableGroup.h>
@ -43,20 +44,20 @@ static bool file_can_execute(const edelib::String& f) {
}
class ControlButton : public Fl_Button {
private:
Fl_Box* tipbox;
edelib::String tipstr;
edelib::String exec;
public:
ControlButton(Fl_Box* t, const edelib::String& ts, const edelib::String& e, int x, int y, int w, int h, const char* l = 0) :
Fl_Button(x, y, w, h, l), tipbox(t), tipstr(ts), exec(e) {
box(FL_FLAT_BOX);
align(FL_ALIGN_WRAP);
color(FL_BACKGROUND2_COLOR);
}
private:
Fl_Box* tipbox;
edelib::String tipstr;
edelib::String exec;
public:
ControlButton(Fl_Box* t, const edelib::String& ts, const edelib::String& e, int x, int y, int w, int h, const char* l = 0) :
Fl_Button(x, y, w, h, l), tipbox(t), tipstr(ts), exec(e) {
box(FL_FLAT_BOX);
align(FL_ALIGN_WRAP);
color(FL_BACKGROUND2_COLOR);
}
~ControlButton() { }
int handle(int event);
~ControlButton() { }
int handle(int event);
};
int ControlButton::handle(int event) {
@ -101,12 +102,11 @@ static void close_cb(Fl_Widget*, void* w) {
win->hide();
}
static void fetch_icon(ControlButton* btn, const char* path, bool abs) {
Fl_Image* img = NULL;
static void fetch_icon(ControlButton* btn, const char* path) {
// see if path is absolute and if not, fetch icon from icon theme
Fl_Image* img = Fl_Shared_Image::get(path);
if(abs) {
img = Fl_Shared_Image::get(path);
} else {
if(!img) {
edelib::String p = edelib::IconTheme::get(path, edelib::ICON_SIZE_LARGE);
if(!p.empty()) {
img = Fl_Shared_Image::get(p.c_str());
@ -123,15 +123,22 @@ static void fetch_icon(ControlButton* btn, const char* path, bool abs) {
}
static void load_buttons(Fl_Group* g, Fl_Box* tipbox) {
#if 0
edelib::Config c;
if(!c.load("ede-conf.conf")) {
E_WARNING("Can't load config\n");
return;
}
#endif
edelib::Resource c;
if(!c.load("ede-conf")) {
E_WARNING("Can't load config\n");
return;
}
char buff[1024];
if(!c.get("edeconf", "Items", buff, sizeof(buff))) {
if(!c.get("EdeConf", "items", buff, sizeof(buff))) {
E_WARNING("Can't find Items key\n");
return;
}
@ -142,7 +149,6 @@ static void load_buttons(Fl_Group* g, Fl_Box* tipbox) {
if(spl.empty())
return;
bool abspath;
const char* section;
//ControlIcon cicon;
StrListIter it = spl.begin(), it_end = spl.end();
@ -152,25 +158,23 @@ static void load_buttons(Fl_Group* g, Fl_Box* tipbox) {
section = (*it).c_str();
edelib::str_trim((char*)section);
if(c.get(section, "Name", buff, sizeof(buff)))
if(c.get(section, "name", buff, sizeof(buff)))
name = buff;
else {
E_WARNING("No %s, skipping...\n", section);
continue;
}
if(c.get(section, "Tip", buff, sizeof(buff)))
if(c.get(section, "tip", buff, sizeof(buff)))
tip = buff;
if(c.get(section, "Exec", buff, sizeof(buff)))
if(c.get(section, "exec", buff, sizeof(buff)))
exec = buff;
ControlButton* cb = new ControlButton(tipbox, tip, exec, 0, 0, 100, 100);
cb->copy_label(name.c_str());
c.get(section, "IconPathAbsolute", abspath, false);
if(c.get(section, "Icon", buff, sizeof(buff)))
fetch_icon(cb, buff, abspath);
c.get(section, "icon", buff, sizeof(buff));
fetch_icon(cb, buff);
g->add(cb);
}