Compare commits

...

27 Commits

Author SHA1 Message Date
Sanel Z 9804f0e93a
Merge pull request #1 from kraileth/readme-improvement
Improve readme
2018-05-22 14:22:14 +02:00
Sanel Zukan a04496c7f0 Do not handle manual for now. 2018-05-22 14:01:57 +02:00
Michael Reim 84f195c9b7 Improve readme 2018-05-04 20:28:07 +02:00
Sanel Zukan 5489ef0b70 Prevent crash when focusing button. 2018-05-04 00:52:05 +02:00
Sanel Zukan cbcb0e2ce4 Show status when battery query fails.
When there is an issue with getting battery details, panel would not
show any icon nor tooltip to mark that status. This changes adds failing
icon and appropriate tooltip message.
2016-07-13 16:07:02 +02:00
Sanel Zukan 09039b46c9 Changed default gtk+ theme.
For now, relay on Adwaita gtk+3 theme. For future, a better approach
should be considered.
2016-07-13 12:53:12 +02:00
Sanel Zukan 7cc34bd248 Make sure 'lib' folders are created first. 2016-07-13 12:52:36 +02:00
Sanel Zukan 482ced1c5c Use rsvg-convert as svg convertor. 2016-06-29 13:27:02 +02:00
Sanel Zukan f09dd4d3d6 Fixing links. 2016-06-16 14:51:33 +02:00
Sanel Zukan 9c6d7ebd0e Updating. 2016-06-16 14:49:39 +02:00
Sanel Zukan 9029fb2f45 Renaming. 2016-06-16 14:45:08 +02:00
Sanel Zukan 6f0fa02cbe Reordering repository 2016-06-08 12:33:37 +00:00
Sanel Zukan f799482f64 DBus in most cases requres pthreads library, especially on OpenBSD in this case. 2015-12-17 00:13:09 +00:00
Sanel Zukan da0370a255 Allow ede-startup.conf values to be overwritten by user specific startup sequence. 2015-12-17 00:05:32 +00:00
Sanel Zukan 3042413e36 Applying patches from Michael to fix openbsd buils. Fixing notification daemon to properly read 'replaces' property. 2015-12-16 17:05:02 +00:00
Sanel Zukan 29475da925 Allow setting splash theme to 'none'.
If 'none' was set, no splash theme will be used. This is another way
splash screen can be disabled without adding '-n' option to evoke.
2014-12-08 23:00:55 +00:00
Sanel Zukan 09b1d6fe74 Sort entries before they are added to the menu list. 2014-12-04 17:08:01 +00:00
Sanel Zukan ef64e70a8b Sort layout descriptions. 2014-12-03 20:48:44 +00:00
Sanel Zukan bd1f834431 Removed comments that prevented applet loading 2014-11-29 02:49:04 +00:00
Sanel Zukan 8f5f3a94ca Cleanup. 2014-11-29 02:43:19 +00:00
Sanel Zukan e154972cdd Small code cleanup. Use the same code for tiling as ede-desktop is using it; this will make tile preview to look the same as will be on desktop background. 2014-11-28 17:45:41 +00:00
Sanel Zukan 8f8a937e98 Added support for wallpaper size update when screen sizes are changed. Also, there are some tricks applied so wallpaper scaling be done only when really is needed. 2014-11-28 15:46:05 +00:00
Sanel Zukan f0c50eeebf Fixing issue with workspace change and window listing. Adding facility for reading configuration from applets: implemting options for configuring fixed layout in taskbar tabs and showing buttons from all desktops. 2014-11-28 01:47:31 +00:00
Sanel Zukan 002bd6b2e7 Adding support for taskbuttons drag & drop. Also fixing child size check bug. 2014-11-19 12:40:42 +00:00
Sanel Zukan 0d0cc8d8b1 Fixing bug 208 - Panel (position 0!) displaced on startup 2014-07-09 12:50:17 +00:00
Sanel Zukan a2b2ae0e27 Adding patch from kraileth, which makes tip compiler compileable with musl libc. 2014-07-09 11:07:06 +00:00
Sanel Zukan e529fb9794 Increasing version number. 2014-06-23 21:11:41 +00:00
37 changed files with 626 additions and 284 deletions

View File

@ -10,7 +10,7 @@
SubDir TOP ;
EdeManualWithToc README ;
# EdeManualWithToc README ;
Clean distclean : $(JCACHEFILE) $(HCACHEFILE) ;

58
README
View File

@ -1,58 +0,0 @@
Readme for EDE
==============
Thank you for showing interest in EDE project. EDE is small and fast desktop environment
that uses http://www.fltk.org[FLTK Toolkit]. For more details and philosophy behind it, check
http://equinox-project.org/wiki/AboutEde[about EDE on our wiki].
As every software project, EDE is always in development so your contribution is always welcome!
Build requirements
------------------
EDE is using FLTK toolkit from http://www.fltk.org[www.fltk.org]. At the time
of this writing, latest stable tree is 1.3.x.
Since FLTK lacks many things needed for developing a full *nix desktop
environment, we have developed a small add-on library called 'edelib'. This
library is also required for compiling EDE and is released together with EDE.
We *strongly* recommend that you use matching versions of EDE and
edelib (e.g. released at the same time) or you make repository checkout at the same time due
their frequent changes.
Also you will need a 'jam' tool. Jam is a make replacement and you will find it on our repository.
Downloading the code
--------------------
The best way to download latest code is checking it out from our repository. These modules
you should checkout (with their paths):
- jam : 'svn co https://ede.svn.sourceforge.net/svnroot/ede/trunk/jam'
- edelib : 'svn co https://ede.svn.sourceforge.net/svnroot/ede/trunk/edelib'
- ede : 'svn co https://ede.svn.sourceforge.net/svnroot/ede/trunk/ede2'
If you already have Jam installed, there is no need to download it.
Compiling and installing
------------------------
In order to build and install EDE do the following steps:
1. compile and install jam first; going to jam source directory and running 'make' will do
the job; after that you should get 'bin.YOUR_PLATFORM' directory (on Linux it will be
bin.linux) and copy 'jam' executable in your $PATH, e.g. /usr/local/bin
2. compile and install edelib; please read README file in edelib directory
3. go in ede2 directory and run './autogen.sh'
4. after that, goes './configure --enable-debug'
5. jam
6. jam install
Please note how this document is quick and short tutorial about EDE installation. For more details,
please check http://equinox-project.org/wiki/InstallationHowTo[Installation Howto] on our wiki.

58
README.md Normal file
View File

@ -0,0 +1,58 @@
# EDE
EDE, the `Equinox Desktop Environment`, is a small and fast desktop
environment that uses the [FLTK toolkit](http://www.fltk.org).
For more details and the philosophy behind it, see
[about EDE on our wiki](http://equinox-project.org/wiki/AboutEde).
## Build requirements
EDE requires FLTK; at the time of this writing, the latest stable
branch is 1.3.x.
Since FLTK lacks many things needed for developing a full *nix desktop
environment, we have developed a small add-on library called
`edelib`. This library is needed both for building and running the
desktop. Edelib is developed and released together with EDE.
It is *strongly* recommended to use matching versions of EDE and
edelib (i.e. versions released at the same time) or to checkout
both from the repository at the same time to make sure they work
together well.
Also you will need the `jam` tool. Jam is a *make* replacement and you
can find it on our repository.
## Downloading the code
The best way to get the latest code is checking it out from our
repository. These are the modules you should checkout (with their paths):
- *jam* - `git clone https://github.com/edeproject/jam.git`
- *edelib* - `git clone https://github.com/edeproject/edelib.git`
- *ede* - `git clone https://github.com/edeproject/ede.git`
If you already have Jam installed, there is of course no need to download
it again. Either vanilla Jam or FTJam can be used to build EDE. Boost Jam is
known to *not* work.
## Compiling and installing
In order to build and install EDE do the following steps:
1. compile and install `jam` first; going to jam source directory and running `make` will do
the job; after that you should get `bin.YOUR_PLATFORM` directory (e.g. on Linux it will be
bin.linux) and copy `jam` executable in your $PATH, e.g. */usr/local/bin*
2. compile and install `edelib`; please read README file in edelib directory
3. change into the ede directory and run `./autogen.sh`
4. after that, do `./configure --enable-debug`
5. jam
6. jam install
Please note that this document is only a quick and short tutorial on installing EDE. For more details
please see [Installation Howto](http://equinox-project.org/wiki/InstallationHowTo) on our wiki.

View File

@ -8,7 +8,7 @@
# GNU General Public License version 2 or newer.
# See COPYING for details.
SVG_CONVERTOR = "rsvg" ;
SVG_CONVERTOR = "rsvg-convert" ;
# SvgToPng [target-png] : [source-svg] : [width] : [height] ;
rule SvgToPng

View File

@ -2,14 +2,14 @@ dnl
dnl $Id: configure.in 1719 2006-08-15 08:56:42Z karijes $
dnl
dnl Part of Equinox Desktop Environment (EDE).
dnl Copyright (c) 2000-2012 EDE Authors.
dnl Copyright (c) 2000-2014 EDE Authors.
dnl
dnl This program is licenced under terms of the
dnl GNU General Public Licence version 2 or newer.
dnl See COPYING for details.
m4_define([ede_major_version], [2])
m4_define([ede_minor_version], [1])
m4_define([ede_minor_version], [2])
m4_define([ede_patch_version], [0])
m4_define([ede_version], [ede_major_version.ede_minor_version.ede_patch_version])

View File

@ -10,4 +10,4 @@
SubDir TOP data pekwm scripts ;
InstallProgram "$(PEKWM_DATA_DIR)/scripts" : pekwm_themeset.sh pekwm_ws_menu.sh ;
# InstallProgram "$(PEKWM_DATA_DIR)/scripts" : pekwm_themeset.sh pekwm_ws_menu.sh ;

View File

@ -102,11 +102,11 @@ const char* bold_keywords[] = {
#define BOLD_KEYWORDS_LEN 8
void close_cb(Fl_Widget*, void*) {
static void close_cb(Fl_Widget*, void*) {
win->hide();
}
char* prepare_style(char* txt, int len) {
static char* prepare_style(char* txt, int len) {
// paint all with 'A' style at startup
char* style = new char[len + 1];
memset(style, 'A', len - 1);
@ -114,12 +114,13 @@ char* prepare_style(char* txt, int len) {
// find bold keywords and paint them
char* p = 0;
unsigned int ln;
for(int i = 0; i < BOLD_KEYWORDS_LEN; i++) {
p = strstr(txt, bold_keywords[i]);
if(!p)
continue;
unsigned int len = strlen(bold_keywords[i]);
memset(&style[p - txt], 'B', len);
if(!p) continue;
ln = strlen(bold_keywords[i]);
memset(&style[p - txt], 'B', ln);
}
return style;

View File

@ -50,16 +50,20 @@ if $(CURL_CFLAGS) || $(CURL_LIBS) {
$(PTHREAD_CFLAGS)
$(PTHREAD_LIBS) ;
MkDir $(XMLRPC_C_LIB_DIR) ;
# xmlrpc-c related builds
rule XmlrpcLibrary {
local lib = [ FDirName $(XMLRPC_C_LIB_DIR) $(<) ] ;
local libe = $(lib:S=$(SUFLIB)) ;
# compile it with OPTIMFLAGS got from top Jamconfig
ObjectCcFlags $(>) : $(XMLRPC_C_FLAGS) $(OPTIMFLAGS) ;
StaticLibrary $(lib) : $(>) ;
LocalDepends $(libe) : $(XMLRPC_C_LIB_DIR) ;
# make sure libraries are build first
LocalDepends $(BINARY) : $(lib:S=$(SUFLIB)) ;
LocalDepends $(BINARY) : $(libe) ;
}
SEARCH_SOURCE += [ FDirName $(XMLRPC_C_SRC_PATH) src ] ;
@ -99,7 +103,7 @@ if $(CURL_CFLAGS) || $(CURL_LIBS) {
curlmulti.c
lock_pthread.c ;
ObjectCcFlags $(CURL_TRANSPORT_SRC) : $(CURL_CFLAGS) ;
ObjectCcFlags $(CURL_TRANSPORT_SRC) : $(XMLRPC_C_FLAGS) $(CURL_CFLAGS) ;
UTIL_SRC =
casprintf.c

View File

@ -3,7 +3,7 @@
*
* Desktop configuration tool
* Part of Equinox Desktop Environment (EDE).
* Copyright (c) 2007-2008 EDE Authors.
* Copyright (c) 2007-2014 EDE Authors.
*
* This program is licensed under terms of the
* GNU General Public License version 2 or newer.
@ -29,7 +29,6 @@
#include <FL/Fl_Color_Chooser.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_Tiled_Image.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/x.H>
@ -43,6 +42,9 @@
#include <edelib/Directory.h>
#include <edelib/ForeignCallback.h>
#include <edelib/Ede.h>
#include <edelib/Netwm.h>
EDELIB_NS_USING(netwm_workarea_get_size)
#define EDE_DESKTOP_CONFIG "ede-desktop"
@ -53,7 +55,7 @@ Fl_Menu_Item mode_menu[] = {
{0}
};
// make sure this part matches array positions in mode_menu[]
/* make sure this part matches array positions in mode_menu[] */
#define IMG_CENTER 0
#define IMG_STRETCH 1
#define IMG_TILE 2
@ -79,7 +81,79 @@ Fl_Input* icon_font_txt;
Fl_Check_Button* engage_with_one_click;
void set_wallpaper(const char* path) {
#define PIXEL_POS(x, y, w, d) ((((y) * (w)) + (x)) * (d))
/* TODO: the same function exists in ede-desktop: move this to edelib */
static Fl_RGB_Image* create_tile(Fl_Image *orig, int X, int Y, int W, int H) {
/* don't tile large image */
if(orig->w() >= W && orig->h() >= H)
return (Fl_RGB_Image*)orig;
int iw = orig->w();
int ih = orig->h();
int idepth = orig->d();
int tx = X - (X % iw);
int ty = Y - (Y % ih);
int tw = W + tx;
int th = H + ty;
unsigned char* dest = new unsigned char[tw * th * orig->d()];
unsigned char* destptr = dest;
unsigned char* src = (unsigned char*)orig->data()[0];
int ppos = 0;
/* for bounds checks */
int imax = iw * ih * idepth;
if(idepth == 3 || idepth == 4) {
for(int j = 0, cj = 0; j < th; j++, cj++) {
if(cj > ih) cj = 0;
for(int i = 0, ci = 0; i < tw; i++, ci++) {
if(ci > iw) ci = 0;
ppos = PIXEL_POS(ci, cj, iw, idepth);
if(ppos > imax) ppos = imax;
*destptr++ = src[ppos];
*destptr++ = src[ppos + 1];
*destptr++ = src[ppos + 2];
if(idepth == 4)
*destptr++ = src[ppos + 3];
}
}
} else if(idepth == 2) {
for(int j = 0, cj = 0; j < th; j++, cj++) {
if(cj > ih) cj = 0;
for(int i = 0, ci = 0; i < tw; i++, ci++) {
if(ci > iw) ci = 0;
ppos = PIXEL_POS(ci, cj, iw, idepth);
if(ppos > imax) ppos = imax;
*destptr++ = src[ppos];
*destptr++ = src[ppos + 1];
}
}
} else {
for(int j = 0, cj = 0; j < th; j++, cj++) {
if(cj > ih) cj = 0;
for(int i = 0, ci = 0; i < tw; i++, ci++) {
if(ci > iw) ci = 0;
ppos = PIXEL_POS(ci, cj, iw, idepth);
if(ppos > imax) ppos = imax;
*destptr++ = src[ppos];
}
}
}
Fl_RGB_Image* c = new Fl_RGB_Image(dest, tw, th, idepth, orig->ld());
c->alloc_array = 1;
return c;
}
static void set_wallpaper(const char* path) {
if(!path)
return;
@ -101,19 +175,12 @@ void set_wallpaper(const char* path) {
* Before doing anything with the image, first scale it relative to wallpaper box,
* which is relative to the screen sizes.
*/
int display_w = DisplayWidth(fl_display, fl_screen);
int display_h = DisplayHeight(fl_display, fl_screen);
int scale_w_factor, scale_h_factor;
int X, Y, W, H;
if(!netwm_workarea_get_size(X, Y, W, H))
Fl::screen_xywh(X, Y, W, H);
if(display_w > area_w)
scale_w_factor = display_w / area_w;
else
scale_w_factor = 1;
if(display_h > area_h)
scale_h_factor = display_h / area_h;
else
scale_h_factor = 1;
int scale_w_factor = (W > area_w) ? W / area_w : 1;
int scale_h_factor = (H > area_h) ? H / area_h : 1;
Fl_Image* rel_img = img->copy(img->w() / scale_w_factor, img->h() / scale_h_factor);
@ -134,9 +201,8 @@ void set_wallpaper(const char* path) {
}
case IMG_TILE: {
Fl_Tiled_Image* tiled = new Fl_Tiled_Image(rel_img, area_w, area_h);
wallpaper_img->size(area_w, area_h);
wallpaper_img->image(tiled);
wallpaper_img->image(create_tile(rel_img, 0, 0, area_w, area_h));
break;
}
@ -168,7 +234,7 @@ void set_wallpaper(const char* path) {
}
}
void disable_wallpaper(bool doit) {
static void disable_wallpaper(bool doit) {
if(doit) {
desk_use_wallpaper->value(0);
desk_background_mode->deactivate();
@ -191,17 +257,12 @@ void disable_wallpaper(bool doit) {
wallpaper->redraw();
}
void set_rgb_color(Fl_Button* btn, unsigned char r, unsigned char g, unsigned char b) {
Fl_Color c = (Fl_Color)edelib::color_rgb_to_fltk(r, g, b);
btn->color(c);
}
void close_cb(Fl_Widget*, void* w) {
static void close_cb(Fl_Widget*, void* w) {
edelib::Window* win = (edelib::Window*)w;
win->hide();
}
void color_cb(Fl_Widget* btn, void*) {
static void color_cb(Fl_Widget* btn, void*) {
unsigned char r, g, b;
edelib::color_fltk_to_rgb(btn->color(), r, g, b);
@ -212,7 +273,7 @@ void color_cb(Fl_Widget* btn, void*) {
}
}
void wallpaper_color_cb(Fl_Widget*, void* w) {
static void wallpaper_color_cb(Fl_Widget*, void* w) {
unsigned char r, g, b;
edelib::color_fltk_to_rgb(desk_background_color->color(), r, g, b);
@ -227,7 +288,7 @@ void wallpaper_color_cb(Fl_Widget*, void* w) {
}
}
void browse_cb(Fl_Widget*, void*) {
static void browse_cb(Fl_Widget*, void*) {
char* ret = fl_file_chooser(_("Background image"), "*.jpg\t*.png", desk_background->value());
if(!ret)
return;
@ -237,7 +298,7 @@ void browse_cb(Fl_Widget*, void*) {
wallpaper->redraw();
}
void wallpaper_use_cb(Fl_Widget*, void*) {
static void wallpaper_use_cb(Fl_Widget*, void*) {
if(desk_use_wallpaper->value()) {
disable_wallpaper(false);
set_wallpaper(desk_background->value());
@ -245,13 +306,13 @@ void wallpaper_use_cb(Fl_Widget*, void*) {
disable_wallpaper(true);
}
void choice_cb(Fl_Widget*, void*) {
static void choice_cb(Fl_Widget*, void*) {
set_wallpaper(desk_background->value());
wallpaper_img->redraw();
wallpaper->redraw();
}
void apply_cb(Fl_Widget*, void* w) {
static void apply_cb(Fl_Widget*, void* w) {
edelib::Resource conf;
conf.set("Desktop", "color", (int)desk_background_color->color());
conf.set("Desktop", "wallpaper_use", desk_use_wallpaper->value());
@ -273,7 +334,7 @@ void apply_cb(Fl_Widget*, void* w) {
edelib::foreign_callback_call("ede-desktop");
}
void ok_cb(Fl_Widget*, void* w) {
static void ok_cb(Fl_Widget*, void* w) {
edelib::Window* win = (edelib::Window*)w;
apply_cb(0, win);
/* a hack so ede-desktop-conf can send a message before it was closed */
@ -281,7 +342,7 @@ void ok_cb(Fl_Widget*, void* w) {
win->hide();
}
void browse_fonts_cb(Fl_Widget*, void* w) {
static void browse_fonts_cb(Fl_Widget*, void* w) {
Fl_Input* in = (Fl_Input*)w;
int retsz;
const char* font_name = Fl::get_font_name((Fl_Font)icon_font, 0);
@ -296,7 +357,7 @@ void browse_fonts_cb(Fl_Widget*, void* w) {
icon_font_size = retsz;
}
void load_settings(void) {
static void load_settings(void) {
int b_mode = 0;
bool d_wp_use = false;
int d_background_color = fl_rgb_color(73, 64, 102); /* keep it in sync with default color in ede-desktop */
@ -376,13 +437,11 @@ int main(int argc, char** argv) {
g1->hide();
g1->begin();
/*
Fl_Box* b1 = new Fl_Box(85, 196, 100, 15);
b1->box(FL_BORDER_BOX);
b1->box(FL_THIN_UP_BOX);
Fl_Box* b2 = new Fl_Box(30, 43, 210, 158);
b2->box(FL_THIN_UP_BOX);
*/
/* box size is intentionaly odd so preserve aspect ratio */
wallpaper = new Fl_Box(43, 53, 184, 138);

View File

@ -168,6 +168,7 @@ static void folder_create_cb(Fl_Widget*, void *d) {
Desktop::Desktop() : EDE_DESKTOP_WINDOW(0, 0, 100, 100, EDE_DESKTOP_APP) {
end();
/* use nice darker blue color as default for background */
color(fl_rgb_color(73, 64, 102));
@ -232,12 +233,30 @@ void Desktop::update_workarea(void) {
if(!netwm_workarea_get_size(X, Y, W, H))
Fl::screen_xywh(X, Y, W, H);
E_DEBUG(E_STRLOC ": resizing to %i %i %i %i\n", X, Y, W, H);
update_workarea(X, Y, W, H);
}
void Desktop::update_workarea(int X, int Y, int W, int H) {
/* prevent multiple calls with the same values */
if(X == x() && Y == y() && W == w() && H == h())
return;
E_DEBUG(E_STRLOC ": resizing to %i %i %i %i (was: %i %i %i %i)\n",
X, Y, W, H, x(), y(), w(), h());
/*
* Check if wallpaper needs resizing. Sometimes, while screen size is updated
* X11 can change x/y, but keep w/h; here, wallpaper size update is not needed.
*/
bool resize_wallpaper = !(W == w() && H == h());
resize(X, Y, W, H);
/* also resize wallpaper if given */
if(wallpaper && wallpaper->visible())
wallpaper->resize(0, 0, w(), h());
if(wallpaper && wallpaper->visible() && resize_wallpaper) {
E_DEBUG(E_STRLOC ": resizing wallpaper to %i %i\n", W, H);
wallpaper->resize(0, 0, W, H);
}
}
void Desktop::read_config(void) {
@ -402,7 +421,6 @@ DesktopIcon *Desktop::read_desktop_file(const char *path, const char *base, Desk
return ret;
}
void Desktop::arrange_icons(void) {
int lw = icon_opts ? icon_opts->label_maxwidth : 75;
int X = (lw / 5) + 10;

View File

@ -72,6 +72,7 @@ public:
void show(void);
void update_workarea(void);
void update_workarea(int X, int Y, int W, int H);
void read_config(void);
void read_desktop_folder(const char *dpath = NULL);

View File

@ -31,4 +31,4 @@ SOURCE = ede-desktop.cpp
ObjectC++Flags $(SOURCE) : $(EDELIB_DBUS_INCLUDE) ;
EdeProgram ede-desktop : $(SOURCE) ;
LinkAgainst ede-desktop : $(EDELIB_DBUS_LIB) $(XSHAPE_LIBS) ;
LinkAgainst ede-desktop : $(EDELIB_DBUS_LIB) $(XSHAPE_LIBS) $(PTHREAD_LIBS) ;

View File

@ -370,10 +370,6 @@ void Wallpaper::set_rootpmap(void) {
bool Wallpaper::load(const char *path, int s, bool rootpmap) {
E_ASSERT(path != NULL);
/* in case this function gets multiple calls */
if(wpath == path && state == s && rootpmap == use_rootpmap)
return true;
Fl_Shared_Image *img = Fl_Shared_Image::get(path);
E_RETURN_VAL_IF_FAIL(img != NULL, false);
@ -423,7 +419,7 @@ void Wallpaper::draw(void) {
iw = im->w();
ih = im->h();
E_RETURN_IF_FAIL(iw > 0 && ih > 0);
if(state == WALLPAPER_CENTER) {
@ -476,7 +472,7 @@ int Wallpaper::handle(int event) {
void Wallpaper::resize(int X, int Y, int W, int H) {
if(X == x() && Y == y() && W == w() && H == h())
return;
Fl_Box::resize(X, Y, W, H);
if(image()) {
/*

View File

@ -125,9 +125,17 @@ static void fetch_current_layout(String &current) {
XFree(vd.variant);
}
static int sort_cmp(const void *a, const void *b) {
XkbRF_VarDescPtr first = (XkbRF_VarDescPtr)a;
XkbRF_VarDescPtr second = (XkbRF_VarDescPtr)b;
return strcmp(first->desc, second->desc);
}
static XkbRF_RulesPtr fetch_all_layouts(const String &current) {
char buf[256];
XkbRF_RulesPtr xkb_rules = NULL;
char buf[256];
XkbRF_RulesPtr xkb_rules = NULL;
XkbRF_DescribeVarsPtr layouts = NULL;
/* try to locate rules file */
for(int i = 0; x11_dirs[i]; i++) {
@ -144,13 +152,18 @@ static XkbRF_RulesPtr fetch_all_layouts(const String &current) {
E_WARNING(E_STRLOC ": Unable to load keyboard rules file\n");
return NULL;
}
done:
for(int i = 0; i < xkb_rules->layouts.num_desc; i++) {
snprintf(buf, sizeof(buf), "%s\t%s", xkb_rules->layouts.desc[i].name, xkb_rules->layouts.desc[i].desc);
layouts = &xkb_rules->layouts;
/* sort them */
qsort(layouts->desc, layouts->num_desc, sizeof(XkbRF_VarDescRec), sort_cmp);
for(int i = 0; i < layouts->num_desc; i++) {
snprintf(buf, sizeof(buf), "%s\t%s", layouts->desc[i].name, layouts->desc[i].desc);
layout_browser->add(buf);
if(current == xkb_rules->layouts.desc[i].name) {
if(current == layouts->desc[i].name) {
/* Fl_Browser counts items from 1 */
layout_browser->select(i + 1);
}

View File

@ -13,7 +13,7 @@ SubDir TOP ede-notify-daemon ;
SOURCE = ede-notify-daemon.cpp NotifyWindow.cpp ;
EdeProgram ede-notify-daemon : $(SOURCE) ;
LinkAgainst ede-notify-daemon : $(EDELIB_DBUS_LIB) ;
LinkAgainst ede-notify-daemon : $(EDELIB_DBUS_LIB) $(PTHREAD_LIBS) ;
TranslationStrings locale : $(SOURCE) ;

View File

@ -115,7 +115,8 @@ void NotifyWindow::set_icon(const char *img) {
}
void NotifyWindow::set_body(const char *s) {
summary->resize(summary->x(), summary->y() - (summary->h() / 2), summary->w(), summary->h());
summary->resize(65, 10, 185, 25);
//summary->resize(summary->x(), summary->y() - (summary->h() / 2), summary->w(), summary->h());
body->value(s);
body->show();
@ -137,7 +138,7 @@ void NotifyWindow::resize(int X, int Y, int W, int H) {
* do not call further if window is shown: different strategy is needed as every time
* window is re-configured, this will be called
*/
if(shown()) return;
//if(shown()) return;
/* resize summary if needed */
if(summary->size() > 0) {

View File

@ -1,7 +1,7 @@
/*
* $Id: ede-panel.cpp 3330 2012-05-28 10:57:50Z karijes $
*
* Copyright (C) 2012 Sanel Zukan
* Copyright (C) 2012-2014 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -31,7 +31,8 @@
class NotifyWindow : public Fl_Window {
private:
int id, exp, timer_set;
unsigned int id;
int exp, timer_set;
Fl_Button *closeb;
Fl_Box *imgbox;
Fl_Multiline_Output *summary, *body;
@ -41,8 +42,8 @@ private:
public:
NotifyWindow();
void set_id(int i) { id = i; }
int get_id(void) { return id; }
void set_id(unsigned int i) { id = i; }
unsigned int get_id(void) { return id; }
void set_icon(const char *img);
void set_summary(const char *s) { summary->value(s); }
@ -52,7 +53,14 @@ public:
* match to spec: if is -1, then we handle it, if is 0, then window will not be closed and
* the rest is sender specific
*/
void set_expire(int t) { exp = t; }
void set_expire(int t, bool update_timer) {
exp = t;
// if(update_timer) {
// remove_timeout();
// add_timeout();
// }
}
void show(void);
virtual void resize(int X, int Y, int W, int H);

View File

@ -1,7 +1,7 @@
/*
* $Id: ede-panel.cpp 3330 2012-05-28 10:57:50Z karijes $
*
* Copyright (C) 2012 Sanel Zukan
* Copyright (C) 2012-2014 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -83,7 +83,8 @@ static bool server_running;
* list of server capabilities
* check all available on: http://people.gnome.org/~mccann/docs/notification-spec/notification-spec-latest.html
*/
static const char *server_caps[] = {"actions", "body", "icon-static", 0};
// static const char *server_caps[] = {"actions", "body", "icon-static", 0};
static const char *server_caps[] = {"body", "icon-static", 0};
/* increased every time new notification window is shown; must be less than UINT_MAX */
static unsigned int notify_id;
@ -128,22 +129,40 @@ static bool get_int_coordinate(const char *n, EdbusDict &hints, int &c) {
return true;
}
static void show_window(unsigned int id,
const char *app_name,
const char *app_icon,
const char *summary,
const char *body,
int expire_timeout,
EdbusDict &hints)
static void show_or_update_window(bool update_only,
unsigned int id,
const char *app_name,
const char *app_icon,
const char *summary,
const char *body,
int expire_timeout,
EdbusDict &hints)
{
byte_t u = get_urgency_level(hints);
NotifyWindow *win = NULL;
NotifyWindow *win = new NotifyWindow();
if(update_only) {
E_DEBUG(E_STRLOC ": Requesting update\n");
/* try to find existing window with given id */
Fl_Window *wi;
NotifyWindow *tmp;
if(!empty_str(summary))
win->set_summary(summary);
if(!empty_str(body))
win->set_body(body);
for(wi = Fl::first_window(); wi; wi = Fl::next_window(wi)) {
if(wi->type() != NOTIFYWINDOW_TYPE) continue;
tmp = (NotifyWindow*)wi;
if(tmp->get_id() == id) {
E_DEBUG(E_STRLOC ": Requesting update - win found\n");
win = tmp;
break;
}
}
}
/* window not found or new window requested */
if(!win) win = new NotifyWindow();
if(!empty_str(summary)) win->set_summary(summary);
if(!empty_str(body)) win->set_body(body);
if(empty_str(app_icon)) {
switch(u) {
case URGENCY_CRITICAL:
@ -158,7 +177,7 @@ static void show_window(unsigned int id,
win->set_icon(app_icon);
win->set_id(id);
win->set_expire(expire_timeout);
win->set_expire(expire_timeout, update_only);
/* according to spec, both coordinates must exist so window can be positioned as desired */
int X, Y;
@ -198,7 +217,8 @@ static void show_window(unsigned int id,
}
/* we are already running loop, so window will handle events */
win->show();
if(!win->shown())
win->show();
}
static int handle_notify(EdbusConnection *dbus, const EdbusMessage *m) {
@ -209,7 +229,7 @@ static int handle_notify(EdbusConnection *dbus, const EdbusMessage *m) {
const char *app_name, *app_icon, *summary, *body;
app_name = app_icon = summary = body = NULL;
unsigned int replaces_id;
unsigned int replaces_id, id;
int expire_timeout;
EdbusMessage::const_iterator it = m->begin();
@ -246,19 +266,33 @@ static int handle_notify(EdbusConnection *dbus, const EdbusMessage *m) {
E_RETURN_VAL_IF_FAIL(it->is_int32(), 0);
expire_timeout = it->to_int32();
/* specification dumb stuff: what if we got UINT_MAX?? here we will reverse to first ID */
if(++notify_id == UINT_MAX) notify_id = 1;
if(replaces_id) {
//replaces_id == notify_id;
if(replaces_id > 0) {
id = replaces_id;
} else {
show_window(notify_id, app_name, app_icon, summary, body, expire_timeout, hints);
/* by the spec, if we got MAX, reversing will be just fine */
if(++notify_id == UINT_MAX) notify_id = 1;
id = notify_id;
}
/* reply sent to client */
/* this should never happen */
E_RETURN_VAL_IF_FAIL(id != 0, 0);
show_or_update_window(replaces_id > 0, id,
app_name, app_icon, summary, body, expire_timeout, hints);
#if 0
if(replaces_id) {
update_window(replaces_id, app_name, app_icon, summary, body, expire_timeout, hints);
sent_id = replaces_id;
} else {
show_window(notify_id, app_name, app_icon, summary, body, expire_timeout, hints);
sent_id = notify_id;
}
#endif
/* reply sent to client, with used window id */
EdbusMessage reply;
reply.create_reply(*m);
reply << EdbusData::from_uint32(replaces_id);
reply << EdbusData::from_uint32(id);
dbus->send(reply);
return 1;
@ -357,7 +391,6 @@ int main(int argc, char **argv) {
dbus.register_object(NOTIFICATIONS_DBUS_PATH);
dbus.method_callback(notifications_dbus_method_cb, &dbus);
//dbus.signal_callback(notifications_dbus_signal_cb, &dbus);
dbus.setup_listener_with_fltk();
server_running = true;

View File

@ -3,8 +3,64 @@
N_EVENTS=5
notify_cmd="notify-send --expire-time=10000"
#notify_cmd="notify-send --expire-time=3000"
#
#for((i=0;i<$N_EVENTS;i++)) do
# $notify_cmd "title $i" "this is content"
#done
for((i=0;i<$N_EVENTS;i++)) do
$notify_cmd "title $i" "this is content"
done
#method call sender=:1.798 -> dest=org.freedesktop.Notifications serial=116 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
# string "Mumble"
# uint32 1
# string "gtk-dialog-info"
# string "User Joined Channel"
# string "<a href='clientid://df93eabe004245bd18dd38cf9a07bd5242b2f522' class='log-user log-target'>madamova</a> entered channel."
# array [
# ]
# array [
# dict entry(
# string "desktop-entry"
# variant string "mumble"
# )
# ]
# int32 -1
dbus-send --type=method_call \
--dest=org.freedesktop.Notifications \
/org/freedesktop/Notifications org.freedesktop.Notifications.Notify \
string:"Mumble" \
uint32:1 \
string:"gtk-dialog-info" \
string:"User Joined Channel" \
string:"<a href='clientid://df93eabe004245bd18dd38cf9a07bd5242b2f522' class='log-user log-target'>madamova</a> entered channel." \
array:string:'' \
dict:string:string:'','' \
int32:-1
sleep 1
dbus-send --type=method_call \
--dest=org.freedesktop.Notifications \
/org/freedesktop/Notifications org.freedesktop.Notifications.Notify \
string:"Mumble 2" \
uint32:1 \
string:"gtk-dialog-info" \
string:"User Joined Channel #2" \
string:"<a href='clientid://df93eabe004245bd18dd38cf9a07bd5242b2f522' class='log-user log-target'>madamova</a> entered channel. asdasd asdasdsa asdasd asdasd asdasdsa" \
array:string:'' \
dict:string:string:'','' \
int32:-1
sleep 1
dbus-send --type=method_call \
--dest=org.freedesktop.Notifications \
/org/freedesktop/Notifications org.freedesktop.Notifications.Notify \
string:"Mumble 2" \
uint32:1 \
string:"gtk-dialog-info" \
string:"User Joined Channel #2 dasdasd asdasfdsa fsdfsdfa sdfsdfasdf asdfsdfasdfasdfasdfa asdfasdfdsafasdfasdfdsafdsaf sadfsdafds" \
string:"doh!" \
array:string:'' \
dict:string:string:'','' \
int32:-1

View File

@ -21,6 +21,9 @@
#ifndef __APPLET_H__
#define __APPLET_H__
#include <edelib/Resource.h>
EDELIB_NS_USING_AS(Resource, PanelResource)
class Fl_Widget;
/* stored version in each applet shared library in case interface get changed */
@ -40,15 +43,6 @@ enum {
EDE_PANEL_APPLET_OPTION_ALIGN_RIGHT = (1 << 4)
};
struct AppletInfo {
const char *name;
const char *klass_name;
const char *version;
const char *icon;
const char *author;
unsigned long options;
};
/*
* each applet want to inherit this class if would like to exchange data with panel
* NOTE: new things could be added in future, but that will be reflected through EDE_PANEL_APPLET_INTERFACE_VERSION
@ -59,6 +53,23 @@ public:
AppletWidget(int X, int Y, int W, int H, const char *l = 0) : T(X, Y, W, H, l) {
T::type(EDE_PANEL_APPLET_TYPE);
}
virtual ~AppletWidget() { }
/*
* Override this method to access panel configuration. Note that 'PanelResource' object
* will be destroyed after applets are loaded, so do not hold reference to this address.
*/
virtual void configure(PanelResource *conf) { }
};
struct AppletInfo {
const char *name;
const char *klass_name;
const char *version;
const char *icon;
const char *author;
unsigned long options;
};
/* module stuff */

View File

@ -141,7 +141,7 @@ void AppletManager::clear(Panel *p) {
* Must be called so widget can actually be added to FLTK parent. Widgets will be created and
* added to the group.
*/
void AppletManager::fill_group(Panel *p) {
void AppletManager::fill_group(Panel *p, PanelResource *res) {
AListIter it = applet_list.begin(), ite = applet_list.end();
AppletData *applet;
@ -150,6 +150,15 @@ void AppletManager::fill_group(Panel *p) {
/* allocate memory for widget and append it to the group */
applet->awidget = applet->create_func();
/* call configuration function if needed */
if(res && applet->awidget->type() == EDE_PANEL_APPLET_TYPE) {
/* a hackery to make compiler happy */
typedef AppletWidget<Fl_Widget> AW;
AW *tmp = (AW*)(applet->awidget);
tmp->configure(res);
}
p->add(applet->awidget);
}
}

View File

@ -29,8 +29,8 @@ class Panel;
class Fl_Widget;
struct AppletData;
typedef edelib::list<AppletData*> AList;
typedef edelib::list<AppletData*>::iterator AListIter;
typedef EDELIB_NS_PREPEND(list<AppletData*>) AList;
typedef EDELIB_NS_PREPEND(list<AppletData*>::iterator) AListIter;
class AppletManager {
private:
@ -38,7 +38,7 @@ private:
public:
bool load(const char *path);
void clear(Panel *p);
void fill_group(Panel *p);
void fill_group(Panel *p, PanelResource *res);
void unfill_group(Panel *p);
bool get_applet_options(Fl_Widget *o, unsigned long &opts);

View File

@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (C) 2012-2013 Sanel Zukan
* Copyright (C) 2012-2014 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,14 +23,11 @@
#include <string.h>
#include <limits.h>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/x.H>
#include <X11/Xproto.h>
#include <edelib/Debug.h>
#include <edelib/List.h>
#include <edelib/WindowXid.h>
#include <edelib/Resource.h>
#include <edelib/Util.h>
#include <edelib/Netwm.h>
#include <edelib/Directory.h>
@ -81,7 +78,8 @@ static int xerror_handler(Display *d, XErrorEvent *e) {
if(e->request_code == X_GetImage)
return 0;
char buf[128];
/* keep it static as no multiple panels will be run */
static char buf[128];
/*
* construct the similar message format like X11 is using by default, but again, little
@ -233,7 +231,7 @@ Panel::Panel() : PanelWindow(300, 30, "ede-panel") {
screen_x = screen_y = screen_w = screen_h = screen_h_half = 0;
width_perc = 100;
can_move_widgets = false;
can_drag = true;
can_drag = false;
box(FL_UP_BOX);
read_config();
@ -270,12 +268,12 @@ void Panel::read_config(void) {
} else {
if(hider) hider->hide();
}
char buf[128];
if(r.get("Panel", "applets", buf, sizeof(buf)))
load_applets(buf);
load_applets(buf, &r);
else
load_applets();
load_applets(0, &r);
}
void Panel::save_config(void) {
@ -397,11 +395,7 @@ void Panel::set_strut(short state) {
if(state == PANEL_STRUT_REMOVE) return;
int sizes[4] = {0, 0, 0, 0};
if(state & PANEL_STRUT_BOTTOM)
sizes[3] = h();
else
sizes[2] = h();
sizes[state & PANEL_STRUT_BOTTOM ? 3 : 2] = h();
/* TODO: netwm_window_set_strut_partial() */
netwm_window_set_strut(fl_xid(this), sizes[0], sizes[1], sizes[2], sizes[3]);
@ -411,8 +405,8 @@ void Panel::show(void) {
if(shown()) return;
/*
* hush known FLTK bug with XGetImage; a lot of errors will be print when menu icons goes
* outside screen; this also make ede-panel, at some point, unresponsible
* hush known FLTK bug with XGetImage; a lot of errors will be printed when menu icons goes
* outside screen; this can stuck ede-panel at some point
*/
XSetErrorHandler((XErrorHandler) xerror_handler);
update_size_and_pos(true, true);
@ -475,21 +469,28 @@ void Panel::update_size_and_pos(bool create_xid, bool update_strut, int X, int Y
if(width_perc >= 100 && update_strut)
set_strut(PANEL_STRUT_REMOVE | PANEL_STRUT_BOTTOM);
} else {
/* FIXME: this does not work well with edewm (nor pekwm). kwin do it correctly. */
position(X, Y);
/*
* I'm not sure what the hell is going on here; if 'y == 0', X will
* move panel few pixels down, even if FLTK is reporting y() == 0.
* Seems like 1 will solve this.
*/
position(X, Y == 0 ? 1 : Y);
if(width_perc >= 100 && update_strut)
set_strut(PANEL_STRUT_REMOVE | PANEL_STRUT_TOP);
}
}
int Panel::handle(int e) {
return Fl_Window::handle(e);
#if 0
switch(e) {
case FL_PUSH:
clicked = Fl::belowmouse();
if(clicked == this)
clicked = 0;
else if(clicked && clicked->takesevents())
else if(clicked && Fl::event_inside(clicked) && clicked->takesevents())
clicked->handle(e);
/* record push position for possible child drag */
@ -498,27 +499,32 @@ int Panel::handle(int e) {
return 1;
case FL_DRAG: {
if(!can_drag) return 1;
/* send drag events to children and do not drag panel in the mean time */
if(clicked && clicked != this && Fl::event_inside(clicked) && clicked->takesevents()) {
cursor(FL_CURSOR_MOVE);
return clicked->handle(e);
} else {
printf("XXXy %p %p\n", clicked, this);
if(!can_drag) return 1;
cursor(FL_CURSOR_MOVE);
/* are moving the panel; only vertical moving is supported */
cursor(FL_CURSOR_MOVE);
/* snap it to the top or bottom, depending on pressed mouse location */
if(Fl::event_y_root() <= screen_h_half && y() > screen_h_half) {
position(x(), screen_y);
if(width_perc >= 100)
set_strut(PANEL_STRUT_TOP);
vpos = PANEL_POSITION_TOP;
}
/* snap it to the top or bottom, depending on pressed mouse location */
if(Fl::event_y_root() <= screen_h_half && y() > screen_h_half) {
position(x(), screen_y);
if(width_perc >= 100)
set_strut(PANEL_STRUT_TOP);
vpos = PANEL_POSITION_TOP;
}
if(Fl::event_y_root() > screen_h_half && y() < screen_h_half) {
position(x(), screen_h - h());
if(width_perc >= 100)
set_strut(PANEL_STRUT_BOTTOM);
vpos = PANEL_POSITION_BOTTOM;
if(Fl::event_y_root() > screen_h_half && y() < screen_h_half) {
position(x(), screen_h - h());
if(width_perc >= 100)
set_strut(PANEL_STRUT_BOTTOM);
vpos = PANEL_POSITION_BOTTOM;
}
return 1;
}
return 1;
}
case FL_RELEASE:
@ -537,11 +543,11 @@ int Panel::handle(int e) {
return 1;
/* fallthrough */
}
return Fl_Window::handle(e);
#endif
}
void Panel::load_applets(const char *applets) {
void Panel::load_applets(const char *applets, PanelResource *res) {
mgr.clear(this);
/*
@ -549,6 +555,7 @@ void Panel::load_applets(const char *applets) {
* (similar string is expected from configuration), fallback is plain string.
*/
static const char *fallback =
#ifndef EDE_PANEL_LOCAL_APPLETS
"start_menu,"
"quick_launch,"
"pager,"
@ -557,10 +564,25 @@ void Panel::load_applets(const char *applets) {
"keyboard_layout,"
"battery_monitor,"
"cpu_monitor,"
#ifdef __linux__
# ifdef __linux__
"mem_monitor,"
#endif
"system_tray";
# endif
"system_tray"
#else /* EDE_PANEL_LOCAL_APPLETS */
"./applets/start-menu/start_menu,"
"./applets/quick-launch/quick_launch,"
"./applets/pager/pager,"
"./applets/clock/clock,"
"./applets/taskbar/taskbar,"
"./applets/keyboard-layout/keyboard_layout,"
"./applets/battery-monitor/battery_monitor,"
"./applets/cpu-monitor/cpu_monitor,"
# ifdef __linux__
"./applets/mem-monitor/mem_monitor,"
# endif
"./applets/system-tray/system_tray"
#endif /* EDE_PANEL_LOCAL_APPLETS */
;
String dir = Resource::find_data("panel-applets");
E_RETURN_IF_FAIL(!dir.empty());
@ -576,13 +598,13 @@ void Panel::load_applets(const char *applets) {
snprintf(path, sizeof(path), "%s" E_DIR_SEPARATOR_STR "%s" APPLET_EXTENSION, dir.c_str(), tok);
#else
/* only for testing, so path separator is hardcoded */
snprintf(path, sizeof(path), "./applets/%s/%s" APPLET_EXTENSION, dir.c_str(), tok);
snprintf(path, sizeof(path), "%s" APPLET_EXTENSION, tok);
#endif
mgr.load(path);
}
free(dup);
mgr.fill_group(this);
mgr.fill_group(this, res);
}
/* TODO: can be better */

View File

@ -68,7 +68,7 @@ public:
void update_size_and_pos(bool create_xid, bool update_strut);
void update_size_and_pos(bool create_xid, bool update_strut, int X, int Y, int W, int H);
int handle(int e);
void load_applets(const char *applets = 0);
void load_applets(const char *applets, PanelResource *res = 0);
int panel_w(void) { return w(); }
int panel_h(void) { return h(); }

View File

@ -1,7 +1,5 @@
/*
* $Id: ede-panel.cpp 3463 2012-12-17 15:49:33Z karijes $
*
* Copyright (C) 2013 Sanel Zukan
* Copyright (C) 2013-2016 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -59,9 +57,10 @@ EDELIB_NS_USING(EDBUS_SYSTEM)
#define UPOWER_INTERFACE "org.freedesktop.UPower.Device"
#define UPOWER_PATH "/org/freedesktop/UPower"
#define BATTERY_MIN 10 /* minimal time before icon to BATTERY_CAUTION_IMG was changed */
#define BATTERY_IMG "battery"
#define BATTERY_CAUTION_IMG "battery-caution"
#define BATTERY_MIN 10 /* minimal time before icon to BATTERY_CAUTION_IMG was changed */
#define BATTERY_IMG "battery"
#define BATTERY_CAUTION_IMG "battery-caution"
#define BATTERY_NO_CONNECTION "dialog-warning"
typedef list<EdbusObjectPath> BatteryList;
typedef list<EdbusObjectPath>::iterator BatteryListIt;
@ -83,15 +82,18 @@ private:
public:
BatteryMonitor() : Fl_Box(0, 0, 30, 25), bimg(0) {
box(FL_FLAT_BOX);
scan_and_init();
if(!scan_and_init()) {
set_icon(0, true);
tooltip(_("Failed to query battery status"));
}
}
EdbusConnection &connection() { return con; }
void tooltip_printf(const char *fmt, ...);
void scan_and_init(void);
int scan_and_init(void);
int update_icon_and_tooltip(void);
void set_icon(double percentage);
void set_icon(double percentage, bool failure = false);
BatteryList &get_batteries(void);
};
@ -186,19 +188,19 @@ void BatteryMonitor::tooltip_printf(const char *fmt, ...) {
tooltip(tip);
}
void BatteryMonitor::scan_and_init(void) {
if(con.connected()) return;
E_RETURN_IF_FAIL(con.connect(EDBUS_SYSTEM));
int BatteryMonitor::scan_and_init(void) {
if(con.connected()) return 1;
E_RETURN_VAL_IF_FAIL(con.connect(EDBUS_SYSTEM), 0);
/* get battery devices */
EdbusMessage msg, reply;
msg.create_method_call(UPOWER_SERVICE, UPOWER_PATH, UPOWER_SERVICE, "EnumerateDevices");
E_RETURN_IF_FAIL(con.send_with_reply_and_block(msg, 1000, reply));
E_RETURN_IF_FAIL(reply.size() == 1);
E_RETURN_VAL_IF_FAIL(con.send_with_reply_and_block(msg, 1000, reply), 0);
E_RETURN_VAL_IF_FAIL(reply.size() == 1, 0);
EdbusMessage::const_iterator it = reply.begin();
E_RETURN_IF_FAIL(it->is_array());
E_RETURN_VAL_IF_FAIL(it->is_array(), 0);
EdbusList arr = it->to_array();
it = arr.begin();
@ -222,6 +224,7 @@ void BatteryMonitor::scan_and_init(void) {
/* ready to receive signals */
con.signal_callback(signal_cb, this);
con.setup_listener_with_fltk();
return 1;
}
int BatteryMonitor::update_icon_and_tooltip(void) {
@ -255,16 +258,22 @@ int BatteryMonitor::update_icon_and_tooltip(void) {
#define BATTERY_MIN 10
void BatteryMonitor::set_icon(double percentage) {
void BatteryMonitor::set_icon(double percentage, bool failure) {
if(E_UNLIKELY(IconLoader::inited() == false)) {
char buf[8];
snprintf(buf, sizeof(buf), "%i%%", (int)percentage);
copy_label(buf);
return;
}
const char *icon = (percentage >= BATTERY_MIN) ? BATTERY_IMG : BATTERY_CAUTION_IMG;
const char *icon;
if(failure)
icon = BATTERY_NO_CONNECTION;
else
icon = (percentage >= BATTERY_MIN) ? BATTERY_IMG : BATTERY_CAUTION_IMG;
/* small check to prevent image loading when not needed */
if(icon == bimg) return;

View File

@ -36,13 +36,17 @@
# include <string.h> /* strncmp */
#endif
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__)
# include <sys/param.h>
# include <sys/sysctl.h>
# if __FreeBSD_version < 500101
# include <sys/dkstat.h>
# if defined(__OpenBSD__)
# include <sys/sched.h>
# else
# include <sys/resource.h>
# if __FreeBSD_version < 500101
# include <sys/dkstat.h>
# else
# include <sys/resource.h>
# endif
# endif
# include <sys/stat.h>
#endif

View File

@ -104,9 +104,10 @@ static void maximize_cb(Fl_Widget*, void *b) {
}
TaskButton::TaskButton(int X, int Y, int W, int H, const char *l) : Fl_Button(X, Y, W, H, l),
xid(0), wspace(0), image_alloc(false), net_wm_icon(0)
xid(0), wspace(0), old_value(0), image_alloc(false), dragged(false), net_wm_icon(0)
{
box(FL_UP_BOX);
align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);
if(IconLoader::inited()) {
@ -226,3 +227,30 @@ void TaskButton::update_image_from_xid(void) {
image(img);
image_alloc = true;
}
int TaskButton::handle(int e) {
switch(e) {
case FL_PUSH:
/*
* Remember old value, as value() result affect will box be drawn as FL_UP_BOX or FL_DOWN_BOX.
* This trick should return box to the old state in case of dragging.
*/
old_value = value();
return Fl_Button::handle(e);
case FL_DRAG:
dragged = true;
return 1;
case FL_RELEASE:
if(dragged) {
Taskbar *taskbar = (Taskbar*)parent();
taskbar->try_dnd(this, Fl::event_x(), Fl::event_y());
dragged = false;
value(old_value);
return 1;
}
/* fallthrough */
}
return Fl_Button::handle(e);
}

View File

@ -29,7 +29,9 @@ private:
/* window ID this button handles */
Window xid;
int wspace;
char old_value; /* for storing value() as it affects boxtype */
bool image_alloc;
bool dragged;
Atom net_wm_icon;
void clear_image(void);
@ -48,6 +50,8 @@ public:
void set_workspace(int s) { wspace = s; }
int get_workspace(void) { return wspace; }
int handle(int e);
};
#endif

View File

@ -1,7 +1,7 @@
/*
* $Id$
*
* Copyright (C) 2012-2013 Sanel Zukan
* Copyright (C) 2012-2014 Sanel Zukan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -100,12 +100,8 @@ static void net_event_cb(int action, Window xid, void *data) {
}
}
Taskbar::Taskbar() : Fl_Group(0, 0, 40, 25), curr_active(NULL), prev_active(NULL) {
Taskbar::Taskbar() : WidgetGroup(0, 0, 40, 25), curr_active(NULL), prev_active(NULL) {
end();
//box(FL_FLAT_BOX);
//color(FL_RED);
fixed_layout = false;
ignore_workspace_value = false;
@ -119,6 +115,15 @@ Taskbar::~Taskbar() {
netwm_callback_remove(net_event_cb);
}
void Taskbar::configure(Resource *res) {
E_RETURN_IF_FAIL(res != NULL);
res->get("Taskbar", "fixed_layout", fixed_layout, false);
res->get("Taskbar", "all_desktops", ignore_workspace_value, false);
if(visible()) update_task_buttons();
}
void Taskbar::update_task_buttons(void) {
Window *wins;
int ws, nwins = netwm_window_get_all_mapped(&wins);
@ -127,10 +132,10 @@ void Taskbar::update_task_buttons(void) {
if(children() > 0) clear();
return;
}
TaskButton *b;
bool need_full_redraw = false;
for(int i = 0, found; i < children(); i++) {
found = 0;
b = (TaskButton*)child(i);
@ -187,19 +192,25 @@ void Taskbar::update_task_buttons(void) {
/* create button */
ws = netwm_window_get_workspace(wins[i]);
b = new TaskButton(0, 0, DEFAULT_CHILD_W, 25);
b->set_window_xid(wins[i]);
b->update_title_from_xid();
b->update_image_from_xid();
b->set_workspace(ws);
/* mark it hidden by default */
b->hide();
/* catch the name changes */
XSelectInput(fl_display, wins[i], PropertyChangeMask | StructureNotifyMask);
b->callback((Fl_Callback*)button_cb, this);
/* add it to our list */
add(b);
if(visible_on_current_workspace(ws)) {
b = new TaskButton(0, 0, DEFAULT_CHILD_W, 25);
b->set_window_xid(wins[i]);
b->update_title_from_xid();
b->update_image_from_xid();
b->set_workspace(ws);
/* catch the name changes */
XSelectInput(fl_display, wins[i], PropertyChangeMask | StructureNotifyMask);
b->callback((Fl_Callback*)button_cb, this);
add(b);
need_full_redraw = true;
//need_full_redraw = true;
b->show();
}
}
@ -211,9 +222,9 @@ void Taskbar::update_task_buttons(void) {
}
void Taskbar::update_workspace_change(void) {
if(children() < 1) return;
if(!children()) return;
current_workspace = netwm_workspace_get_current();
TaskButton *b;
for(int i = 0; i < children(); i++) {
b = (TaskButton*)child(i);
@ -360,7 +371,7 @@ void Taskbar::update_child_icon(Window xid) {
}
void Taskbar::update_child_workspace(Window xid) {
if(children() < 0) return;
if(!children()) return;
TaskButton *o;
for(int i = 0; i < children(); i++) {
@ -382,6 +393,49 @@ void Taskbar::panel_redraw(void) {
parent()->redraw();
}
void Taskbar::try_dnd(TaskButton *b, int xpos, int ypos) {
if(!children()) return;
/*
* try to find position of incoming child, as the child, when is moved
* forward, has to go on 'target_pos + 1' instead only 'target_pos'
*/
int child_pos = find(b);
E_RETURN_IF_FAIL(child_pos != children());
TaskButton *o;
for(int i = 0; i < children(); i++) {
o = (TaskButton*)child(i);
if(o == b) continue;
if((xpos > b->x() && xpos < b->x() + b->w()) &&
(ypos > b->y() && ypos < b->y() + b->h()))
{
/* not moved outside child range */
return;
}
if((xpos > o->x() && xpos < o->x() + o->w()) &&
(ypos > o->y() && ypos < o->y() + o->h()))
{
/* Try to find widget position in array. Widgets in array are not sorted in any order. */
int pos = find(o);
if(pos == children()) {
/* not found, proceed with the search */
continue;
}
/* increase just in case target position is in front */
pos += (pos > child_pos) ? 1 : 0;
insert(*b, pos);
break;
}
}
layout_children();
redraw();
}
EDE_PANEL_APPLET_EXPORT (
Taskbar,
EDE_PANEL_APPLET_OPTION_ALIGN_LEFT | EDE_PANEL_APPLET_OPTION_RESIZABLE_H,

View File

@ -22,28 +22,33 @@
#define __TASKBAR_H__
#include <FL/Fl_Group.H>
#include <edelib/Resource.h>
#include "Applet.h"
EDELIB_NS_USING(Resource)
/* if button should be on visible on all workspaces */
#define ALL_WORKSPACES -1
class TaskButton;
typedef AppletWidget<Fl_Group> WidgetGroup;
class Taskbar : public Fl_Group {
class Taskbar : public WidgetGroup {
public:
TaskButton *curr_active, *prev_active;
bool fixed_layout; /* fixed or streched layout of buttons */
bool ignore_workspace_value; /* should all windows be shown ignoring workspace value */
int current_workspace;
bool visible_on_current_workspace(int ws) {
return ignore_workspace_value || (ws == ALL_WORKSPACES) || (ws == current_workspace);
return (ignore_workspace_value == true) || (ws == ALL_WORKSPACES) || (ws == current_workspace);
}
public:
Taskbar();
~Taskbar();
void configure(Resource *res);
void update_task_buttons(void);
void update_workspace_change(void);
@ -58,6 +63,9 @@ public:
void update_child_workspace(Window xid);
void panel_redraw(void);
/* try to move child on place of other child, but only if it falls within x,y range */
void try_dnd(TaskButton *b, int x, int y);
};
#endif

View File

@ -43,6 +43,10 @@ static Fl_Spinner* timeout_val;
static Fl_Double_Window* main_win;
static Fl_Double_Window* preview_win;
static bool hacks_sorter(SaverHack* const& a, SaverHack* const& b) {
return a->name < b->name;
}
static void dpms_enable_cb(Fl_Widget* w, void* s) {
Fl_Check_Button* o = (Fl_Check_Button*)w;
SaverPrefs* sp = (SaverPrefs*)s;
@ -170,6 +174,7 @@ int main(int argc, char **argv) {
if(sp->curr_hack >= sp->hacks.size())
sp->curr_hack = 0;
sp->hacks.sort(hacks_sorter);
HackListIter it = sp->hacks.begin(), it_end = sp->hacks.end();
for(int i = 1; it != it_end; ++it, i++) {
saver_list->add((*it)->name.c_str(), 0, 0);

View File

@ -74,6 +74,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/param.h>
#include <stdio.h>

View File

@ -215,12 +215,11 @@ int main(int argc, char **argv) {
Fl_Button* close_button = new Fl_Button(435, 224, 90, 25, _("&Close"));
close_button->callback(close_cb);
// check_button somehow steal focus
close_button->take_focus();
win->end();
window_center_on_screen(win);
win->show(argc, argv);
// check_button somehow steal focus
close_button->take_focus();
Fl::run();

View File

@ -42,7 +42,6 @@
EDELIB_NS_USING(Config)
EDELIB_NS_USING(Resource)
EDELIB_NS_USING(RES_SYS_ONLY)
EDELIB_NS_USING(file_remove)
EDELIB_NS_USING(file_test)
EDELIB_NS_USING(str_trim)
@ -59,16 +58,15 @@ EDELIB_NS_USING(EDBUS_SESSION)
EDELIB_NS_USING(EDBUS_SYSTEM)
#endif
#ifdef USE_LOCAL_CONFIG
# define CONFIG_GET_STRVAL(object, section, key, buff) object.get(section, key, buff, sizeof(buff))
#else
# define CONFIG_GET_STRVAL(object, section, key, buff) object.get(section, key, buff, sizeof(buff), RES_SYS_ONLY)
#endif
#define CONFIG_GET_STRVAL(object, section, key, buff) object.get(section, key, buff, sizeof(buff))
/* stolen from xfce's xfsm-shutdown-helper */
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
# define POWEROFF_CMD "/sbin/shutdown -p now"
# define REBOOT_CMD "/sbin/shutdown -r now"
#elif defined(__OpenBSD__)
# define POWEROFF_CMD "/sbin/shutdown -hp now"
# define REBOOT_CMD "/sbin/shutdown -r now"
#elif defined(sun) || defined(__sun)
# define POWEROFF_CMD "/usr/sbin/shutdown -i 5 -g 0 -y"
# define REBOOT_CMD "/usr/sbin/shutdown -i 6 -g 0 -y"

View File

@ -27,7 +27,7 @@ ObjectC++Flags Splash.cpp : -DEDEWM_HAVE_NET_SPLASH ;
ObjectC++Flags evoke.cpp : -DUSE_SIGHUP ;
ObjectC++Flags EvokeService.cpp : $(EDELIB_DBUS_INCLUDE) ;
LinkAgainstAsFirst evoke : $(EDELIB_DBUS_LIB) ;
LinkAgainstAsFirst evoke : $(EDELIB_DBUS_LIB) $(PTHREAD_LIBS) ;
EdeProgram evoke : $(SOURCE) ;

View File

@ -94,7 +94,7 @@ void Splash::show(void) {
void Splash::run(void) {
E_ASSERT(slist != NULL);
if(!show_splash) {
if(!show_splash || (splash_theme && (strcasecmp(splash_theme->c_str(), "none") == 0))) {
while(next_client_nosplash())
;
return;

View File

@ -14,5 +14,5 @@
<setting name="Net/DndDragThreshold" type="int" value="8" />
<setting name="Net/DoubleClickTime" type="int" value="300" />
<setting name="Net/IconThemeName" type="string" value="edeneu" />
<setting name="Net/ThemeName" type="string" value="Raleigh" />
<setting name="Net/ThemeName" type="string" value="Adwaita" />
</ede-settings>