From 2ea73b6996f75279973be662b67fb216e6fcb636 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Tue, 3 Mar 2009 11:47:30 +0000 Subject: [PATCH] Merged changed pkg.m4 from edelib ede-panel has alternative way of calling ede-about dialog Dumped SettingsApplicator.* code from evoke. They are replaced with ede-settings-apply script which should call all programs that needs to apply stored settings. This will reduce code entropy evoke will call ede-settings-apply at the startup ede-bell-conf modified to use "--apply" arg and to apply known settings ede-desktop will start icon exec path via ede-launch Fixed freebsd specific code in ede-panel's battery code --- Jamconfig.in | 6 +++ configure.in | 7 +-- doc/index.txt | 1 + ede-bell-conf/ede-bell-conf.cpp | 90 +++++++++++++++++++++++++-------- ede-conf/ede-conf.cpp | 16 +----- ede-crasher/CrashDialog.cpp | 10 ++-- ede-desktop/DesktopIcon.cpp | 3 +- ede-panel/aboutdialog.cpp | 11 ++++ ede-panel/batterymonitor.cpp | 2 + ede-panel/menu.h | 2 +- evoke/EvokeService.cpp | 4 +- evoke/EvokeService.h | 1 + evoke/Jamfile | 9 ++-- evoke/SettingsApplicator.cpp | 83 ------------------------------ evoke/SettingsApplicator.h | 26 ---------- evoke/evoke.cpp | 11 +++- m4/pkg.m4 | 13 +++-- 17 files changed, 132 insertions(+), 163 deletions(-) delete mode 100644 evoke/SettingsApplicator.cpp delete mode 100644 evoke/SettingsApplicator.h diff --git a/Jamconfig.in b/Jamconfig.in index 8004a51..3479df8 100644 --- a/Jamconfig.in +++ b/Jamconfig.in @@ -86,5 +86,11 @@ COMPOSITELIB ?= @COMPOSITE_LIBS@ ; HALINCLUDE ?= @HAL_CFLAGS@ ; HALLIB ?= @HAL_LIBS@ ; +# X libraries (could be empty if are on standard paths) +X_CFLAGS ?= @X_CFLAGS@ ; +X_LIBS ?= @X_LIBS@ ; +X_PRE_LIBS ?= @X_PRE_LIBS@ ; +X_EXTRA_LIBS ?= @X_EXTRA_LIBS@ ; + # do not touch this JAMCONFIG_READ = "yes" ; diff --git a/configure.in b/configure.in index bd2680b..a816086 100644 --- a/configure.in +++ b/configure.in @@ -48,7 +48,8 @@ AC_PATH_PROG(XGETTEXT, xgettext) AC_PATH_PROG(GDB, gdb) AC_PATH_PROG(PYTHON, python) -AC_PATH_X +dnl X_CFLAGS, X_PRE_LIBS, X_LIBS, X_EXTRA_LIBS are replaced iff +dnl X are on nonstandard paths AC_PATH_XTRA AC_HEADER_STDC @@ -79,7 +80,7 @@ if test "$enable_shape" = "yes"; then fi if test "$enable_composite" = "yes"; then - PKG_CHECK_MODULES(COMPOSITE, [xcomposite, xdamage, xext], [have_xcomposite=yes],) + PKG_CHECK_MODULES(COMPOSITE, [xcomposite, xdamage, xext], [have_xcomposite=yes], [have_composite=no]) if test "$have_xcomposite" = "yes"; then AC_DEFINE(HAVE_COMPOSITE, 1, [Define to 1 if you have Xcomposite extension]) @@ -87,7 +88,7 @@ if test "$enable_composite" = "yes"; then fi if test "$enable_hal" = "yes"; then - PKG_CHECK_MODULES(HAL, [hal, hal-storage], [have_hal=yes],) + PKG_CHECK_MODULES(HAL, [hal, hal-storage], [have_hal=yes], [have_hal=no]) if test "$have_hal" = "yes"; then AC_DEFINE(HAVE_HAL, 1, [Define to 1 if you have HAL libraries]) diff --git a/doc/index.txt b/doc/index.txt index 12423d3..3970138 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -32,6 +32,7 @@ Programs Development +- link: - link:HACKING.html[Contributing (in your spare time ;-)] - link:jambuild.html[Jam build] - link:dbus-usage.html[D-BUS usage] diff --git a/ede-bell-conf/ede-bell-conf.cpp b/ede-bell-conf/ede-bell-conf.cpp index 6b9df55..d190f22 100644 --- a/ede-bell-conf/ede-bell-conf.cpp +++ b/ede-bell-conf/ede-bell-conf.cpp @@ -34,13 +34,17 @@ EDELIB_NS_USING(XSETTINGS_ACTION_CHANGED) EDELIB_NS_USING(XSETTINGS_ACTION_DELETED) EDELIB_NS_USING(XSETTINGS_TYPE_INT) -static Fl_Value_Slider* vol_slide; -static Fl_Value_Slider* pitch_slide; -static Fl_Value_Slider* dur_slide; +static Fl_Value_Slider* vol_slide = NULL; +static Fl_Value_Slider* pitch_slide = NULL; +static Fl_Value_Slider* dur_slide = NULL; static edelib::Window* win; static XSettingsClient* xsc; +static unsigned int vol_val; +static unsigned int pitch_val; +static unsigned int dur_val; + static bool block_xsettings_cb = false; #define CHECK_SETTING(n, setting, action) (strcmp(setting->name, n) == 0) && \ @@ -53,7 +57,8 @@ static bool block_xsettings_cb = false; static int xevent_handler(int e) { if(xsc) xsc->process_xevent(fl_xevent); - return 1; + /* make sure to return 0 so other events could be processed */ + return 0; } static void xsettings_cb(const char* name, XSettingsAction a, XSettingsSetting* s, void* data) { @@ -63,30 +68,49 @@ static void xsettings_cb(const char* name, XSettingsAction a, XSettingsSetting* if(block_xsettings_cb) return; - if(CHECK_SETTING(KEY_VOLUME, s, a)) - vol_slide->value(s->data.v_int); - if(CHECK_SETTING(KEY_PITCH, s, a)) - pitch_slide->value(s->data.v_int); - if(CHECK_SETTING(KEY_DURATION, s, a)) - dur_slide->value(s->data.v_int); + if(CHECK_SETTING(KEY_VOLUME, s, a)) { + vol_val = s->data.v_int; + if(vol_slide) + vol_slide->value(vol_val); + } + + if(CHECK_SETTING(KEY_PITCH, s, a)) { + pitch_val = s->data.v_int; + if(pitch_slide) + pitch_slide->value(pitch_val); + } + + if(CHECK_SETTING(KEY_DURATION, s, a)) { + dur_val = s->data.v_int; + if(dur_slide) + dur_slide->value(dur_val); + } +} + +static void apply_values(void) { + unsigned long v = KBBellPercent | KBBellPitch | KBBellDuration; + XKeyboardControl kc; + kc.bell_percent = vol_val; + kc.bell_pitch = pitch_val; + kc.bell_duration = dur_val; + + XChangeKeyboardControl(fl_display, v, &kc); } static void set_values(bool save) { - 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(); + vol_val = (unsigned int)vol_slide->value(); + pitch_val = (unsigned int)pitch_slide->value(); + dur_val = (unsigned int)dur_slide->value(); - XChangeKeyboardControl(fl_display, v, &kc); + apply_values(); if(save && xsc) { /* disable callback, since modifying the value will trigger it */ block_xsettings_cb = true; - xsc->set(KEY_VOLUME, (unsigned int)vol_slide->value()); - xsc->set(KEY_PITCH, (unsigned int)pitch_slide->value()); - xsc->set(KEY_DURATION, (unsigned int)dur_slide->value()); + xsc->set(KEY_VOLUME, vol_val); + xsc->set(KEY_PITCH, pitch_val); + xsc->set(KEY_DURATION, dur_val); xsc->manager_notify(); block_xsettings_cb = false; @@ -107,7 +131,7 @@ static void test_cb(Fl_Widget*, void*) { XBell(fl_display, 0); } -int main(int argc, char **argv) { +static void window_create(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")); @@ -140,13 +164,37 @@ int main(int argc, char **argv) { test->callback(test_cb); win->end(); win->show(argc, argv); +} +int main(int argc, char **argv) { + bool win_show = true; + + if(argc > 1 && strcmp(argv[1], "--apply") == 0) + win_show = false; + + if(win_show) { + window_create(argc, argv); + Fl::add_handler(xevent_handler); + } else { + /* if window is not going to be shown, we still have to open display */ + fl_open_display(); + } + + /* if window is not shown, xsettings_cb will be triggered anyway */ XSettingsClient x; if(!x.init(fl_display, fl_screen, xsettings_cb, NULL)) xsc = NULL; else xsc = &x; - Fl::add_handler(xevent_handler); + if(!win_show) { + if(xsc) { + apply_values(); + XSync(fl_display, False); + } + + return 0; + } + return Fl::run(); } diff --git a/ede-conf/ede-conf.cpp b/ede-conf/ede-conf.cpp index 9a4e1db..852e433 100644 --- a/ede-conf/ede-conf.cpp +++ b/ede-conf/ede-conf.cpp @@ -27,22 +27,10 @@ #include #include #include -#include typedef edelib::list StrList; typedef edelib::list::iterator StrListIter; -static bool file_can_execute(const edelib::String& f) { - if(edelib::file_executable(f.c_str())) - return true; - - /* find full path then */ - edelib::String fp = edelib::file_path(f.c_str()); - if(fp.empty()) - return false; - return edelib::file_executable(fp.c_str()); -} - class ControlButton : public Fl_Button { private: Fl_Box* tipbox; @@ -81,10 +69,8 @@ int ControlButton::handle(int event) { if(Fl::event_clicks()) { if(exec.empty()) edelib::alert(_("Unable to execute command for '%s'. Command value is not set"), label()); - else if(!file_can_execute(exec.c_str())) - edelib::alert(_("Unable to run program '%s'. Program not found"), exec.c_str()); else - edelib::run_async(exec.c_str()); + edelib::run_async("ede-launch %s", exec.c_str()); } return 1; diff --git a/ede-crasher/CrashDialog.cpp b/ede-crasher/CrashDialog.cpp index 6c6e6db..20218d2 100644 --- a/ede-crasher/CrashDialog.cpp +++ b/ede-crasher/CrashDialog.cpp @@ -10,6 +10,10 @@ * See COPYING for details. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include "icons/core.xpm" #include "CrashDialog.h" @@ -166,7 +170,7 @@ void CrashDialog::show_details(void) { trace_buff->append("\n\n"); trace_buff->append("---------- short summary ----------\n"); - trace_buff->append("\nEDE version: 2.0"); + trace_buff->append("\nEDE version: " PACKAGE_VERSION); trace_buff->append("\nSystem info: "); trace_buff->append(get_uname().c_str()); @@ -271,9 +275,9 @@ void CrashDialog::run(void) { if(appname || apppath) { const char* p = (appname ? appname : apppath); - l.printf(_("Program '%s' just crashed !"), p); + l.printf(_("Program '%s' just crashed!"), p); } else - l += _("Program just crashed !"); + l += _("Program just crashed!"); l += _("\n\nYou can inspect details about this crash by clicking on 'Show details' below"); txt_box->copy_label(l.c_str()); diff --git a/ede-desktop/DesktopIcon.cpp b/ede-desktop/DesktopIcon.cpp index 246f990..57941bb 100644 --- a/ede-desktop/DesktopIcon.cpp +++ b/ede-desktop/DesktopIcon.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef USE_SHAPE #include @@ -430,7 +431,7 @@ int DesktopIcon::handle(int event) { return 1; case FL_RELEASE: if(Fl::event_clicks() > 0) - E_DEBUG(E_STRLOC ": EXECUTE: %s\n", settings->cmd.c_str()); + edelib::run_async("ede-launch %s", settings->cmd.c_str()); return 1; case FL_DND_ENTER: diff --git a/ede-panel/aboutdialog.cpp b/ede-panel/aboutdialog.cpp index 330c511..4321d32 100644 --- a/ede-panel/aboutdialog.cpp +++ b/ede-panel/aboutdialog.cpp @@ -14,6 +14,16 @@ #include #endif +#include +#include +#include "aboutdialog.h" + +void AboutDialog(Fl_Widget*, void*) +{ + fl_start_child_process("ede-launch ede-about", false); +} + +#if 0 #include #include #include @@ -109,3 +119,4 @@ the GNU General Public Licence version 2 or newer.\nSee Details for more.")); win->set_modal(); win->show(); } +#endif diff --git a/ede-panel/batterymonitor.cpp b/ede-panel/batterymonitor.cpp index 526dfc3..0950b39 100644 --- a/ede-panel/batterymonitor.cpp +++ b/ede-panel/batterymonitor.cpp @@ -198,6 +198,8 @@ void BatteryMonitor::battery_check(void) #ifdef __FreeBSD__ #include +#include +#include #define APMDEV21 "/dev/apm0" #define APMDEV22 "/dev/apm" diff --git a/ede-panel/menu.h b/ede-panel/menu.h index 5b6b791..cde9318 100644 --- a/ede-panel/menu.h +++ b/ede-panel/menu.h @@ -31,7 +31,7 @@ static const char default_menu[] = \n\ About\n\ \n\ - \n\ + \n\ Run\n\ \n\ \n\ diff --git a/evoke/EvokeService.cpp b/evoke/EvokeService.cpp index 9559d6a..e9c2d60 100644 --- a/evoke/EvokeService.cpp +++ b/evoke/EvokeService.cpp @@ -46,8 +46,8 @@ EDELIB_NS_USING(str_trim) #define CONFIG_GET_STRVAL(object, section, key, buff) object.get(section, key, buff, sizeof(buff), RES_SYS_ONLY) #endif -static Atom XA_EDE_EVOKE_SHUTDOWN_ALL; -static Atom XA_EDE_EVOKE_QUIT; +static Atom XA_EDE_EVOKE_SHUTDOWN_ALL; +static Atom XA_EDE_EVOKE_QUIT; static int get_int_property_value(Atom at) { Atom real; diff --git a/evoke/EvokeService.h b/evoke/EvokeService.h index c0a3449..f0d528c 100644 --- a/evoke/EvokeService.h +++ b/evoke/EvokeService.h @@ -26,6 +26,7 @@ struct StartupItem { typedef edelib::list StartupItemList; typedef edelib::list::iterator StartupItemListIter; + class Xsm; class EvokeService { diff --git a/evoke/Jamfile b/evoke/Jamfile index 3d67dfa..ce4358c 100644 --- a/evoke/Jamfile +++ b/evoke/Jamfile @@ -16,8 +16,7 @@ SOURCE = evoke.cpp Xsm.cpp Logout.cpp Autostart.cpp - Xshutdown.cpp - SettingsApplicator.cpp ; + Xshutdown.cpp ; CONFIG = ede-settings.conf ede-startup.conf ; @@ -31,8 +30,12 @@ ObjectC++Flags EvokeService.cpp : $(EDELIB_DBUS_INCLUDE) ; LinkAgainstAsFirst evoke : $(EDELIB_DBUS_LIB) ; EdeProgram evoke : $(SOURCE) ; + +ObjectC++Flags ede-startup : $(X_CFLAGS) ; ProgramBare ede-shutdown : ede-shutdown.cpp ; -LinkAgainst ede-shutdown : -lX11 ; +LinkAgainst ede-shutdown : $(X_LIBS) -lX11 ; + +InstallEdeProgram ede-settings-apply ; EdeManualWithToc [ FFileName doc evoke.txt ] ; TranslationStrings locale : $(SOURCE) ; diff --git a/evoke/SettingsApplicator.cpp b/evoke/SettingsApplicator.cpp deleted file mode 100644 index 82d4a9e..0000000 --- a/evoke/SettingsApplicator.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * $Id$ - * - * Evoke, head honcho of everything - * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2007-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 "SettingsApplicator.h" - -EDELIB_NS_USING(XSettingsClient) -EDELIB_NS_USING(XSettingsAction) -EDELIB_NS_USING(XSettingsSetting) -EDELIB_NS_USING(XSETTINGS_ACTION_NEW) -EDELIB_NS_USING(XSETTINGS_ACTION_CHANGED) -EDELIB_NS_USING(XSETTINGS_ACTION_DELETED) -EDELIB_NS_USING(XSETTINGS_TYPE_INT) - -static XSettingsClient* client = NULL; -static Display* client_display = NULL; -static int client_screen; - -static void xsettings_cb(const char* name, XSettingsAction a, XSettingsSetting* s, void* data) { - if(!client) - return; - - if(strcmp(name, "Bell/Volume") == 0 && s->type == XSETTINGS_TYPE_INT) { - XKeyboardControl kc; - - kc.bell_percent = s->data.v_int; - XChangeKeyboardControl(client_display, KBBellPercent, &kc); - return; - } - - if(strcmp(name, "Bell/Pitch") == 0 && s->type == XSETTINGS_TYPE_INT) { - XKeyboardControl kc; - - kc.bell_pitch = s->data.v_int; - XChangeKeyboardControl(client_display, KBBellPitch, &kc); - return; - } - - if(strcmp(name, "Bell/Duration") == 0 && s->type == XSETTINGS_TYPE_INT) { - XKeyboardControl kc; - - kc.bell_duration = s->data.v_int; - XChangeKeyboardControl(client_display, KBBellDuration, &kc); - return; - } -} - -void xsettings_applicator_init(Display* dpy, int scr) { - /* - * make sure we set display first, because after 'init()' callback - * will be imediately called - */ - client_display = dpy; - client_screen = scr; - - client = new XSettingsClient; - if(!client->init(dpy, scr, xsettings_cb, NULL)) { - delete client; - client = NULL; - return; - } -} - -void xsettings_applicator_shutdown(void) { - delete client; - client = NULL; -} - -void xsettings_applicator_process_event(const XEvent* xev) { - if(client) - client->process_xevent(xev); -} diff --git a/evoke/SettingsApplicator.h b/evoke/SettingsApplicator.h deleted file mode 100644 index 6dd9975..0000000 --- a/evoke/SettingsApplicator.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * $Id$ - * - * Evoke, head honcho of everything - * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2007-2009 EDE Authors. - * - * This program is licensed under terms of the - * GNU General Public License version 2 or newer. - * See COPYING for details. - */ - -#ifndef __SETTINGSAPPLICATOR_H__ -#define __SETTINGSAPPLICATOR_H__ - -#include - -/* - * Settings applicator are bunch of functions to run XSettingsClient - * and apply known settings. - */ -void xsettings_applicator_init(Display* dpy, int scr); -void xsettings_applicator_shutdown(void); -void xsettings_applicator_process_event(const XEvent* xev); - -#endif diff --git a/evoke/evoke.cpp b/evoke/evoke.cpp index 4c656b8..783a257 100644 --- a/evoke/evoke.cpp +++ b/evoke/evoke.cpp @@ -19,10 +19,13 @@ #include #include #include +#include #include "EvokeService.h" #include "Autostart.h" +EDELIB_NS_USING(run_async) + #define FOREVER 1e20 #define LOCK_FILE "/tmp/.evoke.lock" @@ -104,8 +107,8 @@ int main(int argc, char** argv) { return 0; if(!service->setup_lock(LOCK_FILE)) { - printf("Either another evoke instance is running or I can't create lock file\n"); - printf("If program abnormaly crashed before, just remove '%s' and start it again\n", LOCK_FILE); + printf("*** Either another evoke instance is running or I can't create lock file.\n"); + printf("*** If program abnormaly crashed before, just remove '%s' and start it again.\n", LOCK_FILE); return 1; } @@ -134,6 +137,10 @@ int main(int argc, char** argv) { PropertyChangeMask | SubstructureNotifyMask | ClientMessage); Fl::add_handler(xmessage_handler); + /* run applicator for settings; it must be done after manager is fully on */ + if(do_startup) + run_async("ede-settings-apply"); + service->start(); while(service->running()) { diff --git a/m4/pkg.m4 b/m4/pkg.m4 index 6fe6b67..39e72a4 100644 --- a/m4/pkg.m4 +++ b/m4/pkg.m4 @@ -1,11 +1,14 @@ dnl -dnl A small modification to remove ending spaces (sz) +dnl $Id$ dnl - +dnl Modified a little bit so returned values does not have ending spaces. (Sanel) +dnl Note: if you do not set 'action-not', if package not found, it will stop configure +dnl script with "Library XY requirements not met..." message +dnl dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page dnl also defines GSTUFF_PKG_ERRORS on error -AC_DEFUN(PKG_CHECK_MODULES, [ +AC_DEFUN([PKG_CHECK_MODULES], [ succeeded=no if test -z "$PKG_CONFIG"; then @@ -35,9 +38,12 @@ AC_DEFUN(PKG_CHECK_MODULES, [ ## -Wl,--export-dynamic $1_LIBS="`$PKG_CONFIG --libs-only-L \"$2\"` `$PKG_CONFIG --libs-only-l \"$2\"`" AC_MSG_RESULT($$1_LIBS) + + $1_VERSION=`$PKG_CONFIG --modversion "$2"` else $1_CFLAGS="" $1_LIBS="" + $1_VERSION="" ## If we have a custom action on failure, don't print errors, but ## do set a variable so people can do so. $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` @@ -50,6 +56,7 @@ AC_DEFUN(PKG_CHECK_MODULES, [ AC_SUBST($1_CFLAGS) AC_SUBST($1_LIBS) + AC_SUBST($1_VERSION) else echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." echo "*** See http://www.freedesktop.org/software/pkgconfig"