From c7c8fc92ea2541304bbbae3defb34c545702a63c Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Thu, 26 Feb 2009 11:15:27 +0000 Subject: [PATCH] Added ede-bell-conf, a tool to configure system bell (that annoying beep thing) Rest are changes so can nicely be compiled on freebsd Also, some changes are in coding style --- Jamfile | 8 +- doc/Jamfile | 2 +- ede-bell-conf/Jamfile | 16 ++++ ede-bell-conf/ede-bell-conf.cpp | 84 +++++++++++++++++++ ede-bell-conf/fl/ede-bell-conf.fl | 36 +++++++++ ede-conf/ede-conf.conf | 8 +- ede-desktop/DesktopIcon.h | 112 +++++++++++++------------- ede-desktop/IconProperties.cpp | 2 - ede-desktop/Wallpaper.h | 24 +++--- ede-desktop/ede-desktop.h | 100 +++++++++++------------ ede-panel/batterymonitor.cpp | 6 +- ede-screensaver-conf/XScreenSaver.cpp | 2 + ede-tip/Fortune.cpp | 9 ++- 13 files changed, 280 insertions(+), 129 deletions(-) create mode 100644 ede-bell-conf/Jamfile create mode 100644 ede-bell-conf/ede-bell-conf.cpp create mode 100644 ede-bell-conf/fl/ede-bell-conf.fl diff --git a/Jamfile b/Jamfile index 9723eaa..42d9ad1 100644 --- a/Jamfile +++ b/Jamfile @@ -17,14 +17,13 @@ Clean distclean : $(JCACHEFILE) $(HCACHEFILE) ; # SubInclude goes after local rules SubInclude TOP ede-about ; +SubInclude TOP ede-bell-conf ; SubInclude TOP ede-calc ; SubInclude TOP ede-conf ; SubInclude TOP ede-crasher ; SubInclude TOP ede-desktop ; SubInclude TOP ede-desktop-conf ; SubInclude TOP ede-screensaver-conf ; -#SubInclude TOP edewm ; -SubInclude TOP efiler ; SubInclude TOP ede-help ; SubInclude TOP eimage ; SubInclude TOP elma ; @@ -37,3 +36,8 @@ SubInclude TOP edewm ; SubInclude TOP evoke ; SubInclude TOP doc ; SubInclude TOP data ; + +# efile is not compileable on FreeBSD +if $(OS) != FREEBSD { + SubInclude TOP efiler ; +} diff --git a/doc/Jamfile b/doc/Jamfile index 5efcd49..e1e4ecf 100644 --- a/doc/Jamfile +++ b/doc/Jamfile @@ -17,7 +17,7 @@ MANUAL_FILES = [ Wildcard manual : *.html : manual ] ; MANUAL_IMGS = [ FDirName $(SUBDIR) manual images ] ; # where will be installed -MANUAL_INSTALL_DIR = [ FDirName $(EDEDOCDIR) manual ] ; +MANUAL_INSTALL_DIR = [ FDirName $(EDE_DOC_DIR) manual ] ; # install generated documents InstallData $(MANUAL_INSTALL_DIR) : $(MANUAL_FILES) ; diff --git a/ede-bell-conf/Jamfile b/ede-bell-conf/Jamfile new file mode 100644 index 0000000..bb885ea --- /dev/null +++ b/ede-bell-conf/Jamfile @@ -0,0 +1,16 @@ +# +# $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-bell-conf ; + +SOURCE = ede-bell-conf.cpp ; + +EdeProgram ede-bell-conf : $(SOURCE) ; +TranslationStrings locale : $(SOURCE) ; diff --git a/ede-bell-conf/ede-bell-conf.cpp b/ede-bell-conf/ede-bell-conf.cpp new file mode 100644 index 0000000..c0c48a5 --- /dev/null +++ b/ede-bell-conf/ede-bell-conf.cpp @@ -0,0 +1,84 @@ +/* + * $Id$ + * + * ede-bell-conf, a tool to configure system bell + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +static Fl_Value_Slider* vol_slide; +static Fl_Value_Slider* pitch_slide; +static Fl_Value_Slider* dur_slide; +static edelib::Window* win; + +static void set_values(void) { + unsigned long v = KBBellPercent | KBBellPitch | KBBellDuration; + XKeyboardControl kc; + kc.bell_percent = (unsigned int)vol_slide->value(); + kc.bell_pitch = (unsigned int)pitch_slide->value(); + kc.bell_duration = (unsigned int)dur_slide->value(); + + XChangeKeyboardControl(fl_display, v, &kc); +} + +static void cancel_cb(Fl_Widget*, void*) { + win->hide(); +} + +static void ok_cb(Fl_Widget*, void*) { + set_values(); + win->hide(); +} + +static void test_cb(Fl_Widget*, void*) { + set_values(); + XBell(fl_display, 0); +} + +int main(int argc, char **argv) { + win = new edelib::Window(330, 210, _("System bell configuration")); + win->begin(); + vol_slide = new Fl_Value_Slider(10, 30, 310, 25, _("Volume")); + vol_slide->type(5); + vol_slide->step(1); + vol_slide->maximum(100); + vol_slide->align(FL_ALIGN_TOP); + + pitch_slide = new Fl_Value_Slider(10, 80, 310, 25, _("Pitch")); + pitch_slide->type(5); + pitch_slide->step(1); + pitch_slide->minimum(100); + pitch_slide->maximum(1000); + pitch_slide->align(FL_ALIGN_TOP); + + dur_slide = new Fl_Value_Slider(10, 130, 310, 25, _("Duration")); + dur_slide->type(5); + dur_slide->step(1); + dur_slide->minimum(0); + dur_slide->maximum(1000); + dur_slide->align(FL_ALIGN_TOP); + + Fl_Button* ok = new Fl_Button(135, 175, 90, 25, _("&OK")); + ok->callback(ok_cb); + + Fl_Button* cancel = new Fl_Button(230, 175, 90, 25, _("&Cancel")); + cancel->callback(cancel_cb); + + Fl_Button* test = new Fl_Button(10, 175, 90, 25, _("&Test")); + test->callback(test_cb); + win->end(); + win->show(argc, argv); + return Fl::run(); +} diff --git a/ede-bell-conf/fl/ede-bell-conf.fl b/ede-bell-conf/fl/ede-bell-conf.fl new file mode 100644 index 0000000..78c3f24 --- /dev/null +++ b/ede-bell-conf/fl/ede-bell-conf.fl @@ -0,0 +1,36 @@ +# data file for the Fltk User Interface Designer (fluid) +version 1.0108 +header_name {.h} +code_name {.cxx} +Function {} {open +} { + Fl_Window {} { + label {System bell configuration} open + xywh {428 267 330 210} type Double visible + } { + Fl_Button {} { + label {&OK} + xywh {135 175 90 25} + } + Fl_Button {} { + label {&Cancel} selected + xywh {230 175 90 25} + } + Fl_Button {} { + label {&Test} + xywh {10 175 90 25} + } + Fl_Value_Slider {} { + label Volume + xywh {10 30 310 25} type {Horz Knob} align 1 step 0.01 textsize 12 + } + Fl_Value_Slider {} { + label Pitch + xywh {10 80 310 25} type {Horz Knob} align 1 step 0.01 textsize 12 + } + Fl_Value_Slider {} { + label Duration + xywh {10 130 310 25} type {Horz Knob} align 1 step 0.01 textsize 12 + } + } +} diff --git a/ede-conf/ede-conf.conf b/ede-conf/ede-conf.conf index 111dc37..5b0754a 100644 --- a/ede-conf/ede-conf.conf +++ b/ede-conf/ede-conf.conf @@ -4,7 +4,7 @@ [EdeConf] # main items - items = edewmconf,ede-desktop-conf,ede-screensaver-conf,ede-timedate + items = edewmconf,ede-desktop-conf,ede-screensaver-conf,ede-timedate, ede-bell-conf [edewmconf] name = Window manager @@ -29,3 +29,9 @@ tip = This item will configure system date and time exec = ede-timedate icon = preferences-date-time + +[ede-bell-conf] + name = Configure system bell + tip = This item will configure system bell + exec = ede-bell-conf + icon = audio-volume-zero diff --git a/ede-desktop/DesktopIcon.h b/ede-desktop/DesktopIcon.h index 523d23d..b8bded4 100644 --- a/ede-desktop/DesktopIcon.h +++ b/ede-desktop/DesktopIcon.h @@ -30,79 +30,79 @@ class MovableIcon; class Fl_Menu_Button; class DesktopIcon : public Fl_Widget { - private: - IconSettings* settings; - const GlobalIconSettings* globals; +private: + IconSettings* settings; + const GlobalIconSettings* globals; - int lwidth; - int lheight; - bool focus; + int lwidth; + int lheight; + bool focus; - MovableIcon* micon; + MovableIcon* micon; - Fl_Image* darker_img; - Fl_Menu_Button* imenu; + Fl_Image* darker_img; + Fl_Menu_Button* imenu; - void load_icon(int face); - void update_label_size(void); - void fix_position(int X, int Y); + void load_icon(int face); + void update_label_size(void); + void fix_position(int X, int Y); - public: - DesktopIcon(GlobalIconSettings* gisett, IconSettings* isett, int bg); - ~DesktopIcon(); +public: + DesktopIcon(GlobalIconSettings* gisett, IconSettings* isett, int bg); + ~DesktopIcon(); - virtual void draw(void); - virtual int handle(int event); + virtual void draw(void); + virtual int handle(int event); - void drag(int x, int y, bool apply); - int drag_icon_x(void); - int drag_icon_y(void); + void drag(int x, int y, bool apply); + int drag_icon_x(void); + int drag_icon_y(void); - /* - * This is 'enhanced' (in some sense) redraw(). Redrawing - * icon will not fully redraw label nor focus box, which laid outside - * icon box. It will use damage() on given region, but called from - * parent, so parent can redraw that region on itself (since label does - * not laid on any box) - * - * Alternative way would be to redraw whole parent, but it is pretty unneeded - * and slow. - */ - void fast_redraw(void); + /* + * This is 'enhanced' (in some sense) redraw(). Redrawing + * icon will not fully redraw label nor focus box, which laid outside + * icon box. It will use damage() on given region, but called from + * parent, so parent can redraw that region on itself (since label does + * not laid on any box) + * + * Alternative way would be to redraw whole parent, but it is pretty unneeded + * and slow. + */ + void fast_redraw(void); - /* - * Here is implemented localy focus schema avoiding - * messy fltk one. Focus/unfocus is handled from Desktop. - */ - void do_focus(void) { focus = true; } - void do_unfocus(void) { focus = false; } - bool is_focused(void) { return focus; } + /* + * Here is implemented localy focus schema avoiding + * messy fltk one. Focus/unfocus is handled from Desktop. + */ + void do_focus(void) { focus = true; } + void do_unfocus(void) { focus = false; } + bool is_focused(void) { return focus; } - Fl_Image* icon_image(void) { return image(); } + Fl_Image* icon_image(void) { return image(); } - void rename(const char* str); + void rename(const char* str); - /* - * make sure this returns String since operator== is - * further used, especially in Desktop - */ - const edelib::String& path(void); + /* + * make sure this returns String since operator== is + * further used, especially in Desktop + */ + const edelib::String& path(void); - int icon_type(void); - void use_icon1(void); - void use_icon2(void); + int icon_type(void); + void use_icon1(void); + void use_icon2(void); }; class MovableIcon : public Fl_Window { - private: - DesktopIcon* icon; - Fl_Box* icon_box; - Pixmap mask; +private: + DesktopIcon* icon; + Fl_Box* icon_box; + Pixmap mask; - public: - MovableIcon(DesktopIcon* i); - ~MovableIcon(); - virtual void show(void); +public: + MovableIcon(DesktopIcon* i); + ~MovableIcon(); + virtual void show(void); }; #endif diff --git a/ede-desktop/IconProperties.cpp b/ede-desktop/IconProperties.cpp index 781798d..3ba2a65 100644 --- a/ede-desktop/IconProperties.cpp +++ b/ede-desktop/IconProperties.cpp @@ -54,8 +54,6 @@ static void ok_cb(Fl_Widget*, void* w) { } static void icon_change_cb(Fl_Button* b, void* d) { - DesktopIconData* data = (DesktopIconData*)d; - edelib::String ret = edelib::icon_chooser(edelib::ICON_SIZE_HUGE); if(ret.empty()) return; diff --git a/ede-desktop/Wallpaper.h b/ede-desktop/Wallpaper.h index ad54508..9903b45 100644 --- a/ede-desktop/Wallpaper.h +++ b/ede-desktop/Wallpaper.h @@ -18,22 +18,22 @@ /* * Class responsible for displaying images at background - * their scaling (TODO), caching(TODO) and making coffee at the spear time. + * their scaling (TODO), caching(TODO) and making coffee at the spare time. */ class Wallpaper : public Fl_Box { - private: - Pixmap rootpmap_pixmap; - bool tiled; - void set_rootpmap(void); +private: + Pixmap rootpmap_pixmap; + bool tiled; + void set_rootpmap(void); - public: - Wallpaper(int X, int Y, int W, int H); - ~Wallpaper(); +public: + Wallpaper(int X, int Y, int W, int H); + ~Wallpaper(); - bool set(const char* path); - bool set_tiled(const char* path); - virtual void draw(void); - virtual int handle(int event); + bool set(const char* path); + bool set_tiled(const char* path); + virtual void draw(void); + virtual int handle(int event); }; #endif diff --git a/ede-desktop/ede-desktop.h b/ede-desktop/ede-desktop.h index 9c5a68e..760e7bc 100644 --- a/ede-desktop/ede-desktop.h +++ b/ede-desktop/ede-desktop.h @@ -97,79 +97,79 @@ typedef edelib::list::iterator StringListIter; #endif class Desktop : public DESKTOP_WINDOW { - private: - static Desktop* pinstance; +private: + static Desktop* pinstance; - int selection_x, selection_y; - bool moving; - bool do_dirwatch; + int selection_x, selection_y; + bool moving; + bool do_dirwatch; - SelectionOverlay* selbox; + SelectionOverlay* selbox; - GlobalIconSettings* gisett; - DesktopSettings* dsett; + GlobalIconSettings* gisett; + DesktopSettings* dsett; - Fl_Menu_Button* dmenu; - Wallpaper* wallpaper; - edelib::EdbusConnection* dbus; + Fl_Menu_Button* dmenu; + Wallpaper* wallpaper; + edelib::EdbusConnection* dbus; - DesktopIconList icons; - DesktopIconList selectionbuff; + DesktopIconList icons; + DesktopIconList selectionbuff; - edelib::String trash_path; + edelib::String trash_path; - void init_internals(void); + void init_internals(void); - void load_icons(const char* path); - void save_icons_positions(void); - bool read_desktop_file(const char* path, IconSettings& is); + void load_icons(const char* path); + void save_icons_positions(void); + bool read_desktop_file(const char* path, IconSettings& is); - void add_icon(DesktopIcon* ic); - bool add_icon_by_path(const char* path, edelib::Resource* conf); - DesktopIcon* find_icon_by_path(const char* path); - bool remove_icon_by_path(const char* path); - bool update_icon_by_path(const char* path); + void add_icon(DesktopIcon* ic); + bool add_icon_by_path(const char* path, edelib::Resource* conf); + DesktopIcon* find_icon_by_path(const char* path); + bool remove_icon_by_path(const char* path); + bool update_icon_by_path(const char* path); - void unfocus_all(void); + void unfocus_all(void); - void select(DesktopIcon* ic, bool do_redraw = true); - void select_only(DesktopIcon* ic); - bool in_selection(const DesktopIcon* ic); - void move_selection(int x, int y, bool apply); + void select(DesktopIcon* ic, bool do_redraw = true); + void select_only(DesktopIcon* ic); + bool in_selection(const DesktopIcon* ic); + void move_selection(int x, int y, bool apply); - void select_in_area(void); + void select_in_area(void); - void dnd_drop_source(const char* src, int src_len, int x, int y); + void dnd_drop_source(const char* src, int src_len, int x, int y); - DesktopIcon* below_mouse(int px, int py); + DesktopIcon* below_mouse(int px, int py); - public: - Desktop(); - ~Desktop(); +public: + Desktop(); + ~Desktop(); - virtual void show(void); - virtual void hide(void); - virtual void draw(void); - virtual int handle(int event); + virtual void show(void); + virtual void hide(void); + virtual void draw(void); + virtual int handle(int event); - static void init(void); - static void shutdown(void); - static Desktop* instance(void); + static void init(void); + static void shutdown(void); + static Desktop* instance(void); - void read_config(void); + void read_config(void); - void update_workarea(void); - void area(int& X, int& Y, int& W, int& H) { X = x(); Y = y(); W = w(); H = h(); } + void update_workarea(void); + void area(int& X, int& Y, int& W, int& H) { X = x(); Y = y(); W = w(); H = h(); } - void set_bg_color(int c, bool do_redraw = true); + void set_bg_color(int c, bool do_redraw = true); - void notify_desktop_changed(void); + void notify_desktop_changed(void); - void dir_watch(const char* dir, const char* changed, int flags); - void dir_watch_on(void) { do_dirwatch = true; } - void dir_watch_off(void) { do_dirwatch = false; } + void dir_watch(const char* dir, const char* changed, int flags); + void dir_watch_on(void) { do_dirwatch = true; } + void dir_watch_off(void) { do_dirwatch = false; } - void execute(const char* cmd); + void execute(const char* cmd); }; #endif diff --git a/ede-panel/batterymonitor.cpp b/ede-panel/batterymonitor.cpp index 34e326c..526dfc3 100644 --- a/ede-panel/batterymonitor.cpp +++ b/ede-panel/batterymonitor.cpp @@ -151,7 +151,7 @@ void BatteryMonitor::update_status() #include int first = 1; -void battery_check(void) +void BatteryMonitor::battery_check(void) { int fd; struct apmreq ar ; @@ -213,7 +213,7 @@ void battery_check(void) #define APM_STAT_BATT_CHARGING 3 int first = 1; -void battery_check(void) +void BatteryMonitor::battery_check(void) { int fd, r; bool p; @@ -284,7 +284,7 @@ void battery_check(void) #define _PATH_APM_NORMAL "/dev/apm" int first = 1; -void battery_check(void) +void BatteryMonitor::battery_check(void) { int fd, r; bool p; diff --git a/ede-screensaver-conf/XScreenSaver.cpp b/ede-screensaver-conf/XScreenSaver.cpp index 3120cde..b6cf337 100644 --- a/ede-screensaver-conf/XScreenSaver.cpp +++ b/ede-screensaver-conf/XScreenSaver.cpp @@ -57,6 +57,8 @@ static int atoms_loaded = 0; static pid_t xscr_preview_pid = 0; static const char* xscr_folder_found = 0; +extern char** environ; + static const char* xscr_hacks_dirs[] = { PREFIX"/lib/xscreensaver/", "/usr/libexec/xscreensaver/", diff --git a/ede-tip/Fortune.cpp b/ede-tip/Fortune.cpp index 68f0acc..d4455d1 100644 --- a/ede-tip/Fortune.cpp +++ b/ede-tip/Fortune.cpp @@ -10,12 +10,17 @@ * See COPYING for the details. */ -#include "Fortune.h" - #include #include #include +#include "Fortune.h" + +/* FreeBSD does not have off_t, not sure about others */ +#ifndef __GLIBC__ +typedef unsigned int off_t; +#endif + struct FortuneFile { FILE* str_file; FILE* dat_file;