Read font from font cache and display it

This commit is contained in:
Sanel Zukan 2011-11-09 14:08:11 +00:00
parent ff5a21c825
commit 23396ec197
4 changed files with 19 additions and 12 deletions

View File

@ -104,12 +104,6 @@ DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) :
gsettings = gs; gsettings = gs;
settings = is; settings = is;
/* setting fonts is TODO :P */
#if 0
Fl::set_font((Fl_Font)20, "-windows-*-medium-r-*-*-14-*-*-*-*-*-*-*");
labelfont((Fl_Font)20);
#endif
label(settings->name.c_str()); label(settings->name.c_str());
imenu = new MenuButton(0, 0, 0, 0); imenu = new MenuButton(0, 0, 0, 0);
@ -127,7 +121,7 @@ DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) :
color(bg); color(bg);
align(FL_ALIGN_WRAP); align(FL_ALIGN_WRAP);
update_label_size(); update_label_font_and_size();
} }
DesktopIcon::~DesktopIcon() { DesktopIcon::~DesktopIcon() {
@ -175,7 +169,8 @@ void DesktopIcon::load_icon(int face) {
darker_img->color_average(FL_BLUE, 0.6); darker_img->color_average(FL_BLUE, 0.6);
} }
void DesktopIcon::update_label_size(void) { void DesktopIcon::update_label_font_and_size(void) {
labelfont(gsettings->label_font);
labelsize(gsettings->label_fontsize); labelsize(gsettings->label_fontsize);
lwidth = gsettings->label_maxwidth; lwidth = gsettings->label_maxwidth;
lheight= 0; lheight= 0;
@ -278,7 +273,7 @@ void DesktopIcon::rename(const char* str) {
settings->name = str; settings->name = str;
label(settings->name.c_str()); label(settings->name.c_str());
update_label_size(); update_label_font_and_size();
redraw(); redraw();
} }

View File

@ -41,7 +41,7 @@ private:
edelib::MenuButton* imenu; edelib::MenuButton* imenu;
void load_icon(int face); void load_icon(int face);
void update_label_size(void); void update_label_font_and_size(void);
void fix_position(int X, int Y); void fix_position(int X, int Y);
public: public:

View File

@ -18,6 +18,7 @@
#include <signal.h> #include <signal.h>
#include <stdlib.h> // rand, srand #include <stdlib.h> // rand, srand
#include <time.h> // time #include <time.h> // time
#include <limits.h>
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/x.H> #include <FL/x.H>
@ -40,6 +41,7 @@
#include <edelib/ForeignCallback.h> #include <edelib/ForeignCallback.h>
#include <edelib/Netwm.h> #include <edelib/Netwm.h>
#include <edelib/WindowXid.h> #include <edelib/WindowXid.h>
#include <edelib/FontCache.h>
#include <edelib/Ede.h> #include <edelib/Ede.h>
#include "ede-desktop.h" #include "ede-desktop.h"
@ -81,6 +83,7 @@ EDELIB_NS_USING(netwm_workarea_get_size)
EDELIB_NS_USING(netwm_window_set_type) EDELIB_NS_USING(netwm_window_set_type)
EDELIB_NS_USING(netwm_callback_add) EDELIB_NS_USING(netwm_callback_add)
EDELIB_NS_USING(netwm_callback_remove) EDELIB_NS_USING(netwm_callback_remove)
EDELIB_NS_USING(font_cache_find)
EDELIB_NS_USING(NETWM_WINDOW_TYPE_DESKTOP) EDELIB_NS_USING(NETWM_WINDOW_TYPE_DESKTOP)
EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKAREA) EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKAREA)
EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKSPACE) EDELIB_NS_USING(NETWM_CHANGED_CURRENT_WORKSPACE)
@ -163,6 +166,7 @@ Desktop::Desktop() : EDE_DESKTOP_WINDOW(0, 0, 100, 100, "") {
/* gnome light blue */ /* gnome light blue */
gisett->label_background = 138; gisett->label_background = 138;
gisett->label_foreground = FL_WHITE; gisett->label_foreground = FL_WHITE;
gisett->label_font = FL_HELVETICA;
gisett->label_fontsize = 12; gisett->label_fontsize = 12;
gisett->label_maxwidth = 75; gisett->label_maxwidth = 75;
gisett->label_transparent = true; gisett->label_transparent = true;
@ -293,7 +297,7 @@ void Desktop::read_config(void) {
} }
bool wuse; bool wuse;
char wpath[256]; char wpath[PATH_MAX], font_name[64];
int bcolor, wmode; int bcolor, wmode;
/* use nice darker blue color as default for background */ /* use nice darker blue color as default for background */
@ -306,13 +310,20 @@ void Desktop::read_config(void) {
/* '138' is gnome light blue */ /* '138' is gnome light blue */
conf.get("Icons", "label_background", gisett->label_background, 138); conf.get("Icons", "label_background", gisett->label_background, 138);
conf.get("Icons", "label_foreground", gisett->label_foreground, FL_WHITE); conf.get("Icons", "label_foreground", gisett->label_foreground, FL_WHITE);
conf.get("Icons", "label_fontsize", gisett->label_fontsize, 12);
conf.get("Icons", "label_maxwidth", gisett->label_maxwidth, 75); conf.get("Icons", "label_maxwidth", gisett->label_maxwidth, 75);
conf.get("Icons", "label_transparent",gisett->label_transparent, true); conf.get("Icons", "label_transparent",gisett->label_transparent, true);
conf.get("Icons", "label_visible", gisett->label_draw, true); conf.get("Icons", "label_visible", gisett->label_draw, true);
conf.get("Icons", "one_click_exec", gisett->one_click_exec, false); conf.get("Icons", "one_click_exec", gisett->one_click_exec, false);
conf.get("Icons", "auto_arrange", gisett->auto_arrange, true); conf.get("Icons", "auto_arrange", gisett->auto_arrange, true);
/* try to get font */
if(conf.get("Icons", "label_font", font_name, sizeof(font_name))) {
font_cache_find(font_name, gisett->label_font,
gisett->label_fontsize,
gisett->label_font,
gisett->label_fontsize);
}
/* minimal allowed font size */ /* minimal allowed font size */
if(gisett->label_fontsize < 8) if(gisett->label_fontsize < 8)
gisett->label_fontsize = 12; gisett->label_fontsize = 12;

View File

@ -44,6 +44,7 @@
struct GlobalIconSettings { struct GlobalIconSettings {
int label_background; int label_background;
int label_foreground; int label_foreground;
int label_font;
int label_fontsize; int label_fontsize;
int label_maxwidth; int label_maxwidth;
bool label_transparent; bool label_transparent;