Submitted By: Igor Zivkovic Date: 2014-01-10 Initial Package Version: 0.11 Upstream Status: Fixed Origin: Upstream Description: Lots of fixes from the upstream svn repository. diff -Naur tint2-0.11/AUTHORS tint2-svn/AUTHORS --- tint2-0.11/AUTHORS 2009-11-05 20:48:26.000000000 +0100 +++ tint2-svn/AUTHORS 2014-01-10 16:11:02.863386346 +0100 @@ -1,6 +1,6 @@ tint2 is developped by : -- Thierry Lorthiois +- Thierry Lorthiois from Omega distribution - Andreas Fink - Euan Freeman (tintwizard) - Christian Ruppert (autotools build system) diff -Naur tint2-0.11/ChangeLog tint2-svn/ChangeLog --- tint2-0.11/ChangeLog 2010-06-26 14:41:52.000000000 +0200 +++ tint2-svn/ChangeLog 2014-01-10 16:11:02.966388080 +0100 @@ -1,5 +1,6 @@ 2010-06-26 - unhide tint2 panel when dragging something +- battery FreeBSD uses the new ACPI API (thx to yamagi.burmeister) 2010-06-16 - Set _NET_WM_ICON_GEOMETRY for every task diff -Naur tint2-0.11/CMakeLists.txt tint2-svn/CMakeLists.txt --- tint2-0.11/CMakeLists.txt 2010-06-15 23:38:14.000000000 +0200 +++ tint2-svn/CMakeLists.txt 2014-01-10 16:11:03.227392515 +0100 @@ -3,18 +3,19 @@ include( FindPkgConfig ) include( CheckLibraryExists ) -pkg_check_modules( X11 REQUIRED x11 xcomposite xdamage xinerama xrender xrandr ) +pkg_check_modules( X11 REQUIRED x11 xcomposite xdamage xinerama xrender xrandr>=1.3 ) pkg_check_modules( PANGOCAIRO REQUIRED pangocairo ) pkg_check_modules( PANGO REQUIRED pango ) pkg_check_modules( CAIRO REQUIRED cairo ) pkg_check_modules( GLIB2 REQUIRED glib-2.0 ) pkg_check_modules( GOBJECT2 REQUIRED gobject-2.0 ) -pkg_check_modules( IMLIB2 REQUIRED imlib2 ) +pkg_check_modules( IMLIB2 REQUIRED imlib2>=1.4.2 ) +pkg_check_modules( SN libstartup-notification-1.0>=0.12 ) find_library( RT_LIBRARY rt ) -if( NOT (X11_FOUND AND PANGOCAIRO_FOUND AND PANGO_FOUND AND CAIRO_FOUND AND GLIB2_FOUND AND GOBJECT2_FOUND AND IMLIB2_FOUND) ) +if( NOT X11_FOUND OR NOT PANGOCAIRO_FOUND OR NOT PANGO_FOUND OR NOT CAIRO_FOUND OR NOT GLIB2_FOUND OR NOT GOBJECT2_FOUND OR NOT IMLIB2_FOUND ) message( FATAL_ERROR "Not all dependencies fulfilled. See http://code.google.com/p/tint2/wiki/Install" ) -endif( NOT (X11_FOUND AND PANGOCAIRO_FOUND AND PANGO_FOUND AND CAIRO_FOUND AND GLIB2_FOUND AND GOBJECT2_FOUND AND IMLIB2_FOUND) ) +endif( NOT X11_FOUND OR NOT PANGOCAIRO_FOUND OR NOT PANGO_FOUND OR NOT CAIRO_FOUND OR NOT GLIB2_FOUND OR NOT GOBJECT2_FOUND OR NOT IMLIB2_FOUND ) string( REPLACE ";" " " FLAGS_REPLACED "${IMLIB2_LDFLAGS}" ) set( CMAKE_REQUIRED_FLAGS "${FLAGS_REPLACED}" ) @@ -29,6 +30,7 @@ src/clock src/systray src/taskbar + src/launcher src/tooltip src/util ${X11_INCLUDE_DIRS} @@ -37,7 +39,8 @@ ${CAIRO_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${GOBJECT2_INCLUDE_DIRS} - ${IMLIB2_INCLUDE_DIRS} ) + ${IMLIB2_INCLUDE_DIRS} + ${SN_INCLUDE_DIRS} ) set( SOURCES src/config.c src/panel.c @@ -45,8 +48,12 @@ src/tint.c src/clock/clock.c src/systray/systraybar.c + src/launcher/launcher.c + src/launcher/xsettings-client.c + src/launcher/xsettings-common.c src/taskbar/task.c src/taskbar/taskbar.c + src/taskbar/taskbarname.c src/tooltip/tooltip.c src/util/area.c src/util/common.c @@ -56,23 +63,29 @@ option( ENABLE_BATTERY "Enable battery status plugin" ON ) option( ENABLE_TINT2CONF "Enable tint2conf build, a GTK+2 theme switcher for tint2" ON ) option( ENABLE_EXAMPLES "Install additional tin2rc examples" OFF ) +option( ENABLE_SN "Startup notification support" ON ) +if( ENABLE_SN ) + if( SN_FOUND ) + add_definitions( -DHAVE_SN -DSN_API_NOT_YET_FROZEN ) + endif( SN_FOUND ) +endif( ENABLE_SN) if( ENABLE_BATTERY ) set( SOURCES ${SOURCES} src/battery/battery.c ) add_definitions( -DENABLE_BATTERY ) endif( ENABLE_BATTERY ) +set( MANDIR share/man CACHE PATH "Directory for man pages" ) +set( DATADIR share CACHE PATH "Directory for shared data" ) +set( SYSCONFDIR /etc CACHE PATH "Directory for configuration files" ) +set( DOCDIR share/doc/tint2 CACHE PATH "Directory for documentation files" ) + if( ENABLE_TINT2CONF ) add_definitions( -DHAVE_VERSION_H ) add_subdirectory( src/tint2conf ) add_dependencies( tint2conf version ) endif( ENABLE_TINT2CONF ) -set( MANDIR share/man CACHE PATH "Directory for man pages" ) -set( DATADIR share CACHE PATH "Directory for shared data" ) -set( SYSCONFDIR /etc CACHE PATH "Directory for configuration files" ) -set( DOCDIR share/doc/tint2 CACHE PATH "Directory for documentation files" ) - add_custom_target( version ALL "${PROJECT_SOURCE_DIR}/get_svnrev.sh" "\"${PROJECT_SOURCE_DIR}\"" ) link_directories( ${X11_LIBRARY_DIRS} @@ -81,7 +94,8 @@ ${CAIRO_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} ${GOBJECT2_LIBRARY_DIRS} - ${IMLIB2_LIBRARY_DIRS} ) + ${IMLIB2_LIBRARY_DIRS} + ${SN_LIBRARY_DIRS} ) add_executable(tint2 ${SOURCES}) target_link_libraries( tint2 ${X11_LIBRARIES} ${PANGOCAIRO_LIBRARIES} @@ -89,7 +103,8 @@ ${CAIRO_LIBRARIES} ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES} - ${IMLIB2_LIBRARIES} ) + ${IMLIB2_LIBRARIES} + ${SN_LIBRARIES} ) if( RT_LIBRARY ) target_link_libraries( tint2 ${RT_LIBRARY} ) endif( RT_LIBRARY ) diff -Naur tint2-0.11/get_svnrev.sh tint2-svn/get_svnrev.sh --- tint2-0.11/get_svnrev.sh 2010-06-26 14:41:58.000000000 +0200 +++ tint2-svn/get_svnrev.sh 2014-01-10 16:11:03.227392515 +0100 @@ -1 +1,27 @@ -echo "#define VERSION_STRING \"0.11\"" > version.h +#!/bin/sh + +FALLBACK=\"0.11-svn\" + +if [ $# -eq 0 ]; then + DIR=. +else + DIR=$1 +fi + +if [ -f version.h ]; then + REV_OLD=$(cat version.h | cut -d" " -f3) +else + REV_OLD=\"\" +fi + +if [ -x "$(which svnversion 2>/dev/null)" -a -d "${DIR}/.svn" ] ; then + REV=\"$(svnversion -n ${DIR})\" +else + REV=${FALLBACK} +fi + +if [ ${REV_OLD} != ${REV} ]; then + echo "Building new version.h" + echo "Rev_old: ${REV_OLD} Rev: ${REV}" + echo "#define VERSION_STRING ${REV}" > version.h +fi diff -Naur tint2-0.11/make_release.sh tint2-svn/make_release.sh --- tint2-0.11/make_release.sh 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/make_release.sh 2014-01-10 16:11:02.966388080 +0100 @@ -0,0 +1,23 @@ +#!/bin/bash + +# usage: ./make_release.sh RELEASE_VERSION_NUMBER + +if [[ $# -ne 1 ]]; then + echo "usage: $0 RELEASE_VERSION_NUMBER" + exit +fi + +DIR=tint2-${1} +echo "Making release ${DIR}" +rm -Rf ${DIR} +svn export . ${DIR} > /dev/null + +# delete unneeded files +rm -f ${DIR}/configure ${DIR}/make_release.sh + +# replace get_svnrev.sh by a simple echo command +echo "echo \"#define VERSION_STRING \\\"${1}\\\"\" > version.h" > ${DIR}/get_svnrev.sh + +# create tarball and remove the exported directory +tar -cjf ${DIR}.tar.bz2 ${DIR} +rm -Rf ${DIR} diff -Naur tint2-0.11/sample/icon_and_text_1.tint2rc tint2-svn/sample/icon_and_text_1.tint2rc --- tint2-0.11/sample/icon_and_text_1.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_and_text_1.tint2rc 2014-01-10 16:11:02.784384975 +0100 @@ -56,6 +56,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 3 +task_tooltip = 0 # Task Icons task_icon_asb = 70 0 0 @@ -90,7 +91,6 @@ clock_rclick_command = orage # Tooltips -tooltip = 0 tooltip_padding = 2 2 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_and_text_2.tint2rc tint2-svn/sample/icon_and_text_2.tint2rc --- tint2-0.11/sample/icon_and_text_2.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_and_text_2.tint2rc 2014-01-10 16:11:02.784384975 +0100 @@ -56,6 +56,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 3 +task_tooltip = 0 # Task Icons task_icon_asb = 80 0 0 @@ -89,7 +90,6 @@ clock_rclick_command = gsimplecal # Tooltips -tooltip = 0 tooltip_padding = 5 0 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_and_text_3.tint2rc tint2-svn/sample/icon_and_text_3.tint2rc --- tint2-0.11/sample/icon_and_text_3.tint2rc 2010-05-15 16:43:01.000000000 +0200 +++ tint2-svn/sample/icon_and_text_3.tint2rc 2014-01-10 16:11:02.784384975 +0100 @@ -62,6 +62,7 @@ task_active_background_id = 3 task_urgent_background_id = 4 task_iconified_background_id = 2 +task_tooltip = 1 # Task Icons task_icon_asb = 80 0 0 @@ -95,7 +96,6 @@ clock_rclick_command = gsimplecal # Tooltips -tooltip = 1 tooltip_padding = 5 0 tooltip_show_timeout = 1.2 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_and_text_4.tint2rc tint2-svn/sample/icon_and_text_4.tint2rc --- tint2-0.11/sample/icon_and_text_4.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_and_text_4.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -62,6 +62,7 @@ task_active_background_id = 1 task_urgent_background_id = 4 task_iconified_background_id = 2 +task_tooltip = 0 # Task Icons task_icon_asb = 100 0 0 @@ -95,7 +96,6 @@ clock_background_id = 1 # Tooltips -tooltip = 0 tooltip_padding = 0 0 tooltip_show_timeout = 0 tooltip_hide_timeout = 0 diff -Naur tint2-0.11/sample/icon_only_1.tint2rc tint2-svn/sample/icon_only_1.tint2rc --- tint2-0.11/sample/icon_only_1.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_only_1.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -74,6 +74,7 @@ task_active_background_id = 5 task_urgent_background_id = 6 task_iconified_background_id = 0 +task_tooltip = 1 # Task Icons task_icon_asb = 100 -25 -8 @@ -109,7 +110,6 @@ clock_rclick_command = gsimplecal # Tooltips -tooltip = 1 tooltip_padding = 5 3 tooltip_show_timeout = 0.8 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_only_2.tint2rc tint2-svn/sample/icon_only_2.tint2rc --- tint2-0.11/sample/icon_only_2.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_only_2.tint2rc 2014-01-10 16:11:02.786385004 +0100 @@ -62,6 +62,7 @@ task_active_background_id = 3 task_urgent_background_id = 3 task_iconified_background_id = 0 +task_tooltip = 1 # Task Icons task_icon_asb = 90 -100 -20 @@ -97,7 +98,6 @@ clock_rclick_command = gsimplecal # Tooltips -tooltip = 1 tooltip_padding = 2 2 tooltip_show_timeout = 0.9 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_only_3.tint2rc tint2-svn/sample/icon_only_3.tint2rc --- tint2-0.11/sample/icon_only_3.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_only_3.tint2rc 2014-01-10 16:11:02.786385004 +0100 @@ -62,6 +62,7 @@ task_active_background_id = 2 task_urgent_background_id = 4 task_iconified_background_id = 0 +task_tooltip = 0 # Task Icons task_icon_asb = 70 0 0 @@ -86,7 +87,6 @@ systray_icon_asb = 100 0 0 # Tooltips -tooltip = 0 tooltip_padding = 2 2 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_only_4.tint2rc tint2-svn/sample/icon_only_4.tint2rc --- tint2-0.11/sample/icon_only_4.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_only_4.tint2rc 2014-01-10 16:11:02.786385004 +0100 @@ -62,6 +62,7 @@ task_active_background_id = 2 task_urgent_background_id = 4 task_iconified_background_id = 3 +task_tooltip = 1 # Task Icons task_icon_asb = 90 0 0 @@ -86,7 +87,6 @@ systray_icon_asb = 100 0 -10 # Tooltips -tooltip = 1 tooltip_padding = 5 0 tooltip_show_timeout = 0.8 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_only_6.tint2rc tint2-svn/sample/icon_only_6.tint2rc --- tint2-0.11/sample/icon_only_6.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_only_6.tint2rc 2014-01-10 16:11:02.786385004 +0100 @@ -62,6 +62,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 3 +task_tooltip = 1 # Task Icons task_icon_asb = 100 0 0 @@ -97,7 +98,6 @@ clock_rclick_command = zenity --calendar # Tooltips -tooltip = 1 tooltip_padding = 3 2 tooltip_show_timeout = 0.9 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/icon_only_7.tint2rc tint2-svn/sample/icon_only_7.tint2rc --- tint2-0.11/sample/icon_only_7.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/icon_only_7.tint2rc 2014-01-10 16:11:02.786385004 +0100 @@ -56,6 +56,7 @@ task_active_background_id = 3 task_urgent_background_id = 0 task_iconified_background_id = 0 +task_tooltip = 1 # Task Icons task_icon_asb = 100 0 0 @@ -93,7 +94,6 @@ time2_timezone = :Europe/Moscow # Tooltips -tooltip = 1 tooltip_padding = 5 4 tooltip_show_timeout = 0.8 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/text_only_1.tint2rc tint2-svn/sample/text_only_1.tint2rc --- tint2-0.11/sample/text_only_1.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/text_only_1.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -68,6 +68,7 @@ task_active_background_id = 1 task_urgent_background_id = 0 task_iconified_background_id = 4 +task_tooltip = 0 # Task Icons task_icon_asb = 100 -90 -15 @@ -103,7 +104,6 @@ clock_rclick_command = gsimplecal # Tooltips -tooltip = 0 tooltip_padding = 5 5 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/text_only_2.tint2rc tint2-svn/sample/text_only_2.tint2rc --- tint2-0.11/sample/text_only_2.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/text_only_2.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -68,6 +68,7 @@ task_active_background_id = 1 task_urgent_background_id = 0 task_iconified_background_id = 4 +task_tooltip = 0 # Task Icons task_icon_asb = 100 -90 -15 @@ -103,7 +104,6 @@ clock_rclick_command = gsimplecal # Tooltips -tooltip = 0 tooltip_padding = 5 5 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/text_only_3.tint2rc tint2-svn/sample/text_only_3.tint2rc --- tint2-0.11/sample/text_only_3.tint2rc 2010-05-18 10:50:17.000000000 +0200 +++ tint2-svn/sample/text_only_3.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -50,6 +50,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 0 +task_tooltip = 0 # Task Icons task_icon_asb = 100 0 0 @@ -81,7 +82,6 @@ clock_background_id = 0 # Tooltips -tooltip = 0 tooltip_padding = 2 2 tooltip_show_timeout = 0.5 tooltip_hide_timeout = 1.2 diff -Naur tint2-0.11/sample/text_only_4.tint2rc tint2-svn/sample/text_only_4.tint2rc --- tint2-0.11/sample/text_only_4.tint2rc 2010-05-18 10:50:17.000000000 +0200 +++ tint2-svn/sample/text_only_4.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -50,6 +50,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 1 +task_tooltip = 0 # Task Icons task_icon_asb = 100 0 0 @@ -74,7 +75,6 @@ systray_icon_asb = 100 -100 -15 # Tooltips -tooltip = 0 tooltip_padding = 0 0 tooltip_show_timeout = 0 tooltip_hide_timeout = 0 diff -Naur tint2-0.11/sample/text_only_5.tint2rc tint2-svn/sample/text_only_5.tint2rc --- tint2-0.11/sample/text_only_5.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/text_only_5.tint2rc 2014-01-10 16:11:02.785384990 +0100 @@ -56,6 +56,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 1 +task_tooltip = 1 # Task Icons task_icon_asb = 50 0 0 @@ -87,7 +88,6 @@ clock_background_id = 0 # Tooltips -tooltip = 1 tooltip_padding = 3 3 tooltip_show_timeout = 1.5 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/text_only_6.tint2rc tint2-svn/sample/text_only_6.tint2rc --- tint2-0.11/sample/text_only_6.tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/text_only_6.tint2rc 2014-01-10 16:11:02.786385004 +0100 @@ -56,6 +56,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 0 +task_tooltip = 0 # Task Icons task_icon_asb = 100 -90 -15 @@ -80,7 +81,6 @@ systray_icon_asb = 100 -70 -15 # Tooltips -tooltip = 0 tooltip_padding = 5 5 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/sample/tint2rc tint2-svn/sample/tint2rc --- tint2-0.11/sample/tint2rc 2010-05-09 21:38:01.000000000 +0200 +++ tint2-svn/sample/tint2rc 2014-01-10 16:11:02.784384975 +0100 @@ -56,6 +56,7 @@ task_active_background_id = 2 task_urgent_background_id = 2 task_iconified_background_id = 3 +task_tooltip = 0 # Task Icons task_icon_asb = 70 0 0 @@ -90,7 +91,6 @@ clock_rclick_command = orage # Tooltips -tooltip = 0 tooltip_padding = 2 2 tooltip_show_timeout = 0.7 tooltip_hide_timeout = 0.3 diff -Naur tint2-0.11/src/battery/battery.c tint2-svn/src/battery/battery.c --- tint2-0.11/src/battery/battery.c 2010-06-11 20:47:26.000000000 +0200 +++ tint2-svn/src/battery/battery.c 2014-01-10 16:11:03.117390642 +0100 @@ -24,20 +24,22 @@ #include #include -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) #include #include #include #include #endif +#if defined(__FreeBSD__) +#include +#include +#endif + #include "window.h" #include "server.h" -#include "area.h" #include "panel.h" -#include "taskbar.h" #include "battery.h" -#include "clock.h" #include "timer.h" #include "common.h" @@ -59,34 +61,38 @@ char *path_current_now; char *path_status; -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) int apm_fd; #endif - void update_batterys(void* arg) { - int i; + int old_percentage = battery_state.percentage; + int16_t old_hours = battery_state.time.hours; + int8_t old_minutes = battery_state.time.minutes; + update_battery(); + if (old_percentage == battery_state.percentage && old_hours == battery_state.time.hours && old_minutes == battery_state.time.minutes) + return; + + int i; for (i=0 ; i < nb_panel ; i++) { if (battery_state.percentage >= percentage_hide) { if (panel1[i].battery.area.on_screen == 1) { - panel1[i].battery.area.on_screen = 0; - // force resize on panel - panel1[i].area.resize = 1; + hide(&panel1[i].battery.area); panel_refresh = 1; } - continue; } else { if (panel1[i].battery.area.on_screen == 0) { - panel1[i].battery.area.on_screen = 1; - // force resize on panel - panel1[i].area.resize = 1; + show(&panel1[i].battery.area); panel_refresh = 1; } } - panel1[i].battery.area.resize = 1; + if (panel1[i].battery.area.on_screen == 1) { + panel1[i].battery.area.resize = 1; + panel_refresh = 1; + } } } @@ -103,7 +109,10 @@ path_energy_full = 0; path_current_now = 0; path_status = 0; -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) + battery_state.percentage = 0; + battery_state.time.hours = 0; + battery_state.time.minutes = 0; +#if defined(__OpenBSD__) || defined(__NetBSD__) apm_fd = -1; #endif } @@ -117,8 +126,9 @@ if (path_current_now) g_free(path_current_now); if (path_status) g_free(path_status); if (battery_low_cmd) g_free(battery_low_cmd); + if (battery_timeout) stop_timeout(battery_timeout); -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) if ((apm_fd != -1) && (close(apm_fd) == -1)) warn("cannot close /dev/apm"); #endif @@ -129,7 +139,7 @@ { if (!battery_enabled) return; -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) apm_fd = open("/dev/apm", O_RDONLY); if (apm_fd < 0) { warn("init_battery: failed to open /dev/apm."); @@ -137,7 +147,7 @@ return; } -#else +#elif !defined(__FreeBSD__) // check battery GDir *directory = 0; GError *error = NULL; @@ -184,8 +194,14 @@ } g_free(path2); } - if (path_energy_now && path_energy_full) { + + path_current_now = g_build_filename(battery_dir, "power_now", NULL); + if (!g_file_test (path_current_now, G_FILE_TEST_EXISTS)) { + g_free(path_current_now); path_current_now = g_build_filename(battery_dir, "current_now", NULL); + } + + if (path_energy_now && path_energy_full) { path_status = g_build_filename(battery_dir, "status", NULL); // check file @@ -218,57 +234,39 @@ { Panel *panel = (Panel*)p; Battery *battery = &panel->battery; - int bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink; if (!battery_enabled) return; + if (battery->area.bg == 0) + battery->area.bg = &g_array_index(backgrounds, Background, 0); + battery->area.parent = p; battery->area.panel = p; battery->area._draw_foreground = draw_battery; + battery->area.size_mode = SIZE_BY_CONTENT; battery->area._resize = resize_battery; - battery->area.resize = 1; - battery->area.redraw = 1; battery->area.on_screen = 1; - - update_battery(&battery_state); - snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); - snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); - - get_text_size(bat1_font_desc, &bat_percentage_height_ink, &bat_percentage_height, panel->area.height, buf_bat_percentage, strlen(buf_bat_percentage)); - get_text_size(bat2_font_desc, &bat_time_height_ink, &bat_time_height, panel->area.height, buf_bat_time, strlen(buf_bat_time)); - - if (panel_horizontal) { - // panel horizonal => fixed height and posy - battery->area.posy = panel->area.bg->border.width + panel->area.paddingy; - battery->area.height = panel->area.height - (2 * battery->area.posy); - } - else { - // panel vertical => fixed width, height, posy and posx - battery->area.posy = panel->clock.area.posy + panel->clock.area.height + panel->area.paddingx; - battery->area.height = (2 * battery->area.paddingxlr) + (bat_time_height + bat_percentage_height); - battery->area.posx = panel->area.bg->border.width + panel->area.paddingy; - battery->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy); - } - - battery->bat1_posy = (battery->area.height - bat_percentage_height) / 2; - battery->bat1_posy -= ((bat_time_height_ink + 2) / 2); - battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2; + battery->area.resize = 1; } void update_battery() { -#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) +#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) // unused on OpenBSD, silence compiler warnings FILE *fp; char tmp[25]; int64_t current_now = 0; #endif +#if defined(__FreeBSD__) + int sysctl_out = 0; + size_t len = 0; +#endif int64_t energy_now = 0, energy_full = 0; int seconds = 0; int8_t new_percentage = 0; -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) struct apm_power_info info; if (ioctl(apm_fd, APM_IOC_GETPOWER, &(info)) < 0) warn("power update: APM_IOC_GETPOWER"); @@ -298,6 +296,45 @@ new_percentage = info.battery_life; +#elif defined(__FreeBSD__) + len = sizeof(sysctl_out); + + if (sysctlbyname("hw.acpi.battery.state", &sysctl_out, &len, NULL, 0) != 0) + fprintf(stderr, "power update: no such sysctl"); + + // attemp to map the battery state to linux + battery_state.state = BATTERY_UNKNOWN; + + switch(sysctl_out) { + case 1: + battery_state.state = BATTERY_DISCHARGING; + break; + case 2: + battery_state.state = BATTERY_CHARGING; + break; + default: + battery_state.state = BATTERY_FULL; + break; + } + + // no mapping for freebsd + energy_full = 0; + energy_now = 0; + + if (sysctlbyname("hw.acpi.battery.time", &sysctl_out, &len, NULL, 0) != 0) + seconds = -1; + else + seconds = sysctl_out * 60; + + // charging or error + if (seconds < 0) + seconds = 0; + + if (sysctlbyname("hw.acpi.battery.life", &sysctl_out, &len, NULL, 0) != 0) + new_percentage = -1; + else + new_percentage = sysctl_out; + #else fp = fopen(path_status, "r"); if(fp != NULL) { @@ -401,69 +438,45 @@ } -void resize_battery(void *obj) +int resize_battery(void *obj) { Battery *battery = obj; - PangoLayout *layout; - int percentage_width, time_width, new_width; + Panel *panel = battery->area.panel; + int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink; + int bat_time_height, bat_time_width, bat_time_height_ink; + int ret = 0; - percentage_width = time_width = 0; battery->area.redraw = 1; - + snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); if(battery_state.state == BATTERY_FULL) { strcpy(buf_bat_time, "Full"); } else { snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); } - // vertical panel doen't adjust width - if (!panel_horizontal) return; - - cairo_surface_t *cs; - cairo_t *c; - Pixmap pmap; - pmap = XCreatePixmap(server.dsp, server.root_win, battery->area.width, battery->area.height, server.depth); - - cs = cairo_xlib_surface_create(server.dsp, pmap, server.visual, battery->area.width, battery->area.height); - c = cairo_create(cs); - layout = pango_cairo_create_layout(c); + get_text_size2(bat1_font_desc, &bat_percentage_height_ink, &bat_percentage_height, &bat_percentage_width, panel->area.height, panel->area.width, buf_bat_percentage, strlen(buf_bat_percentage)); + get_text_size2(bat2_font_desc, &bat_time_height_ink, &bat_time_height, &bat_time_width, panel->area.height, panel->area.width, buf_bat_time, strlen(buf_bat_time)); - // check width - pango_layout_set_font_description(layout, bat1_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_text(layout, buf_bat_percentage, strlen(buf_bat_percentage)); - pango_layout_get_pixel_size(layout, &percentage_width, NULL); - - pango_layout_set_font_description(layout, bat2_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_text(layout, buf_bat_time, strlen(buf_bat_time)); - pango_layout_get_pixel_size(layout, &time_width, NULL); - - if(percentage_width > time_width) new_width = percentage_width; - else new_width = time_width; - - new_width += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width); - - int old_width = battery->area.width; - - Panel *panel = ((Area*)obj)->panel; - battery->area.width = new_width + 1; - battery->area.posx = panel->area.width - battery->area.width - panel->area.paddingxlr - panel->area.bg->border.width; - if (panel->clock.area.on_screen) - battery->area.posx -= (panel->clock.area.width + panel->area.paddingx); - - if(new_width > old_width || new_width < (old_width-6)) { - // refresh and resize other objects on panel - // we try to limit the number of refresh - // printf("battery_width %d, new_width %d\n", battery->area.width, new_width); - panel->area.resize = 1; - systray.area.resize = 1; - panel_refresh = 1; - } - - g_object_unref (layout); - cairo_destroy (c); - cairo_surface_destroy (cs); - XFreePixmap (server.dsp, pmap); + if (panel_horizontal) { + int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width; + new_size += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width); + if (new_size > battery->area.width || new_size < (battery->area.width-2)) { + // we try to limit the number of resize + battery->area.width = new_size; + battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height)/2; + battery->bat2_posy = battery->bat1_posy + bat_percentage_height; + ret = 1; + } + } + else { + int new_size = bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width)); + if (new_size > battery->area.height || new_size < (battery->area.height-2)) { + battery->area.height = new_size; + battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2)/2; + battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2; + ret = 1; + } + } + return ret; } diff -Naur tint2-0.11/src/battery/battery.h tint2-svn/src/battery/battery.h --- tint2-0.11/src/battery/battery.h 2010-04-18 16:28:45.000000000 +0200 +++ tint2-svn/src/battery/battery.h 2014-01-10 16:11:03.117390642 +0100 @@ -71,6 +71,6 @@ void draw_battery(void *obj, cairo_t *c); -void resize_battery(void *obj); +int resize_battery(void *obj); #endif diff -Naur tint2-0.11/src/clock/clock.c tint2-svn/src/clock/clock.c --- tint2-0.11/src/clock/clock.c 2010-06-11 20:47:26.000000000 +0200 +++ tint2-svn/src/clock/clock.c 2014-01-10 16:11:03.134390932 +0100 @@ -2,7 +2,7 @@ * * Tint2 : clock * -* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -26,9 +26,7 @@ #include "window.h" #include "server.h" -#include "area.h" #include "panel.h" -#include "taskbar.h" #include "clock.h" #include "timer.h" #include "common.h" @@ -45,9 +43,9 @@ struct timeval time_clock; PangoFontDescription *time1_font_desc; PangoFontDescription *time2_font_desc; -static char buf_time[40]; -static char buf_date[40]; -static char buf_tooltip[40]; +static char buf_time[256]; +static char buf_date[256]; +static char buf_tooltip[512]; int clock_enabled; static timeout* clock_timeout; @@ -80,6 +78,7 @@ if (time_tooltip_timezone) g_free(time_tooltip_timezone); if (clock_lclick_command) g_free(clock_lclick_command); if (clock_rclick_command) g_free(clock_rclick_command); + if (clock_timeout) stop_timeout(clock_timeout); } @@ -144,45 +143,21 @@ { Panel *panel =(Panel*)p; Clock *clock = &panel->clock; - int time_height, time_height_ink, date_height, date_height_ink; - + + if (clock->area.bg == 0) + clock->area.bg = &g_array_index(backgrounds, Background, 0); clock->area.parent = p; clock->area.panel = p; clock->area._draw_foreground = draw_clock; + clock->area.size_mode = SIZE_BY_CONTENT; clock->area._resize = resize_clock; + // check consistency + if (time1_format == 0) + return; + clock->area.resize = 1; - clock->area.redraw = 1; clock->area.on_screen = 1; - strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone)); - get_text_size(time1_font_desc, &time_height_ink, &time_height, panel->area.height, buf_time, strlen(buf_time)); - if (time2_format) { - strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); - get_text_size(time2_font_desc, &date_height_ink, &date_height, panel->area.height, buf_date, strlen(buf_date)); - } - - if (panel_horizontal) { - // panel horizonal => fixed height and posy - clock->area.posy = panel->area.bg->border.width + panel->area.paddingy; - clock->area.height = panel->area.height - (2 * clock->area.posy); - } - else { - // panel vertical => fixed width, height, posy and posx - clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr; - clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height); - clock->area.posx = panel->area.bg->border.width + panel->area.paddingy; - clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy); - } - - clock->time1_posy = (clock->area.height - time_height) / 2; - if (time2_format) { - strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); - get_text_size(time2_font_desc, &date_height_ink, &date_height, panel->area.height, buf_date, strlen(buf_date)); - - clock->time1_posy -= ((date_height_ink + 2) / 2); - clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2; - } - if (time_tooltip_format) { clock->area._get_tooltip_text = clock_get_tooltip; strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); @@ -224,69 +199,51 @@ } -void resize_clock (void *obj) +int resize_clock (void *obj) { Clock *clock = obj; - PangoLayout *layout; - int time_width, date_width, new_width; + Panel *panel = clock->area.panel; + int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width, ret = 0; clock->area.redraw = 1; - time_width = date_width = 0; + + date_height = date_width = 0; strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone)); - if (time2_format) - strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); - - // vertical panel doen't adjust width - if (!panel_horizontal) return; - - //printf(" resize_clock\n"); - cairo_surface_t *cs; - cairo_t *c; - Pixmap pmap; - pmap = XCreatePixmap (server.dsp, server.root_win, clock->area.width, clock->area.height, server.depth); - - cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height); - c = cairo_create (cs); - layout = pango_cairo_create_layout (c); - - // check width - pango_layout_set_font_description (layout, time1_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_text (layout, buf_time, strlen(buf_time)); - pango_layout_get_pixel_size (layout, &time_width, NULL); + get_text_size2(time1_font_desc, &time_height_ink, &time_height, &time_width, panel->area.height, panel->area.width, buf_time, strlen(buf_time)); if (time2_format) { - pango_layout_set_font_description (layout, time2_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_text (layout, buf_date, strlen(buf_date)); - pango_layout_get_pixel_size (layout, &date_width, NULL); + strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); + get_text_size2(time2_font_desc, &date_height_ink, &date_height, &date_width, panel->area.height, panel->area.width, buf_date, strlen(buf_date)); } - if (time_width > date_width) new_width = time_width; - else new_width = date_width; - new_width += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width); - - Panel *panel = ((Area*)obj)->panel; - if (new_width > clock->area.width || new_width < (clock->area.width-6)) { - // resize clock - // we try to limit the number of resize - // printf("clock_width %d, new_width %d\n", clock->area.width, new_width); - clock->area.width = new_width + 1; - - // resize other objects on panel - panel->area.resize = 1; -#ifdef ENABLE_BATTERY - panel->battery.area.resize = 1; -#endif - systray.area.resize = 1; - panel_refresh = 1; + if (panel_horizontal) { + int new_size = (time_width > date_width) ? time_width : date_width; + new_size += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width); + if (new_size > clock->area.width || new_size < (clock->area.width-6)) { + // we try to limit the number of resize + clock->area.width = new_size + 1; + clock->time1_posy = (clock->area.height - time_height) / 2; + if (time2_format) { + clock->time1_posy -= (date_height)/2; + clock->time2_posy = clock->time1_posy + time_height; + } + ret = 1; + } + } + else { + int new_size = time_height + date_height + (2 * (clock->area.paddingxlr + clock->area.bg->border.width)); + if (new_size != clock->area.height) { + // we try to limit the number of resize + clock->area.height = new_size; + clock->time1_posy = (clock->area.height - time_height) / 2; + if (time2_format) { + clock->time1_posy -= (date_height)/2; + clock->time2_posy = clock->time1_posy + time_height; + } + ret = 1; + } } - clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.bg->border.width; - - g_object_unref (layout); - cairo_destroy (c); - cairo_surface_destroy (cs); - XFreePixmap (server.dsp, pmap); + return ret; } @@ -301,6 +258,6 @@ command = clock_rclick_command; break; } - tint_exec(command); + tint_exec(command); } diff -Naur tint2-0.11/src/clock/clock.h tint2-svn/src/clock/clock.h --- tint2-0.11/src/clock/clock.h 2010-04-18 16:28:45.000000000 +0200 +++ tint2-svn/src/clock/clock.h 2014-01-10 16:11:03.134390932 +0100 @@ -49,7 +49,7 @@ void draw_clock (void *obj, cairo_t *c); -void resize_clock (void *obj); +int resize_clock (void *obj); void clock_action(int button); diff -Naur tint2-0.11/src/config.c tint2-svn/src/config.c --- tint2-0.11/src/config.c 2010-06-12 14:25:21.000000000 +0200 +++ tint2-svn/src/config.c 2014-01-10 16:11:03.032389193 +0100 @@ -3,7 +3,7 @@ * Tint2 : read/write config file * * Copyright (C) 2007 Pål Staurland (staura@gmail.com) -* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -40,7 +40,9 @@ #include "panel.h" #include "task.h" #include "taskbar.h" +#include "taskbarname.h" #include "systraybar.h" +#include "launcher.h" #include "clock.h" #include "config.h" #include "window.h" @@ -58,14 +60,14 @@ // -------------------------------------------------- // backward compatibility // detect if it's an old config file (==1) -static int old_config_file; +static int new_config_file; void default_config() { config_path = 0; snapshot_path = 0; - old_config_file = 1; + new_config_file = 0; } void cleanup_config() @@ -75,45 +77,6 @@ } -void extract_values (const char *value, char **value1, char **value2, char **value3) -{ - char *b=0, *c=0; - - if (*value1) free (*value1); - if (*value2) free (*value2); - if (*value3) free (*value3); - - if ((b = strchr (value, ' '))) { - b[0] = '\0'; - b++; - } - else { - *value2 = 0; - *value3 = 0; - } - *value1 = strdup (value); - g_strstrip(*value1); - - if (b) { - if ((c = strchr (b, ' '))) { - c[0] = '\0'; - c++; - } - else { - c = 0; - *value3 = 0; - } - *value2 = strdup (b); - g_strstrip(*value2); - } - - if (c) { - *value3 = strdup (c); - g_strstrip(*value3); - } -} - - void get_action (char *event, int *action) { if (strcmp (event, "none") == 0) @@ -234,6 +197,31 @@ panel_config.area.height = atoi(value2); } } + else if (strcmp (key, "panel_items") == 0) { + new_config_file = 1; + panel_items_order = strdup(value); + int j; + for (j=0 ; j < strlen(panel_items_order) ; j++) { + if (panel_items_order[j] == 'L') + launcher_enabled = 1; + if (panel_items_order[j] == 'T') + taskbar_enabled = 1; + if (panel_items_order[j] == 'B') { +#ifdef ENABLE_BATTERY + battery_enabled = 1; +#else + fprintf(stderr, "tint2 is build without battery support\n"); +#endif + } + if (panel_items_order[j] == 'S') { + // systray disabled in snapshot mode + if (snapshot_path == 0) + systray_enabled = 1; + } + if (panel_items_order[j] == 'C') + clock_enabled = 1; + } + } else if (strcmp (key, "panel_margin") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.marginx = atoi (value1); @@ -279,7 +267,7 @@ else if (strcmp (key, "panel_dock") == 0) panel_dock = atoi (value); else if (strcmp (key, "urgent_nb_of_blink") == 0) - max_tick_urgent = (atoi (value) * 2) + 1; + max_tick_urgent = atoi (value); else if (strcmp (key, "panel_layer") == 0) { if (strcmp(value, "bottom") == 0) panel_layer = BOTTOM_LAYER; @@ -290,15 +278,6 @@ } /* Battery */ - else if (strcmp (key, "battery") == 0) { -#ifdef ENABLE_BATTERY - if(atoi(value) == 1) - battery_enabled = 1; -#else - if(atoi(value) == 1) - fprintf(stderr, "tint2 is build without battery support\n"); -#endif - } else if (strcmp (key, "battery_low_status") == 0) { #ifdef ENABLE_BATTERY battery_low_status = atoi(value); @@ -355,6 +334,16 @@ /* Clock */ else if (strcmp (key, "time1_format") == 0) { + if (new_config_file == 0) { + clock_enabled = 1; + if (panel_items_order) { + char* tmp = g_strconcat(panel_items_order, "C", NULL); + g_free( panel_items_order ); + panel_items_order = tmp; + } + else + panel_items_order = g_strdup("C"); + } if (strlen(value) > 0) { time1_format = strdup (value); clock_enabled = 1; @@ -426,14 +415,48 @@ else if (strcmp (key, "taskbar_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.bg = &g_array_index(backgrounds, Background, id); - panel_config.g_taskbar.area.bg = panel_config.g_taskbar.bg; + panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) + panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; } else if (strcmp (key, "taskbar_active_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.bg_active = &g_array_index(backgrounds, Background, id); - panel_config.g_taskbar.use_active = 1; + panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "taskbar_name") == 0) { + taskbarname_enabled = atoi (value); + } + else if (strcmp (key, "taskbar_name_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_taskbar.area_name.paddingxlr = panel_config.g_taskbar.area_name.paddingx = atoi (value1); + } + else if (strcmp (key, "taskbar_name_background_id") == 0) { + int id = atoi (value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] == 0) + panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = panel_config.g_taskbar.background_name[TASKBAR_NORMAL]; + } + else if (strcmp (key, "taskbar_name_active_background_id") == 0) { + int id = atoi (value); + id = (id < backgrounds->len && id >= 0) ? id : 0; + panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "taskbar_name_font") == 0) { + taskbarname_font_desc = pango_font_description_from_string (value); + } + else if (strcmp (key, "taskbar_name_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, taskbarname_font.color); + if (value2) taskbarname_font.alpha = (atoi (value2) / 100.0); + else taskbarname_font.alpha = 0.5; + } + else if (strcmp (key, "taskbar_name_active_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, taskbarname_active_font.color); + if (value2) taskbarname_active_font.alpha = (atoi (value2) / 100.0); + else taskbarname_active_font.alpha = 0.5; } /* Task */ @@ -495,17 +518,22 @@ panel_config.g_task.config_background_mask |= (1<len && id >= 0) ? id : 0; + panel_config.launcher.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp(key, "launcher_icon_size") == 0) { + launcher_max_icon_size = atoi(value); + } + else if (strcmp(key, "launcher_item_app") == 0) { + char *app = strdup(value); + panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app); + } + else if (strcmp(key, "launcher_icon_theme") == 0) { + // if XSETTINGS manager running, tint2 use it. + if (!icon_theme_name) + icon_theme_name = strdup(value); + } + else if (strcmp(key, "launcher_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + launcher_alpha = atoi(value1); + launcher_saturation = atoi(value2); + launcher_brightness = atoi(value3); + } + else if (strcmp(key, "launcher_tooltip") == 0) { + launcher_tooltip_enabled = atoi(value); + } + /* Tooltip */ - else if (strcmp (key, "tooltip") == 0) - g_tooltip.enabled = atoi(value); else if (strcmp (key, "tooltip_show_timeout") == 0) { int timeout_msec = 1000*atof(value); g_tooltip.show_timeout_msec = timeout_msec; @@ -600,6 +660,35 @@ } } + // old config option + else if (strcmp(key, "systray") == 0) { + if (new_config_file == 0) { + systray_enabled = atoi(value); + if (systray_enabled) { + if (panel_items_order) { + char* tmp = g_strconcat(panel_items_order, "S", NULL); + g_free( panel_items_order ); + panel_items_order = tmp; + } + else + panel_items_order = g_strdup("S"); + } + } + } + else if (strcmp(key, "battery") == 0) { + if (new_config_file == 0) { + battery_enabled = atoi(value); + if (battery_enabled) { + if (panel_items_order) { + char* tmp = g_strconcat(panel_items_order, "B", NULL); + g_free( panel_items_order ); + panel_items_order = tmp; + } + else + panel_items_order = g_strdup("B"); + } + } + } else fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key); @@ -672,6 +761,18 @@ } } fclose (fp); + + // append Taskbar item + if (new_config_file == 0) { + taskbar_enabled = 1; + if (panel_items_order) { + char* tmp = g_strconcat( "T", panel_items_order, NULL ); + g_free(panel_items_order); + panel_items_order = tmp; + } + else + panel_items_order = g_strdup("T"); + } return 1; } diff -Naur tint2-0.11/src/launcher/launcher.c tint2-svn/src/launcher/launcher.c --- tint2-0.11/src/launcher/launcher.c 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/launcher/launcher.c 2014-01-10 16:11:02.966388080 +0100 @@ -0,0 +1,1101 @@ +/************************************************************************** +* Tint2 : launcher +* +* Copyright (C) 2010 (mrovi@interfete-web-club.com) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_SN +#include +#endif + +#include "window.h" +#include "server.h" +#include "area.h" +#include "panel.h" +#include "taskbar.h" +#include "launcher.h" + +int launcher_enabled; +int launcher_max_icon_size; +int launcher_tooltip_enabled; +int launcher_alpha; +int launcher_saturation; +int launcher_brightness; +char *icon_theme_name; +XSettingsClient *xsettings_client; + +#define ICON_FALLBACK "application-x-executable" + +char *icon_path(Launcher *launcher, const char *icon_name, int size); +void launcher_load_themes(Launcher *launcher); +void free_desktop_entry(DesktopEntry *entry); +int launcher_read_desktop_file(const char *path, DesktopEntry *entry); +Imlib_Image scale_icon(Imlib_Image original, int icon_size); +void free_icon(Imlib_Image icon); +void free_icon_theme(IconTheme *theme); + + +void default_launcher() +{ + launcher_enabled = 0; + launcher_max_icon_size = 0; + launcher_tooltip_enabled = 0; + launcher_alpha = 100; + launcher_saturation = 0; + launcher_brightness = 0; + icon_theme_name = 0; + xsettings_client = NULL; +} + + +void init_launcher() +{ + if (launcher_enabled) { + // if XSETTINGS manager running, tint2 read the icon_theme_name. + xsettings_client = xsettings_client_new(server.dsp, server.screen, xsettings_notify_cb, NULL, NULL); + } +} + + +void init_launcher_panel(void *p) +{ + Panel *panel =(Panel*)p; + Launcher *launcher = &panel->launcher; + + launcher->area.parent = p; + launcher->area.panel = p; + launcher->area._draw_foreground = NULL; + launcher->area.size_mode = SIZE_BY_CONTENT; + launcher->area._resize = resize_launcher; + launcher->area.resize = 1; + launcher->area.redraw = 1; + if (launcher->area.bg == 0) + launcher->area.bg = &g_array_index(backgrounds, Background, 0); + + // check consistency + if (launcher->list_apps == NULL) + return; + + launcher->area.on_screen = 1; + panel_refresh = 1; + + launcher_load_themes(launcher); + launcher_load_icons(launcher); +} + + +void cleanup_launcher() +{ + int i; + GSList *l; + + if (xsettings_client) + xsettings_client_destroy(xsettings_client); + for (i = 0 ; i < nb_panel ; i++) { + Panel *panel = &panel1[i]; + Launcher *launcher = &panel->launcher; + cleanup_launcher_theme(launcher); + } + for (l = panel_config.launcher.list_apps; l ; l = l->next) { + free(l->data); + } + g_slist_free(panel_config.launcher.list_apps); + panel_config.launcher.list_apps = NULL; + free(icon_theme_name); + icon_theme_name = 0; + launcher_enabled = 0; +} + + +void cleanup_launcher_theme(Launcher *launcher) +{ + free_area(&launcher->area); + GSList *l; + for (l = launcher->list_icons; l ; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon*)l->data; + if (launcherIcon) { + free_icon(launcherIcon->icon_scaled); + free_icon(launcherIcon->icon_original); + free(launcherIcon->icon_name); + free(launcherIcon->icon_path); + free(launcherIcon->cmd); + free(launcherIcon->icon_tooltip); + } + free(launcherIcon); + } + g_slist_free(launcher->list_icons); + + for (l = launcher->list_themes; l ; l = l->next) { + IconTheme *theme = (IconTheme*) l->data; + free_icon_theme(theme); + free(theme); + } + g_slist_free(launcher->list_themes); + launcher->list_icons = launcher->list_themes = NULL; +} + + +int resize_launcher(void *obj) +{ + Launcher *launcher = obj; + GSList *l; + int count, icon_size; + int icons_per_column=1, icons_per_row=1, marging=0; + + if (panel_horizontal) + icon_size = launcher->area.height; + else + icon_size = launcher->area.width; + icon_size = icon_size - (2 * launcher->area.bg->border.width) - (2 * launcher->area.paddingy); + if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size) + icon_size = launcher_max_icon_size; + + // Resize icons if necessary + for (l = launcher->list_icons; l ; l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon *)l->data; + if (launcherIcon->icon_size != icon_size || !launcherIcon->icon_original) { + launcherIcon->icon_size = icon_size; + launcherIcon->area.width = launcherIcon->icon_size; + launcherIcon->area.height = launcherIcon->icon_size; + + // Get the path for an icon file with the new size + char *new_icon_path = icon_path(launcher, launcherIcon->icon_name, launcherIcon->icon_size); + if (!new_icon_path) { + // Draw a blank icon + free_icon(launcherIcon->icon_original); + launcherIcon->icon_original = NULL; + free_icon(launcherIcon->icon_scaled); + launcherIcon->icon_scaled = NULL; + new_icon_path = icon_path(launcher, ICON_FALLBACK, launcherIcon->icon_size); + if (new_icon_path) { + launcherIcon->icon_original = imlib_load_image(new_icon_path); + fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, new_icon_path); + free(new_icon_path); + } + launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, icon_size); + continue; + } + if (launcherIcon->icon_path && strcmp(new_icon_path, launcherIcon->icon_path) == 0) { + // If it's the same file just rescale + free_icon(launcherIcon->icon_scaled); + launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, icon_size); + free(new_icon_path); + fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); + } else { + // Free the old files + free_icon(launcherIcon->icon_original); + free_icon(launcherIcon->icon_scaled); + // Load the new file and scale + launcherIcon->icon_original = imlib_load_image(new_icon_path); + launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, launcherIcon->icon_size); + free(launcherIcon->icon_path); + launcherIcon->icon_path = new_icon_path; + fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); + } + } + } + + count = g_slist_length(launcher->list_icons); + + if (panel_horizontal) { + if (!count) launcher->area.width = 0; + else { + int height = launcher->area.height - 2*launcher->area.bg->border.width - 2*launcher->area.paddingy; + // here icons_per_column always higher than 0 + icons_per_column = (height+launcher->area.paddingx) / (icon_size+launcher->area.paddingx); + marging = height - (icons_per_column-1)*(icon_size+launcher->area.paddingx) - icon_size; + icons_per_row = count / icons_per_column + (count%icons_per_column != 0); + launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * launcher->area.paddingx); + } + } + else { + if (!count) launcher->area.height = 0; + else { + int width = launcher->area.width - 2*launcher->area.bg->border.width - 2*launcher->area.paddingy; + // here icons_per_row always higher than 0 + icons_per_row = (width+launcher->area.paddingx) / (icon_size+launcher->area.paddingx); + marging = width - (icons_per_row-1)*(icon_size+launcher->area.paddingx) - icon_size; + icons_per_column = count / icons_per_row+ (count%icons_per_row != 0); + launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * launcher->area.paddingx); + } + } + + int i, posx, posy; + int start = launcher->area.bg->border.width + launcher->area.paddingy + marging/2; + if (panel_horizontal) { + posy = start; + posx = launcher->area.bg->border.width + launcher->area.paddingxlr; + } + else { + posx = start; + posy = launcher->area.bg->border.width + launcher->area.paddingxlr; + } + + for (i=1, l = launcher->list_icons; l ; i++, l = l->next) { + LauncherIcon *launcherIcon = (LauncherIcon*)l->data; + + launcherIcon->y = posy; + launcherIcon->x = posx; + //printf("launcher %d : %d,%d\n", i, posx, posy); + if (panel_horizontal) { + if (i % icons_per_column) + posy += icon_size + launcher->area.paddingx; + else { + posy = start; + posx += (icon_size + launcher->area.paddingx); + } + } + else { + if (i % icons_per_row) + posx += icon_size + launcher->area.paddingx; + else { + posx = start; + posy += (icon_size + launcher->area.paddingx); + } + } + } + return 1; +} + +// Here we override the default layout of the icons; normally Area layouts its children +// in a stack; we need to layout them in a kind of table +void launcher_icon_on_change_layout(void *obj) +{ + LauncherIcon *launcherIcon = (LauncherIcon*)obj; + launcherIcon->area.posy = ((Area*)launcherIcon->area.parent)->posy + launcherIcon->y; + launcherIcon->area.posx = ((Area*)launcherIcon->area.parent)->posx + launcherIcon->x; +} + +const char* launcher_icon_get_tooltip_text(void *obj) +{ + LauncherIcon *launcherIcon = (LauncherIcon*)obj; + return launcherIcon->icon_tooltip; +} + +void draw_launcher_icon(void *obj, cairo_t *c) +{ + LauncherIcon *launcherIcon = (LauncherIcon*)obj; + Imlib_Image icon_scaled = launcherIcon->icon_scaled; + // Render + imlib_context_set_image (icon_scaled); + if (server.real_transparency) { + render_image(launcherIcon->area.pix, 0, 0, imlib_image_get_width(), imlib_image_get_height() ); + } else { + imlib_context_set_drawable(launcherIcon->area.pix); + imlib_render_image_on_drawable (0, 0); + } +} + +Imlib_Image scale_icon(Imlib_Image original, int icon_size) +{ + Imlib_Image icon_scaled; + if (original) { + imlib_context_set_image (original); + icon_scaled = imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), icon_size, icon_size); + imlib_context_set_image (icon_scaled); + imlib_image_set_has_alpha(1); + DATA32* data = imlib_image_get_data(); + adjust_asb(data, icon_size, icon_size, launcher_alpha, (float)launcher_saturation/100, (float)launcher_brightness/100); + imlib_image_put_back_data(data); + } else { + icon_scaled = imlib_create_image(icon_size, icon_size); + imlib_context_set_image (icon_scaled); + imlib_context_set_color(255, 255, 255, 255); + imlib_image_fill_rectangle(0, 0, icon_size, icon_size); + } + return icon_scaled; +} + +void free_icon(Imlib_Image icon) +{ + if (icon) { + imlib_context_set_image(icon); + imlib_free_image(); + } +} + +void launcher_action(LauncherIcon *icon, XEvent* evt) +{ + char *cmd = malloc(strlen(icon->cmd) + 10); + sprintf(cmd, "(%s&)", icon->cmd); +#if HAVE_SN + SnLauncherContext* ctx; + Time time; + + ctx = sn_launcher_context_new(server.sn_dsp, server.screen); + sn_launcher_context_set_name(ctx, icon->icon_tooltip); + sn_launcher_context_set_description(ctx, "Application launched from tint2"); + sn_launcher_context_set_binary_name (ctx, icon->cmd); + // Get a timestamp from the X event + if (evt->type == ButtonPress || evt->type == ButtonRelease) { + time = evt->xbutton.time; + } + else { + fprintf(stderr, "Unknown X event: %d\n", evt->type); + free(cmd); + return; + } + sn_launcher_context_initiate(ctx, "tint2", icon->cmd, time); +#endif /* HAVE_SN */ + pid_t pid; + pid = fork(); + if (pid < 0) { + fprintf(stderr, "Could not fork\n"); + } + else if (pid == 0) { +#if HAVE_SN + sn_launcher_context_setup_child_process (ctx); +#endif // HAVE_SN + // Allow children to exist after parent destruction + setsid (); + // Run the command + execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL); + + fprintf(stderr, "Failed to execlp %s\n", icon->cmd); +#if HAVE_SN + sn_launcher_context_unref (ctx); +#endif // HAVE_SN + _exit(1); + } +#if HAVE_SN + else { + g_tree_insert (server.pids, GINT_TO_POINTER (pid), ctx); + } +#endif // HAVE_SN + free(cmd); +} + +/***************** Freedesktop app.desktop and icon theme handling *********************/ +/* http://standards.freedesktop.org/desktop-entry-spec/ */ +/* http://standards.freedesktop.org/icon-theme-spec/ */ + +// Splits line at first '=' and returns 1 if successful, and parts are not empty +// key and value point to the parts +int parse_dektop_line(char *line, char **key, char **value) +{ + char *p; + int found = 0; + *key = line; + for (p = line; *p; p++) { + if (*p == '=') { + *value = p + 1; + *p = 0; + found = 1; + break; + } + } + if (!found) + return 0; + if (found && (strlen(*key) == 0 || strlen(*value) == 0)) + return 0; + return 1; +} + +int parse_theme_line(char *line, char **key, char **value) +{ + return parse_dektop_line(line, key, value); +} + +void expand_exec(DesktopEntry *entry, const char *path) +{ + // Expand % in exec + // %i -> --icon Icon + // %c -> Name + // %k -> path + if (entry->exec) { + char *exec2 = malloc(strlen(entry->exec) + (entry->name ? strlen(entry->name) : 1) + (entry->icon ? strlen(entry->icon) : 1) + 100); + char *p, *q; + // p will never point to an escaped char + for (p = entry->exec, q = exec2; *p; p++, q++) { + *q = *p; // Copy + if (*p == '\\') { + p++, q++; + // Copy the escaped char + if (*p == '%') // For % we delete the backslash, i.e. write % over it + q--; + *q = *p; + if (!*p) break; + continue; + } + if (*p == '%') { + p++; + if (!*p) break; + if (*p == 'i' && entry->icon != NULL) { + sprintf(q, "--icon '%s'", entry->icon); + q += strlen("--icon ''"); + q += strlen(entry->icon); + q--; // To balance the q++ in the for + } else if (*p == 'c' && entry->name != NULL) { + sprintf(q, "'%s'", entry->name); + q += strlen("''"); + q += strlen(entry->name); + q--; // To balance the q++ in the for + } else if (*p == 'c') { + sprintf(q, "'%s'", path); + q += strlen("''"); + q += strlen(path); + q--; // To balance the q++ in the for + } else { + // We don't care about other expansions + q--; // Delete the last % from q + } + continue; + } + } + *q = '\0'; + free(entry->exec); + entry->exec = exec2; + } +} + +int launcher_read_desktop_file(const char *path, DesktopEntry *entry) +{ + FILE *fp; + char *line = NULL; + size_t line_size; + char *key, *value; + int i; + + entry->name = entry->icon = entry->exec = NULL; + + if ((fp = fopen(path, "rt")) == NULL) { + fprintf(stderr, "Could not open file %s\n", path); + return 0; + } + + gchar **languages = (gchar **)g_get_language_names(); + // lang_index is the index of the language for the best Name key in the language vector + // lang_index_default is a constant that encodes the Name key without a language + int lang_index, lang_index_default; +#define LANG_DBG 0 + if (LANG_DBG) printf("Languages:"); + for (i = 0; languages[i]; i++) { + if (LANG_DBG) printf(" %s", languages[i]); + } + if (LANG_DBG) printf("\n"); + lang_index_default = i; + // we currently do not know about any Name key at all, so use an invalid index + lang_index = lang_index_default + 1; + + int inside_desktop_entry = 0; + while (getline(&line, &line_size, fp) >= 0) { + int len = strlen(line); + if (len == 0) + continue; + line[len - 1] = '\0'; + if (line[0] == '[') { + inside_desktop_entry = (strcmp(line, "[Desktop Entry]") == 0); + } + if (inside_desktop_entry && parse_dektop_line(line, &key, &value)) { + if (strstr(key, "Name") == key) { + if (strcmp(key, "Name") == 0 && lang_index > lang_index_default) { + entry->name = strdup(value); + lang_index = lang_index_default; + } else { + for (i = 0; languages[i] && i < lang_index; i++) { + gchar *localized_key = g_strdup_printf("Name[%s]", languages[i]); + if (strcmp(key, localized_key) == 0) { + if (entry->name) + free(entry->name); + entry->name = strdup(value); + lang_index = i; + } + g_free(localized_key); + } + } + } else if (!entry->exec && strcmp(key, "Exec") == 0) { + entry->exec = strdup(value); + } else if (!entry->icon && strcmp(key, "Icon") == 0) { + entry->icon = strdup(value); + } + } + } + fclose (fp); + // From this point: + // entry->name, entry->icon, entry->exec will never be empty strings (can be NULL though) + + expand_exec(entry, path); + + free(line); + return 1; +} + +void free_desktop_entry(DesktopEntry *entry) +{ + free(entry->name); + free(entry->icon); + free(entry->exec); +} + +void test_launcher_read_desktop_file() +{ + fprintf(stdout, "\033[1;33m"); + DesktopEntry entry; + launcher_read_desktop_file("/usr/share/applications/firefox.desktop", &entry); + printf("Name:%s Icon:%s Exec:%s\n", entry.name, entry.icon, entry.exec); + fprintf(stdout, "\033[0m"); +} + +//TODO Use UTF8 when parsing the file +IconTheme *load_theme(char *name) +{ + // Look for name/index.theme in $HOME/.icons, /usr/share/icons, /usr/share/pixmaps (stop at the first found) + // Parse index.theme -> list of IconThemeDir with attributes + // Return IconTheme* + + IconTheme *theme; + char *file_name; + FILE *f; + char *line = NULL; + size_t line_size; + + if (name == NULL) + return NULL; + + file_name = g_build_filename(g_get_home_dir(), ".icons", name, "index.theme", NULL); + if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_free (file_name); + file_name = g_build_filename("/usr/share/icons", name, "index.theme", NULL); + if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_free (file_name); + file_name = g_build_filename("/usr/share/pixmaps", name, "index.theme", NULL); + if (!g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_free (file_name); + file_name = NULL; + } + } + } + + if (!file_name) { + return NULL; + } + + if ((f = fopen(file_name, "rt")) == NULL) { + fprintf(stderr, "Could not open theme '%s'\n", file_name); + return NULL; + } + + g_free (file_name); + + theme = calloc(1, sizeof(IconTheme)); + theme->name = strdup(name); + theme->list_inherits = NULL; + theme->list_directories = NULL; + + IconThemeDir *current_dir = NULL; + int inside_header = 1; + while (getline(&line, &line_size, f) >= 0) { + char *key, *value; + + int line_len = strlen(line); + if (line_len >= 1) { + if (line[line_len - 1] == '\n') { + line[line_len - 1] = '\0'; + line_len--; + } + } + + if (line_len == 0) + continue; + + if (inside_header) { + if (parse_theme_line(line, &key, &value)) { + if (strcmp(key, "Inherits") == 0) { + // value is like oxygen,wood,default + char *token; + token = strtok(value, ",\n"); + while (token != NULL) + { + theme->list_inherits = g_slist_append(theme->list_inherits, strdup(token)); + token = strtok(NULL, ",\n"); + } + } else if (strcmp(key, "Directories") == 0) { + // value is like 48x48/apps,48x48/mimetypes,32x32/apps,scalable/apps,scalable/mimetypes + char *token; + token = strtok(value, ",\n"); + while (token != NULL) + { + IconThemeDir *dir = calloc(1, sizeof(IconThemeDir)); + dir->name = strdup(token); + dir->max_size = dir->min_size = dir->size = -1; + dir->type = ICON_DIR_TYPE_THRESHOLD; + dir->threshold = 2; + theme->list_directories = g_slist_append(theme->list_directories, dir); + token = strtok(NULL, ",\n"); + } + } + } + } else if (current_dir != NULL) { + if (parse_theme_line(line, &key, &value)) { + if (strcmp(key, "Size") == 0) { + // value is like 24 + sscanf(value, "%d", ¤t_dir->size); + if (current_dir->max_size == -1) + current_dir->max_size = current_dir->size; + if (current_dir->min_size == -1) + current_dir->min_size = current_dir->size; + } else if (strcmp(key, "MaxSize") == 0) { + // value is like 24 + sscanf(value, "%d", ¤t_dir->max_size); + } else if (strcmp(key, "MinSize") == 0) { + // value is like 24 + sscanf(value, "%d", ¤t_dir->min_size); + } else if (strcmp(key, "Threshold") == 0) { + // value is like 2 + sscanf(value, "%d", ¤t_dir->threshold); + } else if (strcmp(key, "Type") == 0) { + // value is Fixed, Scalable or Threshold : default to scalable for unknown Type. + if (strcmp(value, "Fixed") == 0) { + current_dir->type = ICON_DIR_TYPE_FIXED; + } else if (strcmp(value, "Threshold") == 0) { + current_dir->type = ICON_DIR_TYPE_THRESHOLD; + } else { + current_dir->type = ICON_DIR_TYPE_SCALABLE; + } + } else if (strcmp(key, "Context") == 0) { + // usual values: Actions, Applications, Devices, FileSystems, MimeTypes + current_dir->context = strdup(value); + } + } + } + + if (line[0] == '[' && line[line_len - 1] == ']' && strcmp(line, "[Icon Theme]") != 0) { + inside_header = 0; + current_dir = NULL; + line[line_len - 1] = '\0'; + char *dir_name = line + 1; + GSList* dir_item = theme->list_directories; + while (dir_item != NULL) + { + IconThemeDir *dir = dir_item->data; + if (strcmp(dir->name, dir_name) == 0) { + current_dir = dir; + break; + } + dir_item = g_slist_next(dir_item); + } + } + } + fclose(f); + + free(line); + + return theme; +} + +void free_icon_theme(IconTheme *theme) +{ + free(theme->name); + GSList *l_inherits; + for (l_inherits = theme->list_inherits; l_inherits ; l_inherits = l_inherits->next) { + free(l_inherits->data); + } + GSList *l_dir; + for (l_dir = theme->list_directories; l_dir ; l_dir = l_dir->next) { + IconThemeDir *dir = (IconThemeDir *)l_dir->data; + free(dir->name); + free(dir->context); + free(l_dir->data); + } +} + +void test_launcher_read_theme_file() +{ + fprintf(stdout, "\033[1;33m"); + IconTheme *theme = load_theme("oxygen"); + if (!theme) { + printf("Could not load theme\n"); + return; + } + printf("Loaded theme: %s\n", theme->name); + GSList* item = theme->list_inherits; + while (item != NULL) + { + printf("Inherits:%s\n", (char*)item->data); + item = g_slist_next(item); + } + item = theme->list_directories; + while (item != NULL) + { + IconThemeDir *dir = item->data; + printf("Dir:%s Size=%d MinSize=%d MaxSize=%d Threshold=%d Type=%s Context=%s\n", + dir->name, dir->size, dir->min_size, dir->max_size, dir->threshold, + dir->type == ICON_DIR_TYPE_FIXED ? "Fixed" : + dir->type == ICON_DIR_TYPE_SCALABLE ? "Scalable" : + dir->type == ICON_DIR_TYPE_THRESHOLD ? "Threshold" : "?????", + dir->context); + item = g_slist_next(item); + } + fprintf(stdout, "\033[0m"); +} + + +// Populates the list_icons list +void launcher_load_icons(Launcher *launcher) +{ + // Load apps (.desktop style launcher items) + GSList* app = launcher->list_apps; + while (app != NULL) { + DesktopEntry entry; + launcher_read_desktop_file(app->data, &entry); + if (entry.exec) { + LauncherIcon *launcherIcon = calloc(1, sizeof(LauncherIcon)); + launcherIcon->area.parent = launcher; + launcherIcon->area.panel = launcher->area.panel; + launcherIcon->area._draw_foreground = draw_launcher_icon; + launcherIcon->area.size_mode = SIZE_BY_CONTENT; + launcherIcon->area._resize = NULL; + launcherIcon->area.resize = 0; + launcherIcon->area.redraw = 1; + launcherIcon->area.bg = &g_array_index(backgrounds, Background, 0); + launcherIcon->area.on_screen = 1; + launcherIcon->area._on_change_layout = launcher_icon_on_change_layout; + if (launcher_tooltip_enabled) + launcherIcon->area._get_tooltip_text = launcher_icon_get_tooltip_text; + else + launcherIcon->area._get_tooltip_text = NULL; + launcherIcon->is_app_desktop = 1; + launcherIcon->cmd = strdup(entry.exec); + launcherIcon->icon_name = entry.icon ? strdup(entry.icon) : strdup(ICON_FALLBACK); + launcherIcon->icon_size = 1; + launcherIcon->icon_tooltip = entry.name ? strdup(entry.name) : strdup(entry.exec); + free_desktop_entry(&entry); + launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon); + add_area(&launcherIcon->area); + } + app = g_slist_next(app); + } +} + + +// Populates the list_themes list +void launcher_load_themes(Launcher *launcher) +{ + // load the user theme, all the inherited themes recursively (DFS), and the hicolor theme + // avoid inheritance loops + if (!icon_theme_name) { + fprintf(stderr, "Missing launcher theme, default to 'hicolor'.\n"); + icon_theme_name = strdup("hicolor"); + } else { + fprintf(stderr, "Loading %s. Icon theme :", icon_theme_name); + } + + GSList *queue = g_slist_append(NULL, strdup(icon_theme_name)); + GSList *queued = g_slist_append(NULL, strdup(icon_theme_name)); + + int hicolor_loaded = 0; + while (queue || !hicolor_loaded) { + if (!queue) { + GSList* queued_item = queued; + while (queued_item != NULL) { + if (strcmp(queued_item->data, "hicolor") == 0) { + hicolor_loaded = 1; + break; + } + queued_item = g_slist_next(queued_item); + } + if (hicolor_loaded) + break; + queue = g_slist_append(queue, strdup("hicolor")); + queued = g_slist_append(queued, strdup("hicolor")); + } + + char *name = queue->data; + queue = g_slist_remove(queue, name); + + fprintf(stderr, " '%s',", name); + IconTheme *theme = load_theme(name); + if (theme != NULL) { + launcher->list_themes = g_slist_append(launcher->list_themes, theme); + + GSList* item = theme->list_inherits; + int pos = 0; + while (item != NULL) + { + char *parent = item->data; + int duplicate = 0; + GSList* queued_item = queued; + while (queued_item != NULL) { + if (strcmp(queued_item->data, parent) == 0) { + duplicate = 1; + break; + } + queued_item = g_slist_next(queued_item); + } + if (!duplicate) { + queue = g_slist_insert(queue, strdup(parent), pos); + pos++; + queued = g_slist_append(queued, strdup(parent)); + } + item = g_slist_next(item); + } + } + } + fprintf(stderr, "\n"); + + // Free the queue + GSList *l; + for (l = queue; l ; l = l->next) + free(l->data); + g_slist_free(queue); + for (l = queued; l ; l = l->next) + free(l->data); + g_slist_free(queued); +} + +int directory_matches_size(IconThemeDir *dir, int size) +{ + if (dir->type == ICON_DIR_TYPE_FIXED) { + return dir->size == size; + } else if (dir->type == ICON_DIR_TYPE_SCALABLE) { + return dir->min_size <= size && size <= dir->max_size; + } else /*if (dir->type == ICON_DIR_TYPE_THRESHOLD)*/ { + return dir->size - dir->threshold <= size && size <= dir->size + dir->threshold; + } +} + +int directory_size_distance(IconThemeDir *dir, int size) +{ + if (dir->type == ICON_DIR_TYPE_FIXED) { + return abs(dir->size - size); + } else if (dir->type == ICON_DIR_TYPE_SCALABLE) { + if (size < dir->min_size) { + return dir->min_size - size; + } else if (size > dir->max_size) { + return size - dir->max_size; + } else { + return 0; + } + } else /*if (dir->type == ICON_DIR_TYPE_THRESHOLD)*/ { + if (size < dir->size - dir->threshold) { + return dir->min_size - size; + } else if (size > dir->size + dir->threshold) { + return size - dir->max_size; + } else { + return 0; + } + } +} + +#define DEBUG_ICON_SEARCH 0 +// Returns the full path to an icon file (or NULL) given the icon name +char *icon_path(Launcher *launcher, const char *icon_name, int size) +{ + if (icon_name == NULL) + return NULL; + + // If the icon_name is already a path and the file exists, return it + if (strstr(icon_name, "/") == icon_name) { + if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) + return strdup(icon_name); + else + return NULL; + } + + GSList *basenames = NULL; + char *home_icons = g_build_filename(g_get_home_dir(), ".icons", NULL); + basenames = g_slist_append(basenames, home_icons); + char *home_local_icons = g_build_filename(g_get_home_dir(), ".local/share/icons", NULL); + basenames = g_slist_append(basenames, home_local_icons); + basenames = g_slist_append(basenames, "/usr/local/share/icons"); + basenames = g_slist_append(basenames, "/usr/local/share/pixmaps"); + basenames = g_slist_append(basenames, "/usr/share/icons"); + basenames = g_slist_append(basenames, "/usr/share/pixmaps"); + + GSList *extensions = NULL; + extensions = g_slist_append(extensions, ".png"); + extensions = g_slist_append(extensions, ".xpm"); + // if the icon name already contains one of the extensions (e.g. vlc.png instead of vlc) add a special entry + GSList *ext; + for (ext = extensions; ext; ext = g_slist_next(ext)) { + char *extension = (char*) ext->data; + if (strlen(icon_name) > strlen(extension) && + strcmp(extension, icon_name + strlen(icon_name) - strlen(extension)) == 0) { + extensions = g_slist_append(extensions, ""); + break; + } + } + + GSList *theme; + // Stage 1: exact size match + // the theme must have a higher priority than having an exact size match, so we will just use + // the code that searches for the best size match (it will find the exact size match if one exists) + /* + for (theme = launcher->list_themes; theme; theme = g_slist_next(theme)) { + GSList *dir; + for (dir = ((IconTheme*)theme->data)->list_directories; dir; dir = g_slist_next(dir)) { + if (directory_matches_size((IconThemeDir*)dir->data, size)) { + GSList *base; + for (base = basenames; base; base = g_slist_next(base)) { + GSList *ext; + for (ext = extensions; ext; ext = g_slist_next(ext)) { + char *base_name = (char*) base->data; + char *theme_name = ((IconTheme*)theme->data)->name; + char *dir_name = ((IconThemeDir*)dir->data)->name; + char *extension = (char*) ext->data; + char *file_name = malloc(strlen(base_name) + strlen(theme_name) + + strlen(dir_name) + strlen(icon_name) + strlen(extension) + 100); + // filename = directory/$(themename)/subdirectory/iconname.extension + sprintf(file_name, "%s/%s/%s/%s%s", base_name, theme_name, dir_name, icon_name, extension); + //printf("found exact: %s\n", file_name); + //printf("checking %s\n", file_name); + if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_slist_free(basenames); + g_slist_free(extensions); + g_free(home_icons); + g_free(home_local_icons); + return file_name; + } else { + free(file_name); + file_name = NULL; + } + } + } + } + } + } + g_free (file_name); + */ + + // Stage 2: best size match + // Contrary to the freedesktop spec, we are not choosing the closest icon in size, but the next larger icon + // otherwise the quality is usually crap (for size 22, if you can choose 16 or 32, you're better with 32) + // We do fallback to the closest size if we cannot find a larger or equal icon + + // These 3 variables are used for keeping the closest size match + int minimal_size = INT_MAX; + char *best_file_name = NULL; + GSList *best_file_theme = NULL; + + // These 3 variables are used for keeping the next larger match + int next_larger_size = -1; + char *next_larger = NULL; + GSList *next_larger_theme = NULL; + + for (theme = launcher->list_themes; theme; theme = g_slist_next(theme)) { + GSList *dir; + for (dir = ((IconTheme*)theme->data)->list_directories; dir; dir = g_slist_next(dir)) { + GSList *base; + for (base = basenames; base; base = g_slist_next(base)) { + GSList *ext; + for (ext = extensions; ext; ext = g_slist_next(ext)) { + char *base_name = (char*) base->data; + char *theme_name = ((IconTheme*)theme->data)->name; + char *dir_name = ((IconThemeDir*)dir->data)->name; + char *extension = (char*) ext->data; + char *file_name = malloc(strlen(base_name) + strlen(theme_name) + + strlen(dir_name) + strlen(icon_name) + strlen(extension) + 100); + // filename = directory/$(themename)/subdirectory/iconname.extension + sprintf(file_name, "%s/%s/%s/%s%s", base_name, theme_name, dir_name, icon_name, extension); + if (DEBUG_ICON_SEARCH) + printf("checking %s\n", file_name); + if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { + if (DEBUG_ICON_SEARCH) + printf("found: %s\n", file_name); + // Closest match + if (directory_size_distance((IconThemeDir*)dir->data, size) < minimal_size && (!best_file_theme ? 1 : theme == best_file_theme)) { + if (best_file_name) { + free(best_file_name); + best_file_name = NULL; + } + best_file_name = strdup(file_name); + minimal_size = directory_size_distance((IconThemeDir*)dir->data, size); + best_file_theme = theme; + if (DEBUG_ICON_SEARCH) + printf("best_file_name = %s; minimal_size = %d\n", best_file_name, minimal_size); + } + // Next larger match + if (((IconThemeDir*)dir->data)->size >= size && + (next_larger_size == -1 || ((IconThemeDir*)dir->data)->size < next_larger_size) && + (!next_larger_theme ? 1 : theme == next_larger_theme)) { + if (next_larger) { + free(next_larger); + next_larger = NULL; + } + next_larger = strdup(file_name); + next_larger_size = ((IconThemeDir*)dir->data)->size; + next_larger_theme = theme; + if (DEBUG_ICON_SEARCH) + printf("next_larger = %s; next_larger_size = %d\n", next_larger, next_larger_size); + } + } + free(file_name); + } + } + } + } + if (next_larger) { + g_slist_free(basenames); + g_slist_free(extensions); + free(best_file_name); + g_free(home_icons); + g_free(home_local_icons); + return next_larger; + } + if (best_file_name) { + g_slist_free(basenames); + g_slist_free(extensions); + g_free(home_icons); + g_free(home_local_icons); + return best_file_name; + } + + // Stage 3: look in unthemed icons + { + GSList *base; + for (base = basenames; base; base = g_slist_next(base)) { + GSList *ext; + for (ext = extensions; ext; ext = g_slist_next(ext)) { + char *base_name = (char*) base->data; + char *extension = (char*) ext->data; + char *file_name = malloc(strlen(base_name) + strlen(icon_name) + + strlen(extension) + 100); + // filename = directory/iconname.extension + sprintf(file_name, "%s/%s%s", base_name, icon_name, extension); + if (DEBUG_ICON_SEARCH) + printf("checking %s\n", file_name); + if (g_file_test(file_name, G_FILE_TEST_EXISTS)) { + g_slist_free(basenames); + g_slist_free(extensions); + g_free(home_icons); + g_free(home_local_icons); + return file_name; + } else { + free(file_name); + file_name = NULL; + } + } + } + } + + fprintf(stderr, "Could not find icon %s\n", icon_name); + + g_slist_free(basenames); + g_slist_free(extensions); + g_free(home_icons); + g_free(home_local_icons); + return NULL; +} + diff -Naur tint2-0.11/src/launcher/launcher.h tint2-svn/src/launcher/launcher.h --- tint2-0.11/src/launcher/launcher.h 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/launcher/launcher.h 2014-01-10 16:11:02.967388096 +0100 @@ -0,0 +1,91 @@ +/************************************************************************** + * Copyright (C) 2010 (mrovi@interfete-web-club.com) + * + * + **************************************************************************/ + +#ifndef LAUNCHER_H +#define LAUNCHER_H + +#include "common.h" +#include "area.h" +#include "xsettings-client.h" + +typedef struct Launcher { + // always start with area + Area area; + GSList *list_apps; // List of char*, each is a path to a app.desktop file + GSList *list_icons; // List of LauncherIcon* + GSList *list_themes; // List of IconTheme* +} Launcher; + +typedef struct LauncherIcon { + // always start with area + Area area; + Imlib_Image icon_scaled; + Imlib_Image icon_original; + char *cmd; + char *icon_name; + char *icon_path; + char *icon_tooltip; + int icon_size; + int is_app_desktop; + int x, y; +} LauncherIcon; + +typedef struct DesktopEntry { + char *name; + char *exec; + char *icon; +} DesktopEntry; + +#define ICON_DIR_TYPE_SCALABLE 0 +#define ICON_DIR_TYPE_FIXED 1 +#define ICON_DIR_TYPE_THRESHOLD 2 +typedef struct IconThemeDir { + char *name; + int size; + int type; + int max_size; + int min_size; + int threshold; + char *context; +} IconThemeDir; + +typedef struct IconTheme { + char *name; + GSList *list_inherits; // each item is a char* (theme name) + GSList *list_directories; // each item is an IconThemeDir* +} IconTheme; + +extern int launcher_enabled; +extern int launcher_max_icon_size; +extern int launcher_tooltip_enabled; +extern int launcher_alpha; +extern int launcher_saturation; +extern int launcher_brightness; +extern char *icon_theme_name; // theme name +extern XSettingsClient *xsettings_client; + +// default global data +void default_launcher(); + +// initialize launcher : y position, precision, ... +void init_launcher(); +void init_launcher_panel(void *panel); +void cleanup_launcher(); +void cleanup_launcher_theme(Launcher *launcher); + +int resize_launcher(void *obj); +void draw_launcher (void *obj, cairo_t *c); + +// Populates the list_themes list +void launcher_load_themes(Launcher *launcher); +// Populates the list_icons list +void launcher_load_icons(Launcher *launcher); +void launcher_action(LauncherIcon *icon, XEvent* e); + +void test_launcher_read_desktop_file(); +void test_launcher_read_theme_file(); + +#endif diff -Naur tint2-0.11/src/launcher/xsettings-client.c tint2-svn/src/launcher/xsettings-client.c --- tint2-0.11/src/launcher/xsettings-client.c 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/launcher/xsettings-client.c 2014-01-10 16:11:02.967388096 +0100 @@ -0,0 +1,480 @@ +/* + * Copyright © 2001 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Owen Taylor, Red Hat, Inc. + */ +#include +#include +#include +#include + +#include +#include /* For CARD16 */ + +#include "xsettings-client.h" +#include "server.h" +#include "panel.h" +#include "launcher.h" + +struct _XSettingsClient +{ + Display *display; + int screen; + XSettingsNotifyFunc notify; + XSettingsWatchFunc watch; + void *cb_data; + + Window manager_window; + XSettingsList *settings; +}; + + +void xsettings_notify_cb (const char *name, XSettingsAction action, XSettingsSetting *setting, void *data) +{ + //printf("xsettings_notify_cb\n"); + if ((action == XSETTINGS_ACTION_NEW || action == XSETTINGS_ACTION_CHANGED) && name != NULL && setting != NULL) { + if (!strcmp(name, "Net/IconThemeName") && setting->type == XSETTINGS_TYPE_STRING) { + if (icon_theme_name) { + if (strcmp(icon_theme_name, setting->data.v_string) == 0) + return; + free(icon_theme_name); + } + icon_theme_name = strdup(setting->data.v_string); + + int i; + for (i = 0 ; i < nb_panel ; i++) { + Launcher *launcher = &panel1[i].launcher; + cleanup_launcher_theme(launcher); + launcher_load_themes(launcher); + launcher_load_icons(launcher); + launcher->area.resize = 1; + } + } + } +} + + +static void notify_changes (XSettingsClient *client, XSettingsList *old_list) +{ + XSettingsList *old_iter = old_list; + XSettingsList *new_iter = client->settings; + + if (!client->notify) + return; + + while (old_iter || new_iter) { + int cmp; + + if (old_iter && new_iter) + cmp = strcmp (old_iter->setting->name, new_iter->setting->name); + else if (old_iter) + cmp = -1; + else + cmp = 1; + + if (cmp < 0) { + client->notify (old_iter->setting->name, XSETTINGS_ACTION_DELETED, NULL, client->cb_data); + } + else if (cmp == 0) { + if (!xsettings_setting_equal (old_iter->setting, new_iter->setting)) + client->notify (old_iter->setting->name, XSETTINGS_ACTION_CHANGED, new_iter->setting, client->cb_data); + } + else { + client->notify (new_iter->setting->name, XSETTINGS_ACTION_NEW, new_iter->setting, client->cb_data); + } + + if (old_iter) + old_iter = old_iter->next; + if (new_iter) + new_iter = new_iter->next; + } +} + + +static int ignore_errors (Display *display, XErrorEvent *event) +{ + return True; +} + +static char local_byte_order = '\0'; + +#define BYTES_LEFT(buffer) ((buffer)->data + (buffer)->len - (buffer)->pos) + +static XSettingsResult fetch_card16 (XSettingsBuffer *buffer, CARD16 *result) +{ + CARD16 x; + + if (BYTES_LEFT (buffer) < 2) + return XSETTINGS_ACCESS; + + x = *(CARD16 *)buffer->pos; + buffer->pos += 2; + + if (buffer->byte_order == local_byte_order) + *result = x; + else + *result = (x << 8) | (x >> 8); + + return XSETTINGS_SUCCESS; +} + + +static XSettingsResult fetch_ushort (XSettingsBuffer *buffer, unsigned short *result) +{ + CARD16 x; + XSettingsResult r; + + r = fetch_card16 (buffer, &x); + if (r == XSETTINGS_SUCCESS) + *result = x; + + return r; +} + + +static XSettingsResult fetch_card32 (XSettingsBuffer *buffer, CARD32 *result) +{ + CARD32 x; + + if (BYTES_LEFT (buffer) < 4) + return XSETTINGS_ACCESS; + + x = *(CARD32 *)buffer->pos; + buffer->pos += 4; + + if (buffer->byte_order == local_byte_order) + *result = x; + else + *result = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); + + return XSETTINGS_SUCCESS; +} + +static XSettingsResult fetch_card8 (XSettingsBuffer *buffer, CARD8 *result) +{ + if (BYTES_LEFT (buffer) < 1) + return XSETTINGS_ACCESS; + + *result = *(CARD8 *)buffer->pos; + buffer->pos += 1; + + return XSETTINGS_SUCCESS; +} + +#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1))) + +static XSettingsList *parse_settings (unsigned char *data, size_t len) +{ + XSettingsBuffer buffer; + XSettingsResult result = XSETTINGS_SUCCESS; + XSettingsList *settings = NULL; + CARD32 serial; + CARD32 n_entries; + CARD32 i; + XSettingsSetting *setting = NULL; + + local_byte_order = xsettings_byte_order (); + + buffer.pos = buffer.data = data; + buffer.len = len; + + result = fetch_card8 (&buffer, (CARD8*)&buffer.byte_order); + if (buffer.byte_order != MSBFirst && buffer.byte_order != LSBFirst) { + fprintf (stderr, "Invalid byte order %x in XSETTINGS property\n", buffer.byte_order); + result = XSETTINGS_FAILED; + goto out; + } + + buffer.pos += 3; + + result = fetch_card32 (&buffer, &serial); + if (result != XSETTINGS_SUCCESS) + goto out; + + result = fetch_card32 (&buffer, &n_entries); + if (result != XSETTINGS_SUCCESS) + goto out; + + for (i = 0; i < n_entries; i++) { + CARD8 type; + CARD16 name_len; + CARD32 v_int; + size_t pad_len; + + result = fetch_card8 (&buffer, &type); + if (result != XSETTINGS_SUCCESS) + goto out; + + buffer.pos += 1; + + result = fetch_card16 (&buffer, &name_len); + if (result != XSETTINGS_SUCCESS) + goto out; + + pad_len = XSETTINGS_PAD(name_len, 4); + if (BYTES_LEFT (&buffer) < pad_len) { + result = XSETTINGS_ACCESS; + goto out; + } + + setting = malloc (sizeof *setting); + if (!setting) { + result = XSETTINGS_NO_MEM; + goto out; + } + setting->type = XSETTINGS_TYPE_INT; /* No allocated memory */ + + setting->name = malloc (name_len + 1); + if (!setting->name) { + result = XSETTINGS_NO_MEM; + goto out; + } + + memcpy (setting->name, buffer.pos, name_len); + setting->name[name_len] = '\0'; + buffer.pos += pad_len; + + result = fetch_card32 (&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + setting->last_change_serial = v_int; + + switch (type) { + case XSETTINGS_TYPE_INT: + result = fetch_card32 (&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + setting->data.v_int = (INT32)v_int; + break; + case XSETTINGS_TYPE_STRING: + result = fetch_card32 (&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + + pad_len = XSETTINGS_PAD (v_int, 4); + if (v_int + 1 == 0 || /* Guard against wrap-around */ + BYTES_LEFT (&buffer) < pad_len) { + result = XSETTINGS_ACCESS; + goto out; + } + + setting->data.v_string = malloc (v_int + 1); + if (!setting->data.v_string) { + result = XSETTINGS_NO_MEM; + goto out; + } + + memcpy (setting->data.v_string, buffer.pos, v_int); + setting->data.v_string[v_int] = '\0'; + buffer.pos += pad_len; + break; + case XSETTINGS_TYPE_COLOR: + result = fetch_ushort (&buffer, &setting->data.v_color.red); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort (&buffer, &setting->data.v_color.green); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort (&buffer, &setting->data.v_color.blue); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort (&buffer, &setting->data.v_color.alpha); + if (result != XSETTINGS_SUCCESS) + goto out; + break; + default: + /* Quietly ignore unknown types */ + break; + } + + setting->type = type; + + result = xsettings_list_insert (&settings, setting); + if (result != XSETTINGS_SUCCESS) + goto out; + + setting = NULL; + } + + out: + + if (result != XSETTINGS_SUCCESS) { + switch (result) { + case XSETTINGS_NO_MEM: + fprintf(stderr, "Out of memory reading XSETTINGS property\n"); + break; + case XSETTINGS_ACCESS: + fprintf(stderr, "Invalid XSETTINGS property (read off end)\n"); + break; + case XSETTINGS_DUPLICATE_ENTRY: + fprintf (stderr, "Duplicate XSETTINGS entry for '%s'\n", setting->name); + case XSETTINGS_FAILED: + case XSETTINGS_SUCCESS: + case XSETTINGS_NO_ENTRY: + break; + } + + if (setting) + xsettings_setting_free (setting); + + xsettings_list_free (settings); + settings = NULL; + } + + return settings; +} + + +static void read_settings (XSettingsClient *client) +{ + Atom type; + int format; + unsigned long n_items; + unsigned long bytes_after; + unsigned char *data; + int result; + + int (*old_handler) (Display *, XErrorEvent *); + + XSettingsList *old_list = client->settings; + client->settings = NULL; + + old_handler = XSetErrorHandler (ignore_errors); + result = XGetWindowProperty (client->display, client->manager_window, server.atom._XSETTINGS_SETTINGS, 0, LONG_MAX, False, server.atom._XSETTINGS_SETTINGS, &type, &format, &n_items, &bytes_after, &data); + XSetErrorHandler (old_handler); + + if (result == Success && type == server.atom._XSETTINGS_SETTINGS) { + if (format != 8) { + fprintf (stderr, "Invalid format for XSETTINGS property %d", format); + } + else + client->settings = parse_settings (data, n_items); + XFree (data); + } + + notify_changes (client, old_list); + xsettings_list_free (old_list); +} + + +static void check_manager_window (XSettingsClient *client) +{ + if (client->manager_window && client->watch) + client->watch (client->manager_window, False, 0, client->cb_data); + + XGrabServer (client->display); + + client->manager_window = XGetSelectionOwner (server.dsp, server.atom._XSETTINGS_SCREEN); + if (client->manager_window) + XSelectInput (server.dsp, client->manager_window, PropertyChangeMask | StructureNotifyMask); + + XUngrabServer (client->display); + XFlush (client->display); + + if (client->manager_window && client->watch) + client->watch (client->manager_window, True, PropertyChangeMask | StructureNotifyMask, client->cb_data); + + read_settings (client); +} + + +XSettingsClient *xsettings_client_new (Display *display, int screen, XSettingsNotifyFunc notify, XSettingsWatchFunc watch, void *cb_data) +{ + XSettingsClient *client; + + client = malloc (sizeof *client); + if (!client) + return NULL; + + client->display = display; + client->screen = screen; + client->notify = notify; + client->watch = watch; + client->cb_data = cb_data; + + client->manager_window = None; + client->settings = NULL; + + if (client->watch) + client->watch (RootWindow (display, screen), True, StructureNotifyMask, client->cb_data); + + check_manager_window (client); + + if (client->manager_window == None) { + printf("NO XSETTINGS manager, tint2 use config 'launcher_icon_theme'.\n"); + free (client); + return NULL; + } + else + return client; +} + + +void xsettings_client_destroy (XSettingsClient *client) +{ + if (client->watch) + client->watch (RootWindow (client->display, client->screen), False, 0, client->cb_data); + if (client->manager_window && client->watch) + client->watch (client->manager_window, False, 0, client->cb_data); + + xsettings_list_free (client->settings); + free (client); +} + + +XSettingsResult xsettings_client_get_setting (XSettingsClient *client, const char *name, XSettingsSetting **setting) +{ + XSettingsSetting *search = xsettings_list_lookup (client->settings, name); + if (search) { + *setting = xsettings_setting_copy (search); + return *setting ? XSETTINGS_SUCCESS : XSETTINGS_NO_MEM; + } + else + return XSETTINGS_NO_ENTRY; +} + + +Bool xsettings_client_process_event (XSettingsClient *client, XEvent *xev) +{ + /* The checks here will not unlikely cause us to reread + * the properties from the manager window a number of + * times when the manager changes from A->B. But manager changes + * are going to be pretty rare. + */ + if (xev->xany.window == RootWindow (server.dsp, server.screen)) { + if (xev->xany.type == ClientMessage && xev->xclient.message_type == server.atom.MANAGER) { + check_manager_window (client); + return True; + } + } + else if (xev->xany.window == client->manager_window) { + if (xev->xany.type == DestroyNotify) { + check_manager_window (client); + return True; + } + else if (xev->xany.type == PropertyNotify) { + read_settings (client); + return True; + } + } + + return False; +} + diff -Naur tint2-0.11/src/launcher/xsettings-client.h tint2-svn/src/launcher/xsettings-client.h --- tint2-0.11/src/launcher/xsettings-client.h 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/launcher/xsettings-client.h 2014-01-10 16:11:02.967388096 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright © 2001 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Owen Taylor, Red Hat, Inc. + */ +#ifndef XSETTINGS_CLIENT_H +#define XSETTINGS_CLIENT_H + +#include +#include "xsettings-common.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct _XSettingsClient XSettingsClient; + +typedef enum +{ + XSETTINGS_ACTION_NEW, + XSETTINGS_ACTION_CHANGED, + XSETTINGS_ACTION_DELETED +} XSettingsAction; + +typedef void (*XSettingsNotifyFunc) (const char *name, XSettingsAction action, XSettingsSetting *setting, void *cb_data); +typedef void (*XSettingsWatchFunc) (Window window, Bool is_start, long mask, void *cb_data); + +XSettingsClient *xsettings_client_new (Display *display, int screen, XSettingsNotifyFunc notify, XSettingsWatchFunc watch, void *cb_data); +void xsettings_client_destroy (XSettingsClient *client); +Bool xsettings_client_process_event (XSettingsClient *client, XEvent *xev); + +void xsettings_notify_cb (const char *name, XSettingsAction action, XSettingsSetting *setting, void *data); + +XSettingsResult xsettings_client_get_setting (XSettingsClient *client, const char *name, XSettingsSetting **setting); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* XSETTINGS_CLIENT_H */ diff -Naur tint2-0.11/src/launcher/xsettings-common.c tint2-svn/src/launcher/xsettings-common.c --- tint2-0.11/src/launcher/xsettings-common.c 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/launcher/xsettings-common.c 2014-01-10 16:11:02.966388080 +0100 @@ -0,0 +1,268 @@ +/* + * Copyright © 2001 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Owen Taylor, Red Hat, Inc. + */ +#include "string.h" +#include "stdlib.h" + +#include +#include /* For CARD32 */ + +#include "xsettings-common.h" + +XSettingsSetting * +xsettings_setting_copy (XSettingsSetting *setting) +{ + XSettingsSetting *result; + size_t str_len; + + result = malloc (sizeof *result); + if (!result) + return NULL; + + str_len = strlen (setting->name); + result->name = malloc (str_len + 1); + if (!result->name) + goto err; + + memcpy (result->name, setting->name, str_len + 1); + + result->type = setting->type; + + switch (setting->type) + { + case XSETTINGS_TYPE_INT: + result->data.v_int = setting->data.v_int; + break; + case XSETTINGS_TYPE_COLOR: + result->data.v_color = setting->data.v_color; + break; + case XSETTINGS_TYPE_STRING: + str_len = strlen (setting->data.v_string); + result->data.v_string = malloc (str_len + 1); + if (!result->data.v_string) + goto err; + + memcpy (result->data.v_string, setting->data.v_string, str_len + 1); + break; + default: + break; + } + + result->last_change_serial = setting->last_change_serial; + + return result; + + err: + if (result->name) + free (result->name); + free (result); + + return NULL; +} + +XSettingsList * +xsettings_list_copy (XSettingsList *list) +{ + XSettingsList *new = NULL; + XSettingsList *old_iter = list; + XSettingsList *new_iter = NULL; + + while (old_iter) + { + XSettingsList *new_node; + + new_node = malloc (sizeof *new_node); + if (!new_node) + goto error; + + new_node->setting = xsettings_setting_copy (old_iter->setting); + if (!new_node->setting) + { + free (new_node); + goto error; + } + + if (new_iter) + new_iter->next = new_node; + else + new = new_node; + + new_iter = new_node; + + old_iter = old_iter->next; + } + + return new; + + error: + xsettings_list_free (new); + return NULL; +} + +int +xsettings_setting_equal (XSettingsSetting *setting_a, + XSettingsSetting *setting_b) +{ + if (setting_a->type != setting_b->type) + return 0; + + if (strcmp (setting_a->name, setting_b->name) != 0) + return 0; + + switch (setting_a->type) + { + case XSETTINGS_TYPE_INT: + return setting_a->data.v_int == setting_b->data.v_int; + case XSETTINGS_TYPE_COLOR: + return (setting_a->data.v_color.red == setting_b->data.v_color.red && + setting_a->data.v_color.green == setting_b->data.v_color.green && + setting_a->data.v_color.blue == setting_b->data.v_color.blue && + setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); + case XSETTINGS_TYPE_STRING: + return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0; + default: + break; + } + + return 0; +} + +void +xsettings_setting_free (XSettingsSetting *setting) +{ + if (setting->type == XSETTINGS_TYPE_STRING) + free (setting->data.v_string); + + if (setting->name) + free (setting->name); + + free (setting); +} + +void +xsettings_list_free (XSettingsList *list) +{ + while (list) + { + XSettingsList *next = list->next; + + xsettings_setting_free (list->setting); + free (list); + + list = next; + } +} + +XSettingsResult +xsettings_list_insert (XSettingsList **list, + XSettingsSetting *setting) +{ + XSettingsList *node; + XSettingsList *iter; + XSettingsList *last = NULL; + + node = malloc (sizeof *node); + if (!node) + return XSETTINGS_NO_MEM; + node->setting = setting; + + iter = *list; + while (iter) + { + int cmp = strcmp (setting->name, iter->setting->name); + + if (cmp < 0) + break; + else if (cmp == 0) + { + free (node); + return XSETTINGS_DUPLICATE_ENTRY; + } + + last = iter; + iter = iter->next; + } + + if (last) + last->next = node; + else + *list = node; + + node->next = iter; + + return XSETTINGS_SUCCESS; +} + +XSettingsResult +xsettings_list_delete (XSettingsList **list, + const char *name) +{ + XSettingsList *iter; + XSettingsList *last = NULL; + + iter = *list; + while (iter) + { + if (strcmp (name, iter->setting->name) == 0) + { + if (last) + last->next = iter->next; + else + *list = iter->next; + + xsettings_setting_free (iter->setting); + free (iter); + + return XSETTINGS_SUCCESS; + } + + last = iter; + iter = iter->next; + } + + return XSETTINGS_FAILED; +} + +XSettingsSetting * +xsettings_list_lookup (XSettingsList *list, + const char *name) +{ + XSettingsList *iter; + + iter = list; + while (iter) + { + if (strcmp (name, iter->setting->name) == 0) + return iter->setting; + + iter = iter->next; + } + + return NULL; +} + +char +xsettings_byte_order (void) +{ + CARD32 myint = 0x01020304; + return (*(char *)&myint == 1) ? MSBFirst : LSBFirst; +} diff -Naur tint2-0.11/src/launcher/xsettings-common.h tint2-svn/src/launcher/xsettings-common.h --- tint2-0.11/src/launcher/xsettings-common.h 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/launcher/xsettings-common.h 2014-01-10 16:11:02.966388080 +0100 @@ -0,0 +1,111 @@ +/* + * Copyright © 2001 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Owen Taylor, Red Hat, Inc. + */ +#ifndef XSETTINGS_COMMON_H +#define XSETTINGS_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct _XSettingsBuffer XSettingsBuffer; +typedef struct _XSettingsColor XSettingsColor; +typedef struct _XSettingsList XSettingsList; +typedef struct _XSettingsSetting XSettingsSetting; + +/* Types of settings possible. Enum values correspond to + * protocol values. + */ +typedef enum +{ + XSETTINGS_TYPE_INT = 0, + XSETTINGS_TYPE_STRING = 1, + XSETTINGS_TYPE_COLOR = 2, + XSETTINGS_TYPE_NONE = 0xff +} XSettingsType; + +typedef enum +{ + XSETTINGS_SUCCESS, + XSETTINGS_NO_MEM, + XSETTINGS_ACCESS, + XSETTINGS_FAILED, + XSETTINGS_NO_ENTRY, + XSETTINGS_DUPLICATE_ENTRY +} XSettingsResult; + +struct _XSettingsBuffer +{ + char byte_order; + size_t len; + unsigned char *data; + unsigned char *pos; +}; + +struct _XSettingsColor +{ + unsigned short red, green, blue, alpha; +}; + +struct _XSettingsList +{ + XSettingsSetting *setting; + XSettingsList *next; +}; + +struct _XSettingsSetting +{ + char *name; + XSettingsType type; + + union { + int v_int; + char *v_string; + XSettingsColor v_color; + } data; + + unsigned long last_change_serial; +}; + +XSettingsSetting *xsettings_setting_copy (XSettingsSetting *setting); +void xsettings_setting_free (XSettingsSetting *setting); +int xsettings_setting_equal (XSettingsSetting *setting_a, + XSettingsSetting *setting_b); + +void xsettings_list_free (XSettingsList *list); +XSettingsList *xsettings_list_copy (XSettingsList *list); +XSettingsResult xsettings_list_insert (XSettingsList **list, + XSettingsSetting *setting); +XSettingsSetting *xsettings_list_lookup (XSettingsList *list, + const char *name); +XSettingsResult xsettings_list_delete (XSettingsList **list, + const char *name); + +char xsettings_byte_order (void); + +#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1))) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* XSETTINGS_COMMON_H */ diff -Naur tint2-0.11/src/panel.c tint2-svn/src/panel.c --- tint2-0.11/src/panel.c 2010-06-26 14:35:35.000000000 +0200 +++ tint2-svn/src/panel.c 2014-01-10 16:11:02.966388080 +0100 @@ -1,7 +1,7 @@ /************************************************************************** * * Copyright (C) 2008 Pål Staurland (staura@gmail.com) -* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -58,6 +58,7 @@ int panel_autohide_hide_timeout; int panel_autohide_height; int panel_strut_policy; +char *panel_items_order; int max_tick_urgent; @@ -79,6 +80,7 @@ task_dragged = 0; panel_horizontal = 1; panel_position = CENTER; + panel_items_order = 0; panel_autohide = 0; panel_autohide_show_timeout = 0; panel_autohide_hide_timeout = 0; @@ -87,7 +89,7 @@ panel_dock = 0; // default not in the dock panel_layer = BOTTOM_LAYER; // default is bottom layer wm_menu = 0; - max_tick_urgent = 7; + max_tick_urgent = 14; backgrounds = g_array_new(0, 0, sizeof(Background)); memset(&panel_config, 0, sizeof(Panel)); @@ -103,6 +105,8 @@ if (!panel1) return; cleanup_taskbar(); + // taskbarname_font_desc freed here because cleanup_taskbarname() called on _NET_NUMBER_OF_DESKTOPS + if (taskbarname_font_desc) pango_font_description_free(taskbarname_font_desc); int i; Panel *p; @@ -115,6 +119,7 @@ if (p->main_win) XDestroyWindow(server.dsp, p->main_win); } + if (panel_items_order) g_free(panel_items_order); if (panel1) free(panel1); if (backgrounds) g_array_free(backgrounds, 1); @@ -123,7 +128,7 @@ void init_panel() { - int i; + int i, k; Panel *p; if (panel_config.monitor > (server.nb_monitor-1)) { @@ -134,10 +139,12 @@ init_tooltip(); init_systray(); + init_launcher(); init_clock(); #ifdef ENABLE_BATTERY init_battery(); #endif + init_taskbar(); // number of panels (one monitor or 'all' monitors) if (panel_config.monitor >= 0) @@ -156,32 +163,35 @@ if (panel_config.monitor < 0) p->monitor = i; + if ( p->area.bg == 0 ) + p->area.bg = &g_array_index(backgrounds, Background, 0); p->area.parent = p; p->area.panel = p; p->area.on_screen = 1; p->area.resize = 1; + p->area.size_mode = SIZE_BY_LAYOUT; p->area._resize = resize_panel; - p->g_taskbar.area.parent = p; - p->g_taskbar.area.panel = p; - p->g_task.area.panel = p; init_panel_size_and_position(p); - // add childs - if (clock_enabled) { - init_clock_panel(p); - p->area.list = g_slist_append(p->area.list, &p->clock); - } + // add childs according to panel_items + for (k=0 ; k < strlen(panel_items_order) ; k++) { + if (panel_items_order[k] == 'L') + init_launcher_panel(p); + if (panel_items_order[k] == 'T') + init_taskbar_panel(p); #ifdef ENABLE_BATTERY - if (battery_enabled) { - init_battery_panel(p); - p->area.list = g_slist_append(p->area.list, &p->battery); - } + if (panel_items_order[k] == 'B') + init_battery_panel(p); #endif - // systray only on first panel - if (systray.area.on_screen && i == 0) { - init_systray_panel(p); - p->area.list = g_slist_append(p->area.list, &systray); - refresh_systray = 1; + if (panel_items_order[k] == 'S' && i==0) { + // TODO : check systray is only on 1 panel + // at the moment only on panel1[0] allowed + init_systray_panel(p); + refresh_systray = 1; + } + if (panel_items_order[k] == 'C') + init_clock_panel(p); } + set_panel_items_order(p); // catch some events XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 }; @@ -189,7 +199,7 @@ p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att); long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask; - if (g_tooltip.enabled) + if (p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text || (launcher_enabled && launcher_tooltip_enabled)) event_mask |= PointerMotionMask|LeaveWindowMask; if (panel_autohide) event_mask |= LeaveWindowMask|EnterWindowMask; @@ -209,11 +219,10 @@ if (panel_autohide) add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p); + + visible_taskbar(p); } - panel_refresh = 1; - init_taskbar(); - visible_object(); task_refresh_tasklist(); active_task(); } @@ -227,6 +236,8 @@ panel->area.width = (float)server.monitor[panel->monitor].width * panel->area.width / 100; if (panel->pourcenty) panel->area.height = (float)server.monitor[panel->monitor].height * panel->area.height / 100; + if (panel->area.width + panel->marginx > server.monitor[panel->monitor].width) + panel->area.width = server.monitor[panel->monitor].width - panel->marginx; if (panel->area.bg->border.rounded > panel->area.height/2) { printf("panel_background_id rounded is too big... please fix your tint2rc\n"); g_array_append_val(backgrounds, *panel->area.bg); @@ -244,6 +255,8 @@ panel->area.width = (float)server.monitor[panel->monitor].width * old_panel_height / 100; else panel->area.width = old_panel_height; + if (panel->area.height + panel->marginy > server.monitor[panel->monitor].height) + panel->area.height = server.monitor[panel->monitor].height - panel->marginy; if (panel->area.bg->border.rounded > panel->area.width/2) { printf("panel_background_id rounded is too big... please fix your tint2rc\n"); g_array_append_val(backgrounds, *panel->area.bg); @@ -293,107 +306,27 @@ } -void resize_panel(void *obj) +int resize_panel(void *obj) { - Panel *panel = (Panel*)obj; - - if (panel_horizontal) { - int taskbar_width, modulo_width = 0; - - taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width); - if (panel->clock.area.on_screen && panel->clock.area.width) - taskbar_width -= (panel->clock.area.width + panel->area.paddingx); - #ifdef ENABLE_BATTERY - if (panel->battery.area.on_screen && panel->battery.area.width) - taskbar_width -= (panel->battery.area.width + panel->area.paddingx); - #endif - // TODO : systray only on first panel. search better implementation ! - if (systray.area.on_screen && systray.area.width && panel == &panel1[0]) - taskbar_width -= (systray.area.width + panel->area.paddingx); - - if (panel_mode == MULTI_DESKTOP) { - int width = taskbar_width - ((panel->nb_desktop-1) * panel->area.paddingx); - taskbar_width = width / panel->nb_desktop; - modulo_width = width % panel->nb_desktop; - } - - // change posx and width for all taskbar - int i, posx; - posx = panel->area.bg->border.width + panel->area.paddingxlr; + resize_by_layout(obj, 0); + + //printf("resize_panel\n"); + if (panel_mode != MULTI_DESKTOP && taskbar_enabled) { + // propagate width/height on hidden taskbar + int i, width, height; + Panel *panel = (Panel*)obj; + width = panel->taskbar[server.desktop].area.width; + height = panel->taskbar[server.desktop].area.height; for (i=0 ; i < panel->nb_desktop ; i++) { - panel->taskbar[i].area.posx = posx; - panel->taskbar[i].area.width = taskbar_width; + panel->taskbar[i].area.width = width; + panel->taskbar[i].area.height = height; panel->taskbar[i].area.resize = 1; - if (modulo_width) { - panel->taskbar[i].area.width++; - modulo_width--; - } - //printf("taskbar %d : posx %d, width, %d, posy %d\n", i, posx, panel->taskbar[i].area.width, posx + panel->taskbar[i].area.width); - if (panel_mode == MULTI_DESKTOP) - posx += panel->taskbar[i].area.width + panel->area.paddingx; - } - } - else { - int taskbar_height, modulo_height = 0; - int i, posy; - - taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width); - if (panel->clock.area.on_screen && panel->clock.area.height) - taskbar_height -= (panel->clock.area.height + panel->area.paddingx); - #ifdef ENABLE_BATTERY - if (panel->battery.area.on_screen && panel->battery.area.height) - taskbar_height -= (panel->battery.area.height + panel->area.paddingx); - #endif - // TODO : systray only on first panel. search better implementation ! - if (systray.area.on_screen && systray.area.height && panel == &panel1[0]) - taskbar_height -= (systray.area.height + panel->area.paddingx); - - posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - taskbar_height; - if (panel_mode == MULTI_DESKTOP) { - int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx); - taskbar_height = height / panel->nb_desktop; - modulo_height = height % panel->nb_desktop; - } - - // change posy and height for all taskbar - for (i=0 ; i < panel->nb_desktop ; i++) { - panel->taskbar[i].area.posy = posy; - panel->taskbar[i].area.height = taskbar_height; - panel->taskbar[i].area.resize = 1; - if (modulo_height) { - panel->taskbar[i].area.height++; - modulo_height--; - } - if (panel_mode == MULTI_DESKTOP) - posy += panel->taskbar[i].area.height + panel->area.paddingx; } } + return 0; } -void visible_object() -{ - Panel *panel; - int i, j; - - for (i=0 ; i < nb_panel ; i++) { - panel = &panel1[i]; - - Taskbar *taskbar; - for (j=0 ; j < panel->nb_desktop ; j++) { - taskbar = &panel->taskbar[j]; - if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { - // SINGLE_DESKTOP and not current desktop - taskbar->area.on_screen = 0; - } - else { - taskbar->area.on_screen = 1; - } - } - } - panel_refresh = 1; -} - void update_strut(Panel* p) { if (panel_strut_policy == STRUT_NONE) { @@ -449,6 +382,38 @@ } +void set_panel_items_order(Panel *p) +{ + int k, j; + + if (p->area.list) { + g_slist_free(p->area.list); + p->area.list = 0; + } + + for (k=0 ; k < strlen(panel_items_order) ; k++) { + if (panel_items_order[k] == 'L') + p->area.list = g_slist_append(p->area.list, &p->launcher); + if (panel_items_order[k] == 'T') { + for (j=0 ; j < p->nb_desktop ; j++) + p->area.list = g_slist_append(p->area.list, &p->taskbar[j]); + } +#ifdef ENABLE_BATTERY + if (panel_items_order[k] == 'B') + p->area.list = g_slist_append(p->area.list, &p->battery); +#endif + if (panel_items_order[k] == 'S' && p == panel1) { + // TODO : check systray is only on 1 panel + // at the moment only on panel1[0] allowed + p->area.list = g_slist_append(p->area.list, &systray); + } + if (panel_items_order[k] == 'C') + p->area.list = g_slist_append(p->area.list, &p->clock); + } + init_rendering(&p->area, 0); +} + + void set_panel_properties(Panel *p) { XStoreName (server.dsp, p->main_win, "tint2"); @@ -493,7 +458,7 @@ XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5); // XdndAware - Register for Xdnd events - int version=5; + Atom version=4; XChangeProperty(server.dsp, p->main_win, server.atom.XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&version, 1); update_strut(p); @@ -569,12 +534,23 @@ a = l0->data; set_redraw(a); } - // reset task 'state_pix' - int i; + + // reset task/taskbar 'state_pix' + int i, k; Taskbar *tskbar; for (i=0 ; i < p->nb_desktop ; i++) { tskbar = &p->taskbar[i]; - for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { + for (k=0; kstate_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]); + tskbar->state_pix[k] = 0; + if (tskbar->bar_name.state_pix[k]) XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); + tskbar->bar_name.state_pix[k] = 0; + } + tskbar->area.pix = 0; + tskbar->bar_name.area.pix = 0; + l0 = tskbar->area.list; + if (taskbarname_enabled) l0 = l0->next; + for (; l0 ; l0 = l0->next) { set_task_redraw((Task *)l0->data); } } @@ -624,7 +600,9 @@ if ( (tskbar = click_taskbar(panel, x, y)) ) { if (panel_horizontal) { Task *tsk; - for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { + l0 = tskbar->area.list; + if (taskbarname_enabled) l0 = l0->next; + for (; l0 ; l0 = l0->next) { tsk = l0->data; if (tsk->area.on_screen && x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) { return tsk; @@ -633,7 +611,9 @@ } else { Task *tsk; - for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { + l0 = tskbar->area.list; + if (taskbarname_enabled) l0 = l0->next; + for (; l0 ; l0 = l0->next) { tsk = l0->data; if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) { return tsk; @@ -645,6 +625,43 @@ } +Launcher *click_launcher (Panel *panel, int x, int y) +{ + Launcher *launcher = &panel->launcher; + + if (panel_horizontal) { + if (launcher->area.on_screen && x >= launcher->area.posx && x <= (launcher->area.posx + launcher->area.width)) + return launcher; + } + else { + if (launcher->area.on_screen && y >= launcher->area.posy && y <= (launcher->area.posy + launcher->area.height)) + return launcher; + } + return NULL; +} + + +LauncherIcon *click_launcher_icon (Panel *panel, int x, int y) +{ + GSList *l0; + Launcher *launcher; + + //printf("Click x=%d y=%d\n", x, y); + if ( (launcher = click_launcher(panel, x, y)) ) { + LauncherIcon *icon; + for (l0 = launcher->list_icons; l0 ; l0 = l0->next) { + icon = l0->data; + if (x >= (launcher->area.posx + icon->x) && x <= (launcher->area.posx + icon->x + icon->icon_size) && + y >= (launcher->area.posy + icon->y) && y <= (launcher->area.posy + icon->y + icon->icon_size)) { + //printf("Hit rect x=%d y=%d xmax=%d ymax=%d\n", launcher->area.posx + icon->x, launcher->area.posy + icon->y, launcher->area.posx + icon->x + icon->width, launcher->area.posy + icon->y + icon->height); + return icon; + } + } + } + return NULL; +} + + int click_padding(Panel *panel, int x, int y) { if (panel_horizontal) { @@ -682,16 +699,10 @@ GSList* it = result->list; while (it) { Area* a = it->data; - if (panel_horizontal) { - if (a->on_screen && x >= a->posx && x <= (a->posx + a->width)) { - new_result = a; - break; - } - } else { - if (a->on_screen && y >= a->posy && y <= (a->posy + a->height)) { - new_result = a; - break; - } + if (a->on_screen && x >= a->posx && x <= (a->posx + a->width) + && y >= a->posy && y <= (a->posy + a->height)) { + new_result = a; + break; } it = it->next; } diff -Naur tint2-0.11/src/panel.h tint2-svn/src/panel.h --- tint2-0.11/src/panel.h 2010-06-26 14:35:35.000000000 +0200 +++ tint2-svn/src/panel.h 2014-01-10 16:11:03.032389193 +0100 @@ -19,6 +19,7 @@ #include "task.h" #include "taskbar.h" #include "systraybar.h" +#include "launcher.h" #ifdef ENABLE_BATTERY #include "battery.h" @@ -58,6 +59,7 @@ extern int panel_autohide_hide_timeout; extern int panel_autohide_height; // for vertical panels this is of course the width extern int panel_strut_policy; +extern char *panel_items_order; extern int max_tick_urgent; @@ -107,6 +109,8 @@ Battery battery; #endif + Launcher launcher; + // autohide int is_hidden; int hidden_width, hidden_height; @@ -131,10 +135,10 @@ void init_panel(); void init_panel_size_and_position(Panel *panel); -void resize_panel(void *obj); +int resize_panel(void *obj); +void set_panel_items_order(Panel *p); void set_panel_properties(Panel *p); -void visible_object(); // draw background panel void set_panel_background(Panel *p); @@ -144,6 +148,8 @@ Taskbar *click_taskbar (Panel *panel, int x, int y); Task *click_task (Panel *panel, int x, int y); +Launcher *click_launcher (Panel *panel, int x, int y); +LauncherIcon *click_launcher_icon (Panel *panel, int x, int y); int click_padding(Panel *panel, int x, int y); int click_clock(Panel *panel, int x, int y); Area* click_area(Panel *panel, int x, int y); diff -Naur tint2-0.11/src/server.c tint2-svn/src/server.c --- tint2-0.11/src/server.c 2010-06-26 14:35:35.000000000 +0200 +++ tint2-svn/src/server.c 2014-01-10 16:11:03.094390247 +0100 @@ -36,8 +36,10 @@ void server_init_atoms () { server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False); + server.atom._XROOTMAP_ID = XInternAtom (server.dsp, "_XROOTMAP_ID", False); server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False); server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False); + server.atom._NET_DESKTOP_NAMES = XInternAtom (server.dsp, "_NET_DESKTOP_NAMES", False); server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False); server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False); server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False); @@ -79,23 +81,34 @@ server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False); server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False); server.atom.WM_HINTS = XInternAtom(server.dsp, "WM_HINTS", False); + char *name = g_strdup_printf("_XSETTINGS_S%d", DefaultScreen(server.dsp)); + server.atom._XSETTINGS_SCREEN = XInternAtom(server.dsp, name, False); + g_free(name); + server.atom._XSETTINGS_SETTINGS = XInternAtom(server.dsp, "_XSETTINGS_SETTINGS", False); // systray protocol - char *name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp)); - server.atom._NET_SYSTEM_TRAY_SCREEN = XInternAtom(server.dsp, name_trayer, False); + name = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp)); + server.atom._NET_SYSTEM_TRAY_SCREEN = XInternAtom(server.dsp, name, False); + g_free(name); server.atom._NET_SYSTEM_TRAY_OPCODE = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_OPCODE", False); server.atom.MANAGER = XInternAtom(server.dsp, "MANAGER", False); server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False); server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False); server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False); - g_free(name_trayer); // drag 'n' drop server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False); + server.atom.XdndEnter = XInternAtom(server.dsp, "XdndEnter", False); server.atom.XdndPosition = XInternAtom(server.dsp, "XdndPosition", False); server.atom.XdndStatus = XInternAtom(server.dsp, "XdndStatus", False); + server.atom.XdndDrop = XInternAtom(server.dsp, "XdndDrop", False); server.atom.XdndLeave = XInternAtom(server.dsp, "XdndLeave", False); + server.atom.XdndSelection = XInternAtom(server.dsp, "XdndSelection", False); + server.atom.XdndTypeList = XInternAtom(server.dsp, "XdndTypeList", False); + server.atom.XdndActionCopy = XInternAtom(server.dsp, "XdndActionCopy", False); + server.atom.XdndFinished = XInternAtom(server.dsp, "XdndFinished", False); + server.atom.TARGETS = XInternAtom(server.dsp, "TARGETS", False); } @@ -170,8 +183,8 @@ result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); - /* Send back resultcount */ - if (num_results) *num_results = nitems_ret; + // Send back resultcount + if (num_results) *num_results = (int)nitems_ret; if (result == Success && prop_value) return prop_value; else return 0; @@ -183,16 +196,17 @@ Pixmap ret = None; unsigned long *res; - int c = 2; + Atom pixmap_atoms[] = { server.atom._XROOTPMAP_ID, server.atom._XROOTMAP_ID }; + int i; - do { - res = server_get_property (server.root_win, server.atom._XROOTPMAP_ID, XA_PIXMAP, 0); + for (i=0; i 0); + } server.root_pmap = ret; if (server.root_pmap == None) @@ -302,7 +316,7 @@ i++; } next: - for (j=i; j #include +#ifdef HAVE_SN +#include +#include +#endif + typedef struct Global_atom { Atom _XROOTPMAP_ID; + Atom _XROOTMAP_ID; Atom _NET_CURRENT_DESKTOP; Atom _NET_NUMBER_OF_DESKTOPS; + Atom _NET_DESKTOP_NAMES; Atom _NET_DESKTOP_GEOMETRY; Atom _NET_DESKTOP_VIEWPORT; Atom _NET_ACTIVE_WINDOW; @@ -49,7 +56,7 @@ Atom _NET_WM_VISIBLE_NAME; Atom _NET_WM_STRUT; Atom _NET_WM_ICON; - Atom _NET_WM_ICON_GEOMETRY; + Atom _NET_WM_ICON_GEOMETRY; Atom _NET_CLOSE_WINDOW; Atom UTF8_STRING; Atom _NET_SUPPORTING_WM_CHECK; @@ -66,10 +73,19 @@ Atom _NET_SYSTEM_TRAY_ORIENTATION; Atom _XEMBED; Atom _XEMBED_INFO; + Atom _XSETTINGS_SCREEN; + Atom _XSETTINGS_SETTINGS; Atom XdndAware; + Atom XdndEnter; Atom XdndPosition; Atom XdndStatus; + Atom XdndDrop; Atom XdndLeave; + Atom XdndSelection; + Atom XdndTypeList; + Atom XdndActionCopy; + Atom XdndFinished; + Atom TARGETS; } Global_atom; @@ -107,6 +123,10 @@ Colormap colormap; Colormap colormap32; Global_atom atom; +#ifdef HAVE_SN + SnDisplay *sn_dsp; + GTree *pids; +#endif // HAVE_SN } Server_global; diff -Naur tint2-0.11/src/systray/systraybar.c tint2-svn/src/systray/systraybar.c --- tint2-0.11/src/systray/systraybar.c 2010-06-09 17:31:18.000000000 +0200 +++ tint2-svn/src/systray/systraybar.c 2014-01-10 16:11:03.206392156 +0100 @@ -1,7 +1,7 @@ /************************************************************************** * Tint2 : systraybar * -* Copyright (C) 2009 thierry lorthiois (lorthiois@bbsoft.fr) +* Copyright (C) 2009 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * based on 'docker-1.5' from Ben Jansens. * * This program is free software; you can redistribute it and/or @@ -61,6 +61,8 @@ systray.alpha = 100; systray.sort = 3; systray.area._draw_foreground = draw_systray; + systray.area._on_change_layout = on_change_systray; + systray.area.size_mode = SIZE_BY_CONTENT; systray.area._resize = resize_systray; } @@ -89,27 +91,27 @@ systray.alpha = 100; systray.brightness = systray.saturation = 0; } - systray.area.resize = 1; - systray.area.redraw = 1; - systray.area.on_screen = 1; - refresh_systray = 0; } void init_systray_panel(void *p) { - Panel *panel =(Panel*)p; - - if (panel_horizontal) { - systray.area.posy = panel->area.bg->border.width + panel->area.paddingy; - systray.area.height = panel->area.height - (2 * systray.area.posy); - } - else { - systray.area.posx = panel->area.bg->border.width + panel->area.paddingy; - systray.area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy); - } systray.area.parent = p; systray.area.panel = p; + if (systray.area.bg == 0) + systray.area.bg = &g_array_index(backgrounds, Background, 0); + + GSList *l; + int count = 0; + for (l = systray.list_icons; l ; l = l->next) { + if (!((TrayWindow*)l->data)->hide) + count++; + } + if (count == 0) + hide(&systray.area); + else + show(&systray.area); + refresh_systray = 0; } @@ -125,22 +127,19 @@ } -void resize_systray(void *obj) +int resize_systray(void *obj) { Systraybar *sysbar = obj; - Panel *panel = sysbar->area.panel; - TrayWindow *traywin; GSList *l; - int count, icon_size; - int icons_per_column=1, icons_per_row=1, marging=0; + int count; if (panel_horizontal) - icon_size = sysbar->area.height; + sysbar->icon_size = sysbar->area.height; else - icon_size = sysbar->area.width; - icon_size = icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy); - if (systray_max_icon_size > 0 && icon_size > systray_max_icon_size) - icon_size = systray_max_icon_size; + sysbar->icon_size = sysbar->area.width; + sysbar->icon_size = sysbar->icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy); + if (systray_max_icon_size > 0 && sysbar->icon_size > systray_max_icon_size) + sysbar->icon_size = systray_max_icon_size; count = 0; for (l = systray.list_icons; l ; l = l->next) { if (!((TrayWindow*)l->data)->hide) @@ -149,46 +148,32 @@ //printf("count %d\n", count); if (panel_horizontal) { - if (!count) systray.area.width = 0; - else { - int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy; - // here icons_per_column always higher than 0 - icons_per_column = (height+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx); - marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size; - icons_per_row = count / icons_per_column + (count%icons_per_column != 0); - systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx); - } - - systray.area.posx = panel->area.width - panel->area.bg->border.width - panel->area.paddingxlr - systray.area.width; - if (panel->clock.area.on_screen) - systray.area.posx -= (panel->clock.area.width + panel->area.paddingx); -#ifdef ENABLE_BATTERY - if (panel->battery.area.on_screen) - systray.area.posx -= (panel->battery.area.width + panel->area.paddingx); -#endif + int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy; + // here icons_per_column always higher than 0 + sysbar->icons_per_column = (height+sysbar->area.paddingx) / (sysbar->icon_size+sysbar->area.paddingx); + sysbar->marging = height - (sysbar->icons_per_column-1)*(sysbar->icon_size+sysbar->area.paddingx) - sysbar->icon_size; + sysbar->icons_per_row = count / sysbar->icons_per_column + (count%sysbar->icons_per_column != 0); + systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (sysbar->icon_size * sysbar->icons_per_row) + ((sysbar->icons_per_row-1) * systray.area.paddingx); } else { - if (!count) systray.area.height = 0; - else { - int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy; - // here icons_per_row always higher than 0 - icons_per_row = (width+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx); - marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size; - icons_per_column = count / icons_per_row+ (count%icons_per_row != 0); - systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx); - } - - systray.area.posy = panel->area.bg->border.width + panel->area.paddingxlr; - if (panel->clock.area.on_screen) - systray.area.posy += (panel->clock.area.height + panel->area.paddingx); -#ifdef ENABLE_BATTERY - if (panel->battery.area.on_screen) - systray.area.posy += (panel->battery.area.height + panel->area.paddingx); -#endif + int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy; + // here icons_per_row always higher than 0 + sysbar->icons_per_row = (width+sysbar->area.paddingx) / (sysbar->icon_size+sysbar->area.paddingx); + sysbar->marging = width - (sysbar->icons_per_row-1)*(sysbar->icon_size+sysbar->area.paddingx) - sysbar->icon_size; + sysbar->icons_per_column = count / sysbar->icons_per_row+ (count%sysbar->icons_per_row != 0); + systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (sysbar->icon_size * sysbar->icons_per_column) + ((sysbar->icons_per_column-1) * systray.area.paddingx); } + return 1; +} + +void on_change_systray (void *obj) +{ + // here, systray.area.posx/posy are defined by rendering engine. so we can calculate position of tray icon. + Systraybar *sysbar = obj; + Panel *panel = sysbar->area.panel; int i, posx, posy; - int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +marging/2; + int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy + sysbar->marging/2; if (panel_horizontal) { posy = start; posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr; @@ -198,37 +183,38 @@ posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr; } + TrayWindow *traywin; + GSList *l; for (i=1, l = systray.list_icons; l ; i++, l = l->next) { traywin = (TrayWindow*)l->data; if (traywin->hide) continue; traywin->y = posy; traywin->x = posx; - traywin->width = icon_size; - traywin->height = icon_size; + //printf("systray %d : %d,%d\n", i, posx, posy); + traywin->width = sysbar->icon_size; + traywin->height = sysbar->icon_size; if (panel_horizontal) { - if (i % icons_per_column) - posy += icon_size + sysbar->area.paddingx; + if (i % sysbar->icons_per_column) + posy += sysbar->icon_size + sysbar->area.paddingx; else { posy = start; - posx += (icon_size + systray.area.paddingx); + posx += (sysbar->icon_size + systray.area.paddingx); } } else { - if (i % icons_per_row) - posx += icon_size + systray.area.paddingx; + if (i % sysbar->icons_per_row) + posx += sysbar->icon_size + systray.area.paddingx; else { posx = start; - posy += (icon_size + systray.area.paddingx); + posy += (sysbar->icon_size + systray.area.paddingx); } } // position and size the icon window - XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size); - XResizeWindow(server.dsp, traywin->tray_id, icon_size, icon_size); + XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size); + XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size); } - // resize force the redraw - systray.area.redraw = 1; } @@ -277,7 +263,7 @@ // v0.3 trayer specification. tint2 always horizontal. // Vertical panel will draw the systray horizontal. - int orient = 0; + long orient = 0; XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1); VisualID vid; if (server.visual32 && (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)) @@ -373,9 +359,11 @@ if ( XGetWindowAttributes(server.dsp, id, &attr) == False ) return FALSE; unsigned long mask = 0; XSetWindowAttributes set_attr; + Visual* visual = server.visual; //printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height); - printf("icon with depth: %d\n", attr.depth); + //printf("icon with depth: %d\n", attr.depth); if (attr.depth != server.depth || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { + visual = attr.visual; set_attr.colormap = attr.colormap; set_attr.background_pixel = 0; set_attr.border_pixel = 0; @@ -386,9 +374,11 @@ mask = CWBackPixmap; } Window parent_window; - parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, attr.visual, mask, &set_attr); + parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr); old = XSetErrorHandler(window_error_handler); XReparentWindow(server.dsp, id, parent_window, 0, 0); + // watch for the icon trying to resize itself / closing again! + XSelectInput(server.dsp, id, StructureNotifyMask); XSync(server.dsp, False); XSetErrorHandler(old); if (error != FALSE) { @@ -443,17 +433,17 @@ traywin->depth = attr.depth; traywin->damage = 0; + if (systray.area.on_screen == 0) + show(&systray.area); + if (systray.sort == 3) systray.list_icons = g_slist_prepend(systray.list_icons, traywin); else if (systray.sort == 2) systray.list_icons = g_slist_append(systray.list_icons, traywin); else systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows); - systray.area.resize = 1; //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons)); - // watch for the icon trying to resize itself! - XSelectInput(server.dsp, traywin->tray_id, StructureNotifyMask); if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles); XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual); @@ -465,8 +455,8 @@ if (!traywin->hide && !panel->is_hidden) XMapRaised(server.dsp, traywin->id); - // changed in systray force resize on panel - panel->area.resize = 1; + // changed in systray + systray.area.resize = 1; panel_refresh = 1; return TRUE; } @@ -478,7 +468,6 @@ // remove from our list systray.list_icons = g_slist_remove(systray.list_icons, traywin); - systray.area.resize = 1; //printf("remove_icon id %lx, %d\n", traywin->id); XSelectInput(server.dsp, traywin->tray_id, NoEventMask); @@ -498,9 +487,18 @@ stop_timeout(traywin->render_timeout); g_free(traywin); - // changed in systray force resize on panel - Panel *panel = systray.area.panel; - panel->area.resize = 1; + // check empty systray + int count = 0; + GSList *l; + for (l = systray.list_icons; l ; l = l->next) { + if (!((TrayWindow*)l->data)->hide) + count++; + } + if (count == 0) + hide(&systray.area); + + // changed in systray + systray.area.resize = 1; panel_refresh = 1; } @@ -537,6 +535,11 @@ // we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here TrayWindow* traywin = t; traywin->render_timeout = 0; + if ( traywin->width == 0 || traywin->height == 0 ) { + // reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu) + systray_render_icon(traywin); + return; + } // good systray icons support 32 bit depth, but some icons are still 24 bit. // We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and diff -Naur tint2-0.11/src/systray/systraybar.h tint2-svn/src/systray/systraybar.h --- tint2-0.11/src/systray/systraybar.h 2010-04-18 16:28:45.000000000 +0200 +++ tint2-svn/src/systray/systraybar.h 2014-01-10 16:11:03.206392156 +0100 @@ -28,6 +28,7 @@ GSList *list_icons; int sort; int alpha, saturation, brightness; + int icon_size, icons_per_column, icons_per_row, marging; } Systraybar; @@ -63,7 +64,8 @@ void init_systray_panel(void *p); void draw_systray(void *obj, cairo_t *c); -void resize_systray(void *obj); +int resize_systray(void *obj); +void on_change_systray(void *obj); // systray protocol diff -Naur tint2-0.11/src/taskbar/taskbar.c tint2-svn/src/taskbar/taskbar.c --- tint2-0.11/src/taskbar/taskbar.c 2010-06-16 17:00:48.000000000 +0200 +++ tint2-svn/src/taskbar/taskbar.c 2014-01-10 16:11:03.095390264 +0100 @@ -2,7 +2,7 @@ * * Tint2 : taskbar * -* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -41,160 +41,37 @@ Task *task_active; Task *task_drag; +int taskbar_enabled; guint win_hash(gconstpointer key) { return (guint)*((Window*)key); } gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); } void free_ptr_array(gpointer data) { g_ptr_array_free(data, 1); } -void init_taskbar() -{ - Panel *panel; - int i, j; - - if (win_to_task_table == 0) - win_to_task_table = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array); - - task_active = 0; - task_drag = 0; - - for (i=0 ; i < nb_panel ; i++) { - panel = &panel1[i]; - - if (panel->taskbar) { - free(panel->taskbar); - panel->taskbar = 0; - } - - if (panel->g_taskbar.bg == 0) { - panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0); - panel->g_taskbar.area.bg = panel->g_taskbar.bg; - } - if (panel->g_taskbar.bg_active == 0) - panel->g_taskbar.bg_active = panel->g_taskbar.bg; - if (panel->g_task.area.bg == 0) - panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0); - - // taskbar - panel->g_taskbar.area._resize = resize_taskbar; - panel->g_taskbar.area.redraw = 1; - panel->g_taskbar.area.on_screen = 1; - if (panel_horizontal) { - panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy; - panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy); - } - else { - panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy; - panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx); - } - - // task - panel->g_task.area._draw_foreground = draw_task; - panel->g_task.area.redraw = 1; - panel->g_task.area.on_screen = 1; - if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_NORMAL] = 100; - panel->g_task.saturation[TASK_NORMAL] = 0; - panel->g_task.brightness[TASK_NORMAL] = 0; - } - if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL]; - panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL]; - panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL]; - } - if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL]; - panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL]; - panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL]; - } - if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE]; - panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE]; - panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE]; - } - if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0}; - if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL]; - if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL]; - if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE]; - if ((panel->g_task.config_font_mask & (1<g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0); - if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL]; - if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL]; - if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE]; - - if (panel_horizontal) { - panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy; - panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy); - } - else { - panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy; - panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx); - panel->g_task.area.height = panel->g_task.maximum_height; - } - - int k; - for (k=0; kg_task.background[k]->border.rounded > panel->g_task.area.height/2) { - printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", k==0 ? "_" : k==1 ? "_active_" : k==2 ? "_iconified_" : "_urgent_"); - g_array_append_val(backgrounds, *panel->g_task.background[k]); - panel->g_task.background[k] = &g_array_index(backgrounds, Background, backgrounds->len-1); - panel->g_task.background[k]->border.rounded = panel->g_task.area.height/2; - } - } - - // compute vertical position : text and icon - int height_ink, height; - get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5); - - if (!panel->g_task.maximum_width && panel_horizontal) - panel->g_task.maximum_width = server.monitor[panel->monitor].width; - - panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr; - panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); - if (panel->g_task.icon) { - panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); - panel->g_task.text_posx += panel->g_task.icon_size1; - panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2; - } - //printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width); - - Taskbar *tskbar; - panel->nb_desktop = server.nb_desktop; - panel->taskbar = calloc(panel->nb_desktop, sizeof(Taskbar)); - for (j=0 ; j < panel->nb_desktop ; j++) { - tskbar = &panel->taskbar[j]; - memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area)); - tskbar->desktop = j; - if (j == server.desktop && panel->g_taskbar.use_active) - tskbar->area.bg = panel->g_taskbar.bg_active; - - // add taskbar to the panel - panel->area.list = g_slist_append(panel->area.list, tskbar); - } - } -} - -void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data) -{ - remove_task(task_get_task(*(Window*)key)); -} void default_taskbar() { win_to_task_table = 0; urgent_timeout = 0; urgent_list = 0; + taskbar_enabled = 0; + default_taskbarname(); } void cleanup_taskbar() { Panel *panel; Taskbar *tskbar; - int i, j; + int i, j, k; + cleanup_taskbarname(); if (win_to_task_table) g_hash_table_foreach(win_to_task_table, taskbar_remove_task, 0); for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i]; for (j=0 ; j < panel->nb_desktop ; j++) { tskbar = &panel->taskbar[j]; + for (k=0; kstate_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]); + } free_area (&tskbar->area); // remove taskbar from the panel panel->area.list = g_slist_remove(panel->area.list, tskbar); @@ -212,6 +89,158 @@ } +void init_taskbar() +{ + if (win_to_task_table == 0) + win_to_task_table = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array); + + task_active = 0; + task_drag = 0; +} + + +void init_taskbar_panel(void *p) +{ + Panel *panel =(Panel*)p; + int j; + + if (panel->g_taskbar.background[TASKBAR_NORMAL] == 0) { + panel->g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); + panel->g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); + } + if (panel->g_taskbar.background_name[TASKBAR_NORMAL] == 0) { + panel->g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); + panel->g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); + } + if (panel->g_task.area.bg == 0) + panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0); + + // taskbar name + panel->g_taskbar.area_name.panel = panel; + panel->g_taskbar.area_name.size_mode = SIZE_BY_CONTENT; + panel->g_taskbar.area_name._resize = resize_taskbarname; + panel->g_taskbar.area_name._draw_foreground = draw_taskbarname; + panel->g_taskbar.area_name._on_change_layout = 0; + panel->g_taskbar.area_name.resize = 1; + panel->g_taskbar.area_name.on_screen = 1; + + // taskbar + panel->g_taskbar.area.parent = panel; + panel->g_taskbar.area.panel = panel; + panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT; + panel->g_taskbar.area._resize = resize_taskbar; + panel->g_taskbar.area._draw_foreground = draw_taskbar; + panel->g_taskbar.area._on_change_layout = on_change_taskbar; + panel->g_taskbar.area.resize = 1; + panel->g_taskbar.area.on_screen = 1; + if (panel_horizontal) { + panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy; + panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy); + panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy; + panel->g_taskbar.area_name.height = panel->g_taskbar.area.height; + } + else { + panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy; + panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx); + panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx; + panel->g_taskbar.area_name.width = panel->g_taskbar.area.width; + } + + // task + panel->g_task.area.panel = panel; + panel->g_task.area.size_mode = SIZE_BY_LAYOUT; + panel->g_task.area._draw_foreground = draw_task; + panel->g_task.area._on_change_layout = on_change_task; + panel->g_task.area.resize = 1; + panel->g_task.area.on_screen = 1; + if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_NORMAL] = 100; + panel->g_task.saturation[TASK_NORMAL] = 0; + panel->g_task.brightness[TASK_NORMAL] = 0; + } + if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL]; + panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL]; + panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL]; + } + if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL]; + panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL]; + panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL]; + } + if ((panel->g_task.config_asb_mask & (1<g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE]; + panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE]; + panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE]; + } + if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0}; + if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL]; + if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL]; + if ((panel->g_task.config_font_mask & (1<g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE]; + if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0); + if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL]; + if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL]; + if ((panel->g_task.config_background_mask & (1<g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE]; + + if (panel_horizontal) { + panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.background[TASKBAR_NORMAL]->border.width + panel->g_taskbar.area.paddingy; + panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy); + } + else { + panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.background[TASKBAR_NORMAL]->border.width + panel->g_taskbar.area.paddingy; + panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx); + panel->g_task.area.height = panel->g_task.maximum_height; + } + + for (j=0; jg_task.background[j] == 0) + panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0); + if (panel->g_task.background[j]->border.rounded > panel->g_task.area.height/2) { + printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", j==0 ? "_" : j==1 ? "_active_" : j==2 ? "_iconified_" : "_urgent_"); + g_array_append_val(backgrounds, *panel->g_task.background[j]); + panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len-1); + panel->g_task.background[j]->border.rounded = panel->g_task.area.height/2; + } + } + + // compute vertical position : text and icon + int height_ink, height; + get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5); + + if (!panel->g_task.maximum_width && panel_horizontal) + panel->g_task.maximum_width = server.monitor[panel->monitor].width; + + panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr; + panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); + if (panel->g_task.icon) { + panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy); + panel->g_task.text_posx += panel->g_task.icon_size1; + panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2; + } + //printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width); + + Taskbar *tskbar; + panel->nb_desktop = server.nb_desktop; + panel->taskbar = calloc(server.nb_desktop, sizeof(Taskbar)); + for (j=0 ; j < panel->nb_desktop ; j++) { + tskbar = &panel->taskbar[j]; + memcpy(&tskbar->area, &panel->g_taskbar.area, sizeof(Area)); + tskbar->desktop = j; + if (j == server.desktop) + tskbar->area.bg = panel->g_taskbar.background[TASKBAR_ACTIVE]; + else + tskbar->area.bg = panel->g_taskbar.background[TASKBAR_NORMAL]; + } + init_taskbarname_panel(panel); +} + + +void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data) +{ + remove_task(task_get_task(*(Window*)key)); +} + + Task *task_get_task (Window win) { GPtrArray* task_group = task_get_tasks(win); @@ -224,7 +253,7 @@ GPtrArray* task_get_tasks(Window win) { - if (win_to_task_table) + if (win_to_task_table && taskbar_enabled) return g_hash_table_lookup(win_to_task_table, &win); else return 0; @@ -236,6 +265,7 @@ Window *win; int num_results, i; + if (!taskbar_enabled) return; win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); if (!win) return; @@ -259,99 +289,103 @@ } -void resize_taskbar(void *obj) +void draw_taskbar (void *obj, cairo_t *c) { - Taskbar *taskbar = (Taskbar*)obj; - Panel *panel = (Panel*)taskbar->area.panel; - Task *tsk; - GSList *l; - int task_count, border_width; + Taskbar *taskbar = obj; + int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL; + + taskbar->state_pix[state] = taskbar->area.pix; +} - //printf("resize_taskbar : posx et width des taches\n"); - taskbar->area.redraw = 1; - border_width = taskbar->area.bg->border.width; +int resize_taskbar(void *obj) +{ + Taskbar *taskbar = (Taskbar*)obj; + Panel *panel = (Panel*)taskbar->area.panel; + int text_width; + //printf("resize_taskbar %d %d\n", taskbar->area.posx, taskbar->area.posy); if (panel_horizontal) { - int pixel_width, modulo_width=0; - int x, taskbar_width; - - // new task width for 'desktop' - task_count = g_slist_length(taskbar->area.list); - if (!task_count) pixel_width = panel->g_task.maximum_width; - else { - taskbar_width = taskbar->area.width - (2 * border_width) - (2 * panel->g_taskbar.area.paddingxlr); - if (task_count>1) taskbar_width -= ((task_count-1) * panel->g_taskbar.area.paddingx); - - pixel_width = taskbar_width / task_count; - if (pixel_width > panel->g_task.maximum_width) - pixel_width = panel->g_task.maximum_width; - else - modulo_width = taskbar_width % task_count; + resize_by_layout(obj, panel->g_task.maximum_width); + + text_width = panel->g_task.maximum_width; + GSList *l = taskbar->area.list; + if (taskbarname_enabled) l = l->next; + if (l != NULL) { + text_width = ((Task *)l->data)->area.width; } + taskbar->text_width = text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; + } + else { + resize_by_layout(obj, panel->g_task.maximum_height); + + taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; + } + return 0; +} - taskbar->task_width = pixel_width; - taskbar->task_modulo = modulo_width; - taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; - - // change pos_x and width for all tasks - x = taskbar->area.posx + border_width + taskbar->area.paddingxlr; - for (l = taskbar->area.list; l ; l = l->next) { - tsk = l->data; - if (!tsk->area.on_screen) continue; - tsk->area.posx = x; - set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) - tsk->area.width = pixel_width; - long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height }; - XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); - - if (modulo_width) { - tsk->area.width++; - modulo_width--; - } - x += tsk->area.width + panel->g_taskbar.area.paddingx; - } +void on_change_taskbar (void *obj) +{ + Taskbar *tskbar = obj; + int k; + + // reset Pixmap when position/size changed + for (k=0; kstate_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]); + tskbar->state_pix[k] = 0; } - else { - int pixel_height, modulo_height=0; - int y, taskbar_height; + tskbar->area.pix = 0; + tskbar->area.redraw = 1; +} - // new task width for 'desktop' - task_count = g_slist_length(taskbar->area.list); - if (!task_count) pixel_height = panel->g_task.maximum_height; - else { - taskbar_height = taskbar->area.height - (2 * border_width) - (2 * panel->g_taskbar.area.paddingxlr); - if (task_count>1) taskbar_height -= ((task_count-1) * panel->g_taskbar.area.paddingx); - pixel_height = taskbar_height / task_count; - if (pixel_height > panel->g_task.maximum_height) - pixel_height = panel->g_task.maximum_height; - else - modulo_height = taskbar_height % task_count; +void set_taskbar_state(Taskbar *tskbar, int state) +{ + tskbar->area.bg = panel1[0].g_taskbar.background[state]; + tskbar->area.pix = tskbar->state_pix[state]; + if (taskbarname_enabled) { + tskbar->bar_name.area.bg = panel1[0].g_taskbar.background_name[state]; + tskbar->bar_name.area.pix = tskbar->bar_name.state_pix[state]; + } + if (panel_mode != MULTI_DESKTOP) { + if (state == TASKBAR_NORMAL) + tskbar->area.on_screen = 0; + else + tskbar->area.on_screen = 1; + } + if (tskbar->area.on_screen == 1) { + if (tskbar->state_pix[state] == 0) + tskbar->area.redraw = 1; + if (taskbarname_enabled && tskbar->bar_name.state_pix[state] == 0) + tskbar->bar_name.area.redraw = 1; + if (panel_mode == MULTI_DESKTOP && panel1[0].g_taskbar.background[TASKBAR_NORMAL] != panel1[0].g_taskbar.background[TASKBAR_ACTIVE]) { + GSList *l = tskbar->area.list; + if (taskbarname_enabled) l = l->next; + for ( ; l ; l = l->next) + set_task_redraw(l->data); } + } + panel_refresh = 1; +} - taskbar->task_width = pixel_height; - taskbar->task_modulo = modulo_height; - taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; - - // change pos_y and height for all tasks - y = taskbar->area.posy + border_width + taskbar->area.paddingxlr; - for (l = taskbar->area.list; l ; l = l->next) { - tsk = l->data; - if (!tsk->area.on_screen) continue; - tsk->area.posy = y; - set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) - tsk->area.height = pixel_height; - long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height }; - XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); - - if (modulo_height) { - tsk->area.height++; - modulo_height--; - } - y += tsk->area.height + panel->g_taskbar.area.paddingx; +void visible_taskbar(void *p) +{ + Panel *panel =(Panel*)p; + int j; + + Taskbar *taskbar; + for (j=0 ; j < panel->nb_desktop ; j++) { + taskbar = &panel->taskbar[j]; + if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { + // SINGLE_DESKTOP and not current desktop + taskbar->area.on_screen = 0; + } + else { + taskbar->area.on_screen = 1; } } + panel_refresh = 1; } + diff -Naur tint2-0.11/src/taskbar/taskbar.h tint2-svn/src/taskbar/taskbar.h --- tint2-0.11/src/taskbar/taskbar.h 2010-04-23 16:37:39.000000000 +0200 +++ tint2-svn/src/taskbar/taskbar.h 2014-01-10 16:11:03.095390264 +0100 @@ -9,10 +9,23 @@ #define TASKBAR_H #include "task.h" +#include "taskbarname.h" +enum { TASKBAR_NORMAL, TASKBAR_ACTIVE, TASKBAR_STATE_COUNT }; extern GHashTable* win_to_task_table; extern Task *task_active; extern Task *task_drag; +extern int taskbar_enabled; + + +typedef struct { + // always start with area + Area area; + Pixmap state_pix[TASKBAR_STATE_COUNT]; + + char *name; + int posy; +} Taskbarname; // tint2 use one taskbar per desktop. typedef struct { @@ -20,20 +33,20 @@ Area area; int desktop; + Pixmap state_pix[TASKBAR_STATE_COUNT]; + Taskbarname bar_name; + // task parameters - int task_width; - int task_modulo; int text_width; } Taskbar; - typedef struct { //always start with area Area area; - Background* bg; - Background* bg_active; - int use_active; + Area area_name; + Background* background[TASKBAR_STATE_COUNT]; + Background* background_name[TASKBAR_STATE_COUNT]; } Global_taskbar; @@ -44,12 +57,20 @@ void cleanup_taskbar(); void init_taskbar(); +void init_taskbar_panel(void *p); +void draw_taskbar (void *obj, cairo_t *c); +void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data); Task *task_get_task (Window win); GPtrArray* task_get_tasks(Window win); void task_refresh_tasklist (); -void resize_taskbar(void *obj); +int resize_taskbar(void *obj); +void on_change_taskbar (void *obj); +void set_taskbar_state(Taskbar *tskbar, int state); + +// show/hide taskbar according to current desktop +void visible_taskbar(void *p); #endif diff -Naur tint2-0.11/src/taskbar/taskbarname.c tint2-svn/src/taskbar/taskbarname.c --- tint2-0.11/src/taskbar/taskbarname.c 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/taskbar/taskbarname.c 2014-01-10 16:11:03.095390264 +0100 @@ -0,0 +1,161 @@ +/************************************************************************** +* +* Tint2 : taskbarname +* +* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "window.h" +#include "panel.h" +#include "taskbar.h" +#include "server.h" +#include "taskbarname.h" + +int taskbarname_enabled; +PangoFontDescription *taskbarname_font_desc; +Color taskbarname_font; +Color taskbarname_active_font; + + +void default_taskbarname() +{ + taskbarname_enabled = 0; + taskbarname_font_desc = 0; +} + + +void init_taskbarname_panel(void *p) +{ + Panel *panel =(Panel*)p; + Taskbar *tskbar; + int j; + + if (!taskbarname_enabled) return; + + GSList *l, *list = server_get_name_of_desktop(); + for (j=0, l=list ; j < panel->nb_desktop ; j++) { + tskbar = &panel->taskbar[j]; + memcpy(&tskbar->bar_name.area, &panel->g_taskbar.area_name, sizeof(Area)); + tskbar->bar_name.area.parent = tskbar; + if (j == server.desktop) + tskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_ACTIVE]; + else + tskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_NORMAL]; + + // use desktop number if name is missing + if (l) { + tskbar->bar_name.name = g_strdup(l->data); + l = l->next; + } + else + tskbar->bar_name.name = g_strdup_printf("%d", j+1); + + // append the name at the beginning of taskbar + tskbar->area.list = g_slist_append(tskbar->area.list, &tskbar->bar_name); + } + + for (l=list ; l ; l = l->next) + g_free(l->data); + g_slist_free(list); +} + + +void cleanup_taskbarname() +{ + int i, j, k; + Panel *panel; + Taskbar *tskbar; + + for (i=0 ; i < nb_panel ; i++) { + panel = &panel1[i]; + for (j=0 ; j < panel->nb_desktop ; j++) { + tskbar = &panel->taskbar[j]; + if (tskbar->bar_name.name) g_free(tskbar->bar_name.name); + free_area (&tskbar->bar_name.area); + for (k=0; kbar_name.state_pix[k]) XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); + } + tskbar->area.list = g_slist_remove(tskbar->area.list, &tskbar->bar_name); + } + } +} + + +void draw_taskbarname (void *obj, cairo_t *c) +{ + Taskbarname *taskbar_name = obj; + Taskbar *taskbar = taskbar_name->area.parent; + PangoLayout *layout; + Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font; + + int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL; + taskbar_name->state_pix[state] = taskbar_name->area.pix; + + // draw content + layout = pango_cairo_create_layout (c); + pango_layout_set_font_description (layout, taskbarname_font_desc); + pango_layout_set_width (layout, taskbar_name->area.width * PANGO_SCALE); + pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); + pango_layout_set_text (layout, taskbar_name->name, strlen(taskbar_name->name)); + + cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha); + + pango_cairo_update_layout (c, layout); + cairo_move_to (c, 0, taskbar_name->posy); + pango_cairo_show_layout (c, layout); + + g_object_unref (layout); + //printf("draw_taskbarname %s ******************************\n", taskbar_name->name); +} + + +int resize_taskbarname(void *obj) +{ + Taskbarname *taskbar_name = obj; + Panel *panel = taskbar_name->area.panel; + int name_height, name_width, name_height_ink; + int ret = 0; + + taskbar_name->area.redraw = 1; + get_text_size2(taskbarname_font_desc, &name_height_ink, &name_height, &name_width, panel->area.height, panel->area.width, taskbar_name->name, strlen(taskbar_name->name)); + + if (panel_horizontal) { + int new_size = name_width + (2* (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width)); + if (new_size != taskbar_name->area.width) { + taskbar_name->area.width = new_size; + taskbar_name->posy = (taskbar_name->area.height - name_height) / 2; + ret = 1; + } + } + else { + int new_size = name_height + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width)); + if (new_size != taskbar_name->area.height) { + taskbar_name->area.height = new_size; + taskbar_name->posy = (taskbar_name->area.height - name_height) / 2; + ret = 1; + } + } + return ret; +} + diff -Naur tint2-0.11/src/taskbar/taskbarname.h tint2-svn/src/taskbar/taskbarname.h --- tint2-0.11/src/taskbar/taskbarname.h 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/taskbar/taskbarname.h 2014-01-10 16:11:03.095390264 +0100 @@ -0,0 +1,27 @@ +/************************************************************************** +* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +**************************************************************************/ + +#ifndef TASKBARNAME_H +#define TASKBARNAME_H + +#include "common.h" +#include "area.h" + +extern int taskbarname_enabled; +extern PangoFontDescription *taskbarname_font_desc; +extern Color taskbarname_font; +extern Color taskbarname_active_font; + +void default_taskbarname(); +void cleanup_taskbarname(); + +void init_taskbarname_panel(void *p); + +void draw_taskbarname(void *obj, cairo_t *c); + +int resize_taskbarname(void *obj); + + +#endif + diff -Naur tint2-0.11/src/taskbar/task.c tint2-svn/src/taskbar/task.c --- tint2-0.11/src/taskbar/task.c 2010-04-20 00:06:23.000000000 +0200 +++ tint2-svn/src/taskbar/task.c 2014-01-10 16:11:03.095390264 +0100 @@ -3,7 +3,7 @@ * Tint2 : task * * Copyright (C) 2007 Pål Staurland (staura@gmail.com) -* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -96,7 +96,8 @@ new_tsk2->area.on_screen = 0; } new_tsk2->title = new_tsk.title; - new_tsk2->area._get_tooltip_text = task_get_tooltip; + if (panel1[monitor].g_task.tooltip_enabled) + new_tsk2->area._get_tooltip_text = task_get_tooltip; for (k=0; kicon[k] = new_tsk.icon[k]; new_tsk2->state_pix[k] = 0; @@ -159,12 +160,12 @@ } -void get_title(Task *tsk) +int get_title(Task *tsk) { Panel *panel = tsk->area.panel; char *title, *name; - if (!panel->g_task.text && !g_tooltip.enabled) return; + if (!panel->g_task.text && !panel->g_task.tooltip_enabled) return 0; name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0); if (!name || !strlen(name)) { @@ -184,9 +185,16 @@ else title[0] = 0; strcat(title, name); if (name) XFree (name); - - if (tsk->title) - free(tsk->title); + + if (tsk->title) { + // check unecessary title change + if (strcmp(tsk->title, title) == 0) { + free(title); + return 0; + } + else + free(tsk->title); + } tsk->title = title; GPtrArray* task_group = task_get_tasks(tsk->win); @@ -198,7 +206,7 @@ set_task_redraw(tsk2); } } - set_task_redraw(tsk); + return 1; } @@ -209,7 +217,7 @@ int i; Imlib_Image img = NULL; XWMHints *hints = 0; - long *data = 0; + gulong *data = 0; int k; for (k=0; kg_task.icon_size1); - #ifdef __x86_64__ DATA32 icon_data[w * h]; int length = w * h; @@ -304,7 +311,6 @@ set_task_redraw(tsk2); } } - set_task_redraw(tsk); } @@ -343,6 +349,7 @@ Color *config_text; int width=0, height; Panel *panel = (Panel*)tsk->area.panel; + //printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy); if (panel->g_task.text) { /* Layout */ @@ -386,19 +393,64 @@ } +void on_change_task (void *obj) +{ + Task *tsk = obj; + Panel *panel = (Panel*)tsk->area.panel; + + long value[] = { panel->posx+tsk->area.posx, panel->posy+tsk->area.posy, tsk->area.width, tsk->area.height }; + XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); + + // reset Pixmap when position/size changed + set_task_redraw(tsk); +} + +// Given a pointer to the active task (active_task) and a pointer +// to the task that is currently under the mouse (current_task), +// return a pointer to the active task that is on the same desktop +// as current_task. Normally this is simply active_task, except when +// it is set to appear on all desktops. In that case we search for +// another Task on current_task's taskbar, with the same window as +// active_task. +Task *find_active_task(Task *current_task, Task *active_task) +{ + if (active_task == 0) + return current_task; + if (active_task->desktop != ALLDESKTOP) + return active_task; + if (current_task == 0) + return active_task; + + GSList *l0; + Task *tsk; + Taskbar* tskbar = current_task->area.parent; + + l0 = tskbar->area.list; + if (taskbarname_enabled) l0 = l0->next; + for (; l0 ; l0 = l0->next) { + tsk = l0->data; + if (tsk->win == active_task->win) + return tsk; + } + return active_task; +} + Task *next_task(Task *tsk) { if (tsk == 0) return 0; - GSList *l0; + GSList *l0, *lfirst_tsk; Task *tsk1; Taskbar* tskbar = tsk->area.parent; - for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { + l0 = tskbar->area.list; + if (taskbarname_enabled) l0 = l0->next; + lfirst_tsk = l0; + for (; l0 ; l0 = l0->next) { tsk1 = l0->data; if (tsk1 == tsk) { - if (l0->next == 0) l0 = tskbar->area.list; + if (l0->next == 0) l0 = lfirst_tsk; else l0 = l0->next; return l0->data; } @@ -412,15 +464,18 @@ if (tsk == 0) return 0; - GSList *l0; + GSList *l0, *lfirst_tsk; Task *tsk1, *tsk2; Taskbar* tskbar = tsk->area.parent; tsk2 = 0; - for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { + l0 = tskbar->area.list; + if (taskbarname_enabled) l0 = l0->next; + lfirst_tsk = l0; + for (; l0 ; l0 = l0->next) { tsk1 = l0->data; if (tsk1 == tsk) { - if (l0 == tskbar->area.list) { + if (l0 == lfirst_tsk) { l0 = g_slist_last ( l0 ); tsk2 = l0->data; } @@ -444,9 +499,11 @@ //printf("Change active task %ld\n", w1); if (w1) { - Window w2; - if (XGetTransientForHint(server.dsp, w1, &w2) != 0) - if (w2 && !task_get_tasks(w1)) w1 = w2; + if (!task_get_tasks(w1)) { + Window w2; + while (XGetTransientForHint(server.dsp, w1, &w2)) + w1 = w2; + } set_task_state((task_active = task_get_task(w1)), TASK_ACTIVE); } } diff -Naur tint2-0.11/src/taskbar/task.h tint2-svn/src/taskbar/task.h --- tint2-0.11/src/taskbar/task.h 2010-04-19 23:44:40.000000000 +0200 +++ tint2-svn/src/taskbar/task.h 2014-01-10 16:11:03.095390264 +0100 @@ -44,6 +44,7 @@ PangoFontDescription *font_desc; Color font[TASK_STATE_COUNT]; int config_font_mask; + int tooltip_enabled; } Global_task; @@ -69,13 +70,15 @@ void remove_task (Task *tsk); void draw_task (void *obj, cairo_t *c); +void on_change_task (void *obj); void get_icon (Task *tsk); -void get_title(Task *tsk); +int get_title(Task *tsk); void active_task(); void set_task_state(Task* tsk, int state); void set_task_redraw(Task* tsk); +Task *find_active_task(Task *current_task, Task *active_task); Task *next_task (Task *tsk); Task *prev_task (Task *tsk); diff -Naur tint2-0.11/src/tint2conf/CMakeLists.txt tint2-svn/src/tint2conf/CMakeLists.txt --- tint2-0.11/src/tint2conf/CMakeLists.txt 2010-06-14 08:20:41.000000000 +0200 +++ tint2-svn/src/tint2conf/CMakeLists.txt 2014-01-10 16:11:03.034389230 +0100 @@ -20,6 +20,7 @@ set(SOURCES ../util/common.c main.c properties.c + properties_rw.c theme_view.c ) link_directories( ${X11_T2C_LIBRARY_DIRS} ${GLIB2_LIBRARY_DIRS} @@ -35,11 +36,16 @@ ${GTHREAD2_LIBRARIES} ${GTK2_LIBRARIES} ) +if ( NOT DATADIR ) + set( DATADIR share ) +endif( NOT DATADIR ) + add_definitions( -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" ) set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -pthread" ) set_target_properties( tint2conf PROPERTIES LINK_FLAGS "-pthread" ) install( TARGETS tint2conf DESTINATION bin ) install( PROGRAMS tintwizard.py DESTINATION bin ) -install( FILES tint2conf.png tint2conf.svg DESTINATION share/pixmaps ) -install( FILES tint2conf.desktop DESTINATION share/applications ) +install( FILES taskbar.svg DESTINATION ${DATADIR}/icons/hicolor/scalable/apps ) +install( FILES tint2conf.desktop DESTINATION ${DATADIR}/applications ) +install( CODE "execute_process(COMMAND gtk-update-icon-cache -f -t ${DATADIR}/icons/hicolor WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" ) diff -Naur tint2-0.11/src/tint2conf/main.c tint2-svn/src/tint2conf/main.c --- tint2-0.11/src/tint2conf/main.c 2010-06-16 17:11:43.000000000 +0200 +++ tint2-svn/src/tint2conf/main.c 2014-01-10 16:11:03.033389211 +0100 @@ -2,7 +2,7 @@ * * Tint2conf * -* Copyright (C) 2009 Thierry lorthiois (lorthiois@bbsoft.fr) +* Copyright (C) 2009 Thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -24,6 +24,7 @@ #include "common.h" #include "theme_view.h" #include "properties.h" +#include "properties_rw.h" #define SNAPSHOT_TICK 190 @@ -77,15 +78,15 @@ " " " " " " -// " " -// " " + " " + " " " " " " " " " " " " -// " " -// " " + " " + " " " " " " " " @@ -132,6 +133,11 @@ g_thread_init( NULL ); read_config(); initTheme(); + g_set_application_name (_("tint2conf")); + gtk_window_set_default_icon_name("taskbar"); + + // config file use '.' as decimal separator + setlocale(LC_NUMERIC, "POSIX"); // define main layout : container, menubar, toolbar g_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -164,10 +170,6 @@ // load themes load_theme(g_theme_view); - /* temporaire !!!!!!!!!!!!!! - GtkWidget *prop = create_properties(); - gtk_window_present(GTK_WINDOW(prop)); - //*/ gtk_widget_show_all(g_window); gtk_main (); return 0; @@ -189,7 +191,7 @@ "comments", _("Theming tool for tint2 panel"), "version", VERSION_STRING, "copyright", _("Copyright 2009 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU GPL version 3"), - "logo-icon-name", NULL, "authors", authors, + "logo-icon-name", "taskbar", "authors", authors, /* Translators: translate "translator-credits" as your name to have it appear in the credits in the "About" dialog */ @@ -329,22 +331,24 @@ GtkTreeSelection *sel; GtkTreeIter iter; GtkTreeModel *model; - char *file, *cmd; + char *file; sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1); -/* +//* GtkWidget *prop; prop = create_properties(); + config_read_file(file); gtk_window_present(GTK_WINDOW(prop)); //printf("menuProperties : fin\n"); -*/ - - cmd = g_strdup_printf("%s \'%s\' &", g_cmd_property, file); +//*/ +/* + char *cmd = g_strdup_printf("%s \'%s\' &", g_cmd_property, file); printf("cmd %s\n", cmd); system(cmd); g_free(cmd); + //*/ g_free(file); } @@ -580,7 +584,7 @@ } g_width = 500; g_height = 350; - g_cmd_property = g_strconcat( "python ", INSTALL_PREFIX, "/bin/tintwizard.py", (void*)0 ); + g_cmd_property = g_strconcat( "/usr/bin/env python ", INSTALL_PREFIX, "/bin/tintwizard.py", (void*)0 ); // load config path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL); diff -Naur tint2-0.11/src/tint2conf/properties.c tint2-svn/src/tint2conf/properties.c --- tint2-0.11/src/tint2conf/properties.c 2010-06-16 17:11:43.000000000 +0200 +++ tint2-svn/src/tint2conf/properties.c 2014-01-10 16:11:03.034389230 +0100 @@ -1,3 +1,21 @@ +/************************************************************************** +* +* Tint2conf +* +* Copyright (C) 2009 Thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**************************************************************************/ #include "main.h" #include "properties.h" @@ -9,6 +27,8 @@ void change_paragraph(GtkWidget *widget); void create_general(GtkWidget *parent); void create_panel(GtkWidget *parent); +void create_panel_items(GtkWidget *parent); +void create_launcher(GtkWidget *parent); void create_taskbar(GtkWidget *parent); void create_task(GtkWidget *parent); void create_clock(GtkWidget *parent); @@ -22,14 +42,14 @@ { GtkWidget *view, *dialog_vbox3, *button, *notebook; GtkTooltips *tooltips; - GtkWidget *page_panel, *page_taskbar, *page_battery, *page_clock, *page_tooltip, *page_systemtray, *page_task, *page_background; + GtkWidget *page_panel, *page_panel_items, *page_launcher, *page_taskbar, *page_battery, *page_clock, *page_tooltip, *page_systemtray, *page_task, *page_background; GtkWidget *label; tooltips = gtk_tooltips_new (); // global layer view = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (view), _("Preferences")); + gtk_window_set_title (GTK_WINDOW (view), _("Properties")); gtk_window_set_modal (GTK_WINDOW (view), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (view), TRUE); gtk_window_set_type_hint (GTK_WINDOW (view), GDK_WINDOW_TYPE_HINT_DIALOG); @@ -59,15 +79,6 @@ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); // notebook - /* - label = gtk_label_new (_("General")); - gtk_widget_show (label); - page_general = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); - gtk_container_set_border_width(GTK_CONTAINER(page_general), 10); - gtk_widget_show (page_general); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page_general, label); - create_general(page_general); -*/ label = gtk_label_new (_("Panel")); gtk_widget_show (label); page_panel = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); @@ -76,6 +87,22 @@ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page_panel, label); create_panel(page_panel); + label = gtk_label_new (_("Panel items")); + gtk_widget_show (label); + page_panel_items = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_panel_items), 10); + gtk_widget_show (page_panel_items); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page_panel_items, label); + create_panel_items(page_panel_items); + + label = gtk_label_new (_("Launcher")); + gtk_widget_show (label); + page_launcher = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); + gtk_container_set_border_width(GTK_CONTAINER(page_launcher), 10); + gtk_widget_show (page_launcher); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page_launcher, label); + create_launcher(page_launcher); + label = gtk_label_new (_("Taskbar")); gtk_widget_show (label); page_taskbar = gtk_vbox_new (FALSE, DEFAULT_HOR_SPACING); @@ -132,7 +159,6 @@ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page_background, label); create_background(page_background); -printf("create_properties : fin\n"); return view; } @@ -147,17 +173,11 @@ } -void create_general(GtkWidget *parent) -{ -} - - void create_panel(GtkWidget *parent) { int i; GtkWidget *screen_position[12]; GtkWidget *table, *hbox, *frame; - GtkWidget *margin_x, *margin_y, *combo_strut_policy, *combo_layer, *combo_width_type, *combo_height_type, *combo_monitor, *combo_background; GtkWidget *label; label = gtk_label_new (_("Position and size")); @@ -165,70 +185,83 @@ gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - hbox = gtk_hbox_new (FALSE, 20); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 0); - - table = gtk_table_new (2, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + hbox = gtk_hbox_new (FALSE, 20); + gtk_widget_show (hbox); + gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 0); + + // left marging + table = gtk_table_new (2, 1, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + table = gtk_table_new (3, 8, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); label = gtk_label_new (_("Width")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 9000, 1); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - - combo_width_type = gtk_combo_box_new_text (); - gtk_widget_show (combo_width_type); - gtk_table_attach (GTK_TABLE (table), combo_width_type, 4, 5, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_width_type), _("Percent")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_width_type), _("Pixels")); + panel_width = gtk_spin_button_new_with_range (0, 9000, 1); + gtk_widget_show (panel_width); + gtk_table_attach (GTK_TABLE (table), panel_width, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + panel_combo_width_type = gtk_combo_box_new_text (); + gtk_widget_show (panel_combo_width_type); + gtk_table_attach (GTK_TABLE (table), panel_combo_width_type, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_width_type), _("Percent")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_width_type), _("Pixels")); label = gtk_label_new (_("Marging x")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 8, 9, 0, 1, GTK_FILL, 0, 0, 0); + panel_margin_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (panel_margin_x); + gtk_entry_set_max_length (GTK_ENTRY (panel_margin_x), 3); + gtk_table_attach (GTK_TABLE (table), panel_margin_x, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Height")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 9000, 1); - gtk_widget_show (margin_y); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - - combo_height_type = gtk_combo_box_new_text (); - gtk_widget_show (combo_height_type); - gtk_table_attach (GTK_TABLE (table), combo_height_type, 4, 5, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_height_type), _("Percent")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_height_type), _("Pixels")); + panel_height = gtk_spin_button_new_with_range (0, 9000, 1); + gtk_widget_show (panel_height); + gtk_table_attach (GTK_TABLE (table), panel_height, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + change_paragraph(parent); + + panel_combo_height_type = gtk_combo_box_new_text (); + gtk_widget_show (panel_combo_height_type); + gtk_table_attach (GTK_TABLE (table), panel_combo_height_type, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_height_type), _("Percent")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_height_type), _("Pixels")); label = gtk_label_new (_("Marging y")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + panel_margin_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (panel_margin_y); + gtk_entry_set_max_length (GTK_ENTRY (panel_margin_y), 3); + gtk_table_attach (GTK_TABLE (table), panel_margin_y, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + + frame = gtk_frame_new (NULL); + gtk_widget_show (frame); + gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); - margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_y); - gtk_entry_set_max_length (GTK_ENTRY (margin_y), 3); - gtk_table_attach (GTK_TABLE (table), margin_y, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); - - table = gtk_table_new (5, 5, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); - + table = gtk_table_new (5, 5, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); for (i = 0; i < 12; ++i) { screen_position[i] = gtk_toggle_button_new (); gtk_widget_show (screen_position[i]); @@ -254,32 +287,88 @@ gtk_table_attach_defaults (GTK_TABLE (table), screen_position[10], 2, 3, 4, 5); gtk_table_attach_defaults (GTK_TABLE (table), screen_position[11], 3, 4, 4, 5); - frame = gtk_frame_new (NULL); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); + label = gtk_label_new (_("Autohide")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_widget_show (label); + gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); + + table = gtk_table_new (2, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + label = gtk_label_new (_("Autohide")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + panel_autohide = gtk_check_button_new (); + gtk_widget_show (panel_autohide); + gtk_table_attach (GTK_TABLE (table), panel_autohide, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Show panel after")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + panel_autohide_show_time = gtk_spin_button_new_with_range (0, 10000, 0.1); + gtk_widget_show (panel_autohide_show_time); + gtk_table_attach (GTK_TABLE (table), panel_autohide_show_time, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("seconds")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 8, 9, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Hidden size")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + panel_autohide_size = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (panel_autohide_size); + gtk_entry_set_max_length (GTK_ENTRY (panel_autohide_size), 3); + gtk_table_attach (GTK_TABLE (table), panel_autohide_size, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Hide panel after")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + panel_autohide_hide_time = gtk_spin_button_new_with_range (0, 10000, 0.1); + gtk_widget_show (panel_autohide_hide_time); + gtk_table_attach (GTK_TABLE (table), panel_autohide_hide_time, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("seconds")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); + change_paragraph(parent); + label = gtk_label_new (_("Appearance")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Padding horizontal")); + label = gtk_label_new (_("Horizontal padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + panel_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (panel_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (panel_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), panel_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Background")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); @@ -289,160 +378,221 @@ combo_background = gtk_combo_box_new_text (); gtk_widget_show (combo_background); gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 3")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - label = gtk_label_new (_("Padding vertical")); + label = gtk_label_new (_("Vertical padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_y); - gtk_entry_set_max_length (GTK_ENTRY (margin_y), 3); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + panel_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (panel_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (panel_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), panel_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Spacing")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + panel_spacing = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (panel_spacing); + gtk_entry_set_max_length (GTK_ENTRY (panel_spacing), 3); + gtk_table_attach (GTK_TABLE (table), panel_spacing, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Autohide")); + label = gtk_label_new (_("Window manager")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 12, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Autohide")); + label = gtk_label_new (_("Show WM menu")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + panel_wm_menu = gtk_check_button_new (); + gtk_widget_show (panel_wm_menu); + gtk_entry_set_max_length (GTK_ENTRY (panel_wm_menu), 3); + gtk_table_attach (GTK_TABLE (table), panel_wm_menu, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Show panel after")); + label = gtk_label_new (_("Place in dock")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + panel_dock = gtk_check_button_new (); + gtk_widget_show (panel_dock); + gtk_entry_set_max_length (GTK_ENTRY (panel_dock), 3); + gtk_table_attach (GTK_TABLE (table), panel_dock, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Panel's layer")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 10000, 0.1); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + panel_combo_layer = gtk_combo_box_new_text (); + gtk_widget_show (panel_combo_layer); + gtk_entry_set_max_length (GTK_ENTRY (panel_combo_layer), 3); + gtk_table_attach (GTK_TABLE (table), panel_combo_layer, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_layer), _("Top")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_layer), _("Normal")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_layer), _("Bottom")); - label = gtk_label_new (_("seconds")); + label = gtk_label_new (_("Maximized window")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 8, 9, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + panel_combo_strut_policy = gtk_combo_box_new_text (); + gtk_widget_show (panel_combo_strut_policy); + gtk_entry_set_max_length (GTK_ENTRY (panel_combo_strut_policy), 3); + gtk_table_attach (GTK_TABLE (table), panel_combo_strut_policy, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_strut_policy), _("Follow panel size")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_strut_policy), _("Follow hidden size")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_strut_policy), _("Full screen")); - label = gtk_label_new (_("Hidden height")); + label = gtk_label_new (_("Monitor")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + panel_combo_monitor = gtk_combo_box_new_text (); + gtk_widget_show (panel_combo_monitor); + gtk_table_attach (GTK_TABLE (table), panel_combo_monitor, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("All")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("3")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("4")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("5")); + gtk_combo_box_append_text (GTK_COMBO_BOX (panel_combo_monitor), _("6")); - label = gtk_label_new (_("Hide panel after")); + change_paragraph(parent); +} + + +void create_panel_items(GtkWidget *parent) +{ + GtkWidget *table, *label; + + table = gtk_table_new (2, 2, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + label = gtk_label_new (_("Items order")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 10000, 0.1); - gtk_widget_show (margin_y); - gtk_table_attach (GTK_TABLE (table), margin_y, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + items_order = gtk_entry_new (); + gtk_widget_show (items_order); + gtk_entry_set_width_chars (GTK_ENTRY (items_order), 15); + gtk_table_attach (GTK_TABLE (table), items_order, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("seconds")); + change_paragraph(parent); +} + + +void create_launcher(GtkWidget *parent) +{ + GtkWidget *table, *label; + + label = gtk_label_new (_("Applications")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); + gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); change_paragraph(parent); - - label = gtk_label_new (_("Window manager")); + + label = gtk_label_new (_("Appearance")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 12, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (6, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - - label = gtk_label_new (_("WM menu")); + + label = gtk_label_new (_("Horizontal padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + launcher_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (launcher_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (launcher_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), launcher_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Place in dock")); + label = gtk_label_new (_("Vertical padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + launcher_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (launcher_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (launcher_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), launcher_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Layer")); + label = gtk_label_new (_("Spacing")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + + launcher_spacing = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (launcher_spacing); + gtk_entry_set_max_length (GTK_ENTRY (launcher_spacing), 3); + gtk_table_attach (GTK_TABLE (table), launcher_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Background")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - combo_layer = gtk_combo_box_new_text (); - gtk_widget_show (combo_layer); - gtk_entry_set_max_length (GTK_ENTRY (combo_layer), 3); - gtk_table_attach (GTK_TABLE (table), combo_layer, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_layer), _("Top")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_layer), _("Normal")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_layer), _("Bottom")); + combo_background = gtk_combo_box_new_text (); + gtk_widget_show (combo_background); + gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - label = gtk_label_new (_("Strut policy")); + label = gtk_label_new (_("Icon size")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - combo_strut_policy = gtk_combo_box_new_text (); - gtk_widget_show (combo_strut_policy); - gtk_entry_set_max_length (GTK_ENTRY (combo_strut_policy), 3); - gtk_table_attach (GTK_TABLE (table), combo_strut_policy, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_strut_policy), _("Follow size")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_strut_policy), _("Minimum")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_strut_policy), _("None")); + launcher_icon_size = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (launcher_icon_size); + gtk_entry_set_max_length (GTK_ENTRY (launcher_icon_size), 3); + gtk_table_attach (GTK_TABLE (table), launcher_icon_size, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Monitor")); + label = gtk_label_new (_("Icon theme")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - combo_monitor = gtk_combo_box_new_text (); - gtk_widget_show (combo_monitor); - gtk_table_attach (GTK_TABLE (table), combo_monitor, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_monitor), _("All")); + launcher_icon_theme = gtk_combo_box_new_text (); + gtk_widget_show (launcher_icon_theme); + gtk_table_attach (GTK_TABLE (table), launcher_icon_theme, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (launcher_icon_theme), _("Theme 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (launcher_icon_theme), _("Theme 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (launcher_icon_theme), _("Theme 3")); change_paragraph(parent); } @@ -451,11 +601,10 @@ void create_taskbar(GtkWidget *parent) { GtkWidget *table, *label; - GtkWidget *margin_x, *margin_y, *combo_background; - table = gtk_table_new (1, 2, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 2, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); @@ -464,78 +613,166 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + taskbar_show_desktop = gtk_check_button_new (); + gtk_widget_show (taskbar_show_desktop); + gtk_entry_set_max_length (GTK_ENTRY (taskbar_show_desktop), 3); + gtk_table_attach (GTK_TABLE (table), taskbar_show_desktop, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Show taskbar name")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); + + taskbar_show_name = gtk_check_button_new (); + gtk_widget_show (taskbar_show_name); + gtk_entry_set_max_length (GTK_ENTRY (taskbar_show_name), 3); + gtk_table_attach (GTK_TABLE (table), taskbar_show_name, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); - label = gtk_label_new (_("Appearance")); + label = gtk_label_new (_("Taskbar Appearance")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 12, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (3, 12, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Padding horizontal")); + label = gtk_label_new (_("Horizontal padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + taskbar_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (taskbar_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (taskbar_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), taskbar_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Vertical padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + taskbar_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (taskbar_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (taskbar_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), taskbar_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Spacing")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + + taskbar_spacing = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (taskbar_spacing); + gtk_entry_set_max_length (GTK_ENTRY (taskbar_spacing), 3); + gtk_table_attach (GTK_TABLE (table), taskbar_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Inactive background")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + combo_background = gtk_combo_box_new_text (); + gtk_widget_show (combo_background); + gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - label = gtk_label_new (_("Background inactive")); + label = gtk_label_new (_("Active background")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); combo_background = gtk_combo_box_new_text (); gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 3")); + gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + + change_paragraph(parent); + + label = gtk_label_new (_("Name appearance")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_widget_show (label); + gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); + + table = gtk_table_new (6, 22, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + label = gtk_label_new (_("Horizontal padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + taskbar_name_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (taskbar_name_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (taskbar_name_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), taskbar_name_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Padding vertical")); + label = gtk_label_new (_("Inactive font color")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_y); - gtk_entry_set_max_length (GTK_ENTRY (margin_y), 3); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + taskbar_name_inactive_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color), TRUE); + gtk_widget_show (taskbar_name_inactive_color); + gtk_table_attach (GTK_TABLE (table), taskbar_name_inactive_color, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Background active")); + label = gtk_label_new (_("Active font color")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 10, 11, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + + taskbar_name_active_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color), TRUE); + gtk_widget_show (taskbar_name_active_color); + gtk_table_attach (GTK_TABLE (table), taskbar_name_active_color, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Font")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + taskbar_name_font = gtk_font_button_new (); + gtk_widget_show (taskbar_name_font); + gtk_table_attach (GTK_TABLE (table), taskbar_name_font, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); + //gtk_font_button_set_show_style (GTK_FONT_BUTTON (taskbar_name_font), FALSE); + + label = gtk_label_new (_("Inactive background")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); combo_background = gtk_combo_box_new_text (); gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 11, 12, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 3")); + gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + + label = gtk_label_new (_("Active background")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + + combo_background = gtk_combo_box_new_text (); + gtk_widget_show (combo_background); + gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); change_paragraph(parent); } @@ -544,7 +781,6 @@ void create_task(GtkWidget *parent) { GtkWidget *table, *label, *notebook, *page_task; - GtkWidget *margin_x, *combo_background; label = gtk_label_new (_("Mouse action")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); @@ -552,9 +788,9 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); @@ -563,76 +799,80 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("None")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Close")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Shade")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Maximize restore")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Desktop left")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Next task")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Previous task")); + task_mouse_middle = gtk_combo_box_new_text (); + gtk_widget_show (task_mouse_middle); + gtk_table_attach (GTK_TABLE (table), task_mouse_middle, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("None")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Close")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Toggle")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("sShade")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Toggle or iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Maximize or restore")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Desktop left")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Desktop right")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Next task")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_middle), _("Previous task")); label = gtk_label_new (_("Wheel scroll up")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("None")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Close")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Shade")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Maximize restore")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Desktop left")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Next task")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Previous task")); + task_mouse_scroll_up = gtk_combo_box_new_text (); + gtk_widget_show (task_mouse_scroll_up); + gtk_table_attach (GTK_TABLE (table), task_mouse_scroll_up, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("None")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Close")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Toggle")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Shade")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Toggle or iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Maximize or restore")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Desktop left")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Desktop right")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Next task")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_up), _("Previous task")); label = gtk_label_new (_("Right click")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("None")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Close")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Shade")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Maximize restore")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Desktop left")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Next task")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Previous task")); + task_mouse_right = gtk_combo_box_new_text (); + gtk_widget_show (task_mouse_right); + gtk_table_attach (GTK_TABLE (table), task_mouse_right, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("None")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Close")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Toggle")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Shade")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Toggle or iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Maximize or restore")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Desktop left")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Desktop right")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Next task")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_right), _("Previous task")); label = gtk_label_new (_("Wheel scroll down")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("None")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Close")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Shade")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Toggle iconify")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Maximize restore")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Desktop left")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Next task")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Previous task")); + task_mouse_scroll_down = gtk_combo_box_new_text (); + gtk_widget_show (task_mouse_scroll_down); + gtk_table_attach (GTK_TABLE (table), task_mouse_scroll_down, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("None")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Close")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Toggle")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Shade")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Toggle or iconify")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Maximize or restore")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Desktop left")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Desktop right")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Next task")); + gtk_combo_box_append_text (GTK_COMBO_BOX (task_mouse_scroll_down), _("Previous task")); change_paragraph(parent); @@ -642,9 +882,9 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (4, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (4, 13, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); @@ -653,40 +893,86 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + task_show_icon = gtk_check_button_new (); + gtk_widget_show (task_show_icon); + gtk_entry_set_max_length (GTK_ENTRY (task_show_icon), 3); + gtk_table_attach (GTK_TABLE (table), task_show_icon, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Show text")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + task_show_text = gtk_check_button_new (); + gtk_widget_show (task_show_text); + gtk_entry_set_max_length (GTK_ENTRY (task_show_text), 3); + gtk_table_attach (GTK_TABLE (table), task_show_text, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Align center")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + task_align_center = gtk_check_button_new (); + gtk_widget_show (task_align_center); + gtk_entry_set_max_length (GTK_ENTRY (task_align_center), 3); + gtk_table_attach (GTK_TABLE (table), task_align_center, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Font shadow")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); + task_font_shadow = gtk_check_button_new (); + gtk_widget_show (task_font_shadow); + gtk_entry_set_max_length (GTK_ENTRY (task_font_shadow), 3); + gtk_table_attach (GTK_TABLE (table), task_font_shadow, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Maximum width")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + task_maximum_width = gtk_spin_button_new_with_range (0, 9000, 1); + gtk_widget_show (task_maximum_width); + gtk_table_attach (GTK_TABLE (table), task_maximum_width, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Maximum height")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + task_maximum_height = gtk_spin_button_new_with_range (0, 9000, 1); + gtk_widget_show (task_maximum_height); + gtk_table_attach (GTK_TABLE (table), task_maximum_height, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Horizontal padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + + task_padding_x = gtk_spin_button_new_with_range (0, 9000, 1); + gtk_widget_show (task_padding_x); + gtk_table_attach (GTK_TABLE (table), task_padding_x, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Vertical padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 3, 4, GTK_FILL, 0, 0, 0); + + task_padding_y = gtk_spin_button_new_with_range (0, 9000, 1); + gtk_widget_show (task_padding_y); + gtk_table_attach (GTK_TABLE (table), task_padding_y, 7, 8, 3, 4, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Font")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 10, 11, 0, 1, GTK_FILL, 0, 0, 0); + + task_font = gtk_font_button_new (); + gtk_widget_show (task_font); + gtk_table_attach (GTK_TABLE (table), task_font, 11, 12, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style (GTK_FONT_BUTTON (task_font), FALSE); // tasks notebook = gtk_notebook_new (); @@ -728,30 +1014,66 @@ void create_clock(GtkWidget *parent) { GtkWidget *table; - GtkWidget *margin_x, *margin_y, *combo_background; GtkWidget *label; - table = gtk_table_new (1, 2, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (1, 2, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Show clock")); +// change_paragraph(parent); + + label = gtk_label_new (_("Format and timezone")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); + gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); + + table = gtk_table_new (3, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + label = gtk_label_new (_("First line format")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + clock_format_line1 = gtk_entry_new (); + gtk_widget_show (clock_format_line1); + gtk_entry_set_width_chars (GTK_ENTRY (clock_format_line1), 16); + gtk_table_attach (GTK_TABLE (table), clock_format_line1, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - change_paragraph(parent); + label = gtk_label_new (_("Second line format")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Format and timezone")); + clock_format_line2 = gtk_entry_new (); + gtk_widget_show (clock_format_line2); + gtk_entry_set_width_chars (GTK_ENTRY (clock_format_line2), 16); + gtk_table_attach (GTK_TABLE (table), clock_format_line2, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("First line timezone")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); - gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + clock_tmz_line1 = gtk_entry_new (); + gtk_widget_show (clock_tmz_line1); + gtk_entry_set_width_chars (GTK_ENTRY (clock_tmz_line1), 16); + gtk_table_attach (GTK_TABLE (table), clock_tmz_line1, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Second line timezone")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + clock_tmz_line2 = gtk_entry_new (); + gtk_widget_show (clock_tmz_line2); + gtk_entry_set_width_chars (GTK_ENTRY (clock_tmz_line2), 16); + gtk_table_attach (GTK_TABLE (table), clock_tmz_line2, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); change_paragraph(parent); @@ -761,6 +1083,32 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); + table = gtk_table_new (2, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + label = gtk_label_new (_("Left click command")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + clock_left_command = gtk_entry_new (); + gtk_widget_show (clock_left_command); + gtk_entry_set_width_chars (GTK_ENTRY (clock_left_command), 16); + gtk_table_attach (GTK_TABLE (table), clock_left_command, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Right click command")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + clock_right_command = gtk_entry_new (); + gtk_widget_show (clock_right_command); + gtk_entry_set_width_chars (GTK_ENTRY (clock_right_command), 16); + gtk_table_attach (GTK_TABLE (table), clock_right_command, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + change_paragraph(parent); label = gtk_label_new (_("Appearance")); @@ -769,63 +1117,73 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (3, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (3, 22, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Padding horizontal")); + label = gtk_label_new (_("Horizontal padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + clock_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (clock_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (clock_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), clock_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Vertical padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + clock_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (clock_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (clock_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), clock_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Background")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); combo_background = gtk_combo_box_new_text (); gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 3")); + gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - label = gtk_label_new (_("Padding vertical")); + label = gtk_label_new (_("Font first line")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_y); - gtk_entry_set_max_length (GTK_ENTRY (margin_y), 3); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + clock_font_line1 = gtk_font_button_new (); + gtk_widget_show (clock_font_line1); + gtk_table_attach (GTK_TABLE (table), clock_font_line1, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style (GTK_FONT_BUTTON (clock_font_line1), FALSE); - label = gtk_label_new (_("Font color")); + label = gtk_label_new (_("Font second line")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(margin_x), TRUE); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + clock_font_line2 = gtk_font_button_new (); + gtk_widget_show (clock_font_line2); + gtk_table_attach (GTK_TABLE (table), clock_font_line2, 7, 22, 1, 2, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style (GTK_FONT_BUTTON (clock_font_line2), FALSE); - label = gtk_label_new (_("Font")); + label = gtk_label_new (_("Font color")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + clock_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(clock_font_color), TRUE); + gtk_widget_show (clock_font_color); + gtk_table_attach (GTK_TABLE (table), clock_font_color, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); change_paragraph(parent); } @@ -834,51 +1192,135 @@ void create_systemtray(GtkWidget *parent) { GtkWidget *table; - GtkWidget *margin_x; GtkWidget *label; - table = gtk_table_new (1, 2, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 2, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Show notification")); + label = gtk_label_new (_("Icon ordering")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + systray_icon_order = gtk_combo_box_new_text (); + gtk_widget_show (systray_icon_order); + gtk_table_attach (GTK_TABLE (table), systray_icon_order, 1, 2, 1, 2, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (systray_icon_order), _("Ascending")); + gtk_combo_box_append_text (GTK_COMBO_BOX (systray_icon_order), _("Descending")); + gtk_combo_box_append_text (GTK_COMBO_BOX (systray_icon_order), _("Left to right")); + gtk_combo_box_append_text (GTK_COMBO_BOX (systray_icon_order), _("Right to left")); change_paragraph(parent); -} - - -void create_battery(GtkWidget *parent) -{ - GtkWidget *table; - GtkWidget *margin_x, *margin_y, *combo_background; - GtkWidget *label; + label = gtk_label_new (_("Appearance")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_widget_show (label); + gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (1, 2, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (6, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); + + label = gtk_label_new (_("Horizontal padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + systray_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (systray_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (systray_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), systray_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Show battery")); + label = gtk_label_new (_("Vertical padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + systray_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (systray_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (systray_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), systray_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - change_paragraph(parent); + label = gtk_label_new (_("Spacing")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + + systray_spacing = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (systray_spacing); + gtk_entry_set_max_length (GTK_ENTRY (systray_spacing), 3); + gtk_table_attach (GTK_TABLE (table), systray_spacing, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Background")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); + + combo_background = gtk_combo_box_new_text (); + gtk_widget_show (combo_background); + gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); + + label = gtk_label_new (_("Icon size")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + + systray_icon_size = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (systray_icon_size); + gtk_entry_set_max_length (GTK_ENTRY (systray_icon_size), 3); + gtk_table_attach (GTK_TABLE (table), systray_icon_size, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Icon opacity")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + + systray_icon_opacity = gtk_spin_button_new_with_range (0, 100, 1); + gtk_widget_show (systray_icon_opacity); + gtk_entry_set_max_length (GTK_ENTRY (systray_icon_opacity), 3); + gtk_table_attach (GTK_TABLE (table), systray_icon_opacity, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Icon saturation")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + + systray_icon_saturation = gtk_spin_button_new_with_range (-100, 100, 1); + gtk_widget_show (systray_icon_saturation); + gtk_entry_set_max_length (GTK_ENTRY (systray_icon_saturation), 4); + gtk_table_attach (GTK_TABLE (table), systray_icon_saturation, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Icon brightness")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 3, 4, GTK_FILL, 0, 0, 0); + + systray_icon_brightness = gtk_spin_button_new_with_range (-100, 100, 1); + gtk_widget_show (systray_icon_brightness); + gtk_entry_set_max_length (GTK_ENTRY (systray_icon_brightness), 4); + gtk_table_attach (GTK_TABLE (table), systray_icon_brightness, 7, 8, 3, 4, GTK_FILL, 0, 0, 0); + +} + + +void create_battery(GtkWidget *parent) +{ + GtkWidget *table, *label; + + table = gtk_table_new (1, 2, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); label = gtk_label_new (_("Event")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); @@ -886,9 +1328,9 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); @@ -897,10 +1339,10 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 100, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + battery_hide_if_higher = gtk_spin_button_new_with_range (0, 101, 1); + gtk_widget_show (battery_hide_if_higher); + gtk_entry_set_max_length (GTK_ENTRY (battery_hide_if_higher), 3); + gtk_table_attach (GTK_TABLE (table), battery_hide_if_higher, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("%")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); @@ -912,16 +1354,27 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 100, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + battery_alert_if_lower = gtk_spin_button_new_with_range (0, 100, 1); + gtk_widget_show (battery_alert_if_lower); + gtk_entry_set_max_length (GTK_ENTRY (battery_alert_if_lower), 3); + gtk_table_attach (GTK_TABLE (table), battery_alert_if_lower, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("%")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 4, 5, 1, 2, GTK_FILL, 0, 0, 0); + label = gtk_label_new (_("Alert command")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + + battery_alert_cmd = gtk_entry_new (); + gtk_widget_show (battery_alert_cmd); + gtk_entry_set_width_chars (GTK_ENTRY (battery_alert_cmd), 28); + gtk_table_attach (GTK_TABLE (table), battery_alert_cmd, 8, 9, 1, 2, GTK_FILL, 0, 0, 0); + + change_paragraph(parent); label = gtk_label_new (_("Appearance")); @@ -930,73 +1383,73 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (4, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (4, 22, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Padding horizontal")); + label = gtk_label_new (_("Horizontal padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + battery_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (battery_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (battery_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), battery_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Background")); + label = gtk_label_new (_("Vertical padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - combo_background = gtk_combo_box_new_text (); - gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 3")); + battery_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (battery_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (battery_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), battery_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Padding vertical")); + label = gtk_label_new (_("Background")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_y); - gtk_entry_set_max_length (GTK_ENTRY (margin_y), 3); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + combo_background = gtk_combo_box_new_text (); + gtk_widget_show (combo_background); + gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - label = gtk_label_new (_("Font color")); + label = gtk_label_new (_("Font first line")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(margin_x), TRUE); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); + battery_font_line1 = gtk_font_button_new (); + gtk_widget_show (battery_font_line1); + gtk_table_attach (GTK_TABLE (table), battery_font_line1, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style (GTK_FONT_BUTTON (battery_font_line1), FALSE); - label = gtk_label_new (_("Font first line")); + label = gtk_label_new (_("Font second line")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + battery_font_line2 = gtk_font_button_new (); + gtk_widget_show (battery_font_line2); + gtk_table_attach (GTK_TABLE (table), battery_font_line2, 7, 22, 1, 2, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style (GTK_FONT_BUTTON (battery_font_line2), FALSE); - label = gtk_label_new (_("Font second line")); + label = gtk_label_new (_("Font color")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); + battery_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(battery_font_color), TRUE); + gtk_widget_show (battery_font_color); + gtk_table_attach (GTK_TABLE (table), battery_font_color, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); change_paragraph(parent); } @@ -1005,12 +1458,11 @@ void create_tooltip(GtkWidget *parent) { GtkWidget *table; - GtkWidget *margin_x, *margin_y, *combo_background; GtkWidget *label; - table = gtk_table_new (1, 2, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (1, 2, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); @@ -1019,9 +1471,9 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_check_button_new (); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); + tooltip_task_show = gtk_check_button_new (); + gtk_widget_show (tooltip_task_show); + gtk_table_attach (GTK_TABLE (table), tooltip_task_show, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); change_paragraph(parent); @@ -1031,9 +1483,9 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (2, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (2, 22, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); @@ -1042,9 +1494,9 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 10000, 0.1); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + tooltip_show_after = gtk_spin_button_new_with_range (0, 10000, 0.1); + gtk_widget_show (tooltip_show_after); + gtk_table_attach (GTK_TABLE (table), tooltip_show_after, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("seconds")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); @@ -1056,9 +1508,9 @@ gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 10000, 0.1); - gtk_widget_show (margin_y); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + tooltip_hide_after = gtk_spin_button_new_with_range (0, 10000, 0.1); + gtk_widget_show (tooltip_hide_after); + gtk_table_attach (GTK_TABLE (table), tooltip_hide_after, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("seconds")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); @@ -1073,70 +1525,105 @@ gtk_widget_show (label); gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - table = gtk_table_new (3, 10, FALSE); - gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + table = gtk_table_new (3, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - label = gtk_label_new (_("Padding horizontal")); + label = gtk_label_new (_("Horizontal padding")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + tooltip_padding_x = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (tooltip_padding_x); + gtk_entry_set_max_length (GTK_ENTRY (tooltip_padding_x), 3); + gtk_table_attach (GTK_TABLE (table), tooltip_padding_x, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Vertical padding")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + tooltip_padding_y = gtk_spin_button_new_with_range (0, 500, 1); + gtk_widget_show (tooltip_padding_y); + gtk_entry_set_max_length (GTK_ENTRY (tooltip_padding_y), 3); + gtk_table_attach (GTK_TABLE (table), tooltip_padding_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); label = gtk_label_new (_("Background")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); combo_background = gtk_combo_box_new_text (); gtk_widget_show (combo_background); - gtk_table_attach (GTK_TABLE (table), combo_background, 7, 8, 0, 1, GTK_FILL, 0, 0, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 1")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 2")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Back 3")); + gtk_table_attach (GTK_TABLE (table), combo_background, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 1")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 2")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_background), _("Id 3")); - label = gtk_label_new (_("Padding vertical")); + label = gtk_label_new (_("Font")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 0, 1, GTK_FILL, 0, 0, 0); - margin_y = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_y); - gtk_entry_set_max_length (GTK_ENTRY (margin_y), 3); - gtk_table_attach (GTK_TABLE (table), margin_y, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + tooltip_font = gtk_font_button_new (); + gtk_widget_show (tooltip_font); + gtk_table_attach (GTK_TABLE (table), tooltip_font, 7, 22, 0, 1, GTK_FILL, 0, 0, 0); +// gtk_font_button_set_show_style (GTK_FONT_BUTTON (tooltip_font), FALSE); label = gtk_label_new (_("Font color")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3, GTK_FILL, 0, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, 6, 7, 1, 2, GTK_FILL, 0, 0, 0); - margin_x = gtk_color_button_new(); - gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(margin_x), TRUE); - gtk_widget_show (margin_x); - gtk_table_attach (GTK_TABLE (table), margin_x, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); + tooltip_font_color = gtk_color_button_new(); + gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(tooltip_font_color), TRUE); + gtk_widget_show (tooltip_font_color); + gtk_table_attach (GTK_TABLE (table), tooltip_font_color, 7, 8, 1, 2, GTK_FILL, 0, 0, 0); - label = gtk_label_new (_("Font")); + change_paragraph(parent); + + label = gtk_label_new (_("Clock tooltip")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); + gtk_box_pack_start(GTK_BOX (parent), label, FALSE, FALSE, 0); - margin_x = gtk_spin_button_new_with_range (0, 500, 1); - gtk_widget_show (margin_x); - gtk_entry_set_max_length (GTK_ENTRY (margin_x), 3); - gtk_table_attach (GTK_TABLE (table), margin_x, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + table = gtk_table_new (3, 10, FALSE); + gtk_widget_show (table); + gtk_box_pack_start (GTK_BOX (parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings (GTK_TABLE (table), ROW_SPACING); + gtk_table_set_col_spacings (GTK_TABLE (table), COL_SPACING); - change_paragraph(parent); + label = gtk_label_new (_("Clock tooltip format")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0); + + clock_format_tooltip = gtk_entry_new (); + gtk_widget_show (clock_format_tooltip); + gtk_entry_set_width_chars (GTK_ENTRY (clock_format_tooltip), 16); + gtk_table_attach (GTK_TABLE (table), clock_format_tooltip, 3, 4, 0, 1, GTK_FILL, 0, 0, 0); + + label = gtk_label_new (_("Clock tooltip timezone")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + + clock_tmz_tooltip = gtk_entry_new (); + gtk_widget_show (clock_tmz_tooltip); + gtk_entry_set_width_chars (GTK_ENTRY (clock_tmz_tooltip), 16); + gtk_table_attach (GTK_TABLE (table), clock_tmz_tooltip, 3, 4, 1, 2, GTK_FILL, 0, 0, 0); + change_paragraph(parent); } void create_background(GtkWidget *parent) { + + change_paragraph(parent); } diff -Naur tint2-0.11/src/tint2conf/properties.h tint2-svn/src/tint2conf/properties.h --- tint2-0.11/src/tint2conf/properties.h 2010-06-13 00:20:03.000000000 +0200 +++ tint2-svn/src/tint2conf/properties.h 2014-01-10 16:11:03.033389211 +0100 @@ -4,6 +4,45 @@ #include +// panel +GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing; +GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, *panel_autohide_size; +GtkWidget *panel_combo_strut_policy, *panel_combo_layer, *panel_combo_width_type, *panel_combo_height_type, *panel_combo_monitor; +GtkWidget *items_order; + +// taskbar +GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing; +GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font; + +// task +GtkWidget *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down; +GtkWidget *task_show_icon, *task_show_text, *task_align_center, *task_font_shadow; +GtkWidget *task_maximum_width, *task_maximum_height, *task_padding_x, *task_padding_y, *task_font; + +// clock +GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2; +GtkWidget *clock_left_command, *clock_right_command; +GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color; + +// battery +GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd; +GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color; + +// systray +GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing; +GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness; + +// tooltip +GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_color; +GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after; +GtkWidget *clock_format_tooltip, *clock_tmz_tooltip; + +// launcher +GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing; + +// background +GtkWidget *combo_background; +GtkWidget *margin_x, *margin_y; GtkWidget *create_properties(); diff -Naur tint2-0.11/src/tint2conf/properties_rw.c tint2-svn/src/tint2conf/properties_rw.c --- tint2-0.11/src/tint2conf/properties_rw.c 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/tint2conf/properties_rw.c 2014-01-10 16:11:03.033389211 +0100 @@ -0,0 +1,565 @@ + +#include +#include +#include +#include + +#include "common.h" +#include "properties.h" +#include "properties_rw.h" + + +void add_entry (char *key, char *value); +void hex2gdk(char *hex, GdkColor *color); +void get_action(char *event, GtkWidget *combo); + + + +void config_read_file (const char *path) +{ + FILE *fp; + char line[512]; + char *key, *value; + + if ((fp = fopen(path, "r")) == NULL) return; + + while (fgets(line, sizeof(line), fp) != NULL) { + if (parse_line(line, &key, &value)) { + add_entry (key, value); + free (key); + free (value); + } + } + fclose (fp); +} + + +void config_save_file(const char *path) { + //printf("config_save_file : %s\n", path); +} + + +void add_entry (char *key, char *value) +{ + char *value1=0, *value2=0, *value3=0; + + /* Background and border */ + if (strcmp (key, "rounded") == 0) { + // 'rounded' is the first parameter => alloc a new background + //Background bg; + //bg.border.rounded = atoi(value); + //g_array_append_val(backgrounds, bg); + } + else if (strcmp (key, "border_width") == 0) { + //g_array_index(backgrounds, Background, backgrounds->len-1).border.width = atoi(value); + } + else if (strcmp (key, "background_color") == 0) { + extract_values(value, &value1, &value2, &value3); + //Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); + //get_color (value1, bg->back.color); + //if (value2) bg->back.alpha = (atoi (value2) / 100.0); + //else bg->back.alpha = 0.5; + } + else if (strcmp (key, "border_color") == 0) { + extract_values(value, &value1, &value2, &value3); + //Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); + //get_color (value1, bg->border.color); + //if (value2) bg->border.alpha = (atoi (value2) / 100.0); + //else bg->border.alpha = 0.5; + } + + /* Panel */ + else if (strcmp (key, "panel_size") == 0) { + extract_values(value, &value1, &value2, &value3); + char *b; + if ((b = strchr (value1, '%'))) { + b[0] = '\0'; + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); + } + else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_width), atof(value1)); + if (atoi(value1) == 0) { + // full width mode + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_width), 100); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_width_type), 0); + } + if ((b = strchr (value2, '%'))) { + b[0] = '\0'; + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 0); + } + else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_height_type), 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_height), atof(value2)); + } + else if (strcmp (key, "panel_items") == 0) { + gtk_entry_set_text(GTK_ENTRY(items_order), value); + } + else if (strcmp (key, "panel_margin") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_x), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_margin_y), atof(value1)); + } + else if (strcmp (key, "panel_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_x), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_padding_y), atof(value2)); + if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_spacing), atof(value3)); + } + else if (strcmp (key, "panel_position") == 0) { + extract_values(value, &value1, &value2, &value3); + /* + if (strcmp (value1, "top") == 0) panel_position = TOP; + else { + if (strcmp (value1, "bottom") == 0) panel_position = BOTTOM; + else panel_position = CENTER; + } + + if (!value2) panel_position |= CENTER; + else { + if (strcmp (value2, "left") == 0) panel_position |= LEFT; + else { + if (strcmp (value2, "right") == 0) panel_position |= RIGHT; + else panel_position |= CENTER; + } + } + if (!value3) panel_horizontal = 1; + else { + if (strcmp (value3, "vertical") == 0) panel_horizontal = 0; + else panel_horizontal = 1; + } + */ + } + else if (strcmp (key, "panel_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "wm_menu") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_wm_menu), atoi(value)); + } + else if (strcmp (key, "panel_dock") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_dock), atoi(value)); + } + else if (strcmp (key, "panel_layer") == 0) { + if (strcmp(value, "bottom") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 2); + else if (strcmp(value, "top") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 0); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1); + } + else if (strcmp (key, "panel_monitor") == 0) { + //panel_config.monitor = config_get_monitor(value); + } + + /* autohide options */ + else if (strcmp(key, "autohide") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_autohide), atoi(value)); + } + else if (strcmp(key, "autohide_show_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_show_time), atof(value)); + } + else if (strcmp(key, "autohide_hide_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_hide_time), atof(value)); + } + else if (strcmp(key, "strut_policy") == 0) { + if (strcmp(value, "follow_size") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 0); + else if (strcmp(value, "none") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 2); + else + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_strut_policy), 1); + } + else if (strcmp(key, "autohide_height") == 0) { + if (atoi(value) == 0) { + // autohide need height > 0 + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), 1); + } + else + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panel_autohide_size), atof(value)); + } + + /* Battery */ + else if (strcmp (key, "battery_low_status") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_alert_if_lower), atof(value)); + } + else if (strcmp (key, "battery_low_cmd") == 0) { + gtk_entry_set_text(GTK_ENTRY(battery_alert_cmd), value); + } + else if (strcmp (key, "bat1_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line1), value); + } + else if (strcmp (key, "bat2_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line2), value); + } + else if (strcmp (key, "battery_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(battery_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(battery_font_color), (alpha*65535)/100); + } + } + else if (strcmp (key, "battery_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_x), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_padding_y), atof(value2)); + } + else if (strcmp (key, "battery_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "battery_hide") == 0) { + int percentage_hide = atoi (value); + if (percentage_hide == 0) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), 101.0); + else + gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), atof(value)); + } + + /* Clock */ + else if (strcmp (key, "time1_format") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_format_line1), value); + } + else if (strcmp (key, "time2_format") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_format_line2), value); + } + else if (strcmp (key, "time1_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line1), value); + } + else if (strcmp(key, "time1_timezone") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_tmz_line1), value); + } + else if (strcmp(key, "time2_timezone") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_tmz_line2), value); + } + else if (strcmp (key, "time2_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(clock_font_line2), value); + } + else if (strcmp (key, "clock_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(clock_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(clock_font_color), (alpha*65535)/100); + } + } + else if (strcmp (key, "clock_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_x), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(clock_padding_y), atof(value2)); + } + else if (strcmp (key, "clock_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.clock.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp(key, "clock_tooltip") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_format_tooltip), value); + } + else if (strcmp(key, "clock_tooltip_timezone") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_tmz_tooltip), value); + } + else if (strcmp(key, "clock_lclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_left_command), value); + } + else if (strcmp(key, "clock_rclick_command") == 0) { + gtk_entry_set_text(GTK_ENTRY(clock_right_command), value); + } + + /* Taskbar */ + else if (strcmp (key, "taskbar_mode") == 0) { + if (strcmp (value, "multi_desktop") == 0) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop), 1); + else + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_desktop), 0); + } + else if (strcmp (key, "taskbar_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_x), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_padding_y), atof(value2)); + if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_spacing), atof(value3)); + } + else if (strcmp (key, "taskbar_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + //if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) + //panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; + } + else if (strcmp (key, "taskbar_active_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "taskbar_name") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_show_name), atoi(value)); + } + else if (strcmp (key, "taskbar_name_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_x), atof(value1)); + } + else if (strcmp (key, "taskbar_name_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + //if (panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] == 0) + //panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = panel_config.g_taskbar.background_name[TASKBAR_NORMAL]; + } + else if (strcmp (key, "taskbar_name_active_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "taskbar_name_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(taskbar_name_font), value); + } + else if (strcmp (key, "taskbar_name_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(taskbar_name_inactive_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(taskbar_name_inactive_color), (alpha*65535)/100); + } + } + else if (strcmp (key, "taskbar_name_active_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(taskbar_name_active_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(taskbar_name_active_color), (alpha*65535)/100); + } + } + + /* Task */ + else if (strcmp (key, "task_text") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_show_text), atoi(value)); + } + else if (strcmp (key, "task_icon") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_show_icon), atoi(value)); + } + else if (strcmp (key, "task_centered") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_align_center), atoi(value)); + } + else if (strcmp (key, "font_shadow") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(task_font_shadow), atoi(value)); + } + else if (strcmp (key, "urgent_nb_of_blink") == 0) { + //max_tick_urgent = atoi (value); + } + else if (strcmp (key, "task_width") == 0) { + // old parameter : just for backward compatibility + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atof(value)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), 30.0); + } + else if (strcmp (key, "task_maximum_size") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_width), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), 30.0); + if (value2) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_maximum_height), atof(value2)); + } + else if (strcmp (key, "task_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_x), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(task_padding_y), atof(value2)); + } + else if (strcmp (key, "task_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(task_font), value); + } + else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { + /*gchar** split = g_regex_split_simple("_", key, 0, 0); + int status = get_task_status(split[1]); + g_strfreev(split); + extract_values(value, &value1, &value2, &value3); + float alpha = 1; + if (value2) alpha = (atoi (value2) / 100.0); + get_color (value1, panel_config.g_task.font[status].color); + panel_config.g_task.font[status].alpha = alpha; + panel_config.g_task.config_font_mask |= (1<len && id >= 0) ? id : 0; + panel_config.g_task.background[status] = &g_array_index(backgrounds, Background, id); + panel_config.g_task.config_background_mask |= (1<len && id >= 0) ? id : 0; + //systray.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp(key, "systray_sort") == 0) { + if (strcmp(value, "descending") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 1); + else if (strcmp(value, "ascending") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 0); + else if (strcmp(value, "right2left") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 3); + else // default to left2right + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 2); + } + else if (strcmp(key, "systray_icon_size") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atof(value)); + } + else if (strcmp(key, "systray_icon_asb") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_saturation), atof(value2)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_brightness), atof(value3)); + } + + /* Launcher */ + else if (strcmp (key, "launcher_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_x), atof(value1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_padding_y), atof(value2)); + if (value3) gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_spacing), atof(value3)); + } + else if (strcmp (key, "launcher_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //panel_config.launcher.area.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp(key, "launcher_icon_size") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(launcher_icon_size), atof(value)); + } + else if (strcmp(key, "launcher_item_app") == 0) { + //char *app = strdup(value); + //panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app); + } + else if (strcmp(key, "launcher_icon_theme") == 0) { + // if XSETTINGS manager running, tint2 use it. + //icon_theme_name = strdup(value); + } + + /* Tooltip */ + else if (strcmp (key, "tooltip_show_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_show_after), atof(value)); + } + else if (strcmp (key, "tooltip_hide_timeout") == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_hide_after), atof(value)); + } + else if (strcmp (key, "tooltip_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_x), atof(value1)); + if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_padding_y), atof(value2)); + } + else if (strcmp (key, "tooltip_background_id") == 0) { + //int id = atoi (value); + //id = (id < backgrounds->len && id >= 0) ? id : 0; + //g_tooltip.bg = &g_array_index(backgrounds, Background, id); + } + else if (strcmp (key, "tooltip_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + GdkColor col; + hex2gdk(value1, &col); + gtk_color_button_set_color(GTK_COLOR_BUTTON(tooltip_font_color), &col); + if (value2) { + int alpha = atoi(value2); + gtk_color_button_set_alpha(GTK_COLOR_BUTTON(tooltip_font_color), (alpha*65535)/100); + } + } + else if (strcmp (key, "tooltip_font") == 0) { + gtk_font_button_set_font_name(GTK_FONT_BUTTON(tooltip_font), value); + } + + /* Mouse actions */ + else if (strcmp (key, "mouse_middle") == 0) { + get_action(value, task_mouse_middle); + } + else if (strcmp (key, "mouse_right") == 0) { + get_action(value, task_mouse_right); + } + else if (strcmp (key, "mouse_scroll_up") == 0) { + get_action(value, task_mouse_scroll_up); + } + else if (strcmp (key, "mouse_scroll_down") == 0) { + get_action(value, task_mouse_scroll_down); + } + + if (value1) free (value1); + if (value2) free (value2); + if (value3) free (value3); +} + + +void hex2gdk(char *hex, GdkColor *color) +{ + if (hex == NULL || hex[0] != '#') return; + + color->red = 257 * (hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2])); + color->green = 257 * (hex_char_to_int (hex[3]) * 16 + hex_char_to_int (hex[4])); + color->blue = 257 * (hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6])); +} + + +void get_action(char *event, GtkWidget *combo) +{ + if (strcmp (event, "none") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); + else if (strcmp (event, "close") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1); + else if (strcmp (event, "toggle") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 2); + else if (strcmp (event, "iconify") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 3); + else if (strcmp (event, "shade") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 4); + else if (strcmp (event, "toggle_iconify") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 5); + else if (strcmp (event, "maximize_restore") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 6); + else if (strcmp (event, "desktop_left") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 7); + else if (strcmp (event, "desktop_right") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 8); + else if (strcmp (event, "next_task") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 9); + else if (strcmp (event, "prev_task") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 10); +} + diff -Naur tint2-0.11/src/tint2conf/properties_rw.h tint2-svn/src/tint2conf/properties_rw.h --- tint2-0.11/src/tint2conf/properties_rw.h 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/tint2conf/properties_rw.h 2014-01-10 16:11:03.033389211 +0100 @@ -0,0 +1,11 @@ + +#ifndef PROPERTIES_RW +#define PROPERTIES_RW + + +void config_read_file (const char *path); +void config_save_file(const char *path); + + +#endif + diff -Naur tint2-0.11/src/tint2conf/taskbar.svg tint2-svn/src/tint2conf/taskbar.svg --- tint2-0.11/src/tint2conf/taskbar.svg 1970-01-01 01:00:00.000000000 +0100 +++ tint2-svn/src/tint2conf/taskbar.svg 2014-01-10 16:11:03.033389211 +0100 @@ -0,0 +1,436 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Naur tint2-0.11/src/tint2conf/theme_view.c tint2-svn/src/tint2conf/theme_view.c --- tint2-0.11/src/tint2conf/theme_view.c 2010-06-14 17:08:51.000000000 +0200 +++ tint2-svn/src/tint2conf/theme_view.c 2014-01-10 16:11:03.034389230 +0100 @@ -1,3 +1,21 @@ +/************************************************************************** +* +* Tint2conf +* +* Copyright (C) 2009 Thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**************************************************************************/ #include "main.h" @@ -17,7 +35,7 @@ GtkCellRenderer *renderer; GtkWidget *view; - g_store = gtk_list_store_new(NB_COL, G_TYPE_STRING, GDK_TYPE_PIXBUF); + g_store = gtk_list_store_new(NB_COL, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(g_store)); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE); @@ -32,6 +50,12 @@ gtk_tree_view_column_set_visible(col, FALSE); gtk_tree_view_append_column(GTK_TREE_VIEW(view),col); + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, "text", COL_THEME_NAME); + gtk_tree_view_append_column(GTK_TREE_VIEW(view),col); + g_width_list = 200; g_height_list = 30; g_renderer = gtk_cell_renderer_pixbuf_new(); @@ -57,6 +81,13 @@ gtk_list_store_append(g_store, &iter); gtk_list_store_set(g_store, &iter, COL_THEME_FILE, name, -1); + + gchar *b, *n; + b = strrchr(name, '/'); + n = g_strdup(b+1); + b = strrchr(n, '.'); + *b = '\0'; + gtk_list_store_set(g_store, &iter, COL_THEME_NAME, n, -1); } @@ -107,12 +138,12 @@ pixWidth = gdk_pixbuf_get_width(pixbuf); pixHeight = gdk_pixbuf_get_height(pixbuf); - if (g_width_list < pixWidth) { + if (g_width_list != pixWidth) { g_width_list = pixWidth; changeSize = TRUE; } - if (g_height_list < (pixHeight+6)) { - g_height_list = pixHeight+6; + if (g_height_list != (pixHeight+30)) { + g_height_list = pixHeight+30; changeSize = TRUE; } if (changeSize) diff -Naur tint2-0.11/src/tint2conf/theme_view.h tint2-svn/src/tint2conf/theme_view.h --- tint2-0.11/src/tint2conf/theme_view.h 2010-04-04 00:52:52.000000000 +0200 +++ tint2-svn/src/tint2conf/theme_view.h 2014-01-10 16:11:03.032389193 +0100 @@ -6,7 +6,7 @@ extern GtkWidget *g_theme_view; extern GtkListStore *g_store; -enum { COL_THEME_FILE = 0, COL_SNAPSHOT, NB_COL, }; +enum { COL_THEME_FILE = 0, COL_THEME_NAME, COL_SNAPSHOT, NB_COL, }; GtkWidget *create_view(); diff -Naur tint2-0.11/src/tint2conf/tint2conf.desktop tint2-svn/src/tint2conf/tint2conf.desktop --- tint2-0.11/src/tint2conf/tint2conf.desktop 2010-06-11 14:21:30.000000000 +0200 +++ tint2-svn/src/tint2conf/tint2conf.desktop 2014-01-10 16:11:03.034389230 +0100 @@ -143,7 +143,7 @@ Comment[ur_PK]=پینل کی ترتیبات Comment[zh_CN]=自定义面板设置 Exec=tint2conf -Icon=tint2conf +Icon=taskbar Terminal=false Categories=Settings;DesktopSettings; diff -Naur tint2-0.11/src/tint2conf/tint2conf.png tint2-svn/src/tint2conf/tint2conf.png --- tint2-0.11/src/tint2conf/tint2conf.png 2010-06-12 10:55:58.000000000 +0200 +++ tint2-svn/src/tint2conf/tint2conf.png 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +0,0 @@ -PNG - - IHDR00WsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<gIDATh홱jP$B'p*>pP] -uХDwЈh'C2d8$g N 4@h:t>]~.'Q< ٬$I6/ iUU՛W3{lfOifpFeK -IPrQ@fFQF|) v@]^D{̝МfvbO@M=F=nˀmZk\O@\giagy6%}3`fB\%u@EJf>!;Bq' -,$Y,S6dWCN?_6G'N 4B*ߴKIENDB` \ No newline at end of file diff -Naur tint2-0.11/src/tint2conf/tint2conf.svg tint2-svn/src/tint2conf/tint2conf.svg --- tint2-0.11/src/tint2conf/tint2conf.svg 2010-06-12 10:55:58.000000000 +0200 +++ tint2-svn/src/tint2conf/tint2conf.svg 1970-01-01 01:00:00.000000000 +0100 @@ -1,349 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -Naur tint2-0.11/src/tint2conf/tintwizard.py tint2-svn/src/tint2conf/tintwizard.py --- tint2-0.11/src/tint2conf/tintwizard.py 2010-05-09 21:00:13.000000000 +0200 +++ tint2-svn/src/tint2conf/tintwizard.py 2014-01-10 16:11:03.033389211 +0100 @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #*************************************************************************/ -# Last modified: 21st April 2010 +# Last modified: 14th June 2010 import pygtk pygtk.require('2.0') @@ -32,7 +32,7 @@ # Project information NAME = "tintwizard" AUTHORS = ["Euan Freeman "] -VERSION = "0.3.3b" +VERSION = "0.3.4" COMMENTS = "tintwizard generates config files for the lightweight panel replacement tint2" WEBSITE = "http://code.google.com/p/tintwizard/" @@ -46,6 +46,7 @@ PANEL_PADDING_X = "0" PANEL_PADDING_Y = "0" PANEL_MONITOR = "all" +PANEL_ITEMS = "TSC" PANEL_AUTOHIDE_SHOW = "0.0" PANEL_AUTOHIDE_HIDE = "0.0" PANEL_AUTOHIDE_HEIGHT = "0" @@ -102,34 +103,34 @@ def __init__(self, tw): """Create and shows the window.""" self.tw = tw - + # Create top-level window gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) - + self.set_title("Preferences") self.connect("delete_event", self.quit) - + self.layout = gtk.Table(2, 2, False) - + self.table = gtk.Table(5, 2, False) self.table.set_row_spacings(5) self.table.set_col_spacings(5) - + createLabel(self.table, text="Default Font", gridX=0, gridY=0) self.font = gtk.FontButton(self.tw.defaults["font"]) self.font.set_alignment(0, 0.5) self.table.attach(self.font, 1, 2, 0, 1, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND) - + createLabel(self.table, text="Default Background Color", gridX=0, gridY=1) self.bgColor = gtk.ColorButton(gtk.gdk.color_parse(self.tw.defaults["bgColor"])) self.bgColor.set_alignment(0, 0.5) self.table.attach(self.bgColor, 1, 2, 1, 2, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND) - + createLabel(self.table, text="Default Foreground Color", gridX=0, gridY=2) self.fgColor = gtk.ColorButton(gtk.gdk.color_parse(self.tw.defaults["fgColor"])) self.fgColor.set_alignment(0, 0.5) self.table.attach(self.fgColor, 1, 2, 2, 3, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND) - + createLabel(self.table, text="Default Border Color", gridX=0, gridY=3) self.borderColor = gtk.ColorButton(gtk.gdk.color_parse(self.tw.defaults["borderColor"])) self.borderColor.set_alignment(0, 0.5) @@ -139,10 +140,10 @@ self.bgCount = createEntry(self.table, maxSize=6, width=8, text=str(self.tw.defaults["bgCount"]), gridX=1, gridY=4, xExpand=True, yExpand=True) self.layout.attach(self.table, 0, 2, 0, 1, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND, xpadding=20, ypadding=5) - + createButton(self.layout, text="Save", stock=gtk.STOCK_SAVE, name="save", gridX=0, gridY=1, xExpand=True, yExpand=True, handler=self.save) createButton(self.layout, text="Cancel", stock=gtk.STOCK_CANCEL, name="cancel", gridX=1, gridY=1, xExpand=True, yExpand=True, handler=self.quit) - + self.add(self.layout) self.show_all() @@ -226,7 +227,7 @@ # self.table is our main layout manager self.table = gtk.Table(4, 1, False) - + # Set up the dictionary to hold all registered widgets self.propUI = {} @@ -325,38 +326,38 @@ # Add buttons for adding/deleting background styles createButton(self.tableBgs, text="New Background", stock=gtk.STOCK_NEW, name="addBg", gridX=0, gridY=1, xExpand=True, yExpand=True, handler=self.addBgClick) createButton(self.tableBgs, text="Delete Background", stock=gtk.STOCK_DELETE, name="delBg", gridX=1, gridY=1, xExpand=True, yExpand=True, handler=self.delBgClick) - + # Panel self.createPanelDisplayWidgets() self.createPanelSettingsWidgets() self.createPanelAutohideWidgets() - + # Taskbar self.createTaskbarWidgets() - + # Tasks self.createTaskSettingsWidgets() self.createNormalTasksWidgets() self.createActiveTasksWidgets() self.createUrgentTasksWidgets() self.createIconifiedTasksWidgets() - + # System Tray self.createSystemTrayWidgets() - + # Clock self.createClockDisplayWidgets() self.createClockSettingsWidgets() - + # Mouse self.createMouseWidgets() - + # Tooltips self.createTooltipsWidgets() - + # Battery self.createBatteryWidgets() - + # View Config self.configArea = gtk.ScrolledWindow() self.configBuf = gtk.TextBuffer() @@ -373,11 +374,11 @@ self.panelNotebook = gtk.Notebook() self.panelNotebook.set_tab_pos(gtk.POS_TOP) self.panelNotebook.set_current_page(0) - + self.panelNotebook.append_page(self.tablePanelDisplay, gtk.Label("Panel Display")) self.panelNotebook.append_page(self.tablePanelSettings, gtk.Label("Panel Settings")) self.panelNotebook.append_page(self.tablePanelAutohide, gtk.Label("Panel Autohide")) - + self.taskNotebook = gtk.Notebook() self.taskNotebook.set_tab_pos(gtk.POS_TOP) self.taskNotebook.set_current_page(0) @@ -387,7 +388,7 @@ self.taskNotebook.append_page(self.tableTaskActive, gtk.Label("Active Tasks")) self.taskNotebook.append_page(self.tableTaskUrgent, gtk.Label("Urgent Tasks")) self.taskNotebook.append_page(self.tableTaskIconified, gtk.Label("Iconified Tasks")) - + self.clockNotebook = gtk.Notebook() self.clockNotebook.set_tab_pos(gtk.POS_TOP) self.clockNotebook.set_current_page(0) @@ -434,197 +435,200 @@ self.add(self.table) self.show_all() - + # If tintwizard was launched with a tint2 config filename # as an argument, load that config. if self.oneConfigFile: self.readTint2Config() self.generateConfig() - + def createPanelDisplayWidgets(self): """Create the Panel Display widgets.""" - self.tablePanelDisplay = gtk.Table(rows=6, columns=3, homogeneous=False) + self.tablePanelDisplay = gtk.Table(rows=7, columns=3, homogeneous=False) self.tablePanelDisplay.set_row_spacings(5) self.tablePanelDisplay.set_col_spacings(5) - + createLabel(self.tablePanelDisplay, text="Position", gridX=0, gridY=0, xPadding=10) self.panelPosY = createComboBox(self.tablePanelDisplay, ["bottom", "top", "center"], gridX=1, gridY=0, handler=self.changeOccurred) self.panelPosX = createComboBox(self.tablePanelDisplay, ["left", "right", "center"], gridX=2, gridY=0, handler=self.changeOccurred) # Note: registered below - + createLabel(self.tablePanelDisplay, text="Panel Orientation", gridX=0, gridY=1, xPadding=10) self.panelOrientation = createComboBox(self.tablePanelDisplay, ["horizontal", "vertical"], gridX=1, gridY=1, handler=self.changeOccurred) self.registerComponent("panel_position", (self.panelPosY, self.panelPosX, self.panelOrientation)) - - self.panelSizeLabel = createLabel(self.tablePanelDisplay, text="Size (width, height)", gridX=0, gridY=2, xPadding=10) - self.panelSizeX = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_SIZE_X, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.panelSizeY = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_SIZE_Y, gridX=2, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) + + createLabel(self.tablePanelDisplay, text="Panel Items", gridX=0, gridY=2, xPadding=10) + self.panelItems = createEntry(self.tablePanelDisplay, maxSize=7, width=8, text=PANEL_ITEMS, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) + self.registerComponent("panel_items", self.panelItems) + + self.panelSizeLabel = createLabel(self.tablePanelDisplay, text="Size (width, height)", gridX=0, gridY=3, xPadding=10) + self.panelSizeX = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_SIZE_X, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) + self.panelSizeY = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_SIZE_Y, gridX=2, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("panel_size", (self.panelSizeX, self.panelSizeY)) - - createLabel(self.tablePanelDisplay, text="Margin (x, y)", gridX=0, gridY=3, xPadding=10) - self.panelMarginX = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_MARGIN_X, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.panelMarginY = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_MARGIN_Y, gridX=2, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) + + createLabel(self.tablePanelDisplay, text="Margin (x, y)", gridX=0, gridY=4, xPadding=10) + self.panelMarginX = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_MARGIN_X, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) + self.panelMarginY = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_MARGIN_Y, gridX=2, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("panel_margin", (self.panelMarginX, self.panelMarginY)) - - createLabel(self.tablePanelDisplay, text="Padding (x, y)", gridX=0, gridY=4, xPadding=10) - self.panelPadX = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_PADDING_X, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.panelPadY = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_PADDING_Y, gridX=2, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) + + createLabel(self.tablePanelDisplay, text="Padding (x, y)", gridX=0, gridY=5, xPadding=10) + self.panelPadX = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_PADDING_X, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) + self.panelPadY = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=PANEL_PADDING_Y, gridX=2, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - - createLabel(self.tablePanelDisplay, text="Horizontal Spacing", gridX=0, gridY=5, xPadding=10) - self.panelSpacing = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=TASKBAR_SPACING, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) + + createLabel(self.tablePanelDisplay, text="Horizontal Spacing", gridX=0, gridY=6, xPadding=10) + self.panelSpacing = createEntry(self.tablePanelDisplay, maxSize=6, width=8, text=TASKBAR_SPACING, gridX=1, gridY=6, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("panel_padding", (self.panelPadX, self.panelPadY, self.panelSpacing)) - - createLabel(self.tablePanelDisplay, text="Panel Background ID", gridX=0, gridY=6, xPadding=10) - self.panelBg = createComboBox(self.tablePanelDisplay, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=6, handler=self.changeOccurred) + + createLabel(self.tablePanelDisplay, text="Panel Background ID", gridX=0, gridY=7, xPadding=10) + self.panelBg = createComboBox(self.tablePanelDisplay, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=7, handler=self.changeOccurred) self.registerComponent("panel_background_id", self.panelBg) - + def createPanelSettingsWidgets(self): """Create the Panel Settings widgets.""" self.tablePanelSettings = gtk.Table(rows=5, columns=3, homogeneous=False) self.tablePanelSettings.set_row_spacings(5) self.tablePanelSettings.set_col_spacings(5) - + createLabel(self.tablePanelSettings, text="Window Manager Menu", gridX=0, gridY=0, xPadding=10) self.panelMenu = createCheckButton(self.tablePanelSettings, active=False, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("wm_menu", self.panelMenu) - + createLabel(self.tablePanelSettings, text="Place In Window Manager Dock", gridX=0, gridY=1, xPadding=10) self.panelDock = createCheckButton(self.tablePanelSettings, active=False, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("panel_dock", self.panelDock) - + createLabel(self.tablePanelSettings, text="Panel Layer", gridX=0, gridY=2, xPadding=10) self.panelLayer = createComboBox(self.tablePanelSettings, ["bottom", "top", "normal"], gridX=1, gridY=2, handler=self.changeOccurred) self.registerComponent("panel_layer", self.panelLayer) - + createLabel(self.tablePanelSettings, text="Strut Policy", gridX=0, gridY=3, xPadding=10) self.panelAutohideStrut = createComboBox(self.tablePanelSettings, ["none", "minimum", "follow_size"], gridX=1, gridY=3, handler=self.changeOccurred) self.registerComponent("strut_policy", self.panelAutohideStrut) - + createLabel(self.tablePanelSettings, text="Panel Monitor (all, 1, 2, ...)", gridX=0, gridY=4, xPadding=10) self.panelMonitor = createEntry(self.tablePanelSettings, maxSize=6, width=8, text=PANEL_MONITOR, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("panel_monitor", self.panelMonitor) - + def createPanelAutohideWidgets(self): """Create the Panel Autohide widgets.""" self.tablePanelAutohide = gtk.Table(rows=4, columns=3, homogeneous=False) self.tablePanelAutohide.set_row_spacings(5) self.tablePanelAutohide.set_col_spacings(5) - + createLabel(self.tablePanelAutohide, text="Autohide Panel", gridX=0, gridY=0, xPadding=10) self.panelAutohide = createCheckButton(self.tablePanelAutohide, active=False, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("autohide", self.panelAutohide) - + createLabel(self.tablePanelAutohide, text="Autohide Show Timeout (seconds)", gridX=0, gridY=1, xPadding=10) self.panelAutohideShow = createEntry(self.tablePanelAutohide, maxSize=6, width=8, text=PANEL_AUTOHIDE_SHOW, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("autohide_show_timeout", self.panelAutohideShow) - + createLabel(self.tablePanelAutohide, text="Autohide Hide Timeout (seconds)", gridX=0, gridY=2, xPadding=10) self.panelAutohideHide = createEntry(self.tablePanelAutohide, maxSize=6, width=8, text=PANEL_AUTOHIDE_HIDE, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("autohide_hide_timeout", self.panelAutohideHide) - + createLabel(self.tablePanelAutohide, text="Autohide Hidden Height", gridX=0, gridY=3, xPadding=10) self.panelAutohideHeight = createEntry(self.tablePanelAutohide, maxSize=6, width=8, text=PANEL_AUTOHIDE_HEIGHT, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("autohide_height", self.panelAutohideHeight) - + def createTaskbarWidgets(self): """Create the Taskbar widgets.""" self.tableTaskbar = gtk.Table(rows=5, columns=3, homogeneous=False) self.tableTaskbar.set_row_spacings(5) self.tableTaskbar.set_col_spacings(5) - + createLabel(self.tableTaskbar, text="Taskbar Mode", gridX=0, gridY=0, xPadding=10) self.taskbarMode = createComboBox(self.tableTaskbar, ["single_desktop", "multi_desktop"], gridX=1, gridY=0, handler=self.changeOccurred) self.registerComponent("taskbar_mode", self.taskbarMode) - + createLabel(self.tableTaskbar, text="Padding (x, y)", gridX=0, gridY=1, xPadding=10) self.taskbarPadX = createEntry(self.tableTaskbar, maxSize=6, width=8, text=TASKBAR_PADDING_X, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.taskbarPadY = createEntry(self.tableTaskbar, maxSize=6, width=8, text=TASKBAR_PADDING_Y, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskbar, text="Horizontal Spacing", gridX=0, gridY=2, xPadding=10) self.taskbarSpacing = createEntry(self.tableTaskbar, maxSize=6, width=8, text=TASK_SPACING, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("taskbar_padding", (self.taskbarPadX, self.taskbarPadY, self.taskbarSpacing)) - + createLabel(self.tableTaskbar, text="Taskbar Background ID", gridX=0, gridY=3, xPadding=10) self.taskbarBg = createComboBox(self.tableTaskbar, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=3, handler=self.changeOccurred) self.registerComponent("taskbar_background_id", self.taskbarBg) - + createLabel(self.tableTaskbar, text="Active Taskbar Background ID", gridX=0, gridY=4, xPadding=10) self.taskbarActiveBg = createComboBox(self.tableTaskbar, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=4, handler=self.changeOccurred) - self.taskbarActiveBgEnable = createCheckButton(self.tableTaskbar, text="Enable", active=False, gridX=2, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("taskbar_active_background_id", self.taskbarActiveBg) - + def createTaskSettingsWidgets(self): """Create the Task Settings widgets.""" self.tableTask = gtk.Table(rows=12, columns=3, homogeneous=False) self.tableTask.set_row_spacings(5) self.tableTask.set_col_spacings(5) - + createLabel(self.tableTask, text="Number of 'Blinks' on Urgent Event", gridX=0, gridY=0, xPadding=10) self.taskBlinks = createEntry(self.tableTask, maxSize=6, width=8, text=TASK_BLINKS, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("urgent_nb_of_blink", self.taskBlinks) - + createLabel(self.tableTask, text="Show Icons", gridX=0, gridY=1, xPadding=10) self.taskIconCheckButton = createCheckButton(self.tableTask, active=True, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_icon", self.taskIconCheckButton) - + createLabel(self.tableTask, text="Show Text", gridX=0, gridY=2, xPadding=10) self.taskTextCheckButton = createCheckButton(self.tableTask, active=True, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_text", self.taskTextCheckButton) - + createLabel(self.tableTask, text="Centre Text", gridX=0, gridY=3, xPadding=10) self.taskCentreCheckButton = createCheckButton(self.tableTask, active=True, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_centered", self.taskCentreCheckButton) - + createLabel(self.tableTask, text="Font", gridX=0, gridY=4, xPadding=10) self.fontButton = gtk.FontButton() - + if self.defaults["font"] in [None, "None"]: # If there was no font specified in the config file self.defaults["font"] = self.fontButton.get_font_name() # Use the gtk default - + self.fontButton = createFontButton(self.tableTask, font=self.defaults["font"], gridX=1, gridY=4, handler=self.changeOccurred) self.registerComponent("task_font", self.fontButton) - + createLabel(self.tableTask, text="Show Font Shadow", gridX=0, gridY=5, xPadding=10) self.fontShadowCheckButton = createCheckButton(self.tableTask, active=False, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("font_shadow", self.fontShadowCheckButton) - + createLabel(self.tableTask, text="Maximum Size (x, y)", gridX=0, gridY=6, xPadding=10) self.taskMaxSizeX = createEntry(self.tableTask, maxSize=6, width=8, text=TASK_MAXIMUM_SIZE_X, gridX=1, gridY=6, xExpand=True, yExpand=False, handler=self.changeOccurred) self.taskMaxSizeY = createEntry(self.tableTask, maxSize=6, width=8, text=TASK_MAXIMUM_SIZE_Y, gridX=2, gridY=6, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_maximum_size", (self.taskMaxSizeX, self.taskMaxSizeY)) - + createLabel(self.tableTask, text="Padding (x, y)", gridX=0, gridY=7, xPadding=10) self.taskPadX = createEntry(self.tableTask, maxSize=6, width=8, text=TASK_PADDING_X, gridX=1, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) self.taskPadY = createEntry(self.tableTask, maxSize=6, width=8, text=TASK_PADDING_Y, gridX=2, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_padding", (self.taskPadX, self.taskPadY)) - + def createNormalTasksWidgets(self): """Create the Normal Tasks widgets.""" self.tableTaskDefault = gtk.Table(rows=6, columns=3, homogeneous=False) self.tableTaskDefault.set_row_spacings(5) self.tableTaskDefault.set_col_spacings(5) - + createLabel(self.tableTaskDefault, text="Normal Task Background ID", gridX=0, gridY=0, xPadding=10) self.taskBg = createComboBox(self.tableTaskDefault, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=0, handler=self.changeOccurred) self.registerComponent("task_background_id", self.taskBg) - + createLabel(self.tableTaskDefault, text="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX=0, gridY=1, sizeX=3, xPadding=10) - + createLabel(self.tableTaskDefault, text="Normal Icon Alpha (0 to 100)", gridX=0, gridY=2, xPadding=10) self.iconHue = createEntry(self.tableTaskDefault, maxSize=6, width=8, text=ICON_ALPHA, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskDefault, text="Normal Icon Saturation (-100 to 100)", gridX=0, gridY=3, xPadding=10) self.iconSat = createEntry(self.tableTaskDefault, maxSize=6, width=8, text=ICON_SAT, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskDefault, text="Normal Icon Brightness (-100 to 100)", gridX=0, gridY=4, xPadding=10) self.iconBri = createEntry(self.tableTaskDefault, maxSize=6, width=8, text=ICON_BRI, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_icon_asb", (self.iconHue, self.iconSat, self.iconBri)) - + createLabel(self.tableTaskDefault, text="Normal Font Color", gridX=0, gridY=5, xPadding=10) self.fontCol = createEntry(self.tableTaskDefault, maxSize=7, width=9, text="", gridX=1, gridY=5, xExpand=True, yExpand=False, handler=None, name="fontCol") self.fontCol.connect("activate", self.colorTyped) @@ -633,31 +637,31 @@ # Add this AFTER we set color to avoid "changed" event self.fontCol.connect("changed", self.changeOccurred) self.registerComponent("task_font_color", (self.fontCol, self.fontColButton)) - + def createActiveTasksWidgets(self): """Create the Active Tasks widgets.""" self.tableTaskActive = gtk.Table(rows=6, columns=3, homogeneous=False) self.tableTaskActive.set_row_spacings(5) self.tableTaskActive.set_col_spacings(5) - + createLabel(self.tableTaskActive, text="Active Task Background ID", gridX=0, gridY=0, xPadding=10) self.taskActiveBg = createComboBox(self.tableTaskActive, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=0, handler=self.changeOccurred) self.registerComponent("task_active_background_id", self.taskActiveBg) - + createLabel(self.tableTaskActive, text="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX=0, gridY=1, sizeX=3, xPadding=10) - + createLabel(self.tableTaskActive, text="Active Icon Alpha (0 to 100)", gridX=0, gridY=2, xPadding=10) self.activeIconHue = createEntry(self.tableTaskActive, maxSize=6, width=8, text=ACTIVE_ICON_ALPHA, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskActive, text="Active Icon Saturation (-100 to 100)", gridX=0, gridY=3, xPadding=10) self.activeIconSat = createEntry(self.tableTaskActive, maxSize=6, width=8, text=ACTIVE_ICON_SAT, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskActive, text="Active Icon Brightness (-100 to 100)", gridX=0, gridY=4, xPadding=10) self.activeIconBri = createEntry(self.tableTaskActive, maxSize=6, width=8, text=ACTIVE_ICON_BRI, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_active_icon_asb", (self.activeIconHue, self.activeIconSat, self.activeIconBri)) - + createLabel(self.tableTaskActive, text="Active Font Color", gridX=0, gridY=5, xPadding=10) self.fontActiveCol = createEntry(self.tableTaskActive, maxSize=7, width=9, text="", gridX=1, gridY=5, xExpand=True, yExpand=False, handler=None, name="fontActiveCol") self.fontActiveCol.connect("activate", self.colorTyped) @@ -666,31 +670,31 @@ # Add this AFTER we set color to avoid "changed" event self.fontActiveCol.connect("changed", self.changeOccurred) self.registerComponent("task_active_font_color", (self.fontActiveCol, self.fontActiveColButton)) - + def createUrgentTasksWidgets(self): """Create the Urgent Tasks widgets.""" self.tableTaskUrgent = gtk.Table(rows=6, columns=3, homogeneous=False) self.tableTaskUrgent.set_row_spacings(5) self.tableTaskUrgent.set_col_spacings(5) - + createLabel(self.tableTaskUrgent, text="Urgent Task Background ID", gridX=0, gridY=0, xPadding=10) self.taskUrgentBg = createComboBox(self.tableTaskUrgent, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=0, handler=self.changeOccurred) self.registerComponent("task_urgent_background_id", self.taskUrgentBg) - + createLabel(self.tableTaskUrgent, text="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX=0, gridY=1, sizeX=3, xPadding=10) - + createLabel(self.tableTaskUrgent, text="Urgent Icon Alpha (0 to 100)", gridX=0, gridY=2, xPadding=10) self.urgentIconHue = createEntry(self.tableTaskUrgent, maxSize=6, width=8, text=URGENT_ICON_ALPHA, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskUrgent, text="Urgent Icon Saturation (-100 to 100)", gridX=0, gridY=3, xPadding=10) self.urgentIconSat = createEntry(self.tableTaskUrgent, maxSize=6, width=8, text=URGENT_ICON_SAT, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskUrgent, text="Urgent Icon Brightness (-100 to 100)", gridX=0, gridY=4, xPadding=10) self.urgentIconBri = createEntry(self.tableTaskUrgent, maxSize=6, width=8, text=URGENT_ICON_BRI, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_urgent_icon_asb", (self.urgentIconHue, self.urgentIconSat, self.urgentIconBri)) - + createLabel(self.tableTaskUrgent, text="Urgent Font Color", gridX=0, gridY=5, xPadding=10) self.fontUrgentCol = createEntry(self.tableTaskUrgent, maxSize=7, width=9, text="", gridX=1, gridY=5, xExpand=True, yExpand=False, handler=None, name="fontUrgentCol") self.fontUrgentCol.connect("activate", self.colorTyped) @@ -699,31 +703,31 @@ # Add this AFTER we set color to avoid "changed" event self.fontUrgentCol.connect("changed", self.changeOccurred) self.registerComponent("task_urgent_font_color", (self.fontUrgentCol, self.fontUrgentColButton)) - + def createIconifiedTasksWidgets(self): """Create the Iconified Tasks widgets.""" self.tableTaskIconified = gtk.Table(rows=6, columns=3, homogeneous=False) self.tableTaskIconified.set_row_spacings(5) self.tableTaskIconified.set_col_spacings(5) - + createLabel(self.tableTaskIconified, text="Iconified Task Background ID", gridX=0, gridY=0, xPadding=10) self.taskIconifiedBg = createComboBox(self.tableTaskIconified, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=0, handler=self.changeOccurred) self.registerComponent("task_iconified_background_id", self.taskIconifiedBg) - + createLabel(self.tableTaskIconified, text="Note: Default values of 0 for each of these settings leaves icons unchanged!", gridX=0, gridY=1, sizeX=3, xPadding=10) - + createLabel(self.tableTaskIconified, text="Iconified Icon Alpha (0 to 100)", gridX=0, gridY=2, xPadding=10) self.iconifiedIconHue = createEntry(self.tableTaskIconified, maxSize=6, width=8, text=ICONIFIED_ICON_ALPHA, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskIconified, text="Iconified Icon Saturation (-100 to 100)", gridX=0, gridY=3, xPadding=10) self.iconifiedIconSat = createEntry(self.tableTaskIconified, maxSize=6, width=8, text=ICONIFIED_ICON_SAT, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTaskIconified, text="Iconified Icon Brightness (-100 to 100)", gridX=0, gridY=4, xPadding=10) self.iconifiedIconBri = createEntry(self.tableTaskIconified, maxSize=6, width=8, text=ICONIFIED_ICON_BRI, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("task_iconified_icon_asb", (self.iconifiedIconHue, self.iconifiedIconSat, self.iconifiedIconBri)) - + createLabel(self.tableTaskIconified, text="Iconified Font Color", gridX=0, gridY=5, xPadding=10) self.fontIconifiedCol = createEntry(self.tableTaskIconified, maxSize=7, width=9, text="", gridX=1, gridY=5, xExpand=True, yExpand=False, handler=None, name="fontIconifiedCol") self.fontIconifiedCol.connect("activate", self.colorTyped) @@ -732,82 +736,72 @@ # Add this AFTER we set color to avoid "changed" event self.fontIconifiedCol.connect("changed", self.changeOccurred) self.registerComponent("task_iconified_font_color", (self.fontIconifiedCol, self.fontIconifiedColButton)) - + def createSystemTrayWidgets(self): """Create the System Tray widgets.""" self.tableTray = gtk.Table(rows=9, columns=3, homogeneous=False) self.tableTray.set_row_spacings(5) self.tableTray.set_col_spacings(5) - - createLabel(self.tableTray, text="Show System Tray", gridX=0, gridY=0, xPadding=10) - self.trayShow = createCheckButton(self.tableTray, active=True, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.registerComponent("systray", self.trayShow) - + createLabel(self.tableTray, text="Padding (x, y)", gridX=0, gridY=1, xPadding=10) self.trayPadX = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_PADDING_X, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.trayPadY = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_PADDING_Y, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTray, text="Horizontal Spacing", gridX=0, gridY=2, xPadding=10) self.traySpacing = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_SPACING, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("systray_padding", (self.trayPadX, self.trayPadY, self.traySpacing)) - + createLabel(self.tableTray, text="System Tray Background ID", gridX=0, gridY=3, xPadding=10) self.trayBg = createComboBox(self.tableTray, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=3, handler=self.changeOccurred) self.registerComponent("systray_background_id", self.trayBg) - + createLabel(self.tableTray, text="Icon Ordering", gridX=0, gridY=4, xPadding=10) self.trayOrder = createComboBox(self.tableTray, ["ascending", "descending", "left2right", "right2left"], gridX=1, gridY=4, handler=self.changeOccurred) self.registerComponent("systray_sort", self.trayOrder) - + createLabel(self.tableTray, text="Maximum Icon Size (0 for automatic size)", gridX=0, gridY=5, xPadding=10) self.trayMaxIconSize = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_MAX_ICON_SIZE, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("systray_icon_size", self.trayMaxIconSize) - + createLabel(self.tableTray, text="System Tray Icon Alpha (0 to 100)", gridX=0, gridY=6, xPadding=10) self.trayIconHue = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_ICON_ALPHA, gridX=1, gridY=6, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTray, text="System Tray Icon Saturation (-100 to 100)", gridX=0, gridY=7, xPadding=10) self.trayIconSat = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_ICON_SAT, gridX=1, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) # Note: added below - + createLabel(self.tableTray, text="System Tray Icon Brightness (-100 to 100)", gridX=0, gridY=8, xPadding=10) self.trayIconBri = createEntry(self.tableTray, maxSize=6, width=8, text=TRAY_ICON_BRI, gridX=1, gridY=8, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("systray_icon_asb", (self.trayIconHue, self.trayIconSat, self.trayIconBri)) - + def createClockDisplayWidgets(self): """Create the Clock Display widgets.""" self.tableClockDisplays = gtk.Table(rows=3, columns=3, homogeneous=False) self.tableClockDisplays.set_row_spacings(5) self.tableClockDisplays.set_col_spacings(5) - - createLabel(self.tableClockDisplays, text="Show", gridX=0, gridY=0, xPadding=10) - self.clockCheckButton = createCheckButton(self.tableClockDisplays, active=True, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) - + createLabel(self.tableClockDisplays, text="Time 1 Format", gridX=0, gridY=1, xPadding=10) self.clock1Format = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_FMT_1, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.clock1CheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("time1_format", self.clock1Format) - + createLabel(self.tableClockDisplays, text="Time 1 Font", gridX=0, gridY=2, xPadding=10) self.clock1FontButton = createFontButton(self.tableClockDisplays, font=self.defaults["font"], gridX=1, gridY=2, handler=self.changeOccurred) self.registerComponent("time1_font", self.clock1FontButton) - + createLabel(self.tableClockDisplays, text="Time 2 Format", gridX=0, gridY=3, xPadding=10) self.clock2Format = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_FMT_2, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.clock2CheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("time2_format", self.clock2Format) - + createLabel(self.tableClockDisplays, text="Time 2 Font", gridX=0, gridY=4, xPadding=10) self.clock2FontButton = createFontButton(self.tableClockDisplays, font=self.defaults["font"], gridX=1, gridY=4, handler=self.changeOccurred) self.registerComponent("time2_font", self.clock2FontButton) - + createLabel(self.tableClockDisplays, text="Tooltip Format", gridX=0, gridY=5, xPadding=10) self.clockTooltipFormat = createEntry(self.tableClockDisplays, maxSize=50, width=20, text=CLOCK_TOOLTIP, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.clockTooltipCheckButton = createCheckButton(self.tableClockDisplays, text="Show", active=True, gridX=2, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("clock_tooltip", self.clockTooltipFormat) - + self.clockArea = gtk.ScrolledWindow() self.clockBuf = gtk.TextBuffer() self.clockTextView = gtk.TextView(self.clockBuf) @@ -815,13 +809,13 @@ self.clockTextView.set_editable(False) self.clockArea.add_with_viewport(self.clockTextView) self.tableClockDisplays.attach(self.clockArea, 0, 3, 6, 7, xpadding=10) - + def createClockSettingsWidgets(self): """Create the Clock Settings widgets.""" self.tableClockSettings = gtk.Table(rows=3, columns=3, homogeneous=False) self.tableClockSettings.set_row_spacings(5) self.tableClockSettings.set_col_spacings(5) - + createLabel(self.tableClockSettings, text="Clock Font Color", gridX=0, gridY=0, xPadding=10) self.clockFontCol = createEntry(self.tableClockSettings, maxSize=7, width=9, text="", gridX=1, gridY=0, xExpand=True, yExpand=False, handler=None, name="clockFontCol") self.clockFontCol.connect("activate", self.colorTyped) @@ -830,94 +824,91 @@ # Add this AFTER we set color to avoid "changed" event self.clockFontCol.connect("changed", self.changeOccurred) self.registerComponent("clock_font_color", (self.clockFontCol, self.clockFontColButton)) - + createLabel(self.tableClockSettings, text="Padding (x, y)", gridX=0, gridY=1, xPadding=10) self.clockPadX = createEntry(self.tableClockSettings, maxSize=6, width=8, text=CLOCK_PADDING_X, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.clockPadY = createEntry(self.tableClockSettings, maxSize=6, width=8, text=CLOCK_PADDING_Y, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("clock_padding", (self.clockPadX, self.clockPadY)) - + createLabel(self.tableClockSettings, text="Clock Background ID", gridX=0, gridY=2, xPadding=10) self.clockBg = createComboBox(self.tableClockSettings, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=2, handler=self.changeOccurred) self.registerComponent("clock_background_id", self.clockBg) - + createLabel(self.tableClockSettings, text="Left Click Command", gridX=0, gridY=3, xPadding=10) self.clockLClick = createEntry(self.tableClockSettings, maxSize=50, width=20, text=CLOCK_LCLICK, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("clock_lclick_command", self.clockLClick) - + createLabel(self.tableClockSettings, text="Right Click Command", gridX=0, gridY=4, xPadding=10) self.clockRClick = createEntry(self.tableClockSettings, maxSize=50, width=20, text=CLOCK_RCLICK, gridX=1, gridY=4, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("clock_rclick_command", self.clockRClick) - + createLabel(self.tableClockSettings, text="Time 1 Timezone", gridX=0, gridY=5, xPadding=10) self.clockTime1Timezone = createEntry(self.tableClockSettings, maxSize=50, width=20, text=CLOCK_TIME1_TIMEZONE, gridX=1, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.clockTimezone1CheckButton = createCheckButton(self.tableClockSettings, text="Enable", active=False, gridX=2, gridY=5, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("time1_timezone", self.clockTime1Timezone) - + createLabel(self.tableClockSettings, text="Time 2 Timezone", gridX=0, gridY=6, xPadding=10) self.clockTime2Timezone = createEntry(self.tableClockSettings, maxSize=50, width=20, text=CLOCK_TIME2_TIMEZONE, gridX=1, gridY=6, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.clockTimezone2CheckButton = createCheckButton(self.tableClockSettings, text="Enable", active=False, gridX=2, gridY=6, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("time2_timezone", self.clockTime2Timezone) - + createLabel(self.tableClockSettings, text="Tooltip Timezone", gridX=0, gridY=7, xPadding=10) self.clockTooltipTimezone = createEntry(self.tableClockSettings, maxSize=50, width=20, text=CLOCK_TOOLTIP_TIMEZONE, gridX=1, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.clockTimezoneTooltipCheckButton = createCheckButton(self.tableClockSettings, text="Enable", active=False, gridX=2, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("clock_tooltip_timezone", self.clockTooltipTimezone) - + def createMouseWidgets(self): """Creates the Mouse widgets.""" self.tableMouse = gtk.Table(rows=4, columns=3, homogeneous=False) self.tableMouse.set_row_spacings(5) self.tableMouse.set_col_spacings(5) - + mouseCmds = ["none", "close", "toggle", "iconify", "shade", "toggle_iconify", "maximize_restore", "desktop_left", "desktop_right", "next_task", "prev_task"] - + createLabel(self.tableMouse, text="Middle Mouse Click Action", gridX=0, gridY=0, xPadding=10) self.mouseMiddle = createComboBox(self.tableMouse, mouseCmds, gridX=1, gridY=0, handler=self.changeOccurred) self.registerComponent("mouse_middle", self.mouseMiddle) - + createLabel(self.tableMouse, text="Right Mouse Click Action", gridX=0, gridY=1, xPadding=10) self.mouseRight = createComboBox(self.tableMouse, mouseCmds, gridX=1, gridY=1, handler=self.changeOccurred) self.registerComponent("mouse_right", self.mouseRight) - + createLabel(self.tableMouse, text="Mouse Wheel Scroll Up Action", gridX=0, gridY=2, xPadding=10) self.mouseUp = createComboBox(self.tableMouse, mouseCmds, gridX=1, gridY=2, handler=self.changeOccurred) self.registerComponent("mouse_scroll_up", self.mouseUp) - + createLabel(self.tableMouse, text="Mouse Wheel Scroll Down Action", gridX=0, gridY=3, xPadding=10) self.mouseDown = createComboBox(self.tableMouse, mouseCmds, gridX=1, gridY=3, handler=self.changeOccurred) self.registerComponent("mouse_scroll_down", self.mouseDown) - + def createTooltipsWidgets(self): """Creates the Tooltips widgets.""" self.tableTooltip = gtk.Table(rows=7, columns=3, homogeneous=False) self.tableTooltip.set_row_spacings(5) self.tableTooltip.set_col_spacings(5) - + createLabel(self.tableTooltip, text="Show Tooltips", gridX=0, gridY=0, xPadding=10) self.tooltipShow = createCheckButton(self.tableTooltip, active=False, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("tooltip", self.tooltipShow) - + createLabel(self.tableTooltip, text="Padding (x, y)", gridX=0, gridY=1, xPadding=10) self.tooltipPadX = createEntry(self.tableTooltip, maxSize=6, width=8, text=TOOLTIP_PADDING_X, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.tooltipPadY = createEntry(self.tableTooltip, maxSize=6, width=8, text=TOOLTIP_PADDING_Y, gridX=2, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("tooltip_padding", (self.tooltipPadX, self.tooltipPadY)) - + createLabel(self.tableTooltip, text="Tooltip Show Timeout (seconds)", gridX=0, gridY=2, xPadding=10) self.tooltipShowTime = createEntry(self.tableTooltip, maxSize=6, width=8, text=TOOLTIP_SHOW_TIMEOUT, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("tooltip_show_timeout", self.tooltipShowTime) - + createLabel(self.tableTooltip, text="Tooltip Hide Timeout (seconds)", gridX=0, gridY=3, xPadding=10) self.tooltipHideTime = createEntry(self.tableTooltip, maxSize=6, width=8, text=TOOLTIP_HIDE_TIMEOUT, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("tooltip_hide_timeout", self.tooltipHideTime) - + createLabel(self.tableTooltip, text="Tooltip Background ID", gridX=0, gridY=4, xPadding=10) self.tooltipBg = createComboBox(self.tableTooltip, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=4, handler=self.changeOccurred) self.registerComponent("tooltip_background_id", self.tooltipBg) - + createLabel(self.tableTooltip, text="Tooltip Font", gridX=0, gridY=5, xPadding=10) self.tooltipFont = createFontButton(self.tableTooltip, font=self.defaults["font"], gridX=1, gridY=5, handler=self.changeOccurred) self.registerComponent("tooltip_font", self.tooltipFont) - + createLabel(self.tableTooltip, text="Tooltip Font Color", gridX=0, gridY=6, xPadding=10) self.tooltipFontCol = createEntry(self.tableTooltip, maxSize=7, width=9, text="", gridX=1, gridY=6, xExpand=True, yExpand=False, handler=None, name="tooltipFontCol") self.tooltipFontCol.connect("activate", self.colorTyped) @@ -926,37 +917,33 @@ # Add this AFTER we set color to avoid "changed" event self.tooltipFontCol.connect("changed", self.changeOccurred) self.registerComponent("tooltip_font_color", (self.tooltipFontCol, self.tooltipFontColButton)) - + def createBatteryWidgets(self): """Creates the Battery widgets.""" self.tableBattery = gtk.Table(rows=8, columns=3, homogeneous=False) self.tableBattery.set_row_spacings(5) self.tableBattery.set_col_spacings(5) - - createLabel(self.tableBattery, text="Show Battery Applet", gridX=0, gridY=0, xPadding=10) - self.batteryCheckButton = createCheckButton(self.tableBattery, active=False, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred) - self.registerComponent("battery", self.batteryCheckButton) - + createLabel(self.tableBattery, text="Battery Low Status (%)", gridX=0, gridY=1, xPadding=10) self.batteryLow = createEntry(self.tableBattery, maxSize=6, width=8, text=BATTERY_LOW, gridX=1, gridY=1, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("battery_low_status", self.batteryLow) - + createLabel(self.tableBattery, text="Battery Low Action", gridX=0, gridY=2, xPadding=10) self.batteryLowAction = createEntry(self.tableBattery, maxSize=150, width=32, text=BATTERY_ACTION, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("battery_low_cmd", self.batteryLowAction) - + createLabel(self.tableBattery, text="Battery Hide (0 to 100)", gridX=0, gridY=3, xPadding=10) self.batteryHide = createEntry(self.tableBattery, maxSize=6, width=8, text=BATTERY_HIDE, gridX=1, gridY=3, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("battery_hide", self.batteryHide) - + createLabel(self.tableBattery, text="Battery 1 Font", gridX=0, gridY=4, xPadding=10) self.bat1FontButton = createFontButton(self.tableBattery, font=self.defaults["font"], gridX=1, gridY=4, handler=self.changeOccurred) self.registerComponent("bat1_font", self.bat1FontButton) - + createLabel(self.tableBattery, text="Battery 2 Font", gridX=0, gridY=5, xPadding=10) self.bat2FontButton = createFontButton(self.tableBattery, font=self.defaults["font"], gridX=1, gridY=5, handler=self.changeOccurred) self.registerComponent("bat2_font", self.bat2FontButton) - + createLabel(self.tableBattery, text="Battery Font Color", gridX=0, gridY=6, xPadding=10) self.batteryFontCol = createEntry(self.tableBattery, maxSize=7, width=9, text="", gridX=1, gridY=6, xExpand=True, yExpand=False, handler=None, name="batteryFontCol") self.batteryFontCol.connect("activate", self.colorTyped) @@ -965,27 +952,27 @@ # Add this AFTER we set color to avoid "changed" event self.batteryFontCol.connect("changed", self.changeOccurred) self.registerComponent("battery_font_color", (self.batteryFontCol, self.batteryFontColButton)) - + createLabel(self.tableBattery, text="Padding (x, y)", gridX=0, gridY=7, xPadding=10) self.batteryPadX = createEntry(self.tableBattery, maxSize=6, width=8, text=BATTERY_PADDING_X, gridX=1, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) self.batteryPadY = createEntry(self.tableBattery, maxSize=6, width=8, text=BATTERY_PADDING_Y, gridX=2, gridY=7, xExpand=True, yExpand=False, handler=self.changeOccurred) self.registerComponent("battery_padding", (self.batteryPadX, self.batteryPadY)) - + createLabel(self.tableBattery, text="Battery Background ID", gridX=0, gridY=8, xPadding=10) self.batteryBg = createComboBox(self.tableBattery, ["0 (fully transparent)"] + range(1, len(self.bgs)), gridX=1, gridY=8, handler=self.changeOccurred) self.registerComponent("battery_background_id", self.batteryBg) - + def registerComponent(self, configProperty, component): """Registers a component with a particular property from a tint2 config. Note: a component may be a double or triple if that property has more than one value associated with it.""" self.propUI[configProperty] = component - + def getComponent(self, configProperty): """Fetches the component associated with a tint2 property.""" return self.propUI[configProperty] if configProperty in self.propUI else None - + def about(self, action=None): """Displays the About dialog.""" about = gtk.AboutDialog() @@ -1008,10 +995,10 @@ def addBg(self): """Adds a new background to the list of backgrounds.""" self.bgs += [gtk.Table(4, 3, False)] - + createLabel(self.bgs[-1], text="Corner Rounding (px)", gridX=0, gridY=0, xPadding=10) createEntry(self.bgs[-1], maxSize=7, width=9, text=BG_ROUNDING, gridX=1, gridY=0, xExpand=True, yExpand=False, handler=self.changeOccurred, name="rounded") - + createLabel(self.bgs[-1], text="Background Color", gridX=0, gridY=1, xPadding=10) temp = gtk.Entry(7) temp.set_width_chars(9) @@ -1025,10 +1012,10 @@ temp.set_name("bgCol") temp.connect("color-set", self.colorChange) self.bgs[-1].attach(temp, 2, 3, 1, 2, xoptions=gtk.EXPAND, yoptions=gtk.EXPAND) - + createLabel(self.bgs[-1], text="Border Width (px)", gridX=0, gridY=2, xPadding=10) createEntry(self.bgs[-1], maxSize=7, width=9, text=BG_BORDER, gridX=1, gridY=2, xExpand=True, yExpand=False, handler=self.changeOccurred, name="border") - + createLabel(self.bgs[-1], text="Border Color", gridX=0, gridY=3, xPadding=10) temp = gtk.Entry(7) temp.set_width_chars(9) @@ -1067,7 +1054,7 @@ if not init: self.changeOccurred() - + def addBgDefs(self, bgDefs): """Add interface elements for a list of background style definitions. bgDefs should be a list containing dictionaries with the following keys: rounded, @@ -1108,11 +1095,11 @@ self.updateComboBoxes(newId-1, "add") self.bgNotebook.set_current_page(newId) - + def apply(self, widget, event=None, confirmChange=True): """Applies the current config to tint2.""" # Check if tint2 is running - procs = os.popen('pidof "tint2"') # Check list of active processes for tint2 + procs = os.popen('pgrep -x "tint2"') # Check list of active processes for tint2 pids = [] # List of process ids for tint2 for proc in procs.readlines(): @@ -1310,23 +1297,20 @@ self.configBuf.insert(self.configBuf.get_end_iter(), "wm_menu = %s\n" % int(self.panelMenu.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "panel_layer = %s\n" % (self.panelLayer.get_active_text())) self.configBuf.insert(self.configBuf.get_end_iter(), "panel_background_id = %s\n" % (self.panelBg.get_active())) - + self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Panel Autohide\n") self.configBuf.insert(self.configBuf.get_end_iter(), "autohide = %s\n" % int(self.panelAutohide.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "autohide_show_timeout = %s\n" % (self.panelAutohideShow.get_text() if self.panelAutohideShow.get_text() else PANEL_AUTOHIDE_SHOW)) self.configBuf.insert(self.configBuf.get_end_iter(), "autohide_hide_timeout = %s\n" % (self.panelAutohideHide.get_text() if self.panelAutohideHide.get_text() else PANEL_AUTOHIDE_HIDE)) self.configBuf.insert(self.configBuf.get_end_iter(), "autohide_height = %s\n" % (self.panelAutohideHeight.get_text() if self.panelAutohideHeight.get_text() else PANEL_AUTOHIDE_HEIGHT)) self.configBuf.insert(self.configBuf.get_end_iter(), "strut_policy = %s\n" % (self.panelAutohideStrut.get_active_text() if self.panelAutohideStrut.get_active_text() else PANEL_AUTOHIDE_STRUT)) - + self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Taskbar\n") self.configBuf.insert(self.configBuf.get_end_iter(), "taskbar_mode = %s\n" % (self.taskbarMode.get_active_text())) self.configBuf.insert(self.configBuf.get_end_iter(), "taskbar_padding = %s %s %s\n" % (self.taskbarPadX.get_text() if self.taskbarPadX.get_text() else TASKBAR_PADDING_X, self.taskbarPadY.get_text() if self.taskbarPadY.get_text() else TASKBAR_PADDING_X, self.taskbarSpacing.get_text() if self.taskbarSpacing.get_text() else TASK_SPACING)) self.configBuf.insert(self.configBuf.get_end_iter(), "taskbar_background_id = %s\n" % (self.taskbarBg.get_active())) - # Comment out the taskbar_active_background_id if user has "disabled" it - if self.taskbarActiveBgEnable.get_active() == 0: - self.configBuf.insert(self.configBuf.get_end_iter(), "#") self.configBuf.insert(self.configBuf.get_end_iter(), "taskbar_active_background_id = %s\n" % (self.taskbarActiveBg.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Tasks\n") @@ -1341,7 +1325,7 @@ self.configBuf.insert(self.configBuf.get_end_iter(), "task_active_background_id = %s\n" % (self.taskActiveBg.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "task_urgent_background_id = %s\n" % (self.taskUrgentBg.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "task_iconified_background_id = %s\n" % (self.taskIconifiedBg.get_active())) - + self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Task Icons\n") self.configBuf.insert(self.configBuf.get_end_iter(), "task_icon_asb = %s %s %s\n" % (self.iconHue.get_text() if self.iconHue.get_text() else ICON_ALPHA, self.iconSat.get_text() if self.iconSat.get_text() else ICON_SAT, @@ -1355,7 +1339,7 @@ self.configBuf.insert(self.configBuf.get_end_iter(), "task_iconified_icon_asb = %s %s %s\n" % (self.iconifiedIconHue.get_text() if self.iconifiedIconHue.get_text() else ICONIFIED_ICON_ALPHA, self.iconifiedIconSat.get_text() if self.iconifiedIconSat.get_text() else ICONIFIED_ICON_SAT, self.iconifiedIconBri.get_text() if self.iconifiedIconBri.get_text() else ICONIFIED_ICON_BRI)) - + self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Fonts\n") self.configBuf.insert(self.configBuf.get_end_iter(), "task_font = %s\n" % (self.fontButton.get_font_name())) self.configBuf.insert(self.configBuf.get_end_iter(), "task_font_color = %s %s\n" % (self.getHexFromWidget(self.fontColButton), @@ -1369,7 +1353,6 @@ self.configBuf.insert(self.configBuf.get_end_iter(), "font_shadow = %s\n" % int(self.fontShadowCheckButton.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "\n# System Tray\n") - self.configBuf.insert(self.configBuf.get_end_iter(), "systray = %s\n" % int(self.trayShow.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "systray_padding = %s %s %s\n" % (self.trayPadX.get_text() if self.trayPadX.get_text() else TRAY_PADDING_X, self.trayPadY.get_text() if self.trayPadY.get_text() else TRAY_PADDING_Y, self.traySpacing.get_text() if self.traySpacing.get_text() else TRAY_SPACING)) @@ -1379,36 +1362,29 @@ self.configBuf.insert(self.configBuf.get_end_iter(), "systray_icon_asb = %s %s %s\n" % (self.trayIconHue.get_text() if self.trayIconHue.get_text() else TRAY_ICON_ALPHA, self.trayIconSat.get_text() if self.trayIconSat.get_text() else TRAY_ICON_SAT, self.trayIconBri.get_text() if self.trayIconBri.get_text() else TRAY_ICON_BRI)) - - if self.clockCheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Clock\n") - if self.clock1CheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "time1_format = %s\n" % (self.clock1Format.get_text() if self.clock1Format.get_text() else CLOCK_FMT_1)) - self.configBuf.insert(self.configBuf.get_end_iter(), "time1_font = %s\n" % (self.clock1FontButton.get_font_name())) - if self.clock2CheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "time2_format = %s\n" % (self.clock2Format.get_text() if self.clock2Format.get_text() else CLOCK_FMT_2)) - self.configBuf.insert(self.configBuf.get_end_iter(), "time2_font = %s\n" % (self.clock2FontButton.get_font_name())) - - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_font_color = %s %s\n" % (self.getHexFromWidget(self.clockFontColButton), - int(self.clockFontColButton.get_alpha() / 65535.0 * 100))) - - if self.clockTooltipCheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_tooltip = %s\n" % (self.clockTooltipFormat.get_text() if self.clockTooltipFormat.get_text() else CLOCK_TOOLTIP)) - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_padding = %s %s\n" % (self.clockPadX.get_text() if self.clockPadX.get_text() else CLOCK_PADDING_X, - self.clockPadY.get_text() if self.clockPadY.get_text() else CLOCK_PADDING_Y)) - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_background_id = %s\n" % (self.clockBg.get_active())) - if self.clockLClick.get_text(): - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_lclick_command = %s\n" % (self.clockLClick.get_text())) - if self.clockRClick.get_text(): - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_rclick_command = %s\n" % (self.clockRClick.get_text())) - if self.clockTimezone1CheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "time1_timezone = %s\n" % (self.clockTime1Timezone.get_text() if self.clockTime1Timezone.get_text() else CLOCK_TIME1_TIMEZONE)) - if self.clockTimezone2CheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "time2_timezone = %s\n" % (self.clockTime2Timezone.get_text() if self.clockTime2Timezone.get_text() else CLOCK_TIME2_TIMEZONE)) - if self.clockTimezoneTooltipCheckButton.get_active(): - self.configBuf.insert(self.configBuf.get_end_iter(), "clock_tooltip_timezone = %s\n" % (self.clockTooltipTimezone.get_text() if self.clockTooltipTimezone.get_text() else CLOCK_TOOLTIP_TIMEZONE)) - - + + self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Clock\n") + self.configBuf.insert(self.configBuf.get_end_iter(), "time1_format = %s\n" % (self.clock1Format.get_text() if self.clock1Format.get_text() else CLOCK_FMT_1)) + self.configBuf.insert(self.configBuf.get_end_iter(), "time1_font = %s\n" % (self.clock1FontButton.get_font_name())) + self.configBuf.insert(self.configBuf.get_end_iter(), "time2_format = %s\n" % (self.clock2Format.get_text() if self.clock2Format.get_text() else CLOCK_FMT_2)) + self.configBuf.insert(self.configBuf.get_end_iter(), "time2_font = %s\n" % (self.clock2FontButton.get_font_name())) + + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_font_color = %s %s\n" % (self.getHexFromWidget(self.clockFontColButton), + int(self.clockFontColButton.get_alpha() / 65535.0 * 100))) + + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_tooltip = %s\n" % (self.clockTooltipFormat.get_text() if self.clockTooltipFormat.get_text() else CLOCK_TOOLTIP)) + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_padding = %s %s\n" % (self.clockPadX.get_text() if self.clockPadX.get_text() else CLOCK_PADDING_X, + self.clockPadY.get_text() if self.clockPadY.get_text() else CLOCK_PADDING_Y)) + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_background_id = %s\n" % (self.clockBg.get_active())) + if self.clockLClick.get_text(): + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_lclick_command = %s\n" % (self.clockLClick.get_text())) + if self.clockRClick.get_text(): + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_rclick_command = %s\n" % (self.clockRClick.get_text())) + self.configBuf.insert(self.configBuf.get_end_iter(), "time1_timezone = %s\n" % (self.clockTime1Timezone.get_text() if self.clockTime1Timezone.get_text() else CLOCK_TIME1_TIMEZONE)) + self.configBuf.insert(self.configBuf.get_end_iter(), "time2_timezone = %s\n" % (self.clockTime2Timezone.get_text() if self.clockTime2Timezone.get_text() else CLOCK_TIME2_TIMEZONE)) + self.configBuf.insert(self.configBuf.get_end_iter(), "clock_tooltip_timezone = %s\n" % (self.clockTooltipTimezone.get_text() if self.clockTooltipTimezone.get_text() else CLOCK_TOOLTIP_TIMEZONE)) + + self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Tooltips\n") self.configBuf.insert(self.configBuf.get_end_iter(), "tooltip = %s\n" % int(self.tooltipShow.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "tooltip_padding = %s %s\n" % (self.tooltipPadX.get_text() if self.tooltipPadX.get_text() else TOOLTIP_PADDING_Y, @@ -1427,7 +1403,6 @@ self.configBuf.insert(self.configBuf.get_end_iter(), "mouse_scroll_down = %s\n" % (self.mouseDown.get_active_text())) self.configBuf.insert(self.configBuf.get_end_iter(), "\n# Battery\n") - self.configBuf.insert(self.configBuf.get_end_iter(), "battery = %s\n" % int(self.batteryCheckButton.get_active())) self.configBuf.insert(self.configBuf.get_end_iter(), "battery_low_status = %s\n" % (self.batteryLow.get_text() if self.batteryLow.get_text() else BATTERY_LOW)) self.configBuf.insert(self.configBuf.get_end_iter(), "battery_low_cmd = %s\n" % (self.batteryLowAction.get_text() if self.batteryLowAction.get_text() else BATTERY_ACTION)) self.configBuf.insert(self.configBuf.get_end_iter(), "battery_hide = %s\n" % (self.batteryHide.get_text() if self.batteryHide.get_text() else BATTERY_HIDE)) @@ -1523,16 +1498,16 @@ webbrowser.open("http://code.google.com/p/tintwizard/wiki/Help") except: errorDialog(self, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/wiki/Help") - + def main(self): """Enters the main loop.""" gtk.main() - + def new(self, action=None): """Prepares a new config.""" if self.toSave: self.savePrompt() - + self.toSave = True self.filename = None @@ -1636,27 +1611,6 @@ string = string.strip() # Remove whitespace from the VALUE eType = type(prop) # Get widget type - if special: # 'Special' properties are those which are optional - if propType == "time1": - self.clockCheckButton.set_active(True) - self.clock1CheckButton.set_active(True) - elif propType == "time2": - self.clockCheckButton.set_active(True) - self.clock2CheckButton.set_active(True) - elif propType == "clock_tooltip": - self.clockCheckButton.set_active(True) - self.clockTooltipCheckButton.set_active(True) - elif propType == "time1_timezone": - self.clockTimezone1CheckButton.set_active(True) - elif propType == "time2_timezone": - self.clockTimezone2CheckButton.set_active(True) - elif propType == "tooltip_timezone": - self.clockTimezoneTooltipCheckButton.set_active(True) - elif propType == "tray": - self.trayShow.set_active(True) - elif propType == "activeBg": - self.taskbarActiveBgEnable.set_active(True) - if eType == gtk.Entry: prop.set_text(string) prop.activate() @@ -1753,17 +1707,6 @@ f.close() - # Deselect the optional stuff, and we'll re-check them if the config has them enabled - self.clockCheckButton.set_active(False) - self.clock1CheckButton.set_active(False) - self.clock2CheckButton.set_active(False) - self.clockTooltipCheckButton.set_active(False) - self.clockTimezone1CheckButton.set_active(False) - self.clockTimezone2CheckButton.set_active(False) - self.clockTimezoneTooltipCheckButton.set_active(False) - self.trayShow.set_active(False) - self.taskbarActiveBgEnable.set_active(False) - # Remove all background styles so we can create new ones as we read them for i in range(len(self.bgs)): self.delBgClick(None, False) @@ -1775,7 +1718,7 @@ noBgDefs = self.parseBgs(string) self.parseConfig(noBgDefs) - + def reportBug(self, action=None): """Opens the bug report page in the default web browser.""" try: @@ -1783,7 +1726,7 @@ except: errorDialog(self, "Your default web-browser could not be opened.\nPlease visit http://code.google.com/p/tintwizard/issues/entry") - + def resetConfig(self): """Resets all the widgets to their default values.""" # Backgrounds @@ -1799,6 +1742,7 @@ self.panelPosY.set_active(0) self.panelPosX.set_active(0) self.panelOrientation.set_active(0) + self.panelItems.set_text(PANEL_ITEMS) self.panelSizeX.set_text(PANEL_SIZE_X) self.panelSizeY.set_text(PANEL_SIZE_Y) self.panelMarginX.set_text(PANEL_MARGIN_X) @@ -1823,7 +1767,6 @@ self.taskbarSpacing.set_text(TASK_SPACING) self.taskbarBg.set_active(0) self.taskbarActiveBg.set_active(0) - self.taskbarActiveBgEnable.set_active(0) # Tasks self.taskBlinks.set_text(TASK_BLINKS) self.taskCentreCheckButton.set_active(True) @@ -1866,7 +1809,6 @@ self.fontIconifiedCol.set_text(self.defaults["fgColor"]) self.fontShadowCheckButton.set_active(False) # System Tray - self.trayShow.set_active(True) self.trayPadX.set_text(TRAY_PADDING_X) self.trayPadY.set_text(TRAY_PADDING_X) self.traySpacing.set_text(TRAY_SPACING) @@ -1877,14 +1819,10 @@ self.trayIconSat.set_text(TRAY_ICON_SAT) self.trayIconBri.set_text(TRAY_ICON_BRI) # Clock - self.clockCheckButton.set_active(True) self.clock1Format.set_text(CLOCK_FMT_1) - self.clock1CheckButton.set_active(True) self.clock1FontButton.set_font_name(self.defaults["font"]) self.clock2Format.set_text(CLOCK_FMT_2) - self.clock2CheckButton.set_active(True) self.clockTooltipFormat.set_text(CLOCK_TOOLTIP) - self.clockTooltipCheckButton.set_active(False) self.clock2FontButton.set_font_name(self.defaults["font"]) self.clockFontColButton.set_alpha(65535) self.clockFontColButton.set_color(gtk.gdk.color_parse(self.defaults["fgColor"])) @@ -1895,11 +1833,8 @@ self.clockLClick.set_text(CLOCK_LCLICK) self.clockRClick.set_text(CLOCK_RCLICK) self.clockTime1Timezone.set_text(CLOCK_TIME1_TIMEZONE) - self.clockTimezone1CheckButton.set_active(False) self.clockTime2Timezone.set_text(CLOCK_TIME2_TIMEZONE) - self.clockTimezone2CheckButton.set_active(False) self.clockTooltipTimezone.set_text(CLOCK_TOOLTIP_TIMEZONE) - self.clockTimezoneTooltipCheckButton.set_active(False) # Tooltips self.tooltipShow.set_active(False) self.tooltipPadX.set_text(TOOLTIP_PADDING_X) @@ -1917,7 +1852,6 @@ self.mouseUp.set_active(0) self.mouseDown.set_active(0) # Battery - self.batteryCheckButton.set_active(False) self.batteryLow.set_text(BATTERY_LOW) self.batteryLowAction.set_text(BATTERY_ACTION) self.batteryHide.set_text(BATTERY_HIDE) @@ -1929,7 +1863,7 @@ self.batteryPadX.set_text(BATTERY_PADDING_Y) self.batteryPadY.set_text(BATTERY_PADDING_Y) self.batteryBg.set_active(0) - + def save(self, widget=None, event=None): """Saves the generated config file.""" @@ -2049,15 +1983,15 @@ for key in self.defaults: confStr += "%s = %s\n" % (key, str(self.defaults[key])) - + confStr += "#End\n" - + pathName = os.path.expandvars("${HOME}") + "/.config/tint2/" - + f = open(pathName+"tintwizard.conf", "w") - + f.write(confStr) - + f.close() def writeFile(self): @@ -2080,7 +2014,7 @@ # General use functions def createLabel(parent, text="", gridX=0, gridY=0, sizeX=1, sizeY=1, xPadding=0): """Creates a label and adds it to a parent widget.""" - + temp = gtk.Label(text) temp.set_alignment(0, 0.5) parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xpadding=xPadding) @@ -2089,17 +2023,17 @@ def createComboBox(parent, choices=["null"], active=0, gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None): """Creates a combo box with text choices and adds it to a parent widget.""" temp = gtk.combo_box_new_text() - + for choice in choices: temp.append_text(choice) - + temp.set_active(active) - + if handler != None: temp.connect("changed", handler) - + parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0) - + return temp def createEntry(parent, maxSize, width, text="", gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None, name=""): @@ -2108,12 +2042,12 @@ temp.set_width_chars(width) temp.set_text(text) temp.set_name(name) - + if handler != None: temp.connect("changed", handler) - + parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0) - + return temp def createCheckButton(parent, text="", active=False, gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None): @@ -2121,9 +2055,9 @@ temp = gtk.CheckButton(text if text != "" else None) temp.set_active(active) temp.connect("toggled", handler) - + parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0) - + return temp def createButton(parent, text="", stock=None, name="", gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None): @@ -2132,12 +2066,12 @@ temp = gtk.Button(text, stock) else: temp = gtk.Button(text) - + temp.set_name(name) temp.connect("clicked", handler) - + parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0) - + return temp def createFontButton(parent, font, gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None): @@ -2145,9 +2079,9 @@ temp = gtk.FontButton() temp.set_font_name(font) temp.connect("font-set", handler) - + parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0) - + return temp def createColorButton(parent, color="#000000", useAlpha=True, name="", gridX=0, gridY=0, sizeX=1, sizeY=1, xExpand=True, yExpand=True, handler=None): @@ -2155,9 +2089,9 @@ temp.set_use_alpha(useAlpha) temp.set_name(name) temp.connect("color-set", handler) - + parent.attach(temp, gridX, gridX+sizeX, gridY, gridY+sizeY, xoptions=gtk.EXPAND if xExpand else 0, yoptions=gtk.EXPAND if yExpand else 0) - + return temp def confirmDialog(parent, message): @@ -2205,6 +2139,7 @@ if len(sys.argv) > 1 and sys.argv[1] == "-version": print NAME, VERSION exit() - + tw = TintWizardGUI() tw.main() + diff -Naur tint2-0.11/src/tint.c tint2-svn/src/tint.c --- tint2-0.11/src/tint.c 2010-06-26 14:35:35.000000000 +0200 +++ tint2-svn/src/tint.c 2014-01-10 16:11:02.966388080 +0100 @@ -3,7 +3,7 @@ * Tint2 panel * * Copyright (C) 2007 Pål Staurland (staura@gmail.com) -* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -31,6 +31,11 @@ #include #include +#ifdef HAVE_SN +#include +#include +#endif + #include #include "server.h" #include "window.h" @@ -38,10 +43,20 @@ #include "task.h" #include "taskbar.h" #include "systraybar.h" +#include "launcher.h" #include "panel.h" #include "tooltip.h" #include "timer.h" +#include "xsettings-client.h" +// Drag and Drop state variables +Window dnd_source_window; +Window dnd_target_window; +int dnd_version; +Atom dnd_selection; +Atom dnd_atom; +int dnd_sent_request; +char *dnd_launcher_exec; void signal_handler(int sig) { @@ -63,6 +78,7 @@ default_battery(); #endif default_clock(); + default_launcher(); default_taskbar(); default_tooltip(); default_panel(); @@ -91,11 +107,12 @@ // Set signal handler signal_pending = 0; struct sigaction sa = { .sa_handler = signal_handler }; + struct sigaction sa_chld = { .sa_handler = SIG_DFL, .sa_flags = SA_NOCLDWAIT }; sigaction(SIGUSR1, &sa, 0); sigaction(SIGINT, &sa, 0); sigaction(SIGTERM, &sa, 0); sigaction(SIGHUP, &sa, 0); -// signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork() + sigaction(SIGCHLD, &sa_chld, 0); // BSD does not support pselect(), therefore we have to use select and hope that we do not // end up in a race condition there (see 'man select()' on a linux machine for more information) @@ -108,6 +125,58 @@ // sigprocmask(SIG_BLOCK, &block_mask, 0); } +#ifdef HAVE_SN +static int error_trap_depth = 0; + +static void +error_trap_push (SnDisplay *display, + Display *xdisplay) +{ + ++error_trap_depth; +} + +static void +error_trap_pop (SnDisplay *display, + Display *xdisplay) +{ + if (error_trap_depth == 0) + { + fprintf(stderr, "Error trap underflow!\n"); + return; + } + + XSync(xdisplay, False); /* get all errors out of the queue */ + --error_trap_depth; +} + +static void sigchld_handler(int sig) { + // Wait for all dead processes + pid_t pid; + while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { + SnLauncherContext *ctx; + ctx = (SnLauncherContext *) g_tree_lookup (server.pids, GINT_TO_POINTER (pid)); + if (ctx == NULL) { + fprintf(stderr, "Unknown child %d terminated!\n", pid); + } + else { + g_tree_remove (server.pids, GINT_TO_POINTER (pid)); + sn_launcher_context_complete (ctx); + sn_launcher_context_unref (ctx); + } + } +} + +static gint cmp_ptr(gconstpointer a, gconstpointer b) { + if (a < b) + return -1; + else if (a == b) + return 0; + else + return 1; +} + +#endif // HAVE_SN + void init_X11() { server.dsp = XOpenDisplay (NULL); @@ -122,6 +191,19 @@ server_init_visual(); XSetErrorHandler ((XErrorHandler) server_catch_error); +#ifdef HAVE_SN + // Initialize startup-notification + server.sn_dsp = sn_display_new (server.dsp, error_trap_push, error_trap_pop); + server.pids = g_tree_new (cmp_ptr); + // Setup a handler for child termination + struct sigaction act; + memset (&act, 0, sizeof (struct sigaction)); + act.sa_handler = sigchld_handler; + if (sigaction(SIGCHLD, &act, 0)) { + perror("sigaction"); + } +#endif // HAVE_SN + imlib_context_set_display (server.dsp); imlib_context_set_visual (server.visual); imlib_context_set_colormap (server.colormap); @@ -132,7 +214,7 @@ setlocale (LC_ALL, ""); // config file use '.' as decimal separator setlocale(LC_NUMERIC, "POSIX"); - + // load default icon gchar *path; const gchar * const *data_dirs; @@ -153,14 +235,14 @@ void cleanup() { - cleanup_timeout(); cleanup_systray(); - cleanup_panel(); cleanup_tooltip(); cleanup_clock(); + cleanup_launcher(); #ifdef ENABLE_BATTERY cleanup_battery(); #endif + cleanup_panel(); cleanup_config(); if (default_icon) { @@ -170,6 +252,7 @@ imlib_context_disconnect_display(); cleanup_server(); + cleanup_timeout(); if (server.dsp) XCloseDisplay(server.dsp); } @@ -182,7 +265,7 @@ panel->area.width = server.monitor[0].width; panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); - refresh(&panel->area); + rendering(panel); Imlib_Image img = NULL; imlib_context_set_drawable(panel->temp_pmap); @@ -246,16 +329,16 @@ set_active(tsk->win); break; case NEXT_TASK: - if (task_active) { + { Task *tsk1; - tsk1 = next_task(task_active); + tsk1 = next_task(find_active_task(tsk, task_active)); set_active(tsk1->win); } break; case PREV_TASK: - if (task_active) { + { Task *tsk1; - tsk1 = prev_task(task_active); + tsk1 = prev_task(find_active_task(tsk, task_active)); set_active(tsk1->win); } } @@ -277,7 +360,15 @@ else return 0; } - // no task clicked --> check if taskbar clicked + LauncherIcon *icon = click_launcher_icon(panel, e->x, e->y); + if (icon) { + if (e->button == 1) { + return 1; + } else { + return 0; + } + } + // no launcher/task clicked --> check if taskbar clicked Taskbar *tskbar = click_taskbar(panel, e->x, e->y); if (tskbar && e->button == 1 && panel_mode == MULTI_DESKTOP) return 1; @@ -359,8 +450,10 @@ Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent; drag_taskbar->area.list = g_slist_remove(drag_taskbar->area.list, task_drag); - if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) - event_taskbar->area.list = g_slist_prepend(event_taskbar->area.list, task_drag); + if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) { + int i = (taskbarname_enabled) ? 1 : 0; + event_taskbar->area.list = g_slist_insert(event_taskbar->area.list, task_drag, i); + } else event_taskbar->area.list = g_slist_append(event_taskbar->area.list, task_drag); @@ -420,6 +513,15 @@ return; } + if ( click_launcher(panel, e->xbutton.x, e->xbutton.y)) { + LauncherIcon *icon = click_launcher_icon(panel, e->xbutton.x, e->xbutton.y); + if (icon) { + launcher_action(icon, e); + } + task_drag = 0; + return; + } + Taskbar *tskbar; if ( !(tskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y)) ) { // TODO: check better solution to keep window below @@ -458,19 +560,57 @@ Window win = e->xproperty.window; Atom at = e->xproperty.atom; + if (xsettings_client) + xsettings_client_process_event(xsettings_client, e); if (win == server.root_win) { if (!server.got_root_win) { XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); server.got_root_win = 1; } + // Change name of desktops + else if (at == server.atom._NET_DESKTOP_NAMES) { + if (!taskbarname_enabled) return; + GSList *l, *list = server_get_name_of_desktop(); + int j; + gchar *name; + Taskbar *tskbar; + for (i=0 ; i < nb_panel ; i++) { + for (j=0, l=list ; j < panel1[i].nb_desktop ; j++) { + if (l) { + name = g_strdup(l->data); + l = l->next; + } + else + name = g_strdup_printf("%d", j+1); + tskbar = &panel1[i].taskbar[j]; + if (strcmp(name, tskbar->bar_name.name) != 0) { + g_free(tskbar->bar_name.name); + tskbar->bar_name.name = name; + tskbar->bar_name.area.resize = 1; + } + else + g_free(name); + } + } + for (l=list ; l ; l = l->next) + g_free(l->data); + g_slist_free(list); + panel_refresh = 1; + } // Change number of desktops else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) { + if (!taskbar_enabled) return; server.nb_desktop = server_get_number_of_desktop (); + if (server.nb_desktop <= server.desktop) { + server.desktop = server.nb_desktop-1; + } cleanup_taskbar(); init_taskbar(); - visible_object(); for (i=0 ; i < nb_panel ; i++) { + init_taskbar_panel(&panel1[i]); + set_panel_items_order(&panel1[i]); + visible_taskbar(&panel1[i]); panel1[i].area.resize = 1; } task_refresh_tasklist(); @@ -479,28 +619,22 @@ } // Change desktop else if (at == server.atom._NET_CURRENT_DESKTOP) { + if (!taskbar_enabled) return; int old_desktop = server.desktop; server.desktop = server_get_current_desktop (); for (i=0 ; i < nb_panel ; i++) { Panel *panel = &panel1[i]; - if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) { - // redraw both taskbar - if (server.nb_desktop > old_desktop) { - // can happen if last desktop is deleted and we've been on the last desktop - panel->taskbar[old_desktop].area.bg = panel->g_taskbar.bg; - panel->taskbar[old_desktop].area.resize = 1; - } - panel->taskbar[server.desktop].area.bg = panel->g_taskbar.bg_active; - panel->taskbar[server.desktop].area.resize = 1; - panel_refresh = 1; - } + set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL); + set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE); // check ALLDESKTOP task => resize taskbar Taskbar *tskbar; Task *tsk; GSList *l; if (server.nb_desktop > old_desktop) { tskbar = &panel->taskbar[old_desktop]; - for (l = tskbar->area.list; l ; l = l->next) { + l = tskbar->area.list; + if (taskbarname_enabled) l = l->next; + for (; l ; l = l->next) { tsk = l->data; if (tsk->desktop == ALLDESKTOP) { tsk->area.on_screen = 0; @@ -510,7 +644,9 @@ } } tskbar = &panel->taskbar[server.desktop]; - for (l = tskbar->area.list; l ; l = l->next) { + l = tskbar->area.list; + if (taskbarname_enabled) l = l->next; + for (; l ; l = l->next) { tsk = l->data; if (tsk->desktop == ALLDESKTOP) { tsk->area.on_screen = 1; @@ -518,9 +654,6 @@ } } } - if (panel_mode != MULTI_DESKTOP) { - visible_object(); - } } // Window list else if (at == server.atom._NET_CLIENT_LIST) { @@ -532,7 +665,7 @@ active_task(); panel_refresh = 1; } - else if (at == server.atom._XROOTPMAP_ID) { + else if (at == server.atom._XROOTPMAP_ID || at == server.atom._XROOTMAP_ID) { // change Wallpaper for (i=0 ; i < nb_panel ; i++) { set_panel_background(&panel1[i]); @@ -564,12 +697,13 @@ // Window title changed if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { - get_title(tsk); - if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) { - tooltip_copy_text((Area*)tsk); - tooltip_update(); + if (get_title(tsk)) { + if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) { + tooltip_copy_text((Area*)tsk); + tooltip_update(); + } + panel_refresh = 1; } - panel_refresh = 1; } // Demand attention else if (at == server.atom._NET_WM_STATE) { @@ -668,9 +802,150 @@ } } +char *GetAtomName(Display* disp, Atom a) +{ + if (a == None) + return "None"; + else + return XGetAtomName(disp, a); +} + +typedef struct Property +{ + unsigned char *data; + int format, nitems; + Atom type; +} Property; + +//This fetches all the data from a property +struct Property read_property(Display* disp, Window w, Atom property) +{ + Atom actual_type; + int actual_format; + unsigned long nitems; + unsigned long bytes_after; + unsigned char *ret=0; + + int read_bytes = 1024; + + //Keep trying to read the property until there are no + //bytes unread. + do { + if (ret != 0) + XFree(ret); + XGetWindowProperty(disp, w, property, 0, read_bytes, False, AnyPropertyType, + &actual_type, &actual_format, &nitems, &bytes_after, + &ret); + read_bytes *= 2; + } while (bytes_after != 0); + + fprintf(stderr, "DnD %s:%d: Property:\n", __FILE__, __LINE__); + fprintf(stderr, "DnD %s:%d: Actual type: %s\n", __FILE__, __LINE__, GetAtomName(disp, actual_type)); + fprintf(stderr, "DnD %s:%d: Actual format: %d\n", __FILE__, __LINE__, actual_format); + fprintf(stderr, "DnD %s:%d: Number of items: %lu\n", __FILE__, __LINE__, nitems); + + Property p; + p.data = ret; + p.format = actual_format; + p.nitems = nitems; + p.type = actual_type; + + return p; +} + +// This function takes a list of targets which can be converted to (atom_list, nitems) +// and a list of acceptable targets with prioritees (datatypes). It returns the highest +// entry in datatypes which is also in atom_list: ie it finds the best match. +Atom pick_target_from_list(Display* disp, Atom* atom_list, int nitems) +{ + Atom to_be_requested = None; + int i; + for (i = 0; i < nitems; i++) { + char *atom_name = GetAtomName(disp, atom_list[i]); + fprintf(stderr, "DnD %s:%d: Type %d = %s\n", __FILE__, __LINE__, i, atom_name); + + //See if this data type is allowed and of higher priority (closer to zero) + //than the present one. + if (strcmp(atom_name, "STRING") == 0) { + to_be_requested = atom_list[i]; + } + } + + return to_be_requested; +} + +// Finds the best target given up to three atoms provided (any can be None). +// Useful for part of the Xdnd protocol. +Atom pick_target_from_atoms(Display* disp, Atom t1, Atom t2, Atom t3) +{ + Atom atoms[3]; + int n = 0; + + if (t1 != None) + atoms[n++] = t1; + + if (t2 != None) + atoms[n++] = t2; + + if (t3 != None) + atoms[n++] = t3; + + return pick_target_from_list(disp, atoms, n); +} + +// Finds the best target given a local copy of a property. +Atom pick_target_from_targets(Display* disp, Property p) +{ + //The list of targets is a list of atoms, so it should have type XA_ATOM + //but it may have the type TARGETS instead. -void dnd_message(XClientMessageEvent *e) + if ((p.type != XA_ATOM && p.type != server.atom.TARGETS) || p.format != 32) { + //This would be really broken. Targets have to be an atom list + //and applications should support this. Nevertheless, some + //seem broken (MATLAB 7, for instance), so ask for STRING + //next instead as the lowest common denominator + return XA_STRING; + } else { + Atom *atom_list = (Atom*)p.data; + + return pick_target_from_list(disp, atom_list, p.nitems); + } +} + +void dnd_enter(XClientMessageEvent *e) { + dnd_atom = None; + int more_than_3 = e->data.l[1] & 1; + dnd_source_window = e->data.l[0]; + dnd_version = (e->data.l[1] >> 24); + + fprintf(stderr, "DnD %s:%d: DnDEnter\n", __FILE__, __LINE__); + fprintf(stderr, "DnD %s:%d: DnDEnter. Supports > 3 types = %s\n", __FILE__, __LINE__, more_than_3 ? "yes" : "no"); + fprintf(stderr, "DnD %s:%d: Protocol version = %d\n", __FILE__, __LINE__, dnd_version); + fprintf(stderr, "DnD %s:%d: Type 1 = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, e->data.l[2])); + fprintf(stderr, "DnD %s:%d: Type 2 = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, e->data.l[3])); + fprintf(stderr, "DnD %s:%d: Type 3 = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, e->data.l[4])); + + //Query which conversions are available and pick the best + + if (more_than_3) { + //Fetch the list of possible conversions + //Notice the similarity to TARGETS with paste. + Property p = read_property(server.dsp, dnd_source_window, server.atom.XdndTypeList); + dnd_atom = pick_target_from_targets(server.dsp, p); + XFree(p.data); + } else { + //Use the available list + dnd_atom = pick_target_from_atoms(server.dsp, e->data.l[2], e->data.l[3], e->data.l[4]); + } + + fprintf(stderr, "DnD %s:%d: Requested type = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, dnd_atom)); +} + +void dnd_position(XClientMessageEvent *e) +{ + dnd_target_window = e->window; + int accept = 0; Panel *panel = get_panel(e->window); int x, y, mapX, mapY; Window child; @@ -682,6 +957,14 @@ if (task->desktop != server.desktop ) set_desktop (task->desktop); window_action(task, TOGGLE); + } else { + LauncherIcon *icon = click_launcher_icon(panel, mapX, mapY); + if (icon) { + accept = 1; + dnd_launcher_exec = icon->cmd; + } else { + dnd_launcher_exec = 0; + } } // send XdndStatus event to get more XdndPosition events @@ -691,13 +974,42 @@ se.message_type = server.atom.XdndStatus; se.format = 32; se.data.l[0] = e->window; // XID of the target window - se.data.l[1] = 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle + se.data.l[1] = accept ? 1 : 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle se.data.l[2] = 0; // Rectangle x,y for which no more XdndPosition events se.data.l[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events - se.data.l[4] = None; // None = drop will not be accepted + if (accept) { + se.data.l[4] = dnd_version >= 2 ? e->data.l[4] : server.atom.XdndActionCopy; + } else { + se.data.l[4] = None; // None = drop will not be accepted + } + XSendEvent(server.dsp, e->data.l[0], False, NoEventMask, (XEvent*)&se); } +void dnd_drop(XClientMessageEvent *e) +{ + if (dnd_target_window && dnd_launcher_exec) { + if (dnd_version >= 1) { + XConvertSelection(server.dsp, server.atom.XdndSelection, XA_STRING, dnd_selection, dnd_target_window, e->data.l[2]); + } else { + XConvertSelection(server.dsp, server.atom.XdndSelection, XA_STRING, dnd_selection, dnd_target_window, CurrentTime); + } + } else { + //The source is sending anyway, despite instructions to the contrary. + //So reply that we're not interested. + XClientMessageEvent m; + memset(&m, sizeof(m), 0); + m.type = ClientMessage; + m.display = e->display; + m.window = e->data.l[0]; + m.message_type = server.atom.XdndFinished; + m.format = 32; + m.data.l[0] = dnd_target_window; + m.data.l[1] = 0; + m.data.l[2] = None; //Failed. + XSendEvent(server.dsp, e->data.l[0], False, NoEventMask, (XEvent*)&m); + } +} int main (int argc, char *argv[]) { @@ -737,6 +1049,15 @@ x11_fd = ConnectionNumber(server.dsp); XSync(server.dsp, False); + // XDND initialization + dnd_source_window = 0; + dnd_target_window = 0; + dnd_version = 0; + dnd_selection = XInternAtom(server.dsp, "PRIMARY", 0); + dnd_atom = None; + dnd_sent_request = 0; + dnd_launcher_exec = 0; + // sigset_t empty_mask; // sigemptyset(&empty_mask); @@ -754,7 +1075,7 @@ else { if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap); panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); - refresh(&panel->area); + rendering(panel); XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); } } @@ -784,6 +1105,9 @@ if (select(x11_fd+1, &fdset, 0, 0, timeout) > 0) { while (XPending (server.dsp)) { XNextEvent(server.dsp, &e); +#if HAVE_SN + sn_display_process_event (server.sn_dsp, &e); +#endif // HAVE_SN panel = get_panel(e.xany.window); if (panel && panel_autohide) { @@ -820,19 +1144,17 @@ if (e.xmotion.state & button_mask) event_button_motion_notify (&e); - if (!g_tooltip.enabled) break; Panel* panel = get_panel(e.xmotion.window); Area* area = click_area(panel, e.xmotion.x, e.xmotion.y); if (area->_get_tooltip_text) - tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root); + tooltip_trigger_show(area, panel, &e); else tooltip_trigger_hide(); break; } case LeaveNotify: - if (g_tooltip.enabled) - tooltip_trigger_hide(); + tooltip_trigger_hide(); break; case Expose: @@ -862,7 +1184,7 @@ signal_pending = SIGUSR1; break; } - if (e.xany.window == g_tooltip.window || !systray.area.on_screen) + if (e.xany.window == g_tooltip.window || !systray_enabled) break; for (it = systray.list_icons; it; it = g_slist_next(it)) { if (((TrayWindow*)it->data)->tray_id == e.xany.window) { @@ -870,7 +1192,7 @@ break; } } - break; + break; case ClientMessage: ev = &e.xclient; @@ -882,14 +1204,125 @@ // Start real_transparency signal_pending = SIGUSR1; } - if (systray.area.on_screen && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) { + if (systray_enabled && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) { net_message(&e.xclient); } + else if (e.xclient.message_type == server.atom.XdndEnter) { + dnd_enter(&e.xclient); + } else if (e.xclient.message_type == server.atom.XdndPosition) { - dnd_message(&e.xclient); + dnd_position(&e.xclient); + } + else if (e.xclient.message_type == server.atom.XdndDrop) { + dnd_drop(&e.xclient); } break; + case SelectionNotify: + { + Atom target = e.xselection.target; + + fprintf(stderr, "DnD %s:%d: A selection notify has arrived!\n", __FILE__, __LINE__); + fprintf(stderr, "DnD %s:%d: Requestor = %lu\n", __FILE__, __LINE__, e.xselectionrequest.requestor); + fprintf(stderr, "DnD %s:%d: Selection atom = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, e.xselection.selection)); + fprintf(stderr, "DnD %s:%d: Target atom = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, target)); + fprintf(stderr, "DnD %s:%d: Property atom = %s\n", __FILE__, __LINE__, GetAtomName(server.dsp, e.xselection.property)); + + if (e.xselection.property != None && dnd_launcher_exec) { + Property prop = read_property(server.dsp, dnd_target_window, dnd_selection); + + //If we're being given a list of targets (possible conversions) + if (target == server.atom.TARGETS && !dnd_sent_request) { + dnd_sent_request = 1; + dnd_atom = pick_target_from_targets(server.dsp, prop); + + if (dnd_atom == None) { + fprintf(stderr, "No matching datatypes.\n"); + } else { + //Request the data type we are able to select + fprintf(stderr, "Now requsting type %s", GetAtomName(server.dsp, dnd_atom)); + XConvertSelection(server.dsp, dnd_selection, dnd_atom, dnd_selection, dnd_target_window, CurrentTime); + } + } else if (target == dnd_atom) { + //Dump the binary data + fprintf(stderr, "DnD %s:%d: Data begins:\n", __FILE__, __LINE__); + fprintf(stderr, "--------\n"); + int i; + for (i = 0; i < prop.nitems * prop.format/8; i++) + fprintf(stderr, "%c", ((char*)prop.data)[i]); + fprintf(stderr, "--------\n"); + + int cmd_length = 0; + cmd_length += 1; // ( + cmd_length += strlen(dnd_launcher_exec) + 1; // exec + space + cmd_length += 1; // open double quotes + for (i = 0; i < prop.nitems * prop.format/8; i++) { + char c = ((char*)prop.data)[i]; + if (c == '\n') { + if (i < prop.nitems * prop.format/8 - 1) { + cmd_length += 3; // close double quotes, space, open double quotes + } + } else if (c == '\r') { + } else { + cmd_length += 1; // 1 character + if (c == '`' || c == '$' || c == '\\') { + cmd_length += 1; // escape with one backslash + } + } + } + cmd_length += 1; // close double quotes + cmd_length += 2; // &) + cmd_length += 1; // terminator + + char *cmd = malloc(cmd_length); + cmd[0] = '\0'; + strcat(cmd, "("); + strcat(cmd, dnd_launcher_exec); + strcat(cmd, " \""); + for (i = 0; i < prop.nitems * prop.format/8; i++) { + char c = ((char*)prop.data)[i]; + if (c == '\n') { + if (i < prop.nitems * prop.format/8 - 1) { + strcat(cmd, "\" \""); + } + } else if (c == '\r') { + } else { + if (c == '`' || c == '$' || c == '\\') { + strcat(cmd, "\\"); + } + char sc[2]; + sc[0] = c; + sc[1] = '\0'; + strcat(cmd, sc); + } + } + strcat(cmd, "\""); + strcat(cmd, "&)"); + fprintf(stderr, "DnD %s:%d: Running command: %s\n", __FILE__, __LINE__, cmd); + tint_exec(cmd); + free(cmd); + + // Reply OK. + XClientMessageEvent m; + memset(&m, sizeof(m), 0); + m.type = ClientMessage; + m.display = server.dsp; + m.window = dnd_source_window; + m.message_type = server.atom.XdndFinished; + m.format = 32; + m.data.l[0] = dnd_target_window; + m.data.l[1] = 1; + m.data.l[2] = server.atom.XdndActionCopy; //We only ever copy. + XSendEvent(server.dsp, dnd_source_window, False, NoEventMask, (XEvent*)&m); + XSync(server.dsp, False); + } + + XFree(prop.data); + } + + break; + } + default: if (e.type == XDamageNotify+damage_event) { // union needed to avoid strict-aliasing warnings by gcc diff -Naur tint2-0.11/src/tooltip/tooltip.c tint2-svn/src/tooltip/tooltip.c --- tint2-0.11/src/tooltip/tooltip.c 2010-04-20 00:06:23.000000000 +0200 +++ tint2-svn/src/tooltip/tooltip.c 2014-01-10 16:11:03.119390677 +0100 @@ -62,6 +62,8 @@ { if (!g_tooltip.font_desc) g_tooltip.font_desc = pango_font_description_from_string("sans 10"); + if (g_tooltip.bg == 0) + g_tooltip.bg = &g_array_index(backgrounds, Background, 0); XSetWindowAttributes attr; attr.override_redirect = True; @@ -75,10 +77,13 @@ } -void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root) +void tooltip_trigger_show(Area* area, Panel* p, XEvent *e) { - x = x_root; - y = y_root; + // Position the tooltip in the center of the area + x = area->posx + area->width / 2 + e->xmotion.x_root - e->xmotion.x; + y = area->posy + area->height / 2 + e->xmotion.y_root - e->xmotion.y; + if (!panel_horizontal) + y -= height/2; g_tooltip.panel = p; if (g_tooltip.mapped && g_tooltip.area != area) { tooltip_copy_text(area); @@ -93,10 +98,13 @@ void tooltip_show(void* arg) { - int mx, my; - Window w; - XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w); - Area* area = click_area(g_tooltip.panel, mx, my); + int mx, my; + Window w; + XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w); + Area* area; + if (!panel_horizontal) + my += height/2; /* we adjusted y in tooltip_trigger_show, revert or we won't find the correct area anymore */ + area = click_area(g_tooltip.panel, mx, my); stop_tooltip_timeout(); if (!g_tooltip.mapped && area->_get_tooltip_text) { tooltip_copy_text(area); @@ -148,22 +156,22 @@ Panel* panel = g_tooltip.panel; int screen_width = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width; int screen_height = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height; - if ( x+width <= screen_width && y+height <= screen_height && x>=0 && y>=0) + if ( x+width <= screen_width && y+height <= screen_height && x>=server.monitor[panel->monitor].x && y>=server.monitor[panel->monitor].y ) return; // no adjustment needed if (panel_horizontal) { min_x=0; - max_width=screen_width; - max_height=screen_height-panel->area.height; + max_width=server.monitor[panel->monitor].width; + max_height=server.monitor[panel->monitor].height-panel->area.height; if (panel_position & BOTTOM) min_y=0; else min_y=panel->area.height; } else { - max_width=screen_width-panel->area.width; + max_width=server.monitor[panel->monitor].width-panel->area.width; min_y=0; - max_height=screen_height; + max_height=server.monitor[panel->monitor].height; if (panel_position & LEFT) min_x=panel->area.width; else diff -Naur tint2-0.11/src/tooltip/tooltip.h tint2-svn/src/tooltip/tooltip.h --- tint2-0.11/src/tooltip/tooltip.h 2010-04-18 16:28:45.000000000 +0200 +++ tint2-svn/src/tooltip/tooltip.h 2014-01-10 16:11:03.118390659 +0100 @@ -30,7 +30,6 @@ Window window; int show_timeout_msec; int hide_timeout_msec; - Bool enabled; Bool mapped; int paddingx; int paddingy; @@ -50,7 +49,7 @@ void cleanup_tooltip(); void init_tooltip(); -void tooltip_trigger_show(Area* area, Panel* p, int x, int y); +void tooltip_trigger_show(Area* area, Panel* p, XEvent *e); void tooltip_show(void* /*arg*/); void tooltip_update(); void tooltip_trigger_hide(); diff -Naur tint2-0.11/src/util/area.c tint2-svn/src/util/area.c --- tint2-0.11/src/util/area.c 2010-04-18 14:07:36.000000000 +0200 +++ tint2-svn/src/util/area.c 2014-01-10 16:11:03.167391495 +0100 @@ -2,7 +2,7 @@ * * Tint2 : area * -* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -31,24 +31,183 @@ #include "panel.h" -// 1) resize child -// 2) resize parent -// 3) redraw parent -// 4) redraw child +/************************************************************ + * !!! This design is experimental and not yet fully implemented !!!!!!!!!!!!! + * + * DATA ORGANISATION : + * Areas in tint2 are similar to widgets in a GUI. + * All graphical objects (panel, taskbar, task, systray, clock, ...) 'inherit' an abstract class 'Area'. + * This class 'Area' manage the background, border, size, position and padding. + * Area is at the begining of each object (&object == &area). + * + * tint2 define one panel per monitor. And each panel have a tree of Area. + * The root of the tree is Panel.Area. And task, clock, systray, taskbar,... are nodes. + * + * The tree give the localisation of each object : + * - tree's root is in the background while tree's leafe are foreground objects + * - position of a node/Area depend on the layout : parent's position (posx, posy), size of previous brothers and parent's padding + * - size of a node/Area depend on the content (SIZE_BY_CONTENT objects) or on the layout (SIZE_BY_LAYOUT objects) + * + * DRAWING AND LAYERING ENGINE : + * Redrawing an object (like the clock) could come from an 'external event' (date change) + * or from a 'layering event' (position change). + * The following 'drawing engine' take care of : + * - posx/posy of all Area + * - 'layering event' propagation between object + * 1) browse tree SIZE_BY_CONTENT + * - resize SIZE_BY_CONTENT node : children are resized before parent + * - if 'size' changed then 'resize = 1' on the parent + * 2) browse tree SIZE_BY_LAYOUT and POSITION + * - resize SIZE_BY_LAYOUT node : parent is resized before children + * - calculate position (posx,posy) : parent is calculated before children + * - if 'position' changed then 'redraw = 1' + * 3) browse tree REDRAW + * - redraw needed objects : parent is drawn before children + * + * CONFIGURE PANEL'S LAYOUT : + * 'panel_items' parameter (in config) define the list and the order of nodes in tree's panel. + * 'panel_items = SC' define a panel with just Systray and Clock. + * So the tree 'Panel.Area' will have 2 childs (Systray and Clock). + * + ************************************************************/ + +void init_rendering(void *obj, int pos) +{ + Area *a = (Area*)obj; + + // initialize fixed position/size + GSList *l; + for (l = a->list; l ; l = l->next) { + Area *child = ((Area*)l->data); + if (panel_horizontal) { + child->posy = pos + a->bg->border.width + a->paddingy; + child->height = a->height - (2 * (a->bg->border.width + a->paddingy)); + init_rendering(child, child->posy); + } + else { + child->posx = pos + a->bg->border.width + a->paddingy; + child->width = a->width - (2 * (a->bg->border.width + a->paddingy)); + init_rendering(child, child->posx); + } + } +} + + +void rendering(void *obj) +{ + Panel *panel = (Panel*)obj; + + size_by_content(&panel->area); + size_by_layout(&panel->area, 0, 1); + + refresh(&panel->area); +} + + +void size_by_content (Area *a) +{ + // don't resize hiden objects + if (!a->on_screen) return; + + // children node are resized before its parent + GSList *l; + for (l = a->list; l ; l = l->next) + size_by_content(l->data); + + // calculate area's size + a->on_changed = 0; + if (a->resize && a->size_mode == SIZE_BY_CONTENT) { + a->resize = 0; + + if (a->_resize) { + if (a->_resize(a)) { + // 'size' changed => 'resize = 1' on the parent + ((Area*)a->parent)->resize = 1; + a->on_changed = 1; + } + } + } +} + + +void size_by_layout (Area *a, int pos, int level) +{ + // don't resize hiden objects + if (!a->on_screen) return; + + // parent node is resized before its children + // calculate area's size + GSList *l; + if (a->resize && a->size_mode == SIZE_BY_LAYOUT) { + a->resize = 0; + + if (a->_resize) { + a->_resize(a); + // resize childs with SIZE_BY_LAYOUT + for (l = a->list; l ; l = l->next) { + Area *child = ((Area*)l->data); + if (child->size_mode == SIZE_BY_LAYOUT && child->list) + child->resize = 1; + } + } + } + + // update position of childs + pos += a->paddingxlr + a->bg->border.width; + int i=0; + for (l = a->list; l ; l = l->next) { + Area *child = ((Area*)l->data); + if (!child->on_screen) continue; + i++; + + if (panel_horizontal) { + if (pos != child->posx) { + // pos changed => redraw + child->posx = pos; + child->on_changed = 1; + } + } + else { + if (pos != child->posy) { + // pos changed => redraw + child->posy = pos; + child->on_changed = 1; + } + } + + /*// position of each visible object + int k; + for (k=0 ; k < level ; k++) printf(" "); + printf("tree level %d, object %d, pos %d, %s\n", level, i, pos, (child->size_mode == SIZE_BY_LAYOUT) ? "SIZE_BY_LAYOUT" : "SIZE_BY_CONTENT");*/ + size_by_layout(child, pos, level+1); + + if (panel_horizontal) + pos += child->width + a->paddingx; + else + pos += child->height + a->paddingx; + } + + if (a->on_changed) { + // pos/size changed + a->redraw = 1; + if (a->_on_change_layout) + a->_on_change_layout (a); + } +} + + void refresh (Area *a) { // don't draw and resize hide objects if (!a->on_screen) return; - size(a); - // don't draw transparent objects (without foreground and without background) if (a->redraw) { a->redraw = 0; // force redraw of child - GSList *l; - for (l = a->list ; l ; l = l->next) - set_redraw(l->data); + //GSList *l; + //for (l = a->list ; l ; l = l->next) + //((Area*)l->data)->redraw = 1; //printf("draw area posx %d, width %d\n", a->posx, a->width); draw(a); @@ -65,23 +224,95 @@ } -void size (Area *a) +int resize_by_layout(void *obj, int maximum_size) { - GSList *l; + Area *child, *a = (Area*)obj; + int size, nb_by_content=0, nb_by_layout=0; - if (a->resize) { - a->resize = 0; - // force the resize of childs - for (l = a->list; l ; l = l->next) { - Area *area = (Area*)l->data; - area->resize = 1; - size(area); + if (panel_horizontal) { + // detect free size for SIZE_BY_LAYOUT's Area + size = a->width - (2 * (a->paddingxlr + a->bg->border.width)); + GSList *l; + for (l = a->list ; l ; l = l->next) { + child = (Area*)l->data; + if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) { + size -= child->width; + nb_by_content++; + } + if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) + nb_by_layout++; + } + //printf(" resize_by_layout Deb %d, %d\n", nb_by_content, nb_by_layout); + if (nb_by_content+nb_by_layout) + size -= ((nb_by_content+nb_by_layout-1) * a->paddingx); + + int width=0, modulo=0, old_width; + if (nb_by_layout) { + width = size / nb_by_layout; + modulo = size % nb_by_layout; + if (width > maximum_size && maximum_size != 0) { + width = maximum_size; + modulo = 0; + } } - // resize can generate a redraw - if (a->_resize) - a->_resize(a); + // resize SIZE_BY_LAYOUT objects + for (l = a->list ; l ; l = l->next) { + child = (Area*)l->data; + if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) { + old_width = child->width; + child->width = width; + if (modulo) { + child->width++; + modulo--; + } + if (child->width != old_width) + child->on_changed = 1; + } + } } + else { + // detect free size for SIZE_BY_LAYOUT's Area + size = a->height - (2 * (a->paddingxlr + a->bg->border.width)); + GSList *l; + for (l = a->list ; l ; l = l->next) { + child = (Area*)l->data; + if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) { + size -= child->height; + nb_by_content++; + } + if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) + nb_by_layout++; + } + if (nb_by_content+nb_by_layout) + size -= ((nb_by_content+nb_by_layout-1) * a->paddingx); + + int height=0, modulo=0, old_height; + if (nb_by_layout) { + height = size / nb_by_layout; + modulo = size % nb_by_layout; + if (height > maximum_size && maximum_size != 0) { + height = maximum_size; + modulo = 0; + } + } + + // resize SIZE_BY_LAYOUT objects + for (l = a->list ; l ; l = l->next) { + child = (Area*)l->data; + if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) { + old_height = child->height; + child->height = height; + if (modulo) { + child->height++; + modulo--; + } + if (child->height != old_height) + child->on_changed = 1; + } + } + } + return 0; } @@ -94,6 +325,26 @@ set_redraw(l->data); } +void hide(Area *a) +{ + Area *parent = (Area*)a->parent; + + a->on_screen = 0; + parent->resize = 1; + if (panel_horizontal) + a->width = 0; + else + a->height = 0; +} + +void show(Area *a) +{ + Area *parent = (Area*)a->parent; + + a->on_screen = 1; + parent->resize = 1; + a->resize = 1; +} void draw (Area *a) { @@ -137,9 +388,9 @@ draw_rect(c, a->bg->border.width/2.0, a->bg->border.width/2.0, a->width - a->bg->border.width, a->height - a->bg->border.width, a->bg->border.rounded); /* // convert : radian = degre * M_PI/180 - // définir le dégradé dans un carré de (0,0) (100,100) - // ensuite ce dégradé est extrapolé selon le ratio width/height - // dans repère (0, 0) (100, 100) + // definir le degrade dans un carre de (0,0) (100,100) + // ensuite ce degrade est extrapoler selon le ratio width/height + // dans repere (0, 0) (100, 100) double X0, Y0, X1, Y1, degre; // x = X * (a->width / 100), y = Y * (a->height / 100) double x0, y0, x1, y1; @@ -148,13 +399,13 @@ X1 = 100; Y1 = 0; degre = 45; - // et ensuite faire la changement d'unité du repère - // car ce qui doit resté inchangée est les traits et pas la direction + // et ensuite faire la changement d'unite du repere + // car ce qui doit reste inchangee est les traits et pas la direction - // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°) - // ceci peut être appliqué une fois pour toute au départ - // ensuite calculer l'angle dans le nouveau repère - // puis faire une rotation de 90° + // il faut d'abord appliquer une rotation de 90 (et -180 si l'angle est superieur a 180) + // ceci peut etre applique une fois pour toute au depart + // ensuite calculer l'angle dans le nouveau repare + // puis faire une rotation de 90 x0 = X0 * ((double)a->width / 100); x1 = X1 * ((double)a->width / 100); y0 = Y0 * ((double)a->height / 100); @@ -193,7 +444,7 @@ { Area *parent = (Area*)a->parent; - parent->list = g_slist_remove(parent->list, a); + parent->list = g_slist_append(parent->list, a); set_redraw (parent); } diff -Naur tint2-0.11/src/util/area.h tint2-svn/src/util/area.h --- tint2-0.11/src/util/area.h 2010-01-09 01:11:01.000000000 +0100 +++ tint2-svn/src/util/area.h 2014-01-10 16:11:03.167391495 +0100 @@ -47,6 +47,10 @@ } Background; +// way to calculate the size +// SIZE_BY_LAYOUT objects : taskbar and task +// SIZE_BY_CONTENT objects : clock, battery, launcher, systray +enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT }; typedef struct { // coordinate relative to panel window @@ -59,8 +63,12 @@ // list of child : Area object GSList *list; + // object visible on screen. + // An object (like systray) could be enabled but hidden (because no tray icon). int on_screen; - // need compute position and width + // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT) + int size_mode; + // need to calculate position and width int resize; // need redraw Pixmap int redraw; @@ -74,22 +82,34 @@ // each object can overwrite following function void (*_draw_foreground)(void *obj, cairo_t *c); - void (*_resize)(void *obj); - void (*_add_child)(void *obj); - int (*_remove_child)(void *obj); + // update area's content and update size (width/heith). + // return '1' if size changed, '0' otherwise. + int (*_resize)(void *obj); + // after pos/size changed, the rendering engine will call _on_change_layout(Area*) + int on_changed; + void (*_on_change_layout)(void *obj); const char* (*_get_tooltip_text)(void *obj); } Area; +// on startup, initialize fixed pos/size +void init_rendering(void *obj, int pos); - +void rendering(void *obj); +void size_by_content (Area *a); +void size_by_layout (Area *a, int pos, int level); // draw background and foreground void refresh (Area *a); - -void size (Area *a); + +// generic resize for SIZE_BY_LAYOUT objects +int resize_by_layout(void *obj, int maximum_size); // set 'redraw' on an area and childs void set_redraw (Area *a); +// hide/unhide area +void hide(Area *a); +void show(Area *a); + // draw pixmap void draw (Area *a); void draw_background (Area *a, cairo_t *c); diff -Naur tint2-0.11/src/util/common.c tint2-svn/src/util/common.c --- tint2-0.11/src/util/common.c 2010-06-11 20:47:26.000000000 +0200 +++ tint2-svn/src/util/common.c 2014-01-10 16:11:03.167391495 +0100 @@ -3,7 +3,7 @@ * Tint2 : common windows function * * Copyright (C) 2007 Pål Staurland (staura@gmail.com) -* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -146,6 +146,45 @@ } +void extract_values (const char *value, char **value1, char **value2, char **value3) +{ + char *b=0, *c=0; + + if (*value1) free (*value1); + if (*value2) free (*value2); + if (*value3) free (*value3); + + if ((b = strchr (value, ' '))) { + b[0] = '\0'; + b++; + } + else { + *value2 = 0; + *value3 = 0; + } + *value1 = strdup (value); + g_strstrip(*value1); + + if (b) { + if ((c = strchr (b, ' '))) { + c[0] = '\0'; + c++; + } + else { + c = 0; + *value3 = 0; + } + *value2 = strdup (b); + g_strstrip(*value2); + } + + if (c) { + *value3 = strdup (c); + g_strstrip(*value3); + } +} + + void adjust_asb(DATA32 *data, int w, int h, int alpha, float satur, float bright) { unsigned int x, y; diff -Naur tint2-0.11/src/util/common.h tint2-svn/src/util/common.h --- tint2-0.11/src/util/common.h 2010-06-11 20:47:26.000000000 +0200 +++ tint2-svn/src/util/common.h 2014-01-10 16:11:03.167391495 +0100 @@ -49,6 +49,8 @@ int hex_to_rgb (char *hex, int *r, int *g, int *b); void get_color (char *hex, double *rgb); +void extract_values (const char *value, char **value1, char **value2, char **value3); + // adjust Alpha/Saturation/Brightness on an ARGB icon // alpha from 0 to 100, satur from 0 to 1, bright from 0 to 1. void adjust_asb(DATA32 *data, int w, int h, int alpha, float satur, float bright); diff -Naur tint2-0.11/src/util/timer.c tint2-svn/src/util/timer.c --- tint2-0.11/src/util/timer.c 2010-04-23 19:27:34.000000000 +0200 +++ tint2-svn/src/util/timer.c 2014-01-10 16:11:03.166391477 +0100 @@ -77,6 +77,10 @@ free(t); timeout_list = g_slist_remove(timeout_list, t); } + if (multi_timeouts) { + g_hash_table_destroy(multi_timeouts); + multi_timeouts = 0; + } } /** Implementation notes for timeouts: The timeouts are kept in a GSList sorted by their @@ -394,6 +398,7 @@ if (g_slist_length(mth->timeout_list) == 1) { timeout* last_timeout = mth->timeout_list->data; + mth->timeout_list = g_slist_remove(mth->timeout_list, last_timeout); free(last_timeout->multi_timeout); last_timeout->multi_timeout = 0; g_hash_table_remove(multi_timeouts, last_timeout); diff -Naur tint2-0.11/src/util/window.c tint2-svn/src/util/window.c --- tint2-0.11/src/util/window.c 2010-02-08 23:44:56.000000000 +0100 +++ tint2-svn/src/util/window.c 2014-01-10 16:11:03.166391477 +0100 @@ -3,7 +3,7 @@ * Tint2 : common windows function * * Copyright (C) 2007 Pål Staurland (staura@gmail.com) -* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -87,9 +87,12 @@ return 1; } // do not add transient_for windows if the transient window is already in the taskbar - if ( XGetTransientForHint(server.dsp, win, &window) && task_get_tasks(window) ) { - XFree(at); - return 1; + window=win; + while ( XGetTransientForHint(server.dsp, window, &window) ) { + if ( task_get_tasks(window) ) { + XFree(at); + return 1; + } } } XFree(at); @@ -200,6 +203,26 @@ } +GSList *server_get_name_of_desktop () +{ + int count, j; + GSList *list = NULL; + gchar *data_ptr, *ptr; + data_ptr = server_get_property (server.root_win, server.atom._NET_DESKTOP_NAMES, server.atom.UTF8_STRING, &count); + if (data_ptr) { + list = g_slist_append(list, g_strdup(data_ptr)); + for (j = 0; j < count-1; j++) { + if (*(data_ptr + j) == '\0') { + ptr = (gchar*)data_ptr + j + 1; + list = g_slist_append(list, g_strdup(ptr)); + } + } + XFree(data_ptr); + } + return list; +} + + int server_get_current_desktop () { return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL); @@ -218,17 +241,17 @@ } -int get_icon_count (long *data, int num) +int get_icon_count (gulong *data, int num) { int count, pos, w, h; count = 0; pos = 0; - while (pos < num) { + while (pos+2 < num) { w = data[pos++]; h = data[pos++]; pos += w * h; - if (pos > num || w * h == 0) break; + if (pos > num || w <= 0 || h <= 0) break; count++; } @@ -236,10 +259,10 @@ } -long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size) +gulong *get_best_icon (gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size) { int width[icon_count], height[icon_count], pos, i, w, h; - long *icon_data[icon_count]; + gulong *icon_data[icon_count]; /* List up icons */ pos = 0; @@ -301,6 +324,32 @@ //printf("dimension : %d - %d\n", rect_ink.height, rect.height); g_object_unref (layout); + cairo_destroy (c); + cairo_surface_destroy (cs); + XFreePixmap (server.dsp, pmap); +} + + +void get_text_size2(PangoFontDescription *font, int *height_ink, int *height, int *width, int panel_height, int panel_with, char *text, int len) +{ + PangoRectangle rect_ink, rect; + + Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth); + + cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_with); + cairo_t *c = cairo_create (cs); + + PangoLayout *layout = pango_cairo_create_layout (c); + pango_layout_set_font_description (layout, font); + pango_layout_set_text (layout, text, len); + + pango_layout_get_pixel_extents(layout, &rect_ink, &rect); + *height_ink = rect_ink.height; + *height = rect.height; + *width = rect.width; + //printf("dimension : %d - %d\n", rect_ink.height, rect.height); + + g_object_unref (layout); cairo_destroy (c); cairo_surface_destroy (cs); XFreePixmap (server.dsp, pmap); diff -Naur tint2-0.11/src/util/window.h tint2-svn/src/util/window.h --- tint2-0.11/src/util/window.h 2009-09-07 23:41:21.000000000 +0200 +++ tint2-svn/src/util/window.h 2014-01-10 16:11:03.167391495 +0100 @@ -9,6 +9,7 @@ #ifndef WINDOW_H #define WINDOW_H +#include #include @@ -17,13 +18,14 @@ void set_close (Window win); int server_get_current_desktop (); int server_get_number_of_desktop (); +GSList *server_get_name_of_desktop (); int window_is_iconified (Window win); int window_is_urgent (Window win); int window_is_hidden (Window win); int window_is_active (Window win); int window_is_skip_taskbar (Window win); -int get_icon_count (long *data, int num); -long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size); +int get_icon_count (gulong *data, int num); +gulong *get_best_icon (gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size); void window_maximize_restore (Window win); void window_toggle_shade (Window win); int window_get_desktop (Window win); @@ -32,6 +34,7 @@ Window window_get_active (); void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len); +void get_text_size2(PangoFontDescription *font, int *height_ink, int *height, int *width, int panel_height, int panel_with, char *text, int len); #endif