Compare commits
148 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cde7bef1e | ||
|
|
b9ab0ae58e | ||
|
|
2c90c5640e | ||
|
|
cb43e76660 | ||
|
|
0fc22b5cd6 | ||
|
|
a2c5553f4f | ||
|
|
63dd4a3e6c | ||
|
|
a7fc86cfbb | ||
|
|
d72aa2edfb | ||
|
|
54d361cf42 | ||
|
|
153de1aa45 | ||
|
|
fc883a5dd8 | ||
|
|
dfd735956c | ||
|
|
a77b728110 | ||
|
|
5cfffd7c8e | ||
|
|
a73c6928c3 | ||
|
|
d5dfda296f | ||
|
|
89d57f893c | ||
|
|
46371fe816 | ||
|
|
bfe4873204 | ||
|
|
acd1ed5768 | ||
|
|
b6a4fe03df | ||
|
|
b25ad07c30 | ||
|
|
ffcd53e989 | ||
|
|
4e22e0f4e7 | ||
|
|
d6a40c7523 | ||
|
|
4ee2f4e7de | ||
|
|
1567e56a09 | ||
|
|
639ccbf16c | ||
|
|
4d12abdb42 | ||
|
|
23109b8beb | ||
|
|
9882603188 | ||
|
|
aee90e5b99 | ||
|
|
5aa907feeb | ||
|
|
98c5dac781 | ||
|
|
5fab41887a | ||
|
|
c5f6e64a83 | ||
|
|
d758fd167c | ||
|
|
0f96cb66f1 | ||
|
|
3baa3d38a3 | ||
|
|
cc74af00ba | ||
|
|
4a5f0a7d83 | ||
|
|
468bc16b0f | ||
|
|
e6a472e6b7 | ||
|
|
be710ff488 | ||
|
|
aa40473481 | ||
|
|
4170b5d878 | ||
|
|
3c9642c5fc | ||
|
|
e833b27533 | ||
|
|
d17b2d8015 | ||
|
|
93c9830c23 | ||
|
|
51211fa626 | ||
|
|
1fc417e24e | ||
|
|
2e49b66ac2 | ||
|
|
4534bd6aaa | ||
|
|
de982b9ada | ||
|
|
6931a37e95 | ||
|
|
a4ed5c6e38 | ||
|
|
b94cb3eb7e | ||
|
|
8ec7f2dd9c | ||
|
|
330f1093bb | ||
|
|
8e8046af6d | ||
|
|
94e2b5edb1 | ||
|
|
c2d6faabc7 | ||
|
|
d7f294d7c2 | ||
|
|
cb72aa7996 | ||
|
|
661ef0cbe3 | ||
|
|
d47924492a | ||
|
|
e594cf4560 | ||
|
|
4c45538f6e | ||
|
|
e3e81505b9 | ||
|
|
d2c36cb85a | ||
|
|
207129447d | ||
|
|
15150fb577 | ||
|
|
993fd2563d | ||
|
|
7c0df616b9 | ||
|
|
5e9791079d | ||
|
|
4c103423ba | ||
|
|
f438ef712b | ||
|
|
0392c34e71 | ||
|
|
5041f74aad | ||
|
|
6f58ea9e21 | ||
|
|
b0cfb4e933 | ||
|
|
290ab2dfed | ||
|
|
21326dca12 | ||
|
|
6f49df9612 | ||
|
|
fca752849b | ||
|
|
8f2a28f56d | ||
|
|
17beb40283 | ||
|
|
cd76bd311d | ||
|
|
c37d61c862 | ||
|
|
d21507cd4b | ||
|
|
48078ffb25 | ||
| ef4cc5ea56 | |||
| 30469d37f0 | |||
|
|
07ef35aa4a | ||
|
|
040f6479bf | ||
|
|
ce0acdbd5b | ||
|
|
1d15c41c1b | ||
|
|
0d861ebd97 | ||
|
|
7c54f2acf7 | ||
|
|
278a915ba4 | ||
|
|
2c42a78725 | ||
|
|
07592355cb | ||
|
|
61a80b996f | ||
|
|
8c7f4cc825 | ||
|
|
7dad1c4e33 | ||
|
|
f8ceb5a849 | ||
|
|
d45af83eaa | ||
|
|
cbde035f36 | ||
|
|
0f3f6eebd8 | ||
|
|
c5845a7f70 | ||
|
|
b53aea76bd | ||
|
|
a5434a362b | ||
|
|
1922cafa14 | ||
|
|
b4c2b3e6af | ||
|
|
822b149419 | ||
|
|
edc5a02efe | ||
|
|
0867010841 | ||
|
|
031b6b3240 | ||
|
|
502c2f03ac | ||
|
|
55de4c27b8 | ||
|
|
d49ecee3a7 | ||
|
|
62e0ee6a3a | ||
|
|
6304715df3 | ||
|
|
7dbc894d2e | ||
|
|
c3a86e185d | ||
|
|
ce8061573b | ||
|
|
d0506f07a1 | ||
|
|
1d076ee6a4 | ||
|
|
0c36e79996 | ||
|
|
d0e8450225 | ||
|
|
924464423d | ||
|
|
1b2a751de7 | ||
|
|
047c59b53f | ||
|
|
863ef0259c | ||
|
|
d765190e3d | ||
|
|
8976f35c5f | ||
|
|
008eebe4b1 | ||
|
|
cbb76849ea | ||
|
|
cf930fa42e | ||
|
|
da51d37322 | ||
|
|
a09e1a0e45 | ||
|
|
1d4f64d745 | ||
|
|
2857b96c4d | ||
|
|
8b08930268 | ||
|
|
2922708c18 | ||
|
|
5c6385b4c3 |
5
AUTHORS
5
AUTHORS
@@ -24,6 +24,11 @@ Contributors:
|
||||
Jeff Blake (https://gitlab.com/u/berkley4) : more mouse event handlers
|
||||
Vladimir <vladimir-csp@yandex.ru> : translations, bug reports
|
||||
Christophe D. <stophe72.d@gmail.com> : non-rectangular borders
|
||||
Benoit Averty : taskbar enhancements
|
||||
Justin Jacobs : tint2conf fixes
|
||||
Oskari Rauta : separator plugin, gradients
|
||||
Michael Messmore : Support for Path in .desktop files
|
||||
Matthew Otnel : config option systray_name_filter
|
||||
|
||||
Translations:
|
||||
Bosnian:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
project( tint2 )
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
cmake_minimum_required( VERSION 2.8.5 )
|
||||
|
||||
option( ENABLE_BATTERY "Enable battery status plugin" ON )
|
||||
option( ENABLE_TINT2CONF "Enable tint2conf build, a GTK+2 theme configurator for tint2" ON )
|
||||
@@ -13,6 +13,14 @@ if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
|
||||
option( ENABLE_UEVENT "Kernel event handling support" ON )
|
||||
endif( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
|
||||
|
||||
include( GNUInstallDirs )
|
||||
if(NOT docdir)
|
||||
set(docdir ${CMAKE_INSTALL_DOCDIR})
|
||||
endif()
|
||||
if(NOT htmldir)
|
||||
set(htmldir ${docdir}/html)
|
||||
endif()
|
||||
|
||||
include( FindPkgConfig )
|
||||
include( CheckLibraryExists )
|
||||
include( CheckCSourceCompiles )
|
||||
@@ -74,7 +82,13 @@ if( NOT IMLIB_BUILD_WITH_X )
|
||||
message( FATAL_ERROR "Imlib is not built with X support" )
|
||||
endif( NOT IMLIB_BUILD_WITH_X )
|
||||
|
||||
add_definitions( -D_GNU_SOURCE )
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_definitions( -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -D_DEFAULT_SOURCE )
|
||||
else(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_definitions( -D_WITH_GETLINE )
|
||||
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
|
||||
include_directories( ${PROJECT_BINARY_DIR}
|
||||
src
|
||||
@@ -86,7 +100,9 @@ include_directories( ${PROJECT_BINARY_DIR}
|
||||
src/tooltip
|
||||
src/util
|
||||
src/execplugin
|
||||
src/button
|
||||
src/freespace
|
||||
src/separator
|
||||
${X11_INCLUDE_DIRS}
|
||||
${PANGOCAIRO_INCLUDE_DIRS}
|
||||
${PANGO_INCLUDE_DIRS}
|
||||
@@ -113,12 +129,17 @@ set( SOURCES src/config.c
|
||||
src/taskbar/taskbarname.c
|
||||
src/tooltip/tooltip.c
|
||||
src/execplugin/execplugin.c
|
||||
src/button/button.c
|
||||
src/freespace/freespace.c
|
||||
src/separator/separator.c
|
||||
src/tint2rc.c
|
||||
src/util/area.c
|
||||
src/util/common.c
|
||||
src/util/strnatcmp.c
|
||||
src/util/timer.c
|
||||
src/util/cache.c
|
||||
src/util/color.c
|
||||
src/util/gradient.c
|
||||
src/util/window.c )
|
||||
|
||||
if( ENABLE_BATTERY )
|
||||
@@ -190,17 +211,12 @@ endif( ENABLE_TINT2CONF )
|
||||
|
||||
if( ENABLE_ASAN )
|
||||
SET(ASAN_C_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic -Wshadow")
|
||||
SET(ASAN_L_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic ")
|
||||
SET(ASAN_L_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic -fuse-ld=gold ")
|
||||
else()
|
||||
SET(ASAN_C_FLAGS "")
|
||||
SET(ASAN_L_FLAGS "")
|
||||
endif()
|
||||
|
||||
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_version.sh" "\"${PROJECT_SOURCE_DIR}\"" )
|
||||
|
||||
link_directories( ${X11_LIBRARY_DIRS}
|
||||
@@ -235,18 +251,18 @@ endif( RT_LIBRARY )
|
||||
target_link_libraries( tint2 m )
|
||||
|
||||
add_dependencies( tint2 version )
|
||||
set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=c99 ${ASAN_C_FLAGS}" )
|
||||
set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=c11 ${ASAN_C_FLAGS}" )
|
||||
set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${ASAN_L_FLAGS} ${BACKTRACE_L_FLAGS}" )
|
||||
|
||||
install( TARGETS tint2 DESTINATION bin )
|
||||
install( FILES tint2.svg DESTINATION ${DATADIR}/icons/hicolor/scalable/apps )
|
||||
install( FILES tint2.desktop DESTINATION ${DATADIR}/applications )
|
||||
install( CODE "execute_process(COMMAND gtk-update-icon-cache -f -t ${DATADIR}/icons/hicolor WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})" )
|
||||
install( FILES themes/tint2rc DESTINATION ${SYSCONFDIR}/xdg/tint2 )
|
||||
install( FILES default_icon.png DESTINATION ${DATADIR}/tint2 )
|
||||
install( FILES AUTHORS ChangeLog README.md doc/tint2.md doc/manual.html doc/readme.html DESTINATION ${DOCDIR} )
|
||||
install( DIRECTORY doc/images DESTINATION ${DOCDIR} )
|
||||
install( FILES doc/tint2.1 DESTINATION ${MANDIR}/man1 )
|
||||
install( FILES tint2.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps )
|
||||
install( FILES tint2.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications )
|
||||
install( FILES themes/tint2rc DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/tint2 )
|
||||
install( FILES default_icon.png DESTINATION ${CMAKE_INSTALL_DATADIR}/tint2 )
|
||||
install( FILES AUTHORS ChangeLog README.md doc/tint2.md DESTINATION ${docdir} )
|
||||
install( FILES doc/manual.html doc/readme.html DESTINATION ${htmldir} )
|
||||
install( DIRECTORY doc/images DESTINATION ${htmldir} )
|
||||
install( FILES doc/tint2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
|
||||
if( ENABLE_EXTRA_THEMES )
|
||||
add_subdirectory(themes)
|
||||
endif( ENABLE_EXTRA_THEMES )
|
||||
|
||||
1
CONTRIBUTING.md
Normal file
1
CONTRIBUTING.md
Normal file
@@ -0,0 +1 @@
|
||||
Please read https://gitlab.com/o9000/tint2/wikis/Development
|
||||
41
ChangeLog
41
ChangeLog
@@ -1,3 +1,44 @@
|
||||
2017-03-26 0.14.1
|
||||
- Fixes:
|
||||
- Fixed tint2conf problem under FreeBSD (or generally any system using clang).
|
||||
|
||||
2017-03-26 0.14
|
||||
- Enhancements:
|
||||
- New plugin: button.
|
||||
|
||||
2017-03-25 0.13.3
|
||||
- Fixes:
|
||||
- Fixed autohide for non-bottom panels (issue #632)
|
||||
- Translations updated (contributed by Vladimir)
|
||||
|
||||
2017-03-19 0.13.2
|
||||
- Fixes:
|
||||
- Fixed compilation under FreeBSD
|
||||
|
||||
2017-03-12 0.13.1
|
||||
- Fixes:
|
||||
- Fixed compilation with new glibc (issue #625)
|
||||
- Fixed regression in distributing size between taskbars (issue #628)
|
||||
- Create ~/.config dir if it does not exist (issue #629)
|
||||
- Enhancements:
|
||||
- New config option systray_name_filter to hide hide specific apps from the system tray (contributed by Matthew Otnel)
|
||||
- Tint2conf: minor improvements
|
||||
|
||||
2017-03-04 0.13
|
||||
- Fixes:
|
||||
- Ignore monitors with size 0, fixing crash (issue #618)
|
||||
- Battery: support Asus Chromebook Flip C100PA (issue #616)
|
||||
- Panel: do not change struts (available screen size) when shown in autohide mode (issue #619)
|
||||
- tint2conf: executor tooltips are now correctly disabled when text config value is empty (contributed by Justin Jacobs)
|
||||
- Enhancements:
|
||||
- Desktop files (shortcuts) used in launcher are reloaded on click, in case the file has changed
|
||||
- New config option taskbar_hide_if_empty to hide an empty taskbar in multi_desktop mode (contributed by Benoit Averty)
|
||||
- Gradient backgrounds (contributed by Oskari Rauta)
|
||||
- New option: panel_shrink (fixes issue #333)
|
||||
- Support for Path in .desktop files (contributed by Michael Messmore)
|
||||
- Tint2conf start up is much faster
|
||||
- New plugin: separator (contributed by Oskari Rauta)
|
||||
|
||||
2016-08-02 0.12.12
|
||||
- Fixes:
|
||||
- Set task maximum height equal to width if not specified, instead of hardcoding 30 (issue #583; thanks @VastOne)
|
||||
|
||||
23
README.md
23
README.md
@@ -1,14 +1,14 @@
|
||||
# Latest stable release: 0.12.12
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/0.12.12/ChangeLog
|
||||
# Latest stable release: 0.14.1
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/0.14.1/ChangeLog
|
||||
|
||||
Documentation: [doc/tint2.md](doc/tint2.md)
|
||||
|
||||
Compile it with (see also [dependencies](https://gitlab.com/o9000/tint2/wikis/Install#dependencies)):
|
||||
Compile it with (after you install the [dependencies](https://gitlab.com/o9000/tint2/wikis/Install#dependencies)):
|
||||
|
||||
```
|
||||
git clone https://gitlab.com/o9000/tint2.git
|
||||
cd tint2
|
||||
git checkout 0.12.12
|
||||
git checkout 0.14.1
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
@@ -57,10 +57,16 @@ tint2 is a simple panel/taskbar made for modern X window managers. It was specif
|
||||
* [Other frequently asked questions](https://gitlab.com/o9000/tint2/wikis/FAQ)
|
||||
* [Obtain a stack trace when tint2 crashes](https://gitlab.com/o9000/tint2/wikis/Debug)
|
||||
|
||||
# Known issues
|
||||
|
||||
* Graphic glitches on Intel graphics cards can be avoided by changing the acceleration method to UXA ([issue 595](https://gitlab.com/o9000/tint2/issues/595))
|
||||
* Window managers that do not follow exactly the EWMH specification might not interact well with tint2 (known issues for [awesome](https://gitlab.com/o9000/tint2/issues/385), [bspwm](https://gitlab.com/o9000/tint2/issues/524). [openbox-multihead](https://gitlab.com/o9000/tint2/issues/456))
|
||||
* Full transparency requires a compositor such as Compton (if not provided already by the window manager, as in Compiz/Unity, KDE or XFCE)
|
||||
|
||||
# How can I help out?
|
||||
|
||||
* Report bugs and ask questions on the [issue tracker](https://gitlab.com/o9000/tint2/issues);
|
||||
* Contribute to the development by helping us fix bugs and suggesting new features.
|
||||
* Contribute to the development by helping us fix bugs and suggesting new features. Please read the contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
# Links
|
||||
* Home page: https://gitlab.com/o9000/tint2
|
||||
@@ -78,3 +84,10 @@ tint2 is a simple panel/taskbar made for modern X window managers. It was specif
|
||||
## Various configs:
|
||||
|
||||

|
||||
|
||||
## Demos
|
||||
|
||||
* [Compact panel, separator, color gradients](https://gitlab.com/o9000/tint2/wikis/whats-new-0.13.0.gif)
|
||||
* [Executor](https://gitlab.com/o9000/tint2/wikis/whats-new-0.12.4.gif)
|
||||
* [Mouse over effects](https://gitlab.com/o9000/tint2/wikis/whats-new-0.12.3.gif)
|
||||
* [Distribute size between taskbars, freespace](https://gitlab.com/o9000/tint2/wikis/whats-new-0.12.gif)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
DEPENDENCIES:
|
||||
cairo (with X support), pango, glib2, libX11, libXinerama, libXrandr, libXrender, libXcomposite, libXdamage, imlib2 (with X support)
|
||||
you might need -dev packages on Debian
|
||||
252
doc/manual.html
252
doc/manual.html
@@ -218,6 +218,7 @@ It was specifically made for Openbox but it should also work with other window m
|
||||
<ul>
|
||||
<li><p><a href="#introduction">Introduction</a></p></li>
|
||||
<li><p><a href="#backgrounds-and-borders">Backgrounds and borders</a></p></li>
|
||||
<li><p><a href="#gradients">Gradients</a></p></li>
|
||||
<li><p><a href="#panel">Panel</a></p></li>
|
||||
<li><p><a href="#launcher">Launcher</a></p></li>
|
||||
<li><p><a href="#taskbar-pager">Taskbar/Pager</a></p></li>
|
||||
@@ -228,6 +229,8 @@ It was specifically made for Openbox but it should also work with other window m
|
||||
<li><p><a href="#tooltip">Tooltip</a></p></li>
|
||||
<li><p><a href="#battery">Battery</a></p></li>
|
||||
<li><p><a href="#executor">Executor</a></p></li>
|
||||
<li><p><a href="#button">Button</a></p></li>
|
||||
<li><p><a href="#separator">Separator</a></p></li>
|
||||
<li><p><a href="#example-configuration">Example configuration</a></p></li>
|
||||
</ul>
|
||||
<h3 id="introduction">Introduction<a name="introduction" href="#introduction" class="md2man-permalink" title="permalink"></a></h3><p>These are instructions for configuring tint2 directly by editing its config file.
|
||||
@@ -286,7 +289,67 @@ task_active_background_id = 2
|
||||
systray_background_id = 0
|
||||
clock_background_id = 0
|
||||
</code></pre>
|
||||
<p>Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.</p><h3 id="panel">Panel<a name="panel" href="#panel" class="md2man-permalink" title="permalink"></a></h3>
|
||||
<p>Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.</p><h3 id="gradients">Gradients<a name="gradients" href="#gradients" class="md2man-permalink" title="permalink"></a></h3><p>(Available since 0.13.0)</p><p>Backgrounds also allow specifying gradient layers
|
||||
that are drawn on top of the solid color background.</p><p>First the user must define one or more gradients in the config file,
|
||||
each starting with <code>gradient = TYPE</code>. These must be added before backgrounds.</p><p>Then gradients can be added by index to backgrounds,
|
||||
using the <code>gradient_id = INDEX</code>, <code>gradient_id_hover = INDEX</code> and
|
||||
<code>gradient_id_pressed = INDEX</code>, where <code>INDEX</code> is
|
||||
the gradient index, starting from 1.</p><h4 id="gradient-types">Gradient types<a name="gradient-types" href="#gradient-types" class="md2man-permalink" title="permalink"></a></h4><p>Gradients vary the color between fixed control points:
|
||||
* vertical gradients: top-to-bottom;
|
||||
* horizontal gradients: left-to-right;
|
||||
* radial gradients: center-to-corners.</p><p>The user must specify the start and end colors, and can optionally add extra color stops in between
|
||||
using the <code>color_stop</code> option, as explained below.</p><h5 id="vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors">Vertical gradient, with color varying from the top edge to the bottom edge, two colors<a name="vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors" href="#vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>gradient = vertical
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
</code></pre>
|
||||
<h5 id="horizontal-gradient-with-color-varying-from-the-left-edge-to-the-right-edge-two-colors">Horizontal gradient, with color varying from the left edge to the right edge, two colors<a name="horizontal-gradient-with-color-varying-from-the-left-edge-to-the-right-edge-two-colors" href="#horizontal-gradient-with-color-varying-from-the-left-edge-to-the-right-edge-two-colors" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>gradient = horizontal
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
</code></pre>
|
||||
<h5 id="radial-gradient-with-color-varying-from-the-center-to-the-corner-two-colors">Radial gradient, with color varying from the center to the corner, two colors:<a name="radial-gradient-with-color-varying-from-the-center-to-the-corner-two-colors" href="#radial-gradient-with-color-varying-from-the-center-to-the-corner-two-colors" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>gradient = radial
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
</code></pre>
|
||||
<h5 id="adding-extra-color-stops-0-and-100-remain-fixed-more-colors-at-x-between-the-start-and-end-control-points">Adding extra color stops (0% and 100% remain fixed, more colors at x% between the start and end control points)<a name="adding-extra-color-stops-0-and-100-remain-fixed-more-colors-at-x-between-the-start-and-end-control-points" href="#adding-extra-color-stops-0-and-100-remain-fixed-more-colors-at-x-between-the-start-and-end-control-points" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>color_stop = percentage #rrggbb opacity
|
||||
</code></pre>
|
||||
<h4 id="gradient-examples">Gradient examples<a name="gradient-examples" href="#gradient-examples" class="md2man-permalink" title="permalink"></a></h4><pre class="highlight plaintext"><code># Gradient 1: thin film effect
|
||||
gradient = horizontal
|
||||
start_color = #111122 30
|
||||
end_color = #112211 30
|
||||
color_stop = 60 #221111 30
|
||||
|
||||
# Gradient 2: radial glow
|
||||
gradient = radial
|
||||
start_color = #ffffff 20
|
||||
end_color = #ffffff 0
|
||||
|
||||
# Gradient 3: elegant black
|
||||
gradient = vertical
|
||||
start_color = #444444 100
|
||||
end_color = #222222 100
|
||||
|
||||
# Gradient 4: elegant black
|
||||
gradient = horizontal
|
||||
start_color = #111111 100
|
||||
end_color = #222222 100
|
||||
|
||||
# Background 1: Active desktop name
|
||||
rounded = 2
|
||||
border_width = 1
|
||||
border_sides = TBLR
|
||||
background_color = #555555 10
|
||||
border_color = #ffffff 60
|
||||
background_color_hover = #555555 10
|
||||
border_color_hover = #ffffff 60
|
||||
background_color_pressed = #555555 10
|
||||
border_color_pressed = #ffffff 60
|
||||
gradient_id = 3
|
||||
gradient_id_hover = 4
|
||||
gradient_id_pressed = 2
|
||||
|
||||
[...]
|
||||
</code></pre>
|
||||
<h3 id="panel">Panel<a name="panel" href="#panel" class="md2man-permalink" title="permalink"></a></h3>
|
||||
<ul>
|
||||
<li><p><code>panel_items = LTSBC</code> defines the items tint2 will show and the order of those items. Each letter refers to an item, defined as:</p>
|
||||
<ul>
|
||||
@@ -295,8 +358,10 @@ clock_background_id = 0
|
||||
<li><code>S</code> shows the Systray (also called notification area)</li>
|
||||
<li><code>B</code> shows the Battery status</li>
|
||||
<li><code>C</code> shows the Clock</li>
|
||||
<li><code>F</code> adds an extensible spacer (freespace). Has no effect if <code>T</code> is also present. <em>(since 0.12)</em></li>
|
||||
<li><code>F</code> adds an extensible spacer (freespace). You can specify more than one. Has no effect if <code>T</code> is also present. <em>(since 0.12)</em></li>
|
||||
<li><code>E</code> adds an executor plugin. You can specify more than one. <em>(since 0.12.4)</em></li>
|
||||
<li><code>P</code> adds a push button. You can specify more than one. <em>(since 0.14)</em></li>
|
||||
<li><code>:</code> adds a separator. You can specify more than one. <em>(since 0.13.0)</em></li>
|
||||
</ul>
|
||||
<p>For example, <code>panel_items = STC</code> will show the systray, the taskbar and the clock (from left to right).</p></li>
|
||||
<li><p><code>panel_monitor = monitor (all or 1 or 2 or ...)</code> : Which monitor tint2 draws the panel on</p>
|
||||
@@ -325,7 +390,8 @@ panel_size = 94% 30
|
||||
</code></pre>
|
||||
|
||||
<ul>
|
||||
<li><code>panel_margin = horizontal_margin vertical_margin</code> : The margins define the distance between the panel and the horizontal/vertical monitor edge. Use <code>0</code> to obtain a panel with the same size as the edge of the monitor (no margin).</li>
|
||||
<li><p><code>panel_shrink = boolean (0 or 1)</code> : If set to 1, the panel will shrink to a compact size dynamically. <em>(since 0.13)</em></p></li>
|
||||
<li><p><code>panel_margin = horizontal_margin vertical_margin</code> : The margins define the distance between the panel and the horizontal/vertical monitor edge. Use <code>0</code> to obtain a panel with the same size as the edge of the monitor (no margin).</p></li>
|
||||
</ul>
|
||||
<p><img src="images/panel_size_margin.jpg" alt=""></p>
|
||||
<ul>
|
||||
@@ -380,7 +446,8 @@ panel_size = 94% 30
|
||||
<li>You can switch between virtual desktops.</li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
<li><p><code>taskbar_distribute_size = boolean (0 or 1)</code> : If enabled, in multi-desktop mode distributes between taskbars the available size proportionally to the number of tasks. Default: disabled. <em>(since 0.12)</em></p></li>
|
||||
<li><p><code>taskbar_hide_if_empty = boolean (0 or 1)</code> : If enabled, in multi-desktop mode the taskbars corresponding to empty desktops different from the current desktop are hidden. <em>(since 0.13)</em></p></li>
|
||||
<li><p><code>taskbar_distribute_size = boolean (0 or 1)</code> : If enabled, in multi-desktop mode distributes between taskbars the available size proportionally to the number of tasks. Default: disabled. <em>(since 0.12)</em></p></li>
|
||||
<li><p><code>taskbar_padding = horizontal_padding vertical_padding spacing</code></p></li>
|
||||
</ul>
|
||||
<p><img src="images/taskbar_padding.jpg" alt=""></p>
|
||||
@@ -409,7 +476,7 @@ panel_size = 94% 30
|
||||
</ul>
|
||||
<h1 id="taskbar-buttons">Taskbar buttons<a name="taskbar-buttons" href="#taskbar-buttons" class="md2man-permalink" title="permalink"></a></h1><p>The following options configure the task buttons in the taskbar:</p>
|
||||
<ul>
|
||||
<li><p><code>task_icon = boolean (0 or 1)</code> : Whether to display the task icon.</p></li>
|
||||
<li><p><code>task_icon = boolean (0 or 1)</code> : Whether to display the task icon. There is no explicit option to control the task icon size; it depends on the vertical padding set with <code>task_padding</code>.</p></li>
|
||||
<li><p><code>task_text = boolean (0 or 1)</code> : Whether to display the task text.</p></li>
|
||||
<li><p><code>task_centered = boolean (0 or 1)</code> : Whether the task text is centered.</p></li>
|
||||
<li><p><code>task_tooltip = boolean (0 or 1)</code> : Whether to show tooltips for tasks.</p></li>
|
||||
@@ -457,6 +524,7 @@ panel_size = 94% 30
|
||||
<li><p><code>systray_icon_size = max_icon_size</code> : Set the maximum system tray icon size to <code>number</code>. Set to <code>0</code> for automatic icon sizing.</p></li>
|
||||
<li><p><code>systray_icon_asb = alpha (0 to 100) saturation (-100 to 100) brightness (-100 to 100)</code> : Adjust the systray icons color and transparency.</p></li>
|
||||
<li><p><code>systray_monitor = integer (1, 2, ...)</code> : On which monitor to draw the systray. The first monitor is <code>1</code>. <em>(since 0.12)</em></p></li>
|
||||
<li><p><code>systray_name_filter = string</code> : Regular expression to identify icon names to be hidden. For example, <code>^audacious$</code> will hide icons with the exact name <code>audacious</code>, while <code>aud</code> will hide any icons having <code>aud</code> in the name. <em>(since 0.13.1)</em></p></li>
|
||||
</ul>
|
||||
<h3 id="clock">Clock<a name="clock" href="#clock" class="md2man-permalink" title="permalink"></a></h3>
|
||||
<ul>
|
||||
@@ -568,15 +636,15 @@ execp_cache_icon = 1
|
||||
execp_continuous = 2
|
||||
</code></pre>
|
||||
<h5 id="round-trip-time-to-the-gateway-refreshed-every-second">Round-trip time to the gateway, refreshed every second<a name="round-trip-time-to-the-gateway-refreshed-every-second" href="#round-trip-time-to-the-gateway-refreshed-every-second" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>execp = new
|
||||
execp_command = ping -i 1 -W 1 -O -D -n $(ip route | grep default | grep via | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*') | awk '/no/ { print "<span foreground=\"#faa\">timeout</span>"; fflush(); }; /time=/ { gsub(/time=/, "", $8); printf "<span foreground=\"#7af\">%3.0f %s</span>\n", $8, $9; fflush(); } '
|
||||
execp_continuous = 1
|
||||
execp_command = ping -i 1 -c 1 -W 1 -O -D -n $(ip route | grep default | grep via | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*') | awk '/no/ { print "<span foreground=\"#faa\">timeout</span>"; fflush(); }; /time=/ { gsub(/time=/, "", $8); printf "<span foreground=\"#7af\">%3.0f %s</span>\n", $8, $9; fflush(); } '
|
||||
execp_continuous = 0
|
||||
execp_interval = 1
|
||||
execp_markup = 1
|
||||
</code></pre>
|
||||
<h5 id="memory-usage">Memory usage<a name="memory-usage" href="#memory-usage" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>execp = new
|
||||
execp_command = free -s 2 | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%\n", 100*$3/($3+$4); fflush(stdout) }'
|
||||
execp_interval = 1
|
||||
execp_continuous = 1
|
||||
execp_command = free | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%%\n", 100*$3/($3+$4); fflush(stdout) }'
|
||||
execp_interval = 5
|
||||
execp_continuous = 0
|
||||
</code></pre>
|
||||
<h5 id="network-load">Network load<a name="network-load" href="#network-load" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code># Note the use of "stdbuf -oL" to force the program to flush the output line by line.
|
||||
execp = new
|
||||
@@ -584,142 +652,34 @@ execp_command = stdbuf -oL bwm-ng -o csv -t 1000 | awk -F ';' '/total/ { printf
|
||||
execp_continuous = 1
|
||||
execp_interval = 1
|
||||
</code></pre>
|
||||
<h3 id="example-configuration">Example configuration<a name="example-configuration" href="#example-configuration" class="md2man-permalink" title="permalink"></a></h3><pre class="highlight plaintext"><code>#---------------------------------------------
|
||||
## TINT2 CONFIG FILE
|
||||
#---------------------------------------------
|
||||
|
||||
#---------------------------------------------
|
||||
## BACKGROUND AND BORDER
|
||||
#---------------------------------------------
|
||||
rounded = 7
|
||||
border_width = 2
|
||||
background_color = #000000 60
|
||||
border_color = #ffffff 18
|
||||
|
||||
rounded = 5
|
||||
border_width = 0
|
||||
background_color = #ffffff 40
|
||||
border_color = #ffffff 50
|
||||
|
||||
rounded = 5
|
||||
border_width = 0
|
||||
background_color = #ffffff 18
|
||||
border_color = #ffffff 70
|
||||
|
||||
#---------------------------------------------
|
||||
## PANEL
|
||||
#---------------------------------------------
|
||||
panel_monitor = all
|
||||
panel_position = bottom center
|
||||
panel_size = 94% 30
|
||||
panel_margin = 0 0
|
||||
panel_padding = 7 0
|
||||
font_shadow = 0
|
||||
panel_background_id = 1
|
||||
wm_menu = 0
|
||||
panel_dock = 0
|
||||
panel_layer = bottom
|
||||
|
||||
#---------------------------------------------
|
||||
## TASKBAR
|
||||
#---------------------------------------------
|
||||
#taskbar_mode = multi_desktop
|
||||
taskbar_mode = single_desktop
|
||||
taskbar_padding = 2 3 2
|
||||
taskbar_background_id = 0
|
||||
#taskbar_active_background_id = 0
|
||||
|
||||
#---------------------------------------------
|
||||
## TASKS
|
||||
#---------------------------------------------
|
||||
task_icon = 1
|
||||
task_text = 1
|
||||
task_maximum_size = 140 35
|
||||
task_centered = 1
|
||||
task_padding = 6 3
|
||||
task_font = sans 7
|
||||
task_font_color = #ffffff 70
|
||||
task_background_id = 3
|
||||
task_icon_asb = 100 0 0
|
||||
## replace STATUS by 'urgent', 'active' or 'iconfied'
|
||||
#task_STATUS_background_id = 2
|
||||
#task_STATUS_font_color = #ffffff 85
|
||||
#task_STATUS_icon_asb = 100 0 0
|
||||
## example:
|
||||
task_active_background_id = 2
|
||||
task_active_font_color = #ffffff 85
|
||||
task_active_icon_asb = 100 0 0
|
||||
urgent_nb_of_blink = 8
|
||||
|
||||
#---------------------------------------------
|
||||
## SYSTRAYBAR
|
||||
#---------------------------------------------
|
||||
systray = 1
|
||||
systray_padding = 0 4 5
|
||||
systray_background_id = 0
|
||||
systray_sort = left2right
|
||||
systray_icon_size = 0
|
||||
systray_icon_asb = 100 0 0
|
||||
|
||||
#---------------------------------------------
|
||||
## CLOCK
|
||||
#---------------------------------------------
|
||||
time1_format = %H:%M
|
||||
time1_font = sans 8
|
||||
time2_format = %A %d %B
|
||||
time2_font = sans 6
|
||||
clock_font_color = #ffffff 76
|
||||
clock_padding = 1 0
|
||||
clock_background_id = 0
|
||||
#clock_lclick_command = xclock
|
||||
clock_rclick_command = orage
|
||||
#clock_tooltip = %A %d %B
|
||||
#time1_timezone = :US/Hawaii
|
||||
#time2_timezone = :Europe/Berlin
|
||||
#clock_tooltip_timezone = :/usr/share/zoneinfo/Europe/Paris
|
||||
|
||||
#---------------------------------------------
|
||||
## BATTERY
|
||||
#---------------------------------------------
|
||||
battery = 0
|
||||
battery_hide = 98
|
||||
battery_low_status = 10
|
||||
battery_low_cmd = notify-send "battery low"
|
||||
bat1_font = sans 8
|
||||
bat2_font = sans 6
|
||||
battery_font_color = #ffffff 76
|
||||
battery_padding = 1 0
|
||||
battery_background_id = 0
|
||||
|
||||
#---------------------------------------------
|
||||
## TOOLTIP
|
||||
#---------------------------------------------
|
||||
tooltip = 0
|
||||
tooltip_padding = 2 2
|
||||
tooltip_show_timeout = 0.7
|
||||
tooltip_hide_timeout = 0.3
|
||||
tooltip_background_id = 1
|
||||
tooltip_font_color = #OOOOOO 80
|
||||
tooltip_font = sans 10
|
||||
|
||||
#---------------------------------------------
|
||||
## MOUSE ACTION ON TASK
|
||||
#---------------------------------------------
|
||||
mouse_middle = none
|
||||
mouse_right = close
|
||||
mouse_scroll_up = toggle
|
||||
mouse_scroll_down = iconify
|
||||
|
||||
#---------------------------------------------
|
||||
## AUTOHIDE OPTIONS
|
||||
#---------------------------------------------
|
||||
autohide = 0
|
||||
autohide_show_timeout = 0.3
|
||||
autohide_hide_timeout = 2
|
||||
autohide_height = 4
|
||||
strut_policy = minimum
|
||||
</code></pre>
|
||||
<h2 id="author">AUTHOR<a name="author" href="#author" class="md2man-permalink" title="permalink"></a></h2><p>tint2 was written by Thierry Lorthiois <a href="mailto:lorthiois@bbsoft.fr">lorthiois@bbsoft.fr</a>.
|
||||
<h3 id="button">Button<a name="button" href="#button" class="md2man-permalink" title="permalink"></a></h3>
|
||||
<ul>
|
||||
<li><p><code>button = new</code> : Begins the configuration of a new button. Multiple such plugins are supported; just use multiple <code>P</code>s in <code>panel_items</code>. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_icon = text</code> : Name or path of icon (or empty). <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_text = text</code> : Text to display (or empty). <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_tooltip = text</code> : The tooltip (or empty). <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_font = [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]</code> : The font used to draw the text. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_font_color = color opacity</code> : The font color. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_background_id = integer</code> : Which background to use. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_centered = boolean (0 or 1)</code> : Whether to center the text. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_padding = horizontal_padding vertical_padding spacing_between_icon_and_text</code> <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_max_icon_size = integer</code> : Sets a limit to the icon size. Otherwise, the icon will expand to the edges. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_lclick_command = text</code> : Command to execute on left click. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_mclick_command = text</code> : Command to execute on right click. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_rclick_command = text</code> : Command to execute on middle click. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_uwheel_command = text</code> : Command to execute on wheel scroll up. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.14)</em></p></li>
|
||||
<li><p><code>button_dwheel_command = text</code> : Command to execute on wheel scroll down. If not defined, <code>execp_command</code> is executed immediately, unless it is currently running. <em>(since 0.14)</em></p></li>
|
||||
</ul>
|
||||
<h3 id="separator">Separator<a name="separator" href="#separator" class="md2man-permalink" title="permalink"></a></h3>
|
||||
<ul>
|
||||
<li><p><code>separator = new</code> : Begins the configuration of a new separator. Multiple such plugins are supported; just use multiple <code>:</code>s in <code>panel_items</code>. <em>(since 0.13.0)</em></p></li>
|
||||
<li><p><code>separator_background_id = integer</code> : Which background to use. <em>(since 0.13.0)</em></p></li>
|
||||
<li><p><code>separator_color = color opacity</code> : The foreground color. <em>(since 0.13.0)</em></p></li>
|
||||
<li><p><code>separator_style = [empty | line | dots]</code> : The separator style. <em>(since 0.13.0)</em></p></li>
|
||||
<li><p><code>separator_size = integer</code> : The thickness of the separator. Does not include the border and padding. For example, if the style is <code>line</code>, this is the line thickness; if the style is <code>dots</code>, this is the dot's diameter. <em>(since 0.13.0)</em></p></li>
|
||||
<li><p><code>separator_padding = side_padding cap_padding</code> : The padding to add to the sides of the separator, in pixels. <em>(since 0.13.0)</em></p></li>
|
||||
</ul>
|
||||
<h3 id="example-configuration">Example configuration<a name="example-configuration" href="#example-configuration" class="md2man-permalink" title="permalink"></a></h3><p>See /etc/xdg/tint2/tint2rc.</p><h2 id="author">AUTHOR<a name="author" href="#author" class="md2man-permalink" title="permalink"></a></h2><p>tint2 was written by Thierry Lorthiois <a href="mailto:lorthiois@bbsoft.fr">lorthiois@bbsoft.fr</a>.
|
||||
It is based on ttm, originally written by Pål Staurland <a href="mailto:staura@gmail.com">staura@gmail.com</a>.</p><p>This manual page was originally written by Daniel Moerner <a href="mailto:dmoerner@gmail.com">dmoerner@gmail.com</a>, for the Debian project (but may be used by others).
|
||||
It was adopted from the tint2 docs.</p><h2 id="see-also">SEE ALSO<a name="see-also" href="#see-also" class="md2man-permalink" title="permalink"></a></h2><p>The main website <a href="https://gitlab.com/o9000/tint2">https://gitlab.com/o9000/tint2</a>
|
||||
and the wiki page at <a href="https://gitlab.com/o9000/tint2/wikis/home">https://gitlab.com/o9000/tint2/wikis/home</a>.</p><p>This documentation is also provided in HTML and Markdown format in the system's default location
|
||||
|
||||
@@ -199,9 +199,9 @@ pre {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="latest-stable-release-0-12-11"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">0.12.11</span><a name="latest-stable-release-0-12-11" href="#latest-stable-release-0-12-11" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/0.12.11/ChangeLog">https://gitlab.com/o9000/tint2/blob/0.12.11/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (see also <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
|
||||
<h1 id="latest-stable-release-0-14-1"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">0.14.1</span><a name="latest-stable-release-0-14-1" href="#latest-stable-release-0-14-1" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/0.14.1/ChangeLog">https://gitlab.com/o9000/tint2/blob/0.14.1/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
|
||||
cd tint2
|
||||
git checkout 0.12.11
|
||||
git checkout 0.14.1
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
@@ -235,10 +235,16 @@ make -j4
|
||||
<li><a href="https://gitlab.com/o9000/tint2/wikis/FAQ">Other frequently asked questions</a></li>
|
||||
<li><a href="https://gitlab.com/o9000/tint2/wikis/Debug">Obtain a stack trace when tint2 crashes</a></li>
|
||||
</ul>
|
||||
<h1 id="known-issues">Known issues<a name="known-issues" href="#known-issues" class="md2man-permalink" title="permalink"></a></h1>
|
||||
<ul>
|
||||
<li>Graphic glitches on Intel graphics cards can be avoided by changing the acceleration method to UXA (<a href="https://gitlab.com/o9000/tint2/issues/595">issue 595</a>)</li>
|
||||
<li>Window managers that do not follow exactly the EWMH specification might not interact well with tint2 (known issues for <a href="https://gitlab.com/o9000/tint2/issues/385">awesome</a>, <a href="https://gitlab.com/o9000/tint2/issues/524">bspwm</a>. <a href="https://gitlab.com/o9000/tint2/issues/456">openbox-multihead</a>)</li>
|
||||
<li>Full transparency requires a compositor such as Compton (if not provided already by the window manager, as in Compiz/Unity, KDE or XFCE)</li>
|
||||
</ul>
|
||||
<h1 id="how-can-i-help-out">How can I help out?<a name="how-can-i-help-out" href="#how-can-i-help-out" class="md2man-permalink" title="permalink"></a></h1>
|
||||
<ul>
|
||||
<li>Report bugs and ask questions on the <a href="https://gitlab.com/o9000/tint2/issues">issue tracker</a>;</li>
|
||||
<li>Contribute to the development by helping us fix bugs and suggesting new features.</li>
|
||||
<li>Contribute to the development by helping us fix bugs and suggesting new features. Please read the contribution guide: <a href="CONTRIBUTING.md">CONTRIBUTING.md</a></li>
|
||||
</ul>
|
||||
<h1 id="links">Links<a name="links" href="#links" class="md2man-permalink" title="permalink"></a></h1>
|
||||
<ul>
|
||||
@@ -248,6 +254,12 @@ make -j4
|
||||
<li>Downloads: <a href="https://gitlab.com/o9000/tint2-archive/tree/master">https://gitlab.com/o9000/tint2-archive/tree/master</a> or <a href="https://code.google.com/p/tint2/downloads/list">https://code.google.com/p/tint2/downloads/list</a></li>
|
||||
<li>Old project location (inactive): <a href="https://code.google.com/p/tint2">https://code.google.com/p/tint2</a></li>
|
||||
</ul>
|
||||
<h1 id="screenshots">Screenshots<a name="screenshots" href="#screenshots" class="md2man-permalink" title="permalink"></a></h1><h2 id="default-config">Default config:<a name="default-config" href="#default-config" class="md2man-permalink" title="permalink"></a></h2><p><img src="https://gitlab.com/o9000/tint2/uploads/948fa74eca60864352a033580350b4c3/Screenshot_2016-01-23_14-42-57.png" alt="Screenshot_2016-01-23_14-42-57"></p><h2 id="various-configs">Various configs:<a name="various-configs" href="#various-configs" class="md2man-permalink" title="permalink"></a></h2><p><img src="https://gitlab.com/o9000/tint2/wikis/screenshot.png" alt="screenshot"></p>
|
||||
<h1 id="screenshots">Screenshots<a name="screenshots" href="#screenshots" class="md2man-permalink" title="permalink"></a></h1><h2 id="default-config">Default config:<a name="default-config" href="#default-config" class="md2man-permalink" title="permalink"></a></h2><p><img src="https://gitlab.com/o9000/tint2/uploads/948fa74eca60864352a033580350b4c3/Screenshot_2016-01-23_14-42-57.png" alt="Screenshot_2016-01-23_14-42-57"></p><h2 id="various-configs">Various configs:<a name="various-configs" href="#various-configs" class="md2man-permalink" title="permalink"></a></h2><p><img src="https://gitlab.com/o9000/tint2/wikis/screenshot.png" alt="screenshot"></p><h2 id="demos">Demos<a name="demos" href="#demos" class="md2man-permalink" title="permalink"></a></h2>
|
||||
<ul>
|
||||
<li><a href="https://gitlab.com/o9000/tint2/wikis/whats-new-0.13.0.gif">Compact panel, separator, color gradients</a></li>
|
||||
<li><a href="https://gitlab.com/o9000/tint2/wikis/whats-new-0.12.4.gif">Executor</a></li>
|
||||
<li><a href="https://gitlab.com/o9000/tint2/wikis/whats-new-0.12.3.gif">Mouse over effects</a></li>
|
||||
<li><a href="https://gitlab.com/o9000/tint2/wikis/whats-new-0.12.gif">Distribute size between taskbars, freespace</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
320
doc/tint2.1
320
doc/tint2.1
@@ -1,4 +1,4 @@
|
||||
.TH TINT2 1 "2016\-05\-22"
|
||||
.TH TINT2 1 "2017\-03\-26" 0.14.1
|
||||
.SH NAME
|
||||
.PP
|
||||
tint2 \- lightweight panel/taskbar
|
||||
@@ -45,6 +45,8 @@ Introduction \[la]#introduction\[ra]
|
||||
.IP \(bu 2
|
||||
Backgrounds and borders \[la]#backgrounds-and-borders\[ra]
|
||||
.IP \(bu 2
|
||||
Gradients \[la]#gradients\[ra]
|
||||
.IP \(bu 2
|
||||
Panel \[la]#panel\[ra]
|
||||
.IP \(bu 2
|
||||
Launcher \[la]#launcher\[ra]
|
||||
@@ -65,6 +67,10 @@ Battery \[la]#battery\[ra]
|
||||
.IP \(bu 2
|
||||
Executor \[la]#executor\[ra]
|
||||
.IP \(bu 2
|
||||
Button \[la]#button\[ra]
|
||||
.IP \(bu 2
|
||||
Separator \[la]#separator\[ra]
|
||||
.IP \(bu 2
|
||||
Example configuration \[la]#example-configuration\[ra]
|
||||
.RE
|
||||
.SS Introduction
|
||||
@@ -171,6 +177,105 @@ clock_background_id = 0
|
||||
.RE
|
||||
.PP
|
||||
Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.
|
||||
.SS Gradients
|
||||
.PP
|
||||
(Available since 0.13.0)
|
||||
.PP
|
||||
Backgrounds also allow specifying gradient layers
|
||||
that are drawn on top of the solid color background.
|
||||
.PP
|
||||
First the user must define one or more gradients in the config file,
|
||||
each starting with \fB\fCgradient = TYPE\fR\&. These must be added before backgrounds.
|
||||
.PP
|
||||
Then gradients can be added by index to backgrounds,
|
||||
using the \fB\fCgradient_id = INDEX\fR, \fB\fCgradient_id_hover = INDEX\fR and
|
||||
\fB\fCgradient_id_pressed = INDEX\fR, where \fB\fCINDEX\fR is
|
||||
the gradient index, starting from 1.
|
||||
.SS Gradient types
|
||||
.PP
|
||||
Gradients vary the color between fixed control points:
|
||||
* vertical gradients: top\-to\-bottom;
|
||||
* horizontal gradients: left\-to\-right;
|
||||
* radial gradients: center\-to\-corners.
|
||||
.PP
|
||||
The user must specify the start and end colors, and can optionally add extra color stops in between
|
||||
using the \fB\fCcolor_stop\fR option, as explained below.
|
||||
.SS Vertical gradient, with color varying from the top edge to the bottom edge, two colors
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
gradient = vertical
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
.fi
|
||||
.RE
|
||||
.SS Horizontal gradient, with color varying from the left edge to the right edge, two colors
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
gradient = horizontal
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
.fi
|
||||
.RE
|
||||
.SS Radial gradient, with color varying from the center to the corner, two colors:
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
gradient = radial
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
.fi
|
||||
.RE
|
||||
.SS Adding extra color stops (0% and 100% remain fixed, more colors at x% between the start and end control points)
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
color_stop = percentage #rrggbb opacity
|
||||
.fi
|
||||
.RE
|
||||
.SS Gradient examples
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
# Gradient 1: thin film effect
|
||||
gradient = horizontal
|
||||
start_color = #111122 30
|
||||
end_color = #112211 30
|
||||
color_stop = 60 #221111 30
|
||||
|
||||
# Gradient 2: radial glow
|
||||
gradient = radial
|
||||
start_color = #ffffff 20
|
||||
end_color = #ffffff 0
|
||||
|
||||
# Gradient 3: elegant black
|
||||
gradient = vertical
|
||||
start_color = #444444 100
|
||||
end_color = #222222 100
|
||||
|
||||
# Gradient 4: elegant black
|
||||
gradient = horizontal
|
||||
start_color = #111111 100
|
||||
end_color = #222222 100
|
||||
|
||||
# Background 1: Active desktop name
|
||||
rounded = 2
|
||||
border_width = 1
|
||||
border_sides = TBLR
|
||||
background_color = #555555 10
|
||||
border_color = #ffffff 60
|
||||
background_color_hover = #555555 10
|
||||
border_color_hover = #ffffff 60
|
||||
background_color_pressed = #555555 10
|
||||
border_color_pressed = #ffffff 60
|
||||
gradient_id = 3
|
||||
gradient_id_hover = 4
|
||||
gradient_id_pressed = 2
|
||||
|
||||
[...]
|
||||
.fi
|
||||
.RE
|
||||
.SS Panel
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
@@ -187,9 +292,13 @@ Identifier 0 refers to a special background which is fully transparent, identifi
|
||||
.IP \(bu 2
|
||||
\fB\fCC\fR shows the Clock
|
||||
.IP \(bu 2
|
||||
\fB\fCF\fR adds an extensible spacer (freespace). Has no effect if \fB\fCT\fR is also present. \fI(since 0.12)\fP
|
||||
\fB\fCF\fR adds an extensible spacer (freespace). You can specify more than one. Has no effect if \fB\fCT\fR is also present. \fI(since 0.12)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCE\fR adds an executor plugin. You can specify more than one. \fI(since 0.12.4)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCP\fR adds a push button. You can specify more than one. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fC:\fR adds a separator. You can specify more than one. \fI(since 0.13.0)\fP
|
||||
.RE
|
||||
.PP
|
||||
For example, \fB\fCpanel_items = STC\fR will show the systray, the taskbar and the clock (from left to right).
|
||||
@@ -234,6 +343,8 @@ panel_size = 94% 30
|
||||
.RE
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
\fB\fCpanel_shrink = boolean (0 or 1)\fR : If set to 1, the panel will shrink to a compact size dynamically. \fI(since 0.13)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCpanel_margin = horizontal_margin vertical_margin\fR : The margins define the distance between the panel and the horizontal/vertical monitor edge. Use \fB\fC0\fR to obtain a panel with the same size as the edge of the monitor (no margin).
|
||||
.RE
|
||||
.PP
|
||||
@@ -326,7 +437,9 @@ You can switch between virtual desktops.
|
||||
.RE
|
||||
.RE
|
||||
.IP \(bu 2
|
||||
\fB\fCtaskbar_distribute_size = boolean (0 or 1)\fR : If enabled, in multi\-desktop mode distributes between taskbars the available size proportionally to the number of tasks. Default: disabled. \fI(since 0.12)\fP
|
||||
\fB\fCtaskbar_hide_if_empty = boolean (0 or 1)\fR : If enabled, in multi\-desktop mode the taskbars corresponding to empty desktops different from the current desktop are hidden. \fI(since 0.13)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCtaskbar_distribute_size = boolean (0 or 1)\fR : If enabled, in multi\-desktop mode distributes between taskbars the available size proportionally to the number of tasks. Default: disabled. \fI(since 0.12)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCtaskbar_padding = horizontal_padding vertical_padding spacing\fR
|
||||
.RE
|
||||
@@ -379,7 +492,7 @@ You can switch between virtual desktops.
|
||||
The following options configure the task buttons in the taskbar:
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
\fB\fCtask_icon = boolean (0 or 1)\fR : Whether to display the task icon.
|
||||
\fB\fCtask_icon = boolean (0 or 1)\fR : Whether to display the task icon. There is no explicit option to control the task icon size; it depends on the vertical padding set with \fB\fCtask_padding\fR\&.
|
||||
.IP \(bu 2
|
||||
\fB\fCtask_text = boolean (0 or 1)\fR : Whether to display the task text.
|
||||
.IP \(bu 2
|
||||
@@ -460,6 +573,8 @@ The action semantics:
|
||||
\fB\fCsystray_icon_asb = alpha (0 to 100) saturation (\-100 to 100) brightness (\-100 to 100)\fR : Adjust the systray icons color and transparency.
|
||||
.IP \(bu 2
|
||||
\fB\fCsystray_monitor = integer (1, 2, ...)\fR : On which monitor to draw the systray. The first monitor is \fB\fC1\fR\&. \fI(since 0.12)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCsystray_name_filter = string\fR : Regular expression to identify icon names to be hidden. For example, \fB\fC^audacious$\fR will hide icons with the exact name \fB\fCaudacious\fR, while \fB\fCaud\fR will hide any icons having \fB\fCaud\fR in the name. \fI(since 0.13.1)\fP
|
||||
.RE
|
||||
.SS Clock
|
||||
.RS
|
||||
@@ -662,8 +777,8 @@ execp_continuous = 2
|
||||
.RS
|
||||
.nf
|
||||
execp = new
|
||||
execp_command = ping \-i 1 \-W 1 \-O \-D \-n $(ip route | grep default | grep via | grep \-o '[0\-9]*\\.[0\-9]*\\.[0\-9]*\\.[0\-9]*') | awk '/no/ { print "<span foreground=\\"#faa\\">timeout</span>"; fflush(); }; /time=/ { gsub(/time=/, "", $8); printf "<span foreground=\\"#7af\\">%3.0f %s</span>\\n", $8, $9; fflush(); } '
|
||||
execp_continuous = 1
|
||||
execp_command = ping \-i 1 \-c 1 \-W 1 \-O \-D \-n $(ip route | grep default | grep via | grep \-o '[0\-9]*\\.[0\-9]*\\.[0\-9]*\\.[0\-9]*') | awk '/no/ { print "<span foreground=\\"#faa\\">timeout</span>"; fflush(); }; /time=/ { gsub(/time=/, "", $8); printf "<span foreground=\\"#7af\\">%3.0f %s</span>\\n", $8, $9; fflush(); } '
|
||||
execp_continuous = 0
|
||||
execp_interval = 1
|
||||
execp_markup = 1
|
||||
.fi
|
||||
@@ -673,9 +788,9 @@ execp_markup = 1
|
||||
.RS
|
||||
.nf
|
||||
execp = new
|
||||
execp_command = free \-s 2 | awk '/^\-/ { printf "Mem: '$(free \-h | awk '/^Mem:/ { print $2 }')' %.0f%\\n", 100*$3/($3+$4); fflush(stdout) }'
|
||||
execp_interval = 1
|
||||
execp_continuous = 1
|
||||
execp_command = free | awk '/^\-/ { printf "Mem: '$(free \-h | awk '/^Mem:/ { print $2 }')' %.0f%%\\n", 100*$3/($3+$4); fflush(stdout) }'
|
||||
execp_interval = 5
|
||||
execp_continuous = 0
|
||||
.fi
|
||||
.RE
|
||||
.SS Network load
|
||||
@@ -689,146 +804,57 @@ execp_continuous = 1
|
||||
execp_interval = 1
|
||||
.fi
|
||||
.RE
|
||||
.SS Button
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton = new\fR : Begins the configuration of a new button. Multiple such plugins are supported; just use multiple \fB\fCP\fRs in \fB\fCpanel_items\fR\&. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_icon = text\fR : Name or path of icon (or empty). \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_text = text\fR : Text to display (or empty). \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_tooltip = text\fR : The tooltip (or empty). \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_font = [FAMILY\-LIST] [STYLE\-OPTIONS] [SIZE]\fR : The font used to draw the text. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_font_color = color opacity\fR : The font color. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_background_id = integer\fR : Which background to use. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_centered = boolean (0 or 1)\fR : Whether to center the text. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_padding = horizontal_padding vertical_padding spacing_between_icon_and_text\fR \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_max_icon_size = integer\fR : Sets a limit to the icon size. Otherwise, the icon will expand to the edges. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_lclick_command = text\fR : Command to execute on left click. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_mclick_command = text\fR : Command to execute on right click. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_rclick_command = text\fR : Command to execute on middle click. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_uwheel_command = text\fR : Command to execute on wheel scroll up. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.14)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCbutton_dwheel_command = text\fR : Command to execute on wheel scroll down. If not defined, \fB\fCexecp_command\fR is executed immediately, unless it is currently running. \fI(since 0.14)\fP
|
||||
.RE
|
||||
.SS Separator
|
||||
.RS
|
||||
.IP \(bu 2
|
||||
\fB\fCseparator = new\fR : Begins the configuration of a new separator. Multiple such plugins are supported; just use multiple \fB\fC:\fRs in \fB\fCpanel_items\fR\&. \fI(since 0.13.0)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCseparator_background_id = integer\fR : Which background to use. \fI(since 0.13.0)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCseparator_color = color opacity\fR : The foreground color. \fI(since 0.13.0)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCseparator_style = [empty | line | dots]\fR : The separator style. \fI(since 0.13.0)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCseparator_size = integer\fR : The thickness of the separator. Does not include the border and padding. For example, if the style is \fB\fCline\fR, this is the line thickness; if the style is \fB\fCdots\fR, this is the dot's diameter. \fI(since 0.13.0)\fP
|
||||
.IP \(bu 2
|
||||
\fB\fCseparator_padding = side_padding cap_padding\fR : The padding to add to the sides of the separator, in pixels. \fI(since 0.13.0)\fP
|
||||
.RE
|
||||
.SS Example configuration
|
||||
.PP
|
||||
.RS
|
||||
.nf
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## TINT2 CONFIG FILE
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## BACKGROUND AND BORDER
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
rounded = 7
|
||||
border_width = 2
|
||||
background_color = #000000 60
|
||||
border_color = #ffffff 18
|
||||
|
||||
rounded = 5
|
||||
border_width = 0
|
||||
background_color = #ffffff 40
|
||||
border_color = #ffffff 50
|
||||
|
||||
rounded = 5
|
||||
border_width = 0
|
||||
background_color = #ffffff 18
|
||||
border_color = #ffffff 70
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## PANEL
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
panel_monitor = all
|
||||
panel_position = bottom center
|
||||
panel_size = 94% 30
|
||||
panel_margin = 0 0
|
||||
panel_padding = 7 0
|
||||
font_shadow = 0
|
||||
panel_background_id = 1
|
||||
wm_menu = 0
|
||||
panel_dock = 0
|
||||
panel_layer = bottom
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## TASKBAR
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
#taskbar_mode = multi_desktop
|
||||
taskbar_mode = single_desktop
|
||||
taskbar_padding = 2 3 2
|
||||
taskbar_background_id = 0
|
||||
#taskbar_active_background_id = 0
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## TASKS
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
task_icon = 1
|
||||
task_text = 1
|
||||
task_maximum_size = 140 35
|
||||
task_centered = 1
|
||||
task_padding = 6 3
|
||||
task_font = sans 7
|
||||
task_font_color = #ffffff 70
|
||||
task_background_id = 3
|
||||
task_icon_asb = 100 0 0
|
||||
## replace STATUS by 'urgent', 'active' or 'iconfied'
|
||||
#task_STATUS_background_id = 2
|
||||
#task_STATUS_font_color = #ffffff 85
|
||||
#task_STATUS_icon_asb = 100 0 0
|
||||
## example:
|
||||
task_active_background_id = 2
|
||||
task_active_font_color = #ffffff 85
|
||||
task_active_icon_asb = 100 0 0
|
||||
urgent_nb_of_blink = 8
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## SYSTRAYBAR
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
systray = 1
|
||||
systray_padding = 0 4 5
|
||||
systray_background_id = 0
|
||||
systray_sort = left2right
|
||||
systray_icon_size = 0
|
||||
systray_icon_asb = 100 0 0
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## CLOCK
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
time1_format = %H:%M
|
||||
time1_font = sans 8
|
||||
time2_format = %A %d %B
|
||||
time2_font = sans 6
|
||||
clock_font_color = #ffffff 76
|
||||
clock_padding = 1 0
|
||||
clock_background_id = 0
|
||||
#clock_lclick_command = xclock
|
||||
clock_rclick_command = orage
|
||||
#clock_tooltip = %A %d %B
|
||||
#time1_timezone = :US/Hawaii
|
||||
#time2_timezone = :Europe/Berlin
|
||||
#clock_tooltip_timezone = :/usr/share/zoneinfo/Europe/Paris
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## BATTERY
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
battery = 0
|
||||
battery_hide = 98
|
||||
battery_low_status = 10
|
||||
battery_low_cmd = notify\-send "battery low"
|
||||
bat1_font = sans 8
|
||||
bat2_font = sans 6
|
||||
battery_font_color = #ffffff 76
|
||||
battery_padding = 1 0
|
||||
battery_background_id = 0
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## TOOLTIP
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
tooltip = 0
|
||||
tooltip_padding = 2 2
|
||||
tooltip_show_timeout = 0.7
|
||||
tooltip_hide_timeout = 0.3
|
||||
tooltip_background_id = 1
|
||||
tooltip_font_color = #OOOOOO 80
|
||||
tooltip_font = sans 10
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## MOUSE ACTION ON TASK
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
mouse_middle = none
|
||||
mouse_right = close
|
||||
mouse_scroll_up = toggle
|
||||
mouse_scroll_down = iconify
|
||||
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
## AUTOHIDE OPTIONS
|
||||
#\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
autohide = 0
|
||||
autohide_show_timeout = 0.3
|
||||
autohide_hide_timeout = 2
|
||||
autohide_height = 4
|
||||
strut_policy = minimum
|
||||
.fi
|
||||
.RE
|
||||
See /etc/xdg/tint2/tint2rc.
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
tint2 was written by Thierry Lorthiois \[la]lorthiois@bbsoft.fr\[ra]\&.
|
||||
|
||||
306
doc/tint2.md
306
doc/tint2.md
@@ -1,4 +1,4 @@
|
||||
# TINT2 1 "2016-05-22"
|
||||
# TINT2 1 "2017-03-26" 0.14.1
|
||||
|
||||
## NAME
|
||||
tint2 - lightweight panel/taskbar
|
||||
@@ -36,6 +36,8 @@ Goals:
|
||||
|
||||
* [Backgrounds and borders](#backgrounds-and-borders)
|
||||
|
||||
* [Gradients](#gradients)
|
||||
|
||||
* [Panel](#panel)
|
||||
|
||||
* [Launcher](#launcher)
|
||||
@@ -56,6 +58,10 @@ Goals:
|
||||
|
||||
* [Executor](#executor)
|
||||
|
||||
* [Button](#button)
|
||||
|
||||
* [Separator](#separator)
|
||||
|
||||
* [Example configuration](#example-configuration)
|
||||
|
||||
### Introduction
|
||||
@@ -134,6 +140,102 @@ clock_background_id = 0
|
||||
|
||||
Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.
|
||||
|
||||
### Gradients
|
||||
|
||||
(Available since 0.13.0)
|
||||
|
||||
Backgrounds also allow specifying gradient layers
|
||||
that are drawn on top of the solid color background.
|
||||
|
||||
First the user must define one or more gradients in the config file,
|
||||
each starting with `gradient = TYPE`. These must be added before backgrounds.
|
||||
|
||||
Then gradients can be added by index to backgrounds,
|
||||
using the `gradient_id = INDEX`, `gradient_id_hover = INDEX` and
|
||||
`gradient_id_pressed = INDEX`, where `INDEX` is
|
||||
the gradient index, starting from 1.
|
||||
|
||||
#### Gradient types
|
||||
|
||||
Gradients vary the color between fixed control points:
|
||||
* vertical gradients: top-to-bottom;
|
||||
* horizontal gradients: left-to-right;
|
||||
* radial gradients: center-to-corners.
|
||||
|
||||
The user must specify the start and end colors, and can optionally add extra color stops in between
|
||||
using the `color_stop` option, as explained below.
|
||||
|
||||
##### Vertical gradient, with color varying from the top edge to the bottom edge, two colors
|
||||
|
||||
```
|
||||
gradient = vertical
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
```
|
||||
|
||||
##### Horizontal gradient, with color varying from the left edge to the right edge, two colors
|
||||
|
||||
```
|
||||
gradient = horizontal
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
```
|
||||
|
||||
##### Radial gradient, with color varying from the center to the corner, two colors:
|
||||
|
||||
```
|
||||
gradient = radial
|
||||
start_color = #rrggbb opacity
|
||||
end_color = #rrggbb opacity
|
||||
```
|
||||
|
||||
##### Adding extra color stops (0% and 100% remain fixed, more colors at x% between the start and end control points)
|
||||
|
||||
```
|
||||
color_stop = percentage #rrggbb opacity
|
||||
```
|
||||
|
||||
#### Gradient examples
|
||||
|
||||
```
|
||||
# Gradient 1: thin film effect
|
||||
gradient = horizontal
|
||||
start_color = #111122 30
|
||||
end_color = #112211 30
|
||||
color_stop = 60 #221111 30
|
||||
|
||||
# Gradient 2: radial glow
|
||||
gradient = radial
|
||||
start_color = #ffffff 20
|
||||
end_color = #ffffff 0
|
||||
|
||||
# Gradient 3: elegant black
|
||||
gradient = vertical
|
||||
start_color = #444444 100
|
||||
end_color = #222222 100
|
||||
|
||||
# Gradient 4: elegant black
|
||||
gradient = horizontal
|
||||
start_color = #111111 100
|
||||
end_color = #222222 100
|
||||
|
||||
# Background 1: Active desktop name
|
||||
rounded = 2
|
||||
border_width = 1
|
||||
border_sides = TBLR
|
||||
background_color = #555555 10
|
||||
border_color = #ffffff 60
|
||||
background_color_hover = #555555 10
|
||||
border_color_hover = #ffffff 60
|
||||
background_color_pressed = #555555 10
|
||||
border_color_pressed = #ffffff 60
|
||||
gradient_id = 3
|
||||
gradient_id_hover = 4
|
||||
gradient_id_pressed = 2
|
||||
|
||||
[...]
|
||||
```
|
||||
|
||||
### Panel
|
||||
|
||||
* `panel_items = LTSBC` defines the items tint2 will show and the order of those items. Each letter refers to an item, defined as:
|
||||
@@ -142,8 +244,10 @@ Identifier 0 refers to a special background which is fully transparent, identifi
|
||||
* `S` shows the Systray (also called notification area)
|
||||
* `B` shows the Battery status
|
||||
* `C` shows the Clock
|
||||
* `F` adds an extensible spacer (freespace). Has no effect if `T` is also present. *(since 0.12)*
|
||||
* `F` adds an extensible spacer (freespace). You can specify more than one. Has no effect if `T` is also present. *(since 0.12)*
|
||||
* `E` adds an executor plugin. You can specify more than one. *(since 0.12.4)*
|
||||
* `P` adds a push button. You can specify more than one. *(since 0.14)*
|
||||
* `:` adds a separator. You can specify more than one. *(since 0.13.0)*
|
||||
|
||||
For example, `panel_items = STC` will show the systray, the taskbar and the clock (from left to right).
|
||||
|
||||
@@ -169,6 +273,8 @@ Identifier 0 refers to a special background which is fully transparent, identifi
|
||||
panel_size = 94% 30
|
||||
```
|
||||
|
||||
* `panel_shrink = boolean (0 or 1)` : If set to 1, the panel will shrink to a compact size dynamically. *(since 0.13)*
|
||||
|
||||
* `panel_margin = horizontal_margin vertical_margin` : The margins define the distance between the panel and the horizontal/vertical monitor edge. Use `0` to obtain a panel with the same size as the edge of the monitor (no margin).
|
||||
|
||||

|
||||
@@ -241,7 +347,9 @@ panel_size = 94% 30
|
||||
* You can drag-and-drop tasks between virtual desktops;
|
||||
* You can switch between virtual desktops.
|
||||
|
||||
* `taskbar_distribute_size = boolean (0 or 1)` : If enabled, in multi-desktop mode distributes between taskbars the available size proportionally to the number of tasks. Default: disabled. *(since 0.12)*
|
||||
* `taskbar_hide_if_empty = boolean (0 or 1)` : If enabled, in multi-desktop mode the taskbars corresponding to empty desktops different from the current desktop are hidden. *(since 0.13)*
|
||||
|
||||
* `taskbar_distribute_size = boolean (0 or 1)` : If enabled, in multi-desktop mode distributes between taskbars the available size proportionally to the number of tasks. Default: disabled. *(since 0.12)*
|
||||
|
||||
* `taskbar_padding = horizontal_padding vertical_padding spacing`
|
||||
|
||||
@@ -284,7 +392,7 @@ panel_size = 94% 30
|
||||
|
||||
The following options configure the task buttons in the taskbar:
|
||||
|
||||
* `task_icon = boolean (0 or 1)` : Whether to display the task icon.
|
||||
* `task_icon = boolean (0 or 1)` : Whether to display the task icon. There is no explicit option to control the task icon size; it depends on the vertical padding set with `task_padding`.
|
||||
|
||||
* `task_text = boolean (0 or 1)` : Whether to display the task text.
|
||||
|
||||
@@ -358,6 +466,8 @@ The action semantics:
|
||||
|
||||
* `systray_monitor = integer (1, 2, ...)` : On which monitor to draw the systray. The first monitor is `1`. *(since 0.12)*
|
||||
|
||||
* `systray_name_filter = string` : Regular expression to identify icon names to be hidden. For example, `^audacious$` will hide icons with the exact name `audacious`, while `aud` will hide any icons having `aud` in the name. *(since 0.13.1)*
|
||||
|
||||
### Clock
|
||||
|
||||
* `time1_format = %H:%M` : The format used by the first line of the clock.
|
||||
@@ -539,8 +649,8 @@ execp_continuous = 2
|
||||
|
||||
```
|
||||
execp = new
|
||||
execp_command = ping -i 1 -W 1 -O -D -n $(ip route | grep default | grep via | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*') | awk '/no/ { print "<span foreground=\"#faa\">timeout</span>"; fflush(); }; /time=/ { gsub(/time=/, "", $8); printf "<span foreground=\"#7af\">%3.0f %s</span>\n", $8, $9; fflush(); } '
|
||||
execp_continuous = 1
|
||||
execp_command = ping -i 1 -c 1 -W 1 -O -D -n $(ip route | grep default | grep via | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*') | awk '/no/ { print "<span foreground=\"#faa\">timeout</span>"; fflush(); }; /time=/ { gsub(/time=/, "", $8); printf "<span foreground=\"#7af\">%3.0f %s</span>\n", $8, $9; fflush(); } '
|
||||
execp_continuous = 0
|
||||
execp_interval = 1
|
||||
execp_markup = 1
|
||||
```
|
||||
@@ -549,9 +659,9 @@ execp_markup = 1
|
||||
|
||||
```
|
||||
execp = new
|
||||
execp_command = free -s 2 | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%\n", 100*$3/($3+$4); fflush(stdout) }'
|
||||
execp_interval = 1
|
||||
execp_continuous = 1
|
||||
execp_command = free | awk '/^-/ { printf "Mem: '$(free -h | awk '/^Mem:/ { print $2 }')' %.0f%%\n", 100*$3/($3+$4); fflush(stdout) }'
|
||||
execp_interval = 5
|
||||
execp_continuous = 0
|
||||
```
|
||||
|
||||
##### Network load
|
||||
@@ -564,144 +674,50 @@ execp_continuous = 1
|
||||
execp_interval = 1
|
||||
```
|
||||
|
||||
### Button
|
||||
|
||||
* `button = new` : Begins the configuration of a new button. Multiple such plugins are supported; just use multiple `P`s in `panel_items`. *(since 0.14)*
|
||||
|
||||
* `button_icon = text` : Name or path of icon (or empty). *(since 0.14)*
|
||||
|
||||
* `button_text = text` : Text to display (or empty). *(since 0.14)*
|
||||
|
||||
* `button_tooltip = text` : The tooltip (or empty). *(since 0.14)*
|
||||
|
||||
* `button_font = [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]` : The font used to draw the text. *(since 0.14)*
|
||||
|
||||
* `button_font_color = color opacity` : The font color. *(since 0.14)*
|
||||
|
||||
* `button_background_id = integer` : Which background to use. *(since 0.14)*
|
||||
|
||||
* `button_centered = boolean (0 or 1)` : Whether to center the text. *(since 0.14)*
|
||||
|
||||
* `button_padding = horizontal_padding vertical_padding spacing_between_icon_and_text` *(since 0.14)*
|
||||
* `button_max_icon_size = integer` : Sets a limit to the icon size. Otherwise, the icon will expand to the edges. *(since 0.14)*
|
||||
|
||||
* `button_lclick_command = text` : Command to execute on left click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.14)*
|
||||
* `button_mclick_command = text` : Command to execute on right click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.14)*
|
||||
* `button_rclick_command = text` : Command to execute on middle click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.14)*
|
||||
* `button_uwheel_command = text` : Command to execute on wheel scroll up. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.14)*
|
||||
* `button_dwheel_command = text` : Command to execute on wheel scroll down. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.14)*
|
||||
|
||||
### Separator
|
||||
|
||||
* `separator = new` : Begins the configuration of a new separator. Multiple such plugins are supported; just use multiple `:`s in `panel_items`. *(since 0.13.0)*
|
||||
|
||||
* `separator_background_id = integer` : Which background to use. *(since 0.13.0)*
|
||||
|
||||
* `separator_color = color opacity` : The foreground color. *(since 0.13.0)*
|
||||
|
||||
* `separator_style = [empty | line | dots]` : The separator style. *(since 0.13.0)*
|
||||
|
||||
* `separator_size = integer` : The thickness of the separator. Does not include the border and padding. For example, if the style is `line`, this is the line thickness; if the style is `dots`, this is the dot's diameter. *(since 0.13.0)*
|
||||
|
||||
* `separator_padding = side_padding cap_padding` : The padding to add to the sides of the separator, in pixels. *(since 0.13.0)*
|
||||
|
||||
### Example configuration
|
||||
|
||||
```
|
||||
#---------------------------------------------
|
||||
## TINT2 CONFIG FILE
|
||||
#---------------------------------------------
|
||||
|
||||
#---------------------------------------------
|
||||
## BACKGROUND AND BORDER
|
||||
#---------------------------------------------
|
||||
rounded = 7
|
||||
border_width = 2
|
||||
background_color = #000000 60
|
||||
border_color = #ffffff 18
|
||||
|
||||
rounded = 5
|
||||
border_width = 0
|
||||
background_color = #ffffff 40
|
||||
border_color = #ffffff 50
|
||||
|
||||
rounded = 5
|
||||
border_width = 0
|
||||
background_color = #ffffff 18
|
||||
border_color = #ffffff 70
|
||||
|
||||
#---------------------------------------------
|
||||
## PANEL
|
||||
#---------------------------------------------
|
||||
panel_monitor = all
|
||||
panel_position = bottom center
|
||||
panel_size = 94% 30
|
||||
panel_margin = 0 0
|
||||
panel_padding = 7 0
|
||||
font_shadow = 0
|
||||
panel_background_id = 1
|
||||
wm_menu = 0
|
||||
panel_dock = 0
|
||||
panel_layer = bottom
|
||||
|
||||
#---------------------------------------------
|
||||
## TASKBAR
|
||||
#---------------------------------------------
|
||||
#taskbar_mode = multi_desktop
|
||||
taskbar_mode = single_desktop
|
||||
taskbar_padding = 2 3 2
|
||||
taskbar_background_id = 0
|
||||
#taskbar_active_background_id = 0
|
||||
|
||||
#---------------------------------------------
|
||||
## TASKS
|
||||
#---------------------------------------------
|
||||
task_icon = 1
|
||||
task_text = 1
|
||||
task_maximum_size = 140 35
|
||||
task_centered = 1
|
||||
task_padding = 6 3
|
||||
task_font = sans 7
|
||||
task_font_color = #ffffff 70
|
||||
task_background_id = 3
|
||||
task_icon_asb = 100 0 0
|
||||
## replace STATUS by 'urgent', 'active' or 'iconfied'
|
||||
#task_STATUS_background_id = 2
|
||||
#task_STATUS_font_color = #ffffff 85
|
||||
#task_STATUS_icon_asb = 100 0 0
|
||||
## example:
|
||||
task_active_background_id = 2
|
||||
task_active_font_color = #ffffff 85
|
||||
task_active_icon_asb = 100 0 0
|
||||
urgent_nb_of_blink = 8
|
||||
|
||||
#---------------------------------------------
|
||||
## SYSTRAYBAR
|
||||
#---------------------------------------------
|
||||
systray = 1
|
||||
systray_padding = 0 4 5
|
||||
systray_background_id = 0
|
||||
systray_sort = left2right
|
||||
systray_icon_size = 0
|
||||
systray_icon_asb = 100 0 0
|
||||
|
||||
#---------------------------------------------
|
||||
## CLOCK
|
||||
#---------------------------------------------
|
||||
time1_format = %H:%M
|
||||
time1_font = sans 8
|
||||
time2_format = %A %d %B
|
||||
time2_font = sans 6
|
||||
clock_font_color = #ffffff 76
|
||||
clock_padding = 1 0
|
||||
clock_background_id = 0
|
||||
#clock_lclick_command = xclock
|
||||
clock_rclick_command = orage
|
||||
#clock_tooltip = %A %d %B
|
||||
#time1_timezone = :US/Hawaii
|
||||
#time2_timezone = :Europe/Berlin
|
||||
#clock_tooltip_timezone = :/usr/share/zoneinfo/Europe/Paris
|
||||
|
||||
#---------------------------------------------
|
||||
## BATTERY
|
||||
#---------------------------------------------
|
||||
battery = 0
|
||||
battery_hide = 98
|
||||
battery_low_status = 10
|
||||
battery_low_cmd = notify-send "battery low"
|
||||
bat1_font = sans 8
|
||||
bat2_font = sans 6
|
||||
battery_font_color = #ffffff 76
|
||||
battery_padding = 1 0
|
||||
battery_background_id = 0
|
||||
|
||||
#---------------------------------------------
|
||||
## TOOLTIP
|
||||
#---------------------------------------------
|
||||
tooltip = 0
|
||||
tooltip_padding = 2 2
|
||||
tooltip_show_timeout = 0.7
|
||||
tooltip_hide_timeout = 0.3
|
||||
tooltip_background_id = 1
|
||||
tooltip_font_color = #OOOOOO 80
|
||||
tooltip_font = sans 10
|
||||
|
||||
#---------------------------------------------
|
||||
## MOUSE ACTION ON TASK
|
||||
#---------------------------------------------
|
||||
mouse_middle = none
|
||||
mouse_right = close
|
||||
mouse_scroll_up = toggle
|
||||
mouse_scroll_down = iconify
|
||||
|
||||
#---------------------------------------------
|
||||
## AUTOHIDE OPTIONS
|
||||
#---------------------------------------------
|
||||
autohide = 0
|
||||
autohide_show_timeout = 0.3
|
||||
autohide_hide_timeout = 2
|
||||
autohide_height = 4
|
||||
strut_policy = minimum
|
||||
```
|
||||
See /etc/xdg/tint2/tint2rc.
|
||||
|
||||
## AUTHOR
|
||||
tint2 was written by Thierry Lorthiois <lorthiois@bbsoft.fr>.
|
||||
|
||||
@@ -1,46 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
MAJOR=0.12
|
||||
MAJOR=0.14
|
||||
DIRTY=""
|
||||
|
||||
if git status 1>/dev/null 2>/dev/null
|
||||
then
|
||||
git update-index -q --ignore-submodules --refresh
|
||||
# Disallow unstaged changes in the working tree
|
||||
if ! git diff-files --quiet --ignore-submodules --
|
||||
then
|
||||
if [ "$1" = "--strict" ]
|
||||
then
|
||||
echo >&2 "Error: there are unstaged changes."
|
||||
git diff-files --name-status -r --ignore-submodules -- >&2
|
||||
exit 1
|
||||
else
|
||||
DIRTY="-dirty"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disallow uncommitted changes in the index
|
||||
if ! git diff-index --cached --quiet HEAD --ignore-submodules --
|
||||
then
|
||||
if [ "$1" = "--strict" ]
|
||||
then
|
||||
echo >&2 "Error: there are uncommitted changes."
|
||||
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
|
||||
exit 1
|
||||
else
|
||||
DIRTY="-dirty"
|
||||
fi
|
||||
fi
|
||||
VERSION=$(git describe --exact-match 2>/dev/null || echo "$MAJOR-git$(git show -s --pretty=format:%ci | cut -d ' ' -f 1 | tr -d '-').$(git show -s --pretty=format:%h)")$DIRTY
|
||||
else
|
||||
VERSION=$(head -n 1 ChangeLog | cut -d ' ' -f 2)
|
||||
if [ $VERSION = "master" ]
|
||||
then
|
||||
VERSION=$VERSION-$(head -n 1 ChangeLog | cut -d ' ' -f 1)
|
||||
fi
|
||||
fi
|
||||
|
||||
VERSION=$(echo "$VERSION" | sed 's/^v//')
|
||||
VERSION=0.14
|
||||
|
||||
echo '#define VERSION_STRING "'$VERSION'"' > version.h
|
||||
echo $VERSION
|
||||
|
||||
@@ -2,24 +2,6 @@
|
||||
|
||||
# Usage: ./make_release.sh
|
||||
# Creates a tar.gz archive of the current tree.
|
||||
#
|
||||
# To bump the version number for the current commit (make sure you are in HEAD!), run manually:
|
||||
#
|
||||
# git tag -a v0.12 -m 'Version 0.12'
|
||||
#
|
||||
# To generate a release for an older tagged commit, first list the tags with:
|
||||
#
|
||||
# git tag
|
||||
#
|
||||
# then checkout the tagged commit with:
|
||||
#
|
||||
# git checkout tags/v0.1
|
||||
#
|
||||
# Finally, to revert to HEAD:
|
||||
#
|
||||
# git checkout master
|
||||
#
|
||||
# See more at https://gitlab.com/o9000/tint2/wikis/Development
|
||||
|
||||
VERSION=$(./get_version.sh --strict)
|
||||
if [ ! $? -eq 0 ]
|
||||
@@ -28,21 +10,10 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR=tint2-$VERSION
|
||||
ARCHIVE=$DIR.tar.gz
|
||||
echo "Making release $DIR"
|
||||
rm -rf $DIR $ARCHIVE
|
||||
ARCHIVE=tint2-$VERSION.tar.gz
|
||||
|
||||
git checkout-index --prefix=$DIR/ -a
|
||||
|
||||
# Delete unneeded files
|
||||
rm -f $DIR/make_release.sh
|
||||
|
||||
echo "echo \"#define VERSION_STRING \\\"$VERSION\\\"\" > version.h" > $DIR/get_version.sh
|
||||
|
||||
# Create tarball and remove the exported directory
|
||||
tar -czf $ARCHIVE $DIR
|
||||
rm -rf $DIR
|
||||
echo "Making release tint2-$VERSION"
|
||||
git archive --format=tar.gz --prefix=tint2-$VERSION/ v$VERSION >$ARCHIVE
|
||||
|
||||
sha1sum -b $ARCHIVE
|
||||
sha256sum -b $ARCHIVE
|
||||
|
||||
@@ -56,8 +56,11 @@ char *battery_uwheel_command;
|
||||
char *battery_dwheel_command;
|
||||
gboolean battery_found;
|
||||
|
||||
char *battery_sys_prefix = (char*)"";
|
||||
|
||||
void battery_init_fonts();
|
||||
char *battery_get_tooltip(void *obj);
|
||||
int battery_compute_desired_size(void *obj);
|
||||
void battery_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_battery()
|
||||
@@ -155,6 +158,7 @@ void init_battery_panel(void *p)
|
||||
battery->area._draw_foreground = draw_battery;
|
||||
battery->area.size_mode = LAYOUT_FIXED;
|
||||
battery->area._resize = resize_battery;
|
||||
battery->area._compute_desired_size = battery_compute_desired_size;
|
||||
battery->area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
battery->area.on_screen = TRUE;
|
||||
battery->area.resize_needed = 1;
|
||||
@@ -164,6 +168,7 @@ void init_battery_panel(void *p)
|
||||
battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect;
|
||||
if (battery_tooltip_enabled)
|
||||
battery->area._get_tooltip_text = battery_get_tooltip;
|
||||
instantiate_area_gradients(&battery->area);
|
||||
}
|
||||
|
||||
void battery_init_fonts()
|
||||
@@ -197,7 +202,7 @@ void battery_default_font_changed()
|
||||
panels[i].battery.area.resize_needed = TRUE;
|
||||
schedule_redraw(&panels[i].battery.area);
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void update_battery_tick(void *arg)
|
||||
@@ -240,29 +245,19 @@ void update_battery_tick(void *arg)
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
// Show/hide if needed
|
||||
if (!battery_found) {
|
||||
if (panels[i].battery.area.on_screen) {
|
||||
hide(&panels[i].battery.area);
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
hide(&panels[i].battery.area);
|
||||
} else {
|
||||
if (battery_state.percentage >= percentage_hide) {
|
||||
if (panels[i].battery.area.on_screen) {
|
||||
hide(&panels[i].battery.area);
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (!panels[i].battery.area.on_screen) {
|
||||
show(&panels[i].battery.area);
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
}
|
||||
if (battery_state.percentage >= percentage_hide)
|
||||
hide(&panels[i].battery.area);
|
||||
else
|
||||
show(&panels[i].battery.area);
|
||||
}
|
||||
// Redraw if needed
|
||||
if (panels[i].battery.area.on_screen) {
|
||||
if (old_found != battery_found || old_percentage != battery_state.percentage ||
|
||||
old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) {
|
||||
panels[i].battery.area.resize_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,16 +281,61 @@ int update_battery()
|
||||
return err;
|
||||
}
|
||||
|
||||
int battery_compute_desired_size(void *obj)
|
||||
{
|
||||
Battery *battery = (Battery *)obj;
|
||||
Panel *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;
|
||||
|
||||
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);
|
||||
}
|
||||
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),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
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),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
|
||||
if (panel_horizontal) {
|
||||
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
|
||||
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
|
||||
return new_size;
|
||||
} else {
|
||||
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
|
||||
top_bottom_border_width(&battery->area);
|
||||
return new_size;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean resize_battery(void *obj)
|
||||
{
|
||||
Battery *battery = obj;
|
||||
Panel *panel = battery->area.panel;
|
||||
Battery *battery = (Battery *)obj;
|
||||
Panel *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;
|
||||
|
||||
schedule_redraw(&battery->area);
|
||||
|
||||
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
|
||||
if (battery_state.state == BATTERY_FULL) {
|
||||
strcpy(buf_bat_time, "Full");
|
||||
@@ -345,6 +385,8 @@ gboolean resize_battery(void *obj)
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
schedule_redraw(&battery->area);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ extern char *battery_rclick_command;
|
||||
extern char *battery_uwheel_command;
|
||||
extern char *battery_dwheel_command;
|
||||
|
||||
extern char *battery_sys_prefix;
|
||||
|
||||
static inline gchar *chargestate2str(ChargeState state)
|
||||
{
|
||||
switch (state) {
|
||||
|
||||
@@ -38,18 +38,16 @@ struct psy_battery {
|
||||
gint64 timestamp;
|
||||
/* sysfs files */
|
||||
gchar *path_present;
|
||||
gchar *path_energy_now;
|
||||
gchar *path_energy_full;
|
||||
gchar *path_power_now;
|
||||
gchar *path_level_now;
|
||||
gchar *path_level_full;
|
||||
gchar *path_rate_now;
|
||||
gchar *path_status;
|
||||
/* sysfs hints */
|
||||
gboolean energy_in_uamp;
|
||||
gboolean power_in_uamp;
|
||||
/* values */
|
||||
gboolean present;
|
||||
gint energy_now;
|
||||
gint energy_full;
|
||||
gint power_now;
|
||||
gint level_now;
|
||||
gint level_full;
|
||||
gint rate_now;
|
||||
gchar unit;
|
||||
ChargeState status;
|
||||
};
|
||||
|
||||
@@ -76,22 +74,23 @@ static void uevent_battery_plug()
|
||||
static struct uevent_notify psy_plug = {UEVENT_ADD | UEVENT_REMOVE, "power_supply", NULL, uevent_battery_plug};
|
||||
|
||||
#define RETURN_ON_ERROR(err) \
|
||||
if (error) { \
|
||||
if (err) { \
|
||||
g_error_free(err); \
|
||||
fprintf(stderr, RED "%s:%d: errror" RESET "\n", __FILE__, __LINE__); \
|
||||
return FALSE; \
|
||||
}
|
||||
|
||||
static GList *batteries = NULL;
|
||||
static GList *mains = NULL;
|
||||
|
||||
static guint8 energy_to_percent(gint energy_now, gint energy_full)
|
||||
static guint8 level_to_percent(gint level_now, gint level_full)
|
||||
{
|
||||
return 0.5 + ((energy_now <= energy_full ? energy_now : energy_full) * 100.0) / energy_full;
|
||||
return 0.5 + ((level_now <= level_full ? level_now : level_full) * 100.0) / level_full;
|
||||
}
|
||||
|
||||
static enum psy_type power_supply_get_type(const gchar *entryname)
|
||||
{
|
||||
gchar *path_type = g_build_filename("/sys/class/power_supply", entryname, "type", NULL);
|
||||
gchar *path_type = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "type", NULL);
|
||||
GError *error = NULL;
|
||||
gchar *type;
|
||||
gsize typelen;
|
||||
@@ -99,6 +98,7 @@ static enum psy_type power_supply_get_type(const gchar *entryname)
|
||||
g_file_get_contents(path_type, &type, &typelen, &error);
|
||||
g_free(path_type);
|
||||
if (error) {
|
||||
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||
g_error_free(error);
|
||||
return PSY_UNKNOWN;
|
||||
}
|
||||
@@ -122,59 +122,53 @@ static gboolean init_linux_battery(struct psy_battery *bat)
|
||||
{
|
||||
const gchar *entryname = bat->name;
|
||||
|
||||
bat->energy_in_uamp = FALSE;
|
||||
bat->power_in_uamp = FALSE;
|
||||
|
||||
bat->path_present = g_build_filename("/sys/class/power_supply", entryname, "present", NULL);
|
||||
bat->path_present = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "present", NULL);
|
||||
if (!g_file_test(bat->path_present, G_FILE_TEST_EXISTS)) {
|
||||
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||
goto err0;
|
||||
}
|
||||
|
||||
bat->path_energy_now = g_build_filename("/sys/class/power_supply", entryname, "energy_now", NULL);
|
||||
if (!g_file_test(bat->path_energy_now, G_FILE_TEST_EXISTS)) {
|
||||
g_free(bat->path_energy_now);
|
||||
bat->path_energy_now = g_build_filename("/sys/class/power_supply", entryname, "charge_now", NULL);
|
||||
bat->energy_in_uamp = TRUE;
|
||||
bat->path_level_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_now", NULL);
|
||||
bat->path_level_full =
|
||||
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "energy_full", NULL);
|
||||
bat->path_rate_now = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "power_now", NULL);
|
||||
bat->unit = 'W';
|
||||
|
||||
if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) ||
|
||||
!g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) ||
|
||||
!g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) {
|
||||
g_free(bat->path_level_now);
|
||||
g_free(bat->path_level_full);
|
||||
g_free(bat->path_rate_now);
|
||||
bat->path_level_now =
|
||||
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_now", NULL);
|
||||
bat->path_level_full =
|
||||
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "charge_full", NULL);
|
||||
bat->path_rate_now =
|
||||
g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "current_now", NULL);
|
||||
bat->unit = 'A';
|
||||
}
|
||||
if (!g_file_test(bat->path_energy_now, G_FILE_TEST_EXISTS)) {
|
||||
if (!g_file_test(bat->path_level_now, G_FILE_TEST_EXISTS) ||
|
||||
!g_file_test(bat->path_level_full, G_FILE_TEST_EXISTS) ||
|
||||
!g_file_test(bat->path_rate_now, G_FILE_TEST_EXISTS)) {
|
||||
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||
goto err1;
|
||||
}
|
||||
|
||||
if (!bat->energy_in_uamp) {
|
||||
bat->path_energy_full = g_build_filename("/sys/class/power_supply", entryname, "energy_full", NULL);
|
||||
if (!g_file_test(bat->path_energy_full, G_FILE_TEST_EXISTS))
|
||||
goto err2;
|
||||
} else {
|
||||
bat->path_energy_full = g_build_filename("/sys/class/power_supply", entryname, "charge_full", NULL);
|
||||
if (!g_file_test(bat->path_energy_full, G_FILE_TEST_EXISTS))
|
||||
goto err2;
|
||||
}
|
||||
|
||||
bat->path_power_now = g_build_filename("/sys/class/power_supply", entryname, "power_now", NULL);
|
||||
if (!g_file_test(bat->path_power_now, G_FILE_TEST_EXISTS)) {
|
||||
g_free(bat->path_power_now);
|
||||
bat->path_power_now = g_build_filename("/sys/class/power_supply", entryname, "current_now", NULL);
|
||||
bat->power_in_uamp = TRUE;
|
||||
}
|
||||
if (!g_file_test(bat->path_power_now, G_FILE_TEST_EXISTS)) {
|
||||
goto err3;
|
||||
}
|
||||
|
||||
bat->path_status = g_build_filename("/sys/class/power_supply", entryname, "status", NULL);
|
||||
bat->path_status = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "status", NULL);
|
||||
if (!g_file_test(bat->path_status, G_FILE_TEST_EXISTS)) {
|
||||
goto err4;
|
||||
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||
goto err2;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
err4:
|
||||
g_free(bat->path_status);
|
||||
err3:
|
||||
g_free(bat->path_power_now);
|
||||
err2:
|
||||
g_free(bat->path_energy_full);
|
||||
g_free(bat->path_status);
|
||||
err1:
|
||||
g_free(bat->path_energy_now);
|
||||
g_free(bat->path_level_now);
|
||||
g_free(bat->path_level_full);
|
||||
g_free(bat->path_rate_now);
|
||||
err0:
|
||||
g_free(bat->path_present);
|
||||
|
||||
@@ -185,8 +179,9 @@ static gboolean init_linux_mains(struct psy_mains *ac)
|
||||
{
|
||||
const gchar *entryname = ac->name;
|
||||
|
||||
ac->path_online = g_build_filename("/sys/class/power_supply", entryname, "online", NULL);
|
||||
ac->path_online = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", entryname, "online", NULL);
|
||||
if (!g_file_test(ac->path_online, G_FILE_TEST_EXISTS)) {
|
||||
fprintf(stderr, RED "%s:%d: read failed" RESET "\n", __FILE__, __LINE__);
|
||||
g_free(ac->path_online);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -199,9 +194,9 @@ static void psy_battery_free(gpointer data)
|
||||
struct psy_battery *bat = data;
|
||||
g_free(bat->name);
|
||||
g_free(bat->path_status);
|
||||
g_free(bat->path_power_now);
|
||||
g_free(bat->path_energy_full);
|
||||
g_free(bat->path_energy_now);
|
||||
g_free(bat->path_rate_now);
|
||||
g_free(bat->path_level_full);
|
||||
g_free(bat->path_level_now);
|
||||
g_free(bat->path_present);
|
||||
g_free(bat);
|
||||
}
|
||||
@@ -232,10 +227,10 @@ static void add_battery(const char *entryname)
|
||||
|
||||
if (init_linux_battery(bat)) {
|
||||
batteries = g_list_append(batteries, bat);
|
||||
fprintf(stdout, "found battery \"%s\"\n", bat->name);
|
||||
fprintf(stdout, GREEN "Found battery \"%s\"" RESET "\n", bat->name);
|
||||
} else {
|
||||
g_free(bat);
|
||||
fprintf(stderr, RED "failed to initialize battery \"%s\"" RESET "\n", entryname);
|
||||
fprintf(stderr, RED "Failed to initialize battery \"%s\"" RESET "\n", entryname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,10 +241,10 @@ static void add_mains(const char *entryname)
|
||||
|
||||
if (init_linux_mains(ac)) {
|
||||
mains = g_list_append(mains, ac);
|
||||
fprintf(stdout, "found mains \"%s\"\n", ac->name);
|
||||
fprintf(stdout, GREEN "Found mains \"%s\"" RESET "\n", ac->name);
|
||||
} else {
|
||||
g_free(ac);
|
||||
fprintf(stderr, RED "failed to initialize mains \"%s\"" RESET "\n", entryname);
|
||||
fprintf(stderr, RED "Failed to initialize mains \"%s\"" RESET "\n", entryname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,10 +256,13 @@ gboolean battery_os_init()
|
||||
|
||||
battery_os_free();
|
||||
|
||||
directory = g_dir_open("/sys/class/power_supply", 0, &error);
|
||||
gchar *dir_path = g_build_filename(battery_sys_prefix, "/sys/class/power_supply", NULL);
|
||||
directory = g_dir_open(dir_path, 0, &error);
|
||||
g_free(dir_path);
|
||||
RETURN_ON_ERROR(error);
|
||||
|
||||
while ((entryname = g_dir_read_name(directory))) {
|
||||
fprintf(stderr, GREEN "Found power device %s" RESET "\n", entryname);
|
||||
enum psy_type type = power_supply_get_type(entryname);
|
||||
|
||||
switch (type) {
|
||||
@@ -287,15 +285,15 @@ gboolean battery_os_init()
|
||||
return batteries != NULL;
|
||||
}
|
||||
|
||||
static gint estimate_power_usage(struct psy_battery *bat, gint old_energy_now, gint64 old_timestamp)
|
||||
static gint estimate_rate_usage(struct psy_battery *bat, gint old_level_now, gint64 old_timestamp)
|
||||
{
|
||||
gint64 diff_power = ABS(bat->energy_now - old_energy_now);
|
||||
gint64 diff_level = ABS(bat->level_now - old_level_now);
|
||||
gint64 diff_time = bat->timestamp - old_timestamp;
|
||||
|
||||
/* µW = (µWh * 3600) / (µs / 1000000) */
|
||||
gint power = diff_power * 3600 * 1000000 / MAX(1, diff_time);
|
||||
gint rate = diff_level * 3600 * 1000000 / MAX(1, diff_time);
|
||||
|
||||
return power;
|
||||
return rate;
|
||||
}
|
||||
|
||||
static gboolean update_linux_battery(struct psy_battery *bat)
|
||||
@@ -305,15 +303,15 @@ static gboolean update_linux_battery(struct psy_battery *bat)
|
||||
gsize datalen;
|
||||
|
||||
gint64 old_timestamp = bat->timestamp;
|
||||
int old_energy_now = bat->energy_now;
|
||||
gint old_power_now = bat->power_now;
|
||||
int old_level_now = bat->level_now;
|
||||
gint old_rate_now = bat->rate_now;
|
||||
|
||||
/* reset values */
|
||||
bat->present = 0;
|
||||
bat->status = BATTERY_UNKNOWN;
|
||||
bat->energy_now = 0;
|
||||
bat->energy_full = 0;
|
||||
bat->power_now = 0;
|
||||
bat->level_now = 0;
|
||||
bat->level_full = 0;
|
||||
bat->rate_now = 0;
|
||||
bat->timestamp = g_get_monotonic_time();
|
||||
|
||||
/* present */
|
||||
@@ -339,35 +337,35 @@ static gboolean update_linux_battery(struct psy_battery *bat)
|
||||
}
|
||||
g_free(data);
|
||||
|
||||
/* energy now */
|
||||
g_file_get_contents(bat->path_energy_now, &data, &datalen, &error);
|
||||
/* level now */
|
||||
g_file_get_contents(bat->path_level_now, &data, &datalen, &error);
|
||||
RETURN_ON_ERROR(error);
|
||||
bat->energy_now = atoi(data);
|
||||
bat->level_now = atoi(data);
|
||||
g_free(data);
|
||||
|
||||
/* energy full */
|
||||
g_file_get_contents(bat->path_energy_full, &data, &datalen, &error);
|
||||
/* level full */
|
||||
g_file_get_contents(bat->path_level_full, &data, &datalen, &error);
|
||||
RETURN_ON_ERROR(error);
|
||||
bat->energy_full = atoi(data);
|
||||
bat->level_full = atoi(data);
|
||||
g_free(data);
|
||||
|
||||
/* power now */
|
||||
g_file_get_contents(bat->path_power_now, &data, &datalen, &error);
|
||||
/* rate now */
|
||||
g_file_get_contents(bat->path_rate_now, &data, &datalen, &error);
|
||||
if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NODEV)) {
|
||||
/* some hardware does not support reading current power consumption */
|
||||
/* some hardware does not support reading current rate consumption */
|
||||
g_error_free(error);
|
||||
bat->power_now = estimate_power_usage(bat, old_energy_now, old_timestamp);
|
||||
if (bat->power_now == 0 && bat->status != BATTERY_FULL) {
|
||||
bat->rate_now = estimate_rate_usage(bat, old_level_now, old_timestamp);
|
||||
if (bat->rate_now == 0 && bat->status != BATTERY_FULL) {
|
||||
/* If the hardware updates the level slower than our sampling period,
|
||||
* we need to sample more rarely */
|
||||
bat->power_now = old_power_now;
|
||||
bat->rate_now = old_rate_now;
|
||||
bat->timestamp = old_timestamp;
|
||||
}
|
||||
} else if (error) {
|
||||
g_error_free(error);
|
||||
return FALSE;
|
||||
} else {
|
||||
bat->power_now = atoi(data);
|
||||
bat->rate_now = atoi(data);
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
@@ -394,9 +392,9 @@ int battery_os_update(BatteryState *state)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
gint64 total_energy_now = 0;
|
||||
gint64 total_energy_full = 0;
|
||||
gint64 total_power_now = 0;
|
||||
gint64 total_level_now = 0;
|
||||
gint64 total_level_full = 0;
|
||||
gint64 total_rate_now = 0;
|
||||
gint seconds = 0;
|
||||
|
||||
gboolean charging = FALSE;
|
||||
@@ -408,9 +406,9 @@ int battery_os_update(BatteryState *state)
|
||||
struct psy_battery *bat = l->data;
|
||||
update_linux_battery(bat);
|
||||
|
||||
total_energy_now += bat->energy_now;
|
||||
total_energy_full += bat->energy_full;
|
||||
total_power_now += bat->power_now;
|
||||
total_level_now += bat->level_now;
|
||||
total_level_full += bat->level_full;
|
||||
total_rate_now += bat->rate_now;
|
||||
|
||||
charging |= (bat->status == BATTERY_CHARGING);
|
||||
discharging |= (bat->status == BATTERY_DISCHARGING);
|
||||
@@ -432,17 +430,17 @@ int battery_os_update(BatteryState *state)
|
||||
state->state = BATTERY_FULL;
|
||||
|
||||
/* calculate seconds */
|
||||
if (total_power_now > 0) {
|
||||
if (total_rate_now > 0) {
|
||||
if (state->state == BATTERY_CHARGING)
|
||||
seconds = 3600 * (total_energy_full - total_energy_now) / total_power_now;
|
||||
seconds = 3600 * (total_level_full - total_level_now) / total_rate_now;
|
||||
else if (state->state == BATTERY_DISCHARGING)
|
||||
seconds = 3600 * total_energy_now / total_power_now;
|
||||
seconds = 3600 * total_level_now / total_rate_now;
|
||||
seconds = MAX(0, seconds);
|
||||
}
|
||||
battery_state_set_time(state, seconds);
|
||||
|
||||
/* calculate percentage */
|
||||
state->percentage = energy_to_percent(total_energy_now, total_energy_full);
|
||||
state->percentage = level_to_percent(total_level_now, total_level_full);
|
||||
|
||||
/* AC state */
|
||||
state->ac_connected = ac_connected;
|
||||
@@ -450,42 +448,41 @@ int battery_os_update(BatteryState *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gchar *energy_human_readable(struct psy_battery *bat)
|
||||
static gchar *level_human_readable(struct psy_battery *bat)
|
||||
{
|
||||
gint now = bat->energy_now;
|
||||
gint full = bat->energy_full;
|
||||
gchar unit = bat->energy_in_uamp ? 'A' : 'W';
|
||||
gint now = bat->level_now;
|
||||
gint full = bat->level_full;
|
||||
|
||||
if (full >= 1000000) {
|
||||
return g_strdup_printf("%d.%d / %d.%d %ch",
|
||||
now / 1000000,
|
||||
(now % 1000000) / 100000,
|
||||
full / 1000000,
|
||||
(full % 1000000) / 100000,
|
||||
unit);
|
||||
now / 1000000,
|
||||
(now % 1000000) / 100000,
|
||||
full / 1000000,
|
||||
(full % 1000000) / 100000,
|
||||
bat->unit);
|
||||
} else if (full >= 1000) {
|
||||
return g_strdup_printf("%d.%d / %d.%d m%ch",
|
||||
now / 1000,
|
||||
(now % 1000) / 100,
|
||||
full / 1000,
|
||||
(full % 1000) / 100,
|
||||
unit);
|
||||
now / 1000,
|
||||
(now % 1000) / 100,
|
||||
full / 1000,
|
||||
(full % 1000) / 100,
|
||||
bat->unit);
|
||||
} else {
|
||||
return g_strdup_printf("%d / %d µ%ch", now, full, unit);
|
||||
return g_strdup_printf("%d / %d µ%ch", now, full, bat->unit);
|
||||
}
|
||||
}
|
||||
|
||||
static gchar *power_human_readable(struct psy_battery *bat)
|
||||
static gchar *rate_human_readable(struct psy_battery *bat)
|
||||
{
|
||||
gint power = bat->power_now;
|
||||
gchar unit = bat->power_in_uamp ? 'A' : 'W';
|
||||
gint rate = bat->rate_now;
|
||||
gchar unit = bat->unit;
|
||||
|
||||
if (power >= 1000000) {
|
||||
return g_strdup_printf("%d.%d %c", power / 1000000, (power % 1000000) / 100000, unit);
|
||||
} else if (power >= 1000) {
|
||||
return g_strdup_printf("%d.%d m%c", power / 1000, (power % 1000) / 100, unit);
|
||||
} else if (power > 0) {
|
||||
return g_strdup_printf("%d µ%c", power, unit);
|
||||
if (rate >= 1000000) {
|
||||
return g_strdup_printf("%d.%d %c", rate / 1000000, (rate % 1000000) / 100000, unit);
|
||||
} else if (rate >= 1000) {
|
||||
return g_strdup_printf("%d.%d m%c", rate / 1000, (rate % 1000) / 100, unit);
|
||||
} else if (rate > 0) {
|
||||
return g_strdup_printf("%d µ%c", rate, unit);
|
||||
} else {
|
||||
return g_strdup_printf("0 %c", unit);
|
||||
}
|
||||
@@ -510,16 +507,16 @@ char *battery_os_tooltip()
|
||||
continue;
|
||||
}
|
||||
|
||||
gchar *power = power_human_readable(bat);
|
||||
gchar *energy = energy_human_readable(bat);
|
||||
gchar *state = (bat->status == BATTERY_UNKNOWN) ? "Level" : chargestate2str(bat->status);
|
||||
gchar *rate = rate_human_readable(bat);
|
||||
gchar *level = level_human_readable(bat);
|
||||
gchar *state = (bat->status == BATTERY_UNKNOWN) ? "energy" : chargestate2str(bat->status);
|
||||
|
||||
guint8 percentage = energy_to_percent(bat->energy_now, bat->energy_full);
|
||||
guint8 percentage = level_to_percent(bat->level_now, bat->level_full);
|
||||
|
||||
g_string_append_printf(tooltip, "\t%s: %s (%u %%)\n\tPower: %s", state, energy, percentage, power);
|
||||
g_string_append_printf(tooltip, "\t%s: %s (%u %%)\n\trate: %s", state, level, percentage, rate);
|
||||
|
||||
g_free(power);
|
||||
g_free(energy);
|
||||
g_free(rate);
|
||||
g_free(level);
|
||||
}
|
||||
|
||||
for (l = mains; l != NULL; l = l->next) {
|
||||
|
||||
568
src/button/button.c
Normal file
568
src/button/button.c
Normal file
@@ -0,0 +1,568 @@
|
||||
#include "button.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <cairo.h>
|
||||
#include <cairo-xlib.h>
|
||||
#include <math.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "window.h"
|
||||
#include "server.h"
|
||||
#include "panel.h"
|
||||
#include "timer.h"
|
||||
#include "common.h"
|
||||
|
||||
char *button_get_tooltip(void *obj);
|
||||
void button_init_fonts();
|
||||
int button_compute_desired_size(void *obj);
|
||||
void button_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_button()
|
||||
{
|
||||
}
|
||||
|
||||
Button *create_button()
|
||||
{
|
||||
Button *button = calloc(1, sizeof(Button));
|
||||
button->backend = calloc(1, sizeof(ButtonBackend));
|
||||
button->backend->centered = TRUE;
|
||||
button->backend->font_color.alpha = 0.5;
|
||||
return button;
|
||||
}
|
||||
|
||||
gpointer create_button_frontend(gconstpointer arg, gpointer data)
|
||||
{
|
||||
Button *button_backend = (Button *)arg;
|
||||
|
||||
Button *button_frontend = calloc(1, sizeof(Button));
|
||||
button_frontend->backend = button_backend->backend;
|
||||
button_backend->backend->instances = g_list_append(button_backend->backend->instances, button_frontend);
|
||||
button_frontend->frontend = calloc(1, sizeof(ButtonFrontend));
|
||||
return button_frontend;
|
||||
}
|
||||
|
||||
void destroy_button(void *obj)
|
||||
{
|
||||
Button *button = (Button *)obj;
|
||||
if (button->frontend) {
|
||||
// This is a frontend element
|
||||
if (button->frontend->icon) {
|
||||
imlib_context_set_image(button->frontend->icon);
|
||||
imlib_free_image();
|
||||
button->frontend->icon = NULL;
|
||||
}
|
||||
button->backend->instances = g_list_remove_all(button->backend->instances, button);
|
||||
free_and_null(button->frontend);
|
||||
remove_area(&button->area);
|
||||
free_area(&button->area);
|
||||
free_and_null(button);
|
||||
} else {
|
||||
// This is a backend element
|
||||
free_and_null(button->backend->text);
|
||||
free_and_null(button->backend->icon_name);
|
||||
free_and_null(button->backend->tooltip);
|
||||
|
||||
button->backend->bg = NULL;
|
||||
pango_font_description_free(button->backend->font_desc);
|
||||
button->backend->font_desc = NULL;
|
||||
free_and_null(button->backend->lclick_command);
|
||||
free_and_null(button->backend->mclick_command);
|
||||
free_and_null(button->backend->rclick_command);
|
||||
free_and_null(button->backend->dwheel_command);
|
||||
free_and_null(button->backend->uwheel_command);
|
||||
|
||||
if (button->backend->instances) {
|
||||
fprintf(stderr, "Error: Attempt to destroy backend while there are still frontend instances!\n");
|
||||
exit(-1);
|
||||
}
|
||||
free(button->backend);
|
||||
free(button);
|
||||
}
|
||||
}
|
||||
|
||||
void init_button()
|
||||
{
|
||||
GList *to_remove = panel_config.button_list;
|
||||
for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) {
|
||||
if (panel_items_order[k] == 'P') {
|
||||
to_remove = to_remove->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_remove) {
|
||||
if (to_remove == panel_config.button_list) {
|
||||
g_list_free_full(to_remove, destroy_button);
|
||||
panel_config.button_list = NULL;
|
||||
} else {
|
||||
// Cut panel_config.button_list
|
||||
if (to_remove->prev)
|
||||
to_remove->prev->next = NULL;
|
||||
to_remove->prev = NULL;
|
||||
// Remove all elements of to_remove and to_remove itself
|
||||
g_list_free_full(to_remove, destroy_button);
|
||||
}
|
||||
}
|
||||
|
||||
button_init_fonts();
|
||||
for (GList *l = panel_config.button_list; l; l = l->next) {
|
||||
Button *button = l->data;
|
||||
|
||||
// Set missing config options
|
||||
if (!button->backend->bg)
|
||||
button->backend->bg = &g_array_index(backgrounds, Background, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void init_button_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
|
||||
// Make sure this is only done once if there are multiple items
|
||||
if (panel->button_list && ((Button *)panel->button_list->data)->frontend)
|
||||
return;
|
||||
|
||||
// panel->button_list is now a copy of the pointer panel_config.button_list
|
||||
// We make it a deep copy
|
||||
panel->button_list = g_list_copy_deep(panel_config.button_list, create_button_frontend, NULL);
|
||||
|
||||
load_icon_themes();
|
||||
|
||||
for (GList *l = panel->button_list; l; l = l->next) {
|
||||
Button *button = l->data;
|
||||
button->area.bg = button->backend->bg;
|
||||
button->area.paddingx = button->backend->paddingx;
|
||||
button->area.paddingy = button->backend->paddingy;
|
||||
button->area.paddingxlr = button->backend->paddingxlr;
|
||||
button->area.parent = panel;
|
||||
button->area.panel = panel;
|
||||
button->area._dump_geometry = button_dump_geometry;
|
||||
button->area._compute_desired_size = button_compute_desired_size;
|
||||
snprintf(button->area.name, sizeof(button->area.name), "Button");
|
||||
button->area._draw_foreground = draw_button;
|
||||
button->area.size_mode = LAYOUT_FIXED;
|
||||
button->area._resize = resize_button;
|
||||
button->area._get_tooltip_text = button_get_tooltip;
|
||||
button->area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
button->area.has_mouse_press_effect =
|
||||
panel_config.mouse_effects &&
|
||||
(button->area.has_mouse_over_effect = button->backend->lclick_command || button->backend->mclick_command ||
|
||||
button->backend->rclick_command || button->backend->uwheel_command ||
|
||||
button->backend->dwheel_command);
|
||||
|
||||
button->area.resize_needed = TRUE;
|
||||
button->area.on_screen = TRUE;
|
||||
instantiate_area_gradients(&button->area);
|
||||
|
||||
button_reload_icon(button);
|
||||
}
|
||||
}
|
||||
|
||||
void button_init_fonts()
|
||||
{
|
||||
for (GList *l = panel_config.button_list; l; l = l->next) {
|
||||
Button *button = l->data;
|
||||
if (!button->backend->font_desc)
|
||||
button->backend->font_desc = pango_font_description_from_string(get_default_font());
|
||||
}
|
||||
}
|
||||
|
||||
void button_default_font_changed()
|
||||
{
|
||||
gboolean needs_update = FALSE;
|
||||
for (GList *l = panel_config.button_list; l; l = l->next) {
|
||||
Button *button = l->data;
|
||||
|
||||
if (!button->backend->has_font) {
|
||||
pango_font_description_free(button->backend->font_desc);
|
||||
button->backend->font_desc = NULL;
|
||||
needs_update = TRUE;
|
||||
}
|
||||
}
|
||||
if (!needs_update)
|
||||
return;
|
||||
|
||||
button_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
for (GList *l = panels[i].button_list; l; l = l->next) {
|
||||
Button *button = l->data;
|
||||
|
||||
if (!button->backend->has_font) {
|
||||
button->area.resize_needed = TRUE;
|
||||
schedule_redraw(&button->area);
|
||||
}
|
||||
}
|
||||
}
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void button_reload_icon(Button *button)
|
||||
{
|
||||
free_icon(button->frontend->icon);
|
||||
free_icon(button->frontend->icon_hover);
|
||||
free_icon(button->frontend->icon_pressed);
|
||||
button->frontend->icon = NULL;
|
||||
button->frontend->icon_hover = NULL;
|
||||
button->frontend->icon_pressed = NULL;
|
||||
|
||||
button->frontend->icon_load_size = button->frontend->iconw;
|
||||
|
||||
if (!button->backend->icon_name)
|
||||
return;
|
||||
|
||||
char *new_icon_path = get_icon_path(icon_theme_wrapper, button->backend->icon_name, button->frontend->iconw, TRUE);
|
||||
if (new_icon_path)
|
||||
button->frontend->icon = load_image(new_icon_path, TRUE);
|
||||
free(new_icon_path);
|
||||
// On loading error, fallback to default
|
||||
if (!button->frontend->icon) {
|
||||
new_icon_path = get_icon_path(icon_theme_wrapper, DEFAULT_ICON, button->frontend->iconw, TRUE);
|
||||
if (new_icon_path)
|
||||
button->frontend->icon = load_image(new_icon_path, TRUE);
|
||||
free(new_icon_path);
|
||||
}
|
||||
Imlib_Image original = button->frontend->icon;
|
||||
button->frontend->icon = scale_icon(button->frontend->icon, button->frontend->iconw);
|
||||
free_icon(original);
|
||||
|
||||
if (panel_config.mouse_effects) {
|
||||
button->frontend->icon_hover = adjust_icon(button->frontend->icon,
|
||||
panel_config.mouse_over_alpha,
|
||||
panel_config.mouse_over_saturation,
|
||||
panel_config.mouse_over_brightness);
|
||||
button->frontend->icon_pressed = adjust_icon(button->frontend->icon,
|
||||
panel_config.mouse_pressed_alpha,
|
||||
panel_config.mouse_pressed_saturation,
|
||||
panel_config.mouse_pressed_brightness);
|
||||
}
|
||||
schedule_redraw(&button->area);
|
||||
}
|
||||
|
||||
void button_default_icon_theme_changed()
|
||||
{
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
for (GList *l = panels[i].button_list; l; l = l->next) {
|
||||
Button *button = l->data;
|
||||
button_reload_icon(button);
|
||||
}
|
||||
}
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void cleanup_button()
|
||||
{
|
||||
// Cleanup frontends
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
g_list_free_full(panels[i].button_list, destroy_button);
|
||||
panels[i].button_list = NULL;
|
||||
}
|
||||
|
||||
// Cleanup backends
|
||||
g_list_free_full(panel_config.button_list, destroy_button);
|
||||
panel_config.button_list = NULL;
|
||||
}
|
||||
|
||||
int button_compute_desired_size(void *obj)
|
||||
{
|
||||
Button *button = (Button *)obj;
|
||||
Panel *panel = (Panel *)button->area.panel;
|
||||
int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy);
|
||||
int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr);
|
||||
int interior_padding = button->area.paddingx;
|
||||
|
||||
int icon_w, icon_h;
|
||||
if (button->backend->icon_name) {
|
||||
if (panel_horizontal)
|
||||
icon_h = icon_w = button->area.height - top_bottom_border_width(&button->area) - 2 * vert_padding;
|
||||
else
|
||||
icon_h = icon_w = button->area.width - left_right_border_width(&button->area) - 2 * horiz_padding;
|
||||
if (button->backend->max_icon_size) {
|
||||
icon_w = MIN(icon_w, button->backend->max_icon_size);
|
||||
icon_h = MIN(icon_h, button->backend->max_icon_size);
|
||||
}
|
||||
} else {
|
||||
icon_h = icon_w = 0;
|
||||
}
|
||||
|
||||
int txt_height_ink, txt_height, txt_width;
|
||||
if (button->backend->text) {
|
||||
if (panel_horizontal) {
|
||||
get_text_size2(button->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
button->backend->text,
|
||||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
} else {
|
||||
get_text_size2(button->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
button->area.width - icon_w - (icon_w ? interior_padding : 0) -
|
||||
2 * horiz_padding - left_right_border_width(&button->area),
|
||||
button->backend->text,
|
||||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
}
|
||||
} else {
|
||||
txt_height_ink = txt_height = txt_width = 0;
|
||||
}
|
||||
|
||||
if (panel_horizontal) {
|
||||
int new_size = txt_width + icon_w + (txt_width && icon_w ? interior_padding : 0);
|
||||
new_size += 2 * horiz_padding + left_right_border_width(&button->area);
|
||||
return new_size;
|
||||
} else {
|
||||
int new_size;
|
||||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&button->area);
|
||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&button->area));
|
||||
return new_size;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean resize_button(void *obj)
|
||||
{
|
||||
Button *button = (Button *)obj;
|
||||
Panel *panel = (Panel *)button->area.panel;
|
||||
int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy);
|
||||
int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr);
|
||||
int interior_padding = button->area.paddingx;
|
||||
|
||||
int icon_w, icon_h;
|
||||
if (button->backend->icon_name) {
|
||||
if (panel_horizontal)
|
||||
icon_h = icon_w = button->area.height - top_bottom_border_width(&button->area) - 2 * vert_padding;
|
||||
else
|
||||
icon_h = icon_w = button->area.width - left_right_border_width(&button->area) - 2 * horiz_padding;
|
||||
if (button->backend->max_icon_size) {
|
||||
icon_w = MIN(icon_w, button->backend->max_icon_size);
|
||||
icon_h = MIN(icon_h, button->backend->max_icon_size);
|
||||
}
|
||||
} else {
|
||||
icon_h = icon_w = 0;
|
||||
}
|
||||
|
||||
button->frontend->iconw = icon_w;
|
||||
button->frontend->iconh = icon_h;
|
||||
if (button->frontend->icon_load_size != button->frontend->iconw)
|
||||
button_reload_icon(button);
|
||||
|
||||
int txt_height_ink, txt_height, txt_width;
|
||||
if (button->backend->text) {
|
||||
if (panel_horizontal) {
|
||||
get_text_size2(button->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
button->backend->text,
|
||||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
} else {
|
||||
get_text_size2(button->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
button->area.width - icon_w - (icon_w ? interior_padding : 0) -
|
||||
2 * horiz_padding - left_right_border_width(&button->area),
|
||||
button->backend->text,
|
||||
strlen(button->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
}
|
||||
} else {
|
||||
txt_height_ink = txt_height = txt_width = 0;
|
||||
}
|
||||
|
||||
gboolean result = FALSE;
|
||||
if (panel_horizontal) {
|
||||
int new_size = txt_width + icon_w + (txt_width && icon_w ? interior_padding : 0);
|
||||
new_size += 2 * horiz_padding + left_right_border_width(&button->area);
|
||||
if (new_size != button->area.width) {
|
||||
button->area.width = new_size;
|
||||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
int new_size;
|
||||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&button->area);
|
||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&button->area));
|
||||
if (new_size != button->area.height) {
|
||||
button->area.height = new_size;
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
button->frontend->textw = txt_width;
|
||||
button->frontend->texth = txt_height;
|
||||
if (button->backend->centered) {
|
||||
if (icon_w) {
|
||||
button->frontend->icony = (button->area.height - icon_h) / 2;
|
||||
button->frontend->iconx = (button->area.width - txt_width - (txt_width ? interior_padding : 0) - icon_w) / 2;
|
||||
button->frontend->texty = (button->area.height - txt_height) / 2;
|
||||
button->frontend->textx = button->frontend->iconx + icon_w + interior_padding;
|
||||
} else {
|
||||
button->frontend->texty = (button->area.height - txt_height) / 2;
|
||||
button->frontend->textx = (button->area.width - txt_width) / 2;
|
||||
}
|
||||
} else {
|
||||
if (icon_w) {
|
||||
button->frontend->icony = (button->area.height - icon_h) / 2;
|
||||
button->frontend->iconx = left_border_width(&button->area) + horiz_padding;
|
||||
button->frontend->texty = (button->area.height - txt_height) / 2;
|
||||
button->frontend->textx = button->frontend->iconx + icon_w + interior_padding;
|
||||
} else {
|
||||
button->frontend->texty = (button->area.height - txt_height) / 2;
|
||||
button->frontend->textx = left_border_width(&button->area) + horiz_padding;
|
||||
}
|
||||
}
|
||||
|
||||
schedule_redraw(&button->area);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void draw_button(void *obj, cairo_t *c)
|
||||
{
|
||||
Button *button = obj;
|
||||
|
||||
if (button->frontend->icon) {
|
||||
// Render icon
|
||||
Imlib_Image image;
|
||||
if (panel_config.mouse_effects) {
|
||||
if (button->area.mouse_state == MOUSE_OVER)
|
||||
image = button->frontend->icon_hover ? button->frontend->icon_hover : button->frontend->icon;
|
||||
else if (button->area.mouse_state == MOUSE_DOWN)
|
||||
image = button->frontend->icon_pressed ? button->frontend->icon_pressed : button->frontend->icon;
|
||||
else
|
||||
image = button->frontend->icon;
|
||||
} else {
|
||||
image = button->frontend->icon;
|
||||
}
|
||||
|
||||
imlib_context_set_image(image);
|
||||
render_image(button->area.pix, button->frontend->iconx, button->frontend->icony);
|
||||
}
|
||||
|
||||
// Render text
|
||||
if (button->backend->text) {
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
|
||||
pango_layout_set_font_description(layout, button->backend->font_desc);
|
||||
pango_layout_set_width(layout, button->frontend->textw * PANGO_SCALE);
|
||||
pango_layout_set_alignment(layout, button->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT);
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
||||
pango_layout_set_text(layout, button->backend->text, strlen(button->backend->text));
|
||||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout,
|
||||
c,
|
||||
button->frontend->textx,
|
||||
button->frontend->texty,
|
||||
&button->backend->font_color,
|
||||
panel_config.font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
}
|
||||
}
|
||||
|
||||
void button_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Button *button = obj;
|
||||
|
||||
if (button->frontend->icon) {
|
||||
Imlib_Image tmp = imlib_context_get_image();
|
||||
imlib_context_set_image(button->frontend->icon);
|
||||
fprintf(stderr,
|
||||
"%*sIcon: x = %d, y = %d, w = %d, h = %d\n",
|
||||
indent,
|
||||
"",
|
||||
button->frontend->iconx,
|
||||
button->frontend->icony,
|
||||
imlib_image_get_width(),
|
||||
imlib_image_get_height());
|
||||
if (tmp)
|
||||
imlib_context_set_image(tmp);
|
||||
}
|
||||
fprintf(stderr,
|
||||
"%*sText: x = %d, y = %d, w = %d, align = %s, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
button->frontend->textx,
|
||||
button->frontend->texty,
|
||||
button->frontend->textw,
|
||||
button->backend->centered ? "center" : "left",
|
||||
button->backend->text);
|
||||
}
|
||||
|
||||
void button_action(void *obj, int mouse_button, int x, int y)
|
||||
{
|
||||
Button *button = obj;
|
||||
char *command = NULL;
|
||||
switch (mouse_button) {
|
||||
case 1:
|
||||
command = button->backend->lclick_command;
|
||||
break;
|
||||
case 2:
|
||||
command = button->backend->mclick_command;
|
||||
break;
|
||||
case 3:
|
||||
command = button->backend->rclick_command;
|
||||
break;
|
||||
case 4:
|
||||
command = button->backend->uwheel_command;
|
||||
break;
|
||||
case 5:
|
||||
command = button->backend->dwheel_command;
|
||||
break;
|
||||
}
|
||||
if (command) {
|
||||
char *full_cmd = g_strdup_printf("export BUTTON_X=%d;"
|
||||
"export BUTTON_Y=%d;"
|
||||
"export BUTTON_W=%d;"
|
||||
"export BUTTON_H=%d; %s",
|
||||
x,
|
||||
y,
|
||||
button->area.width,
|
||||
button->area.height,
|
||||
command);
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "Could not fork\n");
|
||||
} else if (pid == 0) {
|
||||
// Child process
|
||||
// Allow children to exist after parent destruction
|
||||
setsid();
|
||||
// Run the command
|
||||
execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL);
|
||||
fprintf(stderr, "Failed to execlp %s\n", full_cmd);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *button_get_tooltip(void *obj)
|
||||
{
|
||||
Button *button = obj;
|
||||
|
||||
if (button->backend->tooltip && strlen(button->backend->tooltip) > 0)
|
||||
return strdup(button->backend->tooltip);
|
||||
return NULL;
|
||||
}
|
||||
112
src/button/button.h
Normal file
112
src/button/button.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef BUTTON_H
|
||||
#define BUTTON_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
#include "area.h"
|
||||
#include "common.h"
|
||||
#include "timer.h"
|
||||
|
||||
// Architecture:
|
||||
// Panel panel_config contains an array of Button, each storing all config options and all the state variables.
|
||||
// Only these run commands.
|
||||
//
|
||||
// Tint2 maintains an array of Panels, one for each monitor. Each stores an array of Button which was initially copied
|
||||
// from panel_config. Each works as a frontend to the corresponding Button in panel_config as backend, using the
|
||||
// backend's config and state variables.
|
||||
|
||||
typedef struct ButtonBackend {
|
||||
// Config:
|
||||
char *icon_name;
|
||||
char *text;
|
||||
char *tooltip;
|
||||
gboolean centered;
|
||||
int max_icon_size;
|
||||
gboolean has_font;
|
||||
PangoFontDescription *font_desc;
|
||||
Color font_color;
|
||||
char *lclick_command;
|
||||
char *mclick_command;
|
||||
char *rclick_command;
|
||||
char *uwheel_command;
|
||||
char *dwheel_command;
|
||||
// paddingxlr = horizontal padding left/right
|
||||
// paddingx = horizontal padding between childs
|
||||
int paddingxlr, paddingx, paddingy;
|
||||
Background *bg;
|
||||
|
||||
// List of Button which are frontends for this backend, one for each panel
|
||||
GList *instances;
|
||||
} ButtonBackend;
|
||||
|
||||
typedef struct ButtonFrontend {
|
||||
// Frontend state:
|
||||
Imlib_Image icon;
|
||||
Imlib_Image icon_hover;
|
||||
Imlib_Image icon_pressed;
|
||||
int icon_load_size;
|
||||
int iconx;
|
||||
int icony;
|
||||
int iconw;
|
||||
int iconh;
|
||||
int textx;
|
||||
int texty;
|
||||
int textw;
|
||||
int texth;
|
||||
} ButtonFrontend;
|
||||
|
||||
typedef struct Button {
|
||||
Area area;
|
||||
// All elements have the backend pointer set. However only backend elements have ownership.
|
||||
ButtonBackend *backend;
|
||||
// Set only for frontend Button items.
|
||||
ButtonFrontend *frontend;
|
||||
} Button;
|
||||
|
||||
// Called before the config is read and panel_config/panels are created.
|
||||
// Afterwards, the config parsing code creates the array of Button in panel_config and populates the configuration fields
|
||||
// in the backend.
|
||||
// Probably does nothing.
|
||||
void default_button();
|
||||
|
||||
// Creates a new Button item with only the backend field set. The state is NOT initialized. The config is initialized to
|
||||
// the default values.
|
||||
// This will be used by the config code to populate its backedn config fields.
|
||||
Button *create_button();
|
||||
|
||||
void destroy_button(void *obj);
|
||||
|
||||
// Called after the config is read and panel_config is populated, but before panels are created.
|
||||
// Initializes the state of the backend items.
|
||||
// panel_config.panel_items is used to determine which backend items are enabled. The others should be destroyed and
|
||||
// removed from panel_config.button_list.
|
||||
void init_button();
|
||||
|
||||
// Called after each on-screen panel is created, with a pointer to the panel.
|
||||
// Initializes the state of the frontend items. Also adds a pointer to it in backend->instances.
|
||||
// At this point the Area has not been added yet to the GUI tree, but it will be added right away.
|
||||
void init_button_panel(void *panel);
|
||||
|
||||
// Called just before the panels are destroyed. Afterwards, tint2 exits or restarts and reads the config again.
|
||||
// Releases all frontends and then all the backends.
|
||||
// The frontend items are not freed by this function, only their members. The items are Areas which are freed in the
|
||||
// GUI element tree cleanup function (remove_area).
|
||||
void cleanup_button();
|
||||
|
||||
// Called on draw, obj = pointer to the front-end Button item.
|
||||
void draw_button(void *obj, cairo_t *c);
|
||||
|
||||
// Called on resize, obj = pointer to the front-end Button item.
|
||||
// Returns 1 if the new size is different than the previous size.
|
||||
gboolean resize_button(void *obj);
|
||||
|
||||
// Called on mouse click event.
|
||||
void button_action(void *obj, int button, int x, int y);
|
||||
|
||||
void button_default_font_changed();
|
||||
void button_default_icon_theme_changed();
|
||||
|
||||
void button_reload_icon(Button *button);
|
||||
|
||||
#endif // BUTTON_H
|
||||
@@ -55,6 +55,7 @@ static timeout *clock_timeout;
|
||||
|
||||
void clock_init_fonts();
|
||||
char *clock_get_tooltip(void *obj);
|
||||
int clock_compute_desired_size(void *obj);
|
||||
void clock_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_clock()
|
||||
@@ -117,7 +118,7 @@ void update_clocks_sec(void *arg)
|
||||
for (int i = 0; i < num_panels; i++)
|
||||
panels[i].clock.area.resize_needed = 1;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void update_clocks_min(void *arg)
|
||||
@@ -131,7 +132,7 @@ void update_clocks_min(void *arg)
|
||||
for (int i = 0; i < num_panels; i++)
|
||||
panels[i].clock.area.resize_needed = 1;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +163,13 @@ gboolean time_format_needs_sec_ticks(char *time_format)
|
||||
|
||||
void init_clock()
|
||||
{
|
||||
}
|
||||
|
||||
void init_clock_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
Clock *clock = &panel->clock;
|
||||
|
||||
if (!clock_timeout) {
|
||||
if (time_format_needs_sec_ticks(time1_format) || time_format_needs_sec_ticks(time2_format)) {
|
||||
clock_timeout = add_timeout(10, 1000, update_clocks_sec, 0, &clock_timeout);
|
||||
@@ -169,12 +177,6 @@ void init_clock()
|
||||
clock_timeout = add_timeout(10, 1000, update_clocks_min, 0, &clock_timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_clock_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
Clock *clock = &panel->clock;
|
||||
|
||||
if (!clock->area.bg)
|
||||
clock->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
@@ -184,11 +186,12 @@ void init_clock_panel(void *p)
|
||||
snprintf(clock->area.name, sizeof(clock->area.name), "Clock");
|
||||
clock->area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
clock->area.has_mouse_press_effect = clock->area.has_mouse_over_effect =
|
||||
panel_config.mouse_effects && (clock_lclick_command || clock_mclick_command || clock_rclick_command ||
|
||||
clock_uwheel_command || clock_dwheel_command);
|
||||
panel_config.mouse_effects && (clock_lclick_command || clock_mclick_command || clock_rclick_command ||
|
||||
clock_uwheel_command || clock_dwheel_command);
|
||||
clock->area._draw_foreground = draw_clock;
|
||||
clock->area.size_mode = LAYOUT_FIXED;
|
||||
clock->area._resize = resize_clock;
|
||||
clock->area._compute_desired_size = clock_compute_desired_size;
|
||||
clock->area._dump_geometry = clock_dump_geometry;
|
||||
// check consistency
|
||||
if (!time1_format)
|
||||
@@ -196,6 +199,7 @@ void init_clock_panel(void *p)
|
||||
|
||||
clock->area.resize_needed = 1;
|
||||
clock->area.on_screen = TRUE;
|
||||
instantiate_area_gradients(&clock->area);
|
||||
|
||||
if (time_tooltip_format) {
|
||||
clock->area._get_tooltip_text = clock_get_tooltip;
|
||||
@@ -236,49 +240,88 @@ void clock_default_font_changed()
|
||||
panels[i].clock.area.resize_needed = TRUE;
|
||||
schedule_redraw(&panels[i].clock.area);
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
gboolean resize_clock(void *obj)
|
||||
void clock_compute_text_geometry(Panel *panel,
|
||||
int *time_height_ink,
|
||||
int *time_height,
|
||||
int *time_width,
|
||||
int *date_height_ink,
|
||||
int *date_height,
|
||||
int *date_width)
|
||||
{
|
||||
Clock *clock = obj;
|
||||
Panel *panel = clock->area.panel;
|
||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
|
||||
gboolean result = FALSE;
|
||||
|
||||
schedule_redraw(&clock->area);
|
||||
|
||||
date_height = date_width = 0;
|
||||
*date_height = *date_width = 0;
|
||||
strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone));
|
||||
get_text_size2(time1_font_desc,
|
||||
&time_height_ink,
|
||||
&time_height,
|
||||
&time_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
buf_time,
|
||||
strlen(buf_time),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
time_height_ink,
|
||||
time_height,
|
||||
time_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
buf_time,
|
||||
strlen(buf_time),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
if (time2_format) {
|
||||
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),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
date_height_ink,
|
||||
date_height,
|
||||
date_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
buf_date,
|
||||
strlen(buf_date),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
int clock_compute_desired_size(void *obj)
|
||||
{
|
||||
Clock *clock = (Clock *)obj;
|
||||
Panel *panel = (Panel *)clock->area.panel;
|
||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
|
||||
clock_compute_text_geometry(panel,
|
||||
&time_height_ink,
|
||||
&time_height,
|
||||
&time_width,
|
||||
&date_height_ink,
|
||||
&date_height,
|
||||
&date_width);
|
||||
|
||||
if (panel_horizontal) {
|
||||
int new_size = (time_width > date_width) ? time_width : date_width;
|
||||
new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
|
||||
return new_size;
|
||||
} else {
|
||||
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
|
||||
return new_size;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean resize_clock(void *obj)
|
||||
{
|
||||
Clock *clock = (Clock *)obj;
|
||||
Panel *panel = (Panel *)clock->area.panel;
|
||||
gboolean result = FALSE;
|
||||
|
||||
schedule_redraw(&clock->area);
|
||||
|
||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
|
||||
clock_compute_text_geometry(panel,
|
||||
&time_height_ink,
|
||||
&time_height,
|
||||
&time_width,
|
||||
&date_height_ink,
|
||||
&date_height,
|
||||
&date_width);
|
||||
|
||||
int new_size = clock_compute_desired_size(clock);
|
||||
if (panel_horizontal) {
|
||||
if (new_size > clock->area.width || new_size < (clock->area.width - 6)) {
|
||||
// we try to limit the number of resizes
|
||||
clock->area.width = new_size + 1;
|
||||
@@ -290,7 +333,6 @@ gboolean resize_clock(void *obj)
|
||||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
|
||||
if (new_size != clock->area.height) {
|
||||
// we try to limit the number of resizes
|
||||
clock->area.height = new_size;
|
||||
@@ -339,21 +381,10 @@ void draw_clock(void *obj, cairo_t *c)
|
||||
void clock_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Clock *clock = (Clock *)obj;
|
||||
fprintf(stderr,
|
||||
"%*sText 1: y = %d, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
clock->time1_posy,
|
||||
buf_time);
|
||||
fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", clock->time1_posy, buf_time);
|
||||
if (time2_format) {
|
||||
fprintf(stderr,
|
||||
"%*sText 2: y = %d, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
clock->time2_posy,
|
||||
buf_date);
|
||||
fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", clock->time2_posy, buf_date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
char *clock_get_tooltip(void *obj)
|
||||
|
||||
236
src/config.c
236
src/config.c
@@ -31,14 +31,14 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <pango/pangoxft.h>
|
||||
#include <pango/pango-font.h>
|
||||
#include <Imlib2.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef TINT2CONF
|
||||
|
||||
#include "tint2rc.h"
|
||||
#include "common.h"
|
||||
#include "server.h"
|
||||
#include "strnatcmp.h"
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "window.h"
|
||||
#include "tooltip.h"
|
||||
#include "timer.h"
|
||||
#include "separator.h"
|
||||
#include "execplugin.h"
|
||||
|
||||
#ifdef ENABLE_BATTERY
|
||||
@@ -202,6 +203,15 @@ void load_launcher_app_dir(const char *path)
|
||||
g_list_free(files);
|
||||
}
|
||||
|
||||
Separator *get_or_create_last_separator()
|
||||
{
|
||||
if (!panel_config.separator_list) {
|
||||
fprintf(stderr, "Warning: separator items should shart with 'separator = new'\n");
|
||||
panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator());
|
||||
}
|
||||
return (Separator *)g_list_last(panel_config.separator_list)->data;
|
||||
}
|
||||
|
||||
Execp *get_or_create_last_execp()
|
||||
{
|
||||
if (!panel_config.execp_list) {
|
||||
@@ -211,6 +221,15 @@ Execp *get_or_create_last_execp()
|
||||
return (Execp *)g_list_last(panel_config.execp_list)->data;
|
||||
}
|
||||
|
||||
Button *get_or_create_last_button()
|
||||
{
|
||||
if (!panel_config.button_list) {
|
||||
fprintf(stderr, "Warning: button items should start with 'button = new'\n");
|
||||
panel_config.button_list = g_list_append(panel_config.button_list, create_button());
|
||||
}
|
||||
return (Button *)g_list_last(panel_config.button_list)->data;
|
||||
}
|
||||
|
||||
void add_entry(char *key, char *value)
|
||||
{
|
||||
char *value1 = 0, *value2 = 0, *value3 = 0;
|
||||
@@ -233,10 +252,10 @@ void add_entry(char *key, char *value)
|
||||
init_background(&bg);
|
||||
bg.border.radius = atoi(value);
|
||||
g_array_append_val(backgrounds, bg);
|
||||
read_bg_color_hover = 0;
|
||||
read_border_color_hover = 0;
|
||||
read_bg_color_press = 0;
|
||||
read_border_color_press = 0;
|
||||
read_bg_color_hover = FALSE;
|
||||
read_border_color_hover = FALSE;
|
||||
read_bg_color_press = FALSE;
|
||||
read_border_color_press = FALSE;
|
||||
} else if (strcmp(key, "border_width") == 0) {
|
||||
g_array_index(backgrounds, Background, backgrounds->len - 1).border.width = atoi(value);
|
||||
} else if (strcmp(key, "border_sides") == 0) {
|
||||
@@ -304,6 +323,59 @@ void add_entry(char *key, char *value)
|
||||
else
|
||||
bg->border_color_pressed.alpha = 0.5;
|
||||
read_border_color_press = 1;
|
||||
} else if (strcmp(key, "gradient_id") == 0) {
|
||||
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
||||
int id = atoi(value);
|
||||
id = (id < gradients->len && id >= 0) ? id : -1;
|
||||
if (id >= 0)
|
||||
bg->gradients[MOUSE_NORMAL] = &g_array_index(gradients, GradientClass, id);
|
||||
} else if (strcmp(key, "gradient_id_hover") == 0 || strcmp(key, "hover_gradient_id") == 0) {
|
||||
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
||||
int id = atoi(value);
|
||||
id = (id < gradients->len && id >= 0) ? id : -1;
|
||||
if (id >= 0)
|
||||
bg->gradients[MOUSE_OVER] = &g_array_index(gradients, GradientClass, id);
|
||||
} else if (strcmp(key, "gradient_id_pressed") == 0 || strcmp(key, "pressed_gradient_id") == 0) {
|
||||
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
||||
int id = atoi(value);
|
||||
id = (id < gradients->len && id >= 0) ? id : -1;
|
||||
if (id >= 0)
|
||||
bg->gradients[MOUSE_DOWN] = &g_array_index(gradients, GradientClass, id);
|
||||
}
|
||||
|
||||
/* Gradients */
|
||||
else if (strcmp(key, "gradient") == 0) {
|
||||
// Create a new gradient
|
||||
GradientClass g;
|
||||
init_gradient(&g, gradient_type_from_string(value));
|
||||
g_array_append_val(gradients, g);
|
||||
} else if (strcmp(key, "start_color") == 0) {
|
||||
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, g->start_color.rgb);
|
||||
if (value2)
|
||||
g->start_color.alpha = (atoi(value2) / 100.0);
|
||||
else
|
||||
g->start_color.alpha = 0.5;
|
||||
} else if (strcmp(key, "end_color") == 0) {
|
||||
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, g->end_color.rgb);
|
||||
if (value2)
|
||||
g->end_color.alpha = (atoi(value2) / 100.0);
|
||||
else
|
||||
g->end_color.alpha = 0.5;
|
||||
} else if (strcmp(key, "color_stop") == 0) {
|
||||
GradientClass *g = &g_array_index(gradients, GradientClass, gradients->len - 1);
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
ColorStop *color_stop = (ColorStop *) calloc(1, sizeof(ColorStop));
|
||||
color_stop->offset = atof(value1) / 100.0;
|
||||
get_color(value2, color_stop->color.rgb);
|
||||
if (value3)
|
||||
color_stop->color.alpha = (atoi(value3) / 100.0);
|
||||
else
|
||||
color_stop->color.alpha = 0.5;
|
||||
g->extra_color_stops = g_list_append(g->extra_color_stops, color_stop);
|
||||
}
|
||||
|
||||
/* Panel */
|
||||
@@ -311,6 +383,8 @@ void add_entry(char *key, char *value)
|
||||
panel_config.monitor = config_get_monitor(value);
|
||||
} else if (strcmp(key, "primary_monitor_first") == 0) {
|
||||
primary_monitor_first = atoi(value);
|
||||
} else if (strcmp(key, "panel_shrink") == 0) {
|
||||
panel_shrink = atoi(value);
|
||||
} else if (strcmp(key, "panel_size") == 0) {
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
|
||||
@@ -527,6 +601,45 @@ void add_entry(char *key, char *value)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Separator */
|
||||
else if (strcmp(key, "separator") == 0) {
|
||||
panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator());
|
||||
} else if (strcmp(key, "separator_background_id") == 0) {
|
||||
Separator *separator = get_or_create_last_separator();
|
||||
int id = atoi(value);
|
||||
id = (id < backgrounds->len && id >= 0) ? id : 0;
|
||||
separator->area.bg = &g_array_index(backgrounds, Background, id);
|
||||
} else if (strcmp(key, "separator_color") == 0) {
|
||||
Separator *separator = get_or_create_last_separator();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, separator->color.rgb);
|
||||
if (value2)
|
||||
separator->color.alpha = (atoi(value2) / 100.0);
|
||||
else
|
||||
separator->color.alpha = 0.5;
|
||||
} else if (strcmp(key, "separator_style") == 0) {
|
||||
Separator *separator = get_or_create_last_separator();
|
||||
if (g_str_equal(value, "empty"))
|
||||
separator->style = SEPARATOR_EMPTY;
|
||||
else if (g_str_equal(value, "line"))
|
||||
separator->style = SEPARATOR_LINE;
|
||||
else if (g_str_equal(value, "dots"))
|
||||
separator->style = SEPARATOR_DOTS;
|
||||
else
|
||||
fprintf(stderr, RED "Invalid separator_style value: %s" RESET "\n", value);
|
||||
} else if (strcmp(key, "separator_size") == 0) {
|
||||
Separator *separator = get_or_create_last_separator();
|
||||
separator->thickness = atoi(value);
|
||||
} else if (strcmp(key, "separator_padding") == 0) {
|
||||
Separator *separator = get_or_create_last_separator();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
separator->area.paddingxlr = separator->area.paddingx = atoi(value1);
|
||||
if (value2)
|
||||
separator->area.paddingy = atoi(value2);
|
||||
if (value3)
|
||||
separator->area.paddingx = atoi(value3);
|
||||
}
|
||||
|
||||
/* Execp */
|
||||
else if (strcmp(key, "execp") == 0) {
|
||||
panel_config.execp_list = g_list_append(panel_config.execp_list, create_execp());
|
||||
@@ -634,6 +747,82 @@ void add_entry(char *key, char *value)
|
||||
execp->backend->dwheel_command = strdup(value);
|
||||
}
|
||||
|
||||
/* Button */
|
||||
else if (strcmp(key, "button") == 0) {
|
||||
panel_config.button_list = g_list_append(panel_config.button_list, create_button());
|
||||
} else if (strcmp(key, "button_icon") == 0 && strlen(value)) {
|
||||
Button *button = get_or_create_last_button();
|
||||
button->backend->icon_name = strdup(value);
|
||||
} else if (strcmp(key, "button_text") == 0 && strlen(value)) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->text);
|
||||
button->backend->text = strdup(value);
|
||||
} else if (strcmp(key, "button_tooltip") == 0 && strlen(value)) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->tooltip);
|
||||
button->backend->tooltip = strdup(value);
|
||||
} else if (strcmp(key, "button_font") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
pango_font_description_free(button->backend->font_desc);
|
||||
button->backend->font_desc = pango_font_description_from_string(value);
|
||||
button->backend->has_font = TRUE;
|
||||
} else if (strcmp(key, "button_font_color") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, button->backend->font_color.rgb);
|
||||
if (value2)
|
||||
button->backend->font_color.alpha = atoi(value2) / 100.0;
|
||||
else
|
||||
button->backend->font_color.alpha = 0.5;
|
||||
} else if (strcmp(key, "button_padding") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
button->backend->paddingxlr = button->backend->paddingx = atoi(value1);
|
||||
if (value2)
|
||||
button->backend->paddingy = atoi(value2);
|
||||
else
|
||||
button->backend->paddingy = 0;
|
||||
if (value3)
|
||||
button->backend->paddingx = atoi(value3);
|
||||
} else if (strcmp(key, "button_max_icon_size") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
button->backend->max_icon_size = MAX(0, atoi(value));
|
||||
} else if (strcmp(key, "button_background_id") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
int id = atoi(value);
|
||||
id = (id < backgrounds->len && id >= 0) ? id : 0;
|
||||
button->backend->bg = &g_array_index(backgrounds, Background, id);
|
||||
} else if (strcmp(key, "button_centered") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
button->backend->centered = atoi(value);
|
||||
} else if (strcmp(key, "button_lclick_command") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->lclick_command);
|
||||
if (strlen(value) > 0)
|
||||
button->backend->lclick_command = strdup(value);
|
||||
} else if (strcmp(key, "button_mclick_command") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->mclick_command);
|
||||
if (strlen(value) > 0)
|
||||
button->backend->mclick_command = strdup(value);
|
||||
} else if (strcmp(key, "button_rclick_command") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->rclick_command);
|
||||
if (strlen(value) > 0)
|
||||
button->backend->rclick_command = strdup(value);
|
||||
} else if (strcmp(key, "button_uwheel_command") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->uwheel_command);
|
||||
if (strlen(value) > 0)
|
||||
button->backend->uwheel_command = strdup(value);
|
||||
} else if (strcmp(key, "button_dwheel_command") == 0) {
|
||||
Button *button = get_or_create_last_button();
|
||||
free_and_null(button->backend->dwheel_command);
|
||||
if (strlen(value) > 0)
|
||||
button->backend->dwheel_command = strdup(value);
|
||||
}
|
||||
|
||||
/* Clock */
|
||||
else if (strcmp(key, "time1_format") == 0) {
|
||||
if (!new_config_file) {
|
||||
@@ -771,6 +960,8 @@ void add_entry(char *key, char *value)
|
||||
hide_inactive_tasks = atoi(value);
|
||||
} else if (strcmp(key, "taskbar_hide_different_monitor") == 0) {
|
||||
hide_task_diff_monitor = atoi(value);
|
||||
} else if (strcmp(key, "taskbar_hide_if_empty") == 0) {
|
||||
hide_taskbar_if_empty = atoi(value);
|
||||
} else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) {
|
||||
always_show_all_desktop_tasks = atoi(value);
|
||||
} else if (strcmp(key, "taskbar_sort_order") == 0) {
|
||||
@@ -904,6 +1095,10 @@ void add_entry(char *key, char *value)
|
||||
systray.brightness = atoi(value3);
|
||||
} else if (strcmp(key, "systray_monitor") == 0) {
|
||||
systray_monitor = atoi(value) - 1;
|
||||
} else if (strcmp(key, "systray_name_filter") == 0) {
|
||||
if (systray_hide_name_filter)
|
||||
free(systray_hide_name_filter);
|
||||
systray_hide_name_filter = strdup(value);
|
||||
}
|
||||
|
||||
/* Launcher */
|
||||
@@ -1068,20 +1263,21 @@ void add_entry(char *key, char *value)
|
||||
|
||||
gboolean config_read_file(const char *path)
|
||||
{
|
||||
FILE *fp;
|
||||
char line[512];
|
||||
char *key, *value;
|
||||
|
||||
if ((fp = fopen(path, "r")) == NULL)
|
||||
FILE *fp = fopen(path, "r");
|
||||
if (!fp)
|
||||
return FALSE;
|
||||
|
||||
while (fgets(line, sizeof(line), fp) != NULL) {
|
||||
char* line = NULL;
|
||||
size_t line_size = 0;
|
||||
while (getline(&line, &line_size, fp) >= 0) {
|
||||
char *key, *value;
|
||||
if (parse_line(line, &key, &value)) {
|
||||
add_entry(key, value);
|
||||
free(key);
|
||||
free(value);
|
||||
}
|
||||
}
|
||||
free(line);
|
||||
fclose(fp);
|
||||
|
||||
if (!read_panel_position) {
|
||||
@@ -1134,6 +1330,13 @@ gboolean config_read_default_path()
|
||||
g_free(path1);
|
||||
|
||||
// copy tint2rc from system directory to user directory
|
||||
|
||||
fprintf(stderr, "tint2 warning: could not find a config file! Creating a default one.\n");
|
||||
// According to the XDG Base Directory Specification (https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html)
|
||||
// if the user's config directory does not exist, we should create it with permissions set to 0700.
|
||||
if (!g_file_test(g_get_user_config_dir(), G_FILE_TEST_IS_DIR))
|
||||
g_mkdir(g_get_user_config_dir(), 0700);
|
||||
|
||||
gchar *path2 = 0;
|
||||
system_dirs = g_get_system_config_dirs();
|
||||
for (int i = 0; system_dirs[i]; i++) {
|
||||
@@ -1162,15 +1365,18 @@ gboolean config_read_default_path()
|
||||
return result;
|
||||
}
|
||||
|
||||
// generate empty config file
|
||||
fprintf(stderr, "tint2 warning: could not find a config file!\n");
|
||||
// generate config file
|
||||
gchar *dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL);
|
||||
if (!g_file_test(dir, G_FILE_TEST_IS_DIR))
|
||||
g_mkdir(dir, 0700);
|
||||
g_free(dir);
|
||||
|
||||
path1 = g_build_filename(g_get_user_config_dir(), "tint2", "tint2rc", NULL);
|
||||
copy_file("/dev/null", path1);
|
||||
FILE *f = fopen(path1, "w");
|
||||
if (f) {
|
||||
fwrite(themes_tint2rc, 1, themes_tint2rc_len, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
gboolean result = config_read_file(path1);
|
||||
config_path = strdup(path1);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
void execp_timer_callback(void *arg);
|
||||
char *execp_get_tooltip(void *obj);
|
||||
void execp_init_fonts();
|
||||
int execp_compute_desired_size(void *obj);
|
||||
void execp_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_execp()
|
||||
@@ -32,12 +33,11 @@ Execp *create_execp()
|
||||
Execp *execp = calloc(1, sizeof(Execp));
|
||||
execp->backend = calloc(1, sizeof(ExecpBackend));
|
||||
execp->backend->child_pipe = -1;
|
||||
|
||||
execp->backend->cmd_pids = g_tree_new(cmp_ptr);
|
||||
execp->backend->interval = 30;
|
||||
execp->backend->cache_icon = TRUE;
|
||||
execp->backend->centered = TRUE;
|
||||
execp->backend->font_color.alpha = 0.5;
|
||||
|
||||
return execp;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@ void destroy_execp(void *obj)
|
||||
// This is a frontend element
|
||||
execp->backend->instances = g_list_remove_all(execp->backend->instances, execp);
|
||||
free_and_null(execp->frontend);
|
||||
remove_area(&execp->area);
|
||||
free_area(&execp->area);
|
||||
free_and_null(execp);
|
||||
} else {
|
||||
// This is a backend element
|
||||
stop_timeout(execp->backend->timer);
|
||||
@@ -80,6 +83,10 @@ void destroy_execp(void *obj)
|
||||
close(execp->backend->child_pipe);
|
||||
execp->backend->child_pipe = -1;
|
||||
}
|
||||
if (execp->backend->cmd_pids) {
|
||||
g_tree_destroy(execp->backend->cmd_pids);
|
||||
execp->backend->cmd_pids = NULL;
|
||||
}
|
||||
|
||||
execp->backend->bg = NULL;
|
||||
pango_font_description_free(execp->backend->font_desc);
|
||||
@@ -159,6 +166,7 @@ void init_execp_panel(void *p)
|
||||
execp->area.parent = panel;
|
||||
execp->area.panel = panel;
|
||||
execp->area._dump_geometry = execp_dump_geometry;
|
||||
execp->area._compute_desired_size = execp_compute_desired_size;
|
||||
snprintf(execp->area.name,
|
||||
sizeof(execp->area.name),
|
||||
"Execp %s",
|
||||
@@ -176,6 +184,7 @@ void init_execp_panel(void *p)
|
||||
|
||||
execp->area.resize_needed = TRUE;
|
||||
execp->area.on_screen = TRUE;
|
||||
instantiate_area_gradients(&execp->area);
|
||||
|
||||
if (!execp->backend->timer)
|
||||
execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer);
|
||||
@@ -217,7 +226,7 @@ void execp_default_font_changed()
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void cleanup_execp()
|
||||
@@ -281,15 +290,85 @@ gboolean reload_icon(Execp *execp)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean resize_execp(void *obj)
|
||||
int execp_compute_desired_size(void *obj)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
Panel *panel = execp->area.panel;
|
||||
Execp *execp = (Execp *)obj;
|
||||
Panel *panel = (Panel *)execp->area.panel;
|
||||
int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
|
||||
int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
|
||||
int interior_padding = execp->area.paddingx;
|
||||
|
||||
schedule_redraw(&execp->area);
|
||||
int icon_w, icon_h;
|
||||
if (reload_icon(execp)) {
|
||||
if (execp->backend->icon) {
|
||||
imlib_context_set_image(execp->backend->icon);
|
||||
icon_w = imlib_image_get_width();
|
||||
icon_h = imlib_image_get_height();
|
||||
} else {
|
||||
icon_w = icon_h = 0;
|
||||
}
|
||||
} else {
|
||||
icon_w = icon_h = 0;
|
||||
}
|
||||
|
||||
int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2;
|
||||
|
||||
int txt_height_ink, txt_height, txt_width;
|
||||
if (panel_horizontal) {
|
||||
get_text_size2(execp->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->has_markup);
|
||||
} else {
|
||||
get_text_size2(execp->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
!text_next_line
|
||||
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
|
||||
left_right_border_width(&execp->area)
|
||||
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->has_markup);
|
||||
}
|
||||
|
||||
if (panel_horizontal) {
|
||||
int new_size = txt_width;
|
||||
if (icon_w)
|
||||
new_size += interior_padding + icon_w;
|
||||
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
|
||||
return new_size;
|
||||
} else {
|
||||
int new_size;
|
||||
if (!text_next_line) {
|
||||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
|
||||
} else {
|
||||
new_size =
|
||||
icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
}
|
||||
return new_size;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean resize_execp(void *obj)
|
||||
{
|
||||
Execp *execp = (Execp *)obj;
|
||||
Panel *panel = (Panel *)execp->area.panel;
|
||||
int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
|
||||
int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
|
||||
int interior_padding = execp->area.paddingx;
|
||||
|
||||
int icon_w, icon_h;
|
||||
if (reload_icon(execp)) {
|
||||
@@ -399,6 +478,8 @@ gboolean resize_execp(void *obj)
|
||||
}
|
||||
}
|
||||
|
||||
schedule_redraw(&execp->area);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -464,6 +545,18 @@ void execp_dump_geometry(void *obj, int indent)
|
||||
execp->backend->text);
|
||||
}
|
||||
|
||||
void execp_force_update(Execp *execp)
|
||||
{
|
||||
if (execp->backend->child_pipe > 0) {
|
||||
// Command currently running, nothing to do
|
||||
} else {
|
||||
if (execp->backend->timer)
|
||||
stop_timeout(execp->backend->timer);
|
||||
// Run command right away
|
||||
execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer);
|
||||
}
|
||||
}
|
||||
|
||||
void execp_action(void *obj, int button, int x, int y)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
@@ -495,20 +588,32 @@ void execp_action(void *obj, int button, int x, int y)
|
||||
execp->area.width,
|
||||
execp->area.height,
|
||||
command);
|
||||
tint_exec(full_cmd);
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "Could not fork\n");
|
||||
} else if (pid == 0) {
|
||||
// Child process
|
||||
// Allow children to exist after parent destruction
|
||||
setsid();
|
||||
// Run the command
|
||||
execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL);
|
||||
fprintf(stderr, "Failed to execlp %s\n", full_cmd);
|
||||
exit(1);
|
||||
}
|
||||
// Parent process
|
||||
g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1));
|
||||
g_free(full_cmd);
|
||||
} else {
|
||||
if (execp->backend->child_pipe > 0) {
|
||||
// Command currently running, nothing to do
|
||||
} else {
|
||||
if (execp->backend->timer)
|
||||
stop_timeout(execp->backend->timer);
|
||||
// Run command right away
|
||||
execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer);
|
||||
}
|
||||
execp_force_update(execp);
|
||||
}
|
||||
}
|
||||
|
||||
void execp_cmd_completed(Execp *execp, pid_t pid)
|
||||
{
|
||||
g_tree_remove(execp->backend->cmd_pids, GINT_TO_POINTER(pid));
|
||||
execp_force_update(execp);
|
||||
}
|
||||
|
||||
void execp_timer_callback(void *arg)
|
||||
{
|
||||
Execp *execp = arg;
|
||||
@@ -538,6 +643,7 @@ void execp_timer_callback(void *arg)
|
||||
close(pipe_fd[0]);
|
||||
return;
|
||||
} else if (child == 0) {
|
||||
fprintf(stderr, "Executing: %s\n", execp->backend->command);
|
||||
// We are in the child
|
||||
close(pipe_fd[0]);
|
||||
dup2(pipe_fd[1], 1); // 1 is stdout
|
||||
|
||||
@@ -70,6 +70,7 @@ typedef struct ExecpBackend {
|
||||
|
||||
// List of Execp which are frontends for this backend, one for each panel
|
||||
GList *instances;
|
||||
GTree *cmd_pids;
|
||||
} ExecpBackend;
|
||||
|
||||
typedef struct ExecpFrontend {
|
||||
@@ -130,6 +131,8 @@ gboolean resize_execp(void *obj);
|
||||
// Called on mouse click event.
|
||||
void execp_action(void *obj, int button, int x, int y);
|
||||
|
||||
void execp_cmd_completed(Execp *obj, pid_t pid);
|
||||
|
||||
// Called to check if new output from the command can be read.
|
||||
// No command might be running.
|
||||
// Returns 1 if the output has been updated and a redraw is needed.
|
||||
|
||||
@@ -30,31 +30,57 @@
|
||||
#include "freespace.h"
|
||||
#include "common.h"
|
||||
|
||||
int freespace_area_compute_desired_size(void *obj);
|
||||
|
||||
void init_freespace_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
FreeSpace *freespace = &panel->freespace;
|
||||
|
||||
if (!freespace->area.bg)
|
||||
freespace->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
freespace->area.parent = p;
|
||||
freespace->area.panel = p;
|
||||
snprintf(freespace->area.name, sizeof(freespace->area.name), "Freespace");
|
||||
freespace->area.size_mode = LAYOUT_FIXED;
|
||||
freespace->area.resize_needed = 1;
|
||||
freespace->area.on_screen = TRUE;
|
||||
freespace->area._resize = resize_freespace;
|
||||
// Make sure this is only done once if there are multiple items
|
||||
if (panel->freespace_list)
|
||||
return;
|
||||
|
||||
for (size_t k = 0; k < strlen(panel_items_order); k++) {
|
||||
if (panel_items_order[k] == 'F') {
|
||||
FreeSpace *freespace = (FreeSpace *) calloc(1, sizeof(FreeSpace));
|
||||
panel->freespace_list = g_list_append(panel->freespace_list, freespace);
|
||||
if (!freespace->area.bg)
|
||||
freespace->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
freespace->area.parent = p;
|
||||
freespace->area.panel = p;
|
||||
snprintf(freespace->area.name, sizeof(freespace->area.name), "Freespace");
|
||||
freespace->area.size_mode = LAYOUT_FIXED;
|
||||
freespace->area.resize_needed = 1;
|
||||
freespace->area.on_screen = TRUE;
|
||||
freespace->area._resize = resize_freespace;
|
||||
freespace->area._compute_desired_size = freespace_area_compute_desired_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup_freespace(Panel *panel)
|
||||
{
|
||||
if (panel->freespace_list)
|
||||
g_list_free_full(panel->freespace_list, free);
|
||||
panel->freespace_list = NULL;
|
||||
}
|
||||
|
||||
int freespace_get_max_size(Panel *p)
|
||||
{
|
||||
if (panel_shrink)
|
||||
return 0;
|
||||
// Get space used by every element except the freespace
|
||||
int size = 0;
|
||||
int spacers = 0;
|
||||
for (GList *walk = p->area.children; walk; walk = g_list_next(walk)) {
|
||||
Area *a = (Area *)walk->data;
|
||||
|
||||
if (a->_resize == resize_freespace || !a->on_screen)
|
||||
if (!a->on_screen)
|
||||
continue;
|
||||
if (a->_resize == resize_freespace) {
|
||||
spacers++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (panel_horizontal)
|
||||
size += a->width + p->area.paddingx;
|
||||
@@ -67,7 +93,13 @@ int freespace_get_max_size(Panel *p)
|
||||
else
|
||||
size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr;
|
||||
|
||||
return size;
|
||||
return size / spacers;
|
||||
}
|
||||
|
||||
int freespace_area_compute_desired_size(void *obj)
|
||||
{
|
||||
FreeSpace *freespace = (FreeSpace *) obj;
|
||||
return freespace_get_max_size((Panel *)freespace->area.panel);
|
||||
}
|
||||
|
||||
gboolean resize_freespace(void *obj)
|
||||
@@ -89,6 +121,6 @@ gboolean resize_freespace(void *obj)
|
||||
}
|
||||
|
||||
schedule_redraw(&freespace->area);
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ typedef struct FreeSpace {
|
||||
Area area;
|
||||
} FreeSpace;
|
||||
|
||||
void cleanup_freespace();
|
||||
struct Panel;
|
||||
|
||||
void cleanup_freespace(struct Panel *panel);
|
||||
void init_freespace_panel(void *panel);
|
||||
|
||||
gboolean resize_freespace(void *obj);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
static gint compare_strings(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
@@ -110,7 +111,7 @@ void expand_exec(DesktopEntry *entry, const char *path)
|
||||
|
||||
gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry)
|
||||
{
|
||||
entry->name = entry->generic_name = entry->icon = entry->exec = NULL;
|
||||
entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL;
|
||||
entry->hidden_from_menus = FALSE;
|
||||
|
||||
FILE *fp = fopen(path, "rt");
|
||||
@@ -185,6 +186,8 @@ gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry)
|
||||
}
|
||||
} else if (!entry->exec && strcmp(key, "Exec") == 0) {
|
||||
entry->exec = strdup(value);
|
||||
} else if (!entry->cwd && strcmp(key, "Path") == 0) {
|
||||
entry->cwd = strdup(value);
|
||||
} else if (!entry->icon && strcmp(key, "Icon") == 0) {
|
||||
entry->icon = strdup(value);
|
||||
} else if (strcmp(key, "NoDisplay") == 0) {
|
||||
@@ -209,11 +212,11 @@ gboolean read_desktop_file_from_dir(const char *path, const char *file_name, Des
|
||||
g_free(full_path);
|
||||
return TRUE;
|
||||
}
|
||||
free(entry->name);
|
||||
free(entry->generic_name);
|
||||
free(entry->icon);
|
||||
free(entry->exec);
|
||||
entry->name = entry->generic_name = entry->icon = entry->exec = NULL;
|
||||
free_and_null(entry->name);
|
||||
free_and_null(entry->generic_name);
|
||||
free_and_null(entry->icon);
|
||||
free_and_null(entry->exec);
|
||||
free_and_null(entry->cwd);
|
||||
|
||||
GList *subdirs = NULL;
|
||||
|
||||
@@ -252,7 +255,7 @@ gboolean read_desktop_file_from_dir(const char *path, const char *file_name, Des
|
||||
gboolean read_desktop_file(const char *path, DesktopEntry *entry)
|
||||
{
|
||||
entry->path = strdup(path);
|
||||
entry->name = entry->generic_name = entry->icon = entry->exec = NULL;
|
||||
entry->name = entry->generic_name = entry->icon = entry->exec = entry->cwd = NULL;
|
||||
|
||||
if (strchr(path, '/'))
|
||||
return read_desktop_file_full_path(path, entry);
|
||||
@@ -265,12 +268,12 @@ gboolean read_desktop_file(const char *path, DesktopEntry *entry)
|
||||
|
||||
void free_desktop_entry(DesktopEntry *entry)
|
||||
{
|
||||
free(entry->name);
|
||||
free(entry->generic_name);
|
||||
free(entry->icon);
|
||||
free(entry->exec);
|
||||
free(entry->path);
|
||||
entry->name = entry->generic_name = entry->icon = entry->exec = entry->path = NULL;
|
||||
free_and_null(entry->name);
|
||||
free_and_null(entry->generic_name);
|
||||
free_and_null(entry->icon);
|
||||
free_and_null(entry->exec);
|
||||
free_and_null(entry->path);
|
||||
free_and_null(entry->cwd);
|
||||
}
|
||||
|
||||
void test_read_desktop_file()
|
||||
|
||||
@@ -15,6 +15,7 @@ typedef struct DesktopEntry {
|
||||
char *exec;
|
||||
char *icon;
|
||||
char *path;
|
||||
char *cwd;
|
||||
gboolean hidden_from_menus;
|
||||
} DesktopEntry;
|
||||
|
||||
|
||||
@@ -305,6 +305,7 @@ void free_themes(IconThemeWrapper *wrapper)
|
||||
{
|
||||
if (!wrapper)
|
||||
return;
|
||||
free(wrapper->icon_theme_name);
|
||||
for (GSList *l = wrapper->themes; l; l = l->next) {
|
||||
IconTheme *theme = (IconTheme *)l->data;
|
||||
free_icon_theme(theme);
|
||||
@@ -739,7 +740,7 @@ void add_icon_path_to_cache(IconThemeWrapper *wrapper, const char *icon_name, in
|
||||
g_free(key);
|
||||
}
|
||||
|
||||
char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size)
|
||||
char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size, gboolean use_fallbacks)
|
||||
{
|
||||
if (!wrapper)
|
||||
return NULL;
|
||||
@@ -760,6 +761,8 @@ char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size)
|
||||
return path;
|
||||
}
|
||||
|
||||
if (!use_fallbacks)
|
||||
goto notfound;
|
||||
fprintf(stderr, YELLOW "Icon not found in default theme: %s" RESET "\n", icon_name);
|
||||
load_fallbacks(wrapper);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ void free_icon_theme(IconTheme *theme);
|
||||
|
||||
// Returns the full path to an icon file (or NULL) given the list of icon themes to search and the icon name
|
||||
// Note: needs to be released with free().
|
||||
char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size);
|
||||
char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size, gboolean use_fallbacks);
|
||||
|
||||
// Returns a list of the directories used to store icons.
|
||||
// Do not free the result, it is cached.
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "window.h"
|
||||
@@ -53,10 +52,18 @@ char *icon_theme_name_xsettings;
|
||||
int launcher_icon_theme_override;
|
||||
int startup_notifications;
|
||||
Background *launcher_icon_bg;
|
||||
GList *launcher_icon_gradients;
|
||||
|
||||
IconThemeWrapper *icon_theme_wrapper;
|
||||
|
||||
Imlib_Image scale_icon(Imlib_Image original, int icon_size);
|
||||
void free_icon(Imlib_Image icon);
|
||||
void launcher_icon_dump_geometry(void *obj, int indent);
|
||||
void launcher_reload_icon(Launcher *launcher, LauncherIcon *launcherIcon);
|
||||
void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon);
|
||||
void launcher_reload_hidden_icons(Launcher *launcher);
|
||||
void launcher_icon_on_change_layout(void *obj);
|
||||
int launcher_compute_desired_size(void *obj);
|
||||
|
||||
void default_launcher()
|
||||
{
|
||||
@@ -71,6 +78,7 @@ void default_launcher()
|
||||
launcher_icon_theme_override = 0;
|
||||
startup_notifications = 0;
|
||||
launcher_icon_bg = NULL;
|
||||
launcher_icon_gradients = NULL;
|
||||
}
|
||||
|
||||
void init_launcher()
|
||||
@@ -88,6 +96,7 @@ void init_launcher_panel(void *p)
|
||||
launcher->area._draw_foreground = NULL;
|
||||
launcher->area.size_mode = LAYOUT_FIXED;
|
||||
launcher->area._resize = resize_launcher;
|
||||
launcher->area._compute_desired_size = launcher_compute_desired_size;
|
||||
launcher->area.resize_needed = 1;
|
||||
schedule_redraw(&launcher->area);
|
||||
if (!launcher->area.bg)
|
||||
@@ -100,13 +109,23 @@ void init_launcher_panel(void *p)
|
||||
if (launcher->list_apps == NULL)
|
||||
return;
|
||||
|
||||
launcher->area.on_screen = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
// This will be recomputed on resize, we just initialize to a non-zero value
|
||||
launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size : 24;
|
||||
|
||||
launcher_load_themes(launcher);
|
||||
launcher->area.on_screen = TRUE;
|
||||
schedule_panel_redraw();
|
||||
instantiate_area_gradients(&launcher->area);
|
||||
|
||||
load_icon_themes();
|
||||
launcher_load_icons(launcher);
|
||||
}
|
||||
|
||||
void free_icon_themes()
|
||||
{
|
||||
free_themes(icon_theme_wrapper);
|
||||
icon_theme_wrapper = NULL;
|
||||
}
|
||||
|
||||
void cleanup_launcher()
|
||||
{
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
@@ -143,118 +162,117 @@ void cleanup_launcher_theme(Launcher *launcher)
|
||||
free(launcherIcon->icon_path);
|
||||
free(launcherIcon->cmd);
|
||||
g_free(launcherIcon->icon_tooltip);
|
||||
free(launcherIcon->config_path);
|
||||
}
|
||||
free(launcherIcon);
|
||||
}
|
||||
g_slist_free(launcher->list_icons);
|
||||
launcher->list_icons = NULL;
|
||||
|
||||
free_themes(launcher->icon_theme_wrapper);
|
||||
launcher->icon_theme_wrapper = NULL;
|
||||
}
|
||||
|
||||
gboolean resize_launcher(void *obj)
|
||||
int launcher_compute_icon_size(Launcher *launcher)
|
||||
{
|
||||
Launcher *launcher = obj;
|
||||
int icons_per_column = 1, icons_per_row = 1, margin = 0;
|
||||
|
||||
int icon_size;
|
||||
if (panel_horizontal) {
|
||||
icon_size = launcher->area.height;
|
||||
} else {
|
||||
icon_size = launcher->area.width;
|
||||
}
|
||||
int icon_size = panel_horizontal ? launcher->area.height : launcher->area.width;
|
||||
icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) -
|
||||
(2 * launcher->area.paddingy);
|
||||
if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size)
|
||||
icon_size = launcher_max_icon_size;
|
||||
return icon_size;
|
||||
}
|
||||
|
||||
void launcher_compute_geometry(Launcher *launcher,
|
||||
int *size,
|
||||
int *icon_size,
|
||||
int *icons_per_column,
|
||||
int *icons_per_row,
|
||||
int *margin)
|
||||
{
|
||||
int count = 0;
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (launcherIcon->area.on_screen)
|
||||
count++;
|
||||
}
|
||||
|
||||
*icon_size = launcher_compute_icon_size(launcher);
|
||||
*icons_per_column = 1;
|
||||
*icons_per_row = 1;
|
||||
*margin = 0;
|
||||
if (panel_horizontal) {
|
||||
if (!count) {
|
||||
*size = 0;
|
||||
} else {
|
||||
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
|
||||
// here icons_per_column always higher than 0
|
||||
*icons_per_column = (height + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx);
|
||||
*margin = height - (*icons_per_column - 1) * (*icon_size + launcher->area.paddingx) - *icon_size;
|
||||
*icons_per_row = count / *icons_per_column + (count % *icons_per_column != 0);
|
||||
*size = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
|
||||
(*icon_size * *icons_per_row) + ((*icons_per_row - 1) * launcher->area.paddingx);
|
||||
}
|
||||
} else {
|
||||
if (!count) {
|
||||
*size = 0;
|
||||
} else {
|
||||
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
|
||||
// here icons_per_row always higher than 0
|
||||
*icons_per_row = (width + launcher->area.paddingx) / (*icon_size + launcher->area.paddingx);
|
||||
*margin = width - (*icons_per_row - 1) * (*icon_size + launcher->area.paddingx) - *icon_size;
|
||||
*icons_per_column = count / *icons_per_row + (count % *icons_per_row != 0);
|
||||
*size = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
|
||||
(*icon_size * *icons_per_column) + ((*icons_per_column - 1) * launcher->area.paddingx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int launcher_compute_desired_size(void *obj)
|
||||
{
|
||||
Launcher *launcher = (Launcher *)obj;
|
||||
|
||||
int size, icon_size, icons_per_column, icons_per_row, margin;
|
||||
launcher_compute_geometry(launcher, &size, &icon_size, &icons_per_column, &icons_per_row, &margin);
|
||||
return size;
|
||||
}
|
||||
|
||||
gboolean resize_launcher(void *obj)
|
||||
{
|
||||
Launcher *launcher = (Launcher *)obj;
|
||||
|
||||
int size, icons_per_column, icons_per_row, margin;
|
||||
launcher_compute_geometry(launcher, &size, &launcher->icon_size, &icons_per_column, &icons_per_row, &margin);
|
||||
|
||||
// Resize icons if necessary
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (launcherIcon->icon_size != icon_size || !launcherIcon->image) {
|
||||
launcherIcon->icon_size = icon_size;
|
||||
if (launcherIcon->icon_size != launcher->icon_size || !launcherIcon->image) {
|
||||
launcherIcon->icon_size = launcher->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 =
|
||||
get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size);
|
||||
if (!new_icon_path) {
|
||||
// Draw a blank icon
|
||||
free_icon(launcherIcon->image);
|
||||
free_icon(launcherIcon->image_hover);
|
||||
free_icon(launcherIcon->image_pressed);
|
||||
launcherIcon->image = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Free the old files
|
||||
free_icon(launcherIcon->image);
|
||||
free_icon(launcherIcon->image_hover);
|
||||
free_icon(launcherIcon->image_pressed);
|
||||
// Load the new file
|
||||
launcherIcon->image = load_image(new_icon_path, 1);
|
||||
// On loading error, fallback to default
|
||||
if (!launcherIcon->image) {
|
||||
free(new_icon_path);
|
||||
new_icon_path = get_icon_path(launcher->icon_theme_wrapper, DEFAULT_ICON, launcherIcon->icon_size);
|
||||
if (new_icon_path)
|
||||
launcherIcon->image = imlib_load_image_immediately(new_icon_path);
|
||||
}
|
||||
|
||||
if (!launcherIcon->image) {
|
||||
// Loading default icon failed, draw a blank icon
|
||||
free(new_icon_path);
|
||||
} else {
|
||||
// Loaded icon successfully, rescale it
|
||||
Imlib_Image original = launcherIcon->image;
|
||||
launcherIcon->image = scale_icon(launcherIcon->image, launcherIcon->icon_size);
|
||||
free_icon(original);
|
||||
free(launcherIcon->icon_path);
|
||||
launcherIcon->icon_path = new_icon_path;
|
||||
fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (panel_config.mouse_effects) {
|
||||
launcherIcon->image_hover = adjust_icon(launcherIcon->image,
|
||||
panel_config.mouse_over_alpha,
|
||||
panel_config.mouse_over_saturation,
|
||||
panel_config.mouse_over_brightness);
|
||||
launcherIcon->image_pressed = adjust_icon(launcherIcon->image,
|
||||
panel_config.mouse_pressed_alpha,
|
||||
panel_config.mouse_pressed_saturation,
|
||||
panel_config.mouse_pressed_brightness);
|
||||
launcher_reload_icon_image(launcher, launcherIcon);
|
||||
}
|
||||
}
|
||||
save_icon_cache(launcher->icon_theme_wrapper);
|
||||
save_icon_cache(icon_theme_wrapper);
|
||||
|
||||
int count = g_slist_length(launcher->list_icons);
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (!count) {
|
||||
launcher->area.width = 0;
|
||||
} else {
|
||||
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
|
||||
// here icons_per_column always higher than 0
|
||||
icons_per_column = (height + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
|
||||
margin = 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 = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
|
||||
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
|
||||
int count = 0;
|
||||
gboolean needs_repositioning = FALSE;
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (launcherIcon->area.on_screen) {
|
||||
count++;
|
||||
if (launcherIcon->area.posx < 0 || launcherIcon->area.posy < 0)
|
||||
needs_repositioning = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (!count) {
|
||||
launcher->area.height = 0;
|
||||
}
|
||||
|
||||
if (!needs_repositioning) {
|
||||
if (panel_horizontal) {
|
||||
if (launcher->area.width == size)
|
||||
return FALSE;
|
||||
launcher->area.width = size;
|
||||
} else {
|
||||
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
|
||||
// here icons_per_row always higher than 0
|
||||
icons_per_row = (width + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
|
||||
margin = 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 = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
|
||||
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
|
||||
if (launcher->area.height == size)
|
||||
return FALSE;
|
||||
launcher->area.height = size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,31 +286,29 @@ gboolean resize_launcher(void *obj)
|
||||
posy = top_border_width(&launcher->area) + launcher->area.paddingxlr;
|
||||
}
|
||||
|
||||
int i;
|
||||
GSList *l;
|
||||
for (i = 1, l = launcher->list_icons; l; i++, l = l->next) {
|
||||
int i = 0;
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
|
||||
if (!launcherIcon->area.on_screen)
|
||||
continue;
|
||||
i++;
|
||||
launcherIcon->y = posy;
|
||||
launcherIcon->x = posx;
|
||||
launcherIcon->area.posy = ((Area *)launcherIcon->area.parent)->posy + launcherIcon->y;
|
||||
launcherIcon->area.posx = ((Area *)launcherIcon->area.parent)->posx + launcherIcon->x;
|
||||
launcherIcon->area.width = launcherIcon->icon_size;
|
||||
launcherIcon->area.height = launcherIcon->icon_size;
|
||||
launcher_icon_on_change_layout(launcherIcon);
|
||||
// printf("launcher %d : %d,%d\n", i, posx, posy);
|
||||
if (panel_horizontal) {
|
||||
if (i % icons_per_column) {
|
||||
posy += icon_size + launcher->area.paddingx;
|
||||
posy += launcher->icon_size + launcher->area.paddingx;
|
||||
} else {
|
||||
posy = start;
|
||||
posx += (icon_size + launcher->area.paddingx);
|
||||
posx += (launcher->icon_size + launcher->area.paddingx);
|
||||
}
|
||||
} else {
|
||||
if (i % icons_per_row) {
|
||||
posx += icon_size + launcher->area.paddingx;
|
||||
posx += launcher->icon_size + launcher->area.paddingx;
|
||||
} else {
|
||||
posx = start;
|
||||
posy += (icon_size + launcher->area.paddingx);
|
||||
posy += (launcher->icon_size + launcher->area.paddingx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,6 +337,12 @@ void launcher_icon_on_change_layout(void *obj)
|
||||
launcherIcon->area.height = launcherIcon->icon_size;
|
||||
}
|
||||
|
||||
int launcher_icon_compute_desired_size(void *obj)
|
||||
{
|
||||
LauncherIcon *icon = (LauncherIcon *)obj;
|
||||
return icon->icon_size;
|
||||
}
|
||||
|
||||
char *launcher_icon_get_tooltip_text(void *obj)
|
||||
{
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)obj;
|
||||
@@ -350,12 +372,7 @@ void draw_launcher_icon(void *obj, cairo_t *c)
|
||||
void launcher_icon_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)obj;
|
||||
fprintf(stderr,
|
||||
"%*sIcon: w = h = %d, name = %s\n",
|
||||
indent,
|
||||
"",
|
||||
launcherIcon->icon_size,
|
||||
launcherIcon->icon_name);
|
||||
fprintf(stderr, "%*sIcon: w = h = %d, name = %s\n", indent, "", launcherIcon->icon_size, launcherIcon->icon_name);
|
||||
}
|
||||
|
||||
Imlib_Image scale_icon(Imlib_Image original, int icon_size)
|
||||
@@ -401,6 +418,8 @@ void free_icon(Imlib_Image icon)
|
||||
|
||||
void launcher_action(LauncherIcon *icon, XEvent *evt)
|
||||
{
|
||||
launcher_reload_icon((Launcher *)icon->area.parent, icon);
|
||||
launcher_reload_hidden_icons((Launcher *)icon->area.parent);
|
||||
char *cmd = calloc(strlen(icon->cmd) + 10, 1);
|
||||
sprintf(cmd, "(%s&)", icon->cmd);
|
||||
#if HAVE_SN
|
||||
@@ -436,6 +455,8 @@ void launcher_action(LauncherIcon *icon, XEvent *evt)
|
||||
// Allow children to exist after parent destruction
|
||||
setsid();
|
||||
// Run the command
|
||||
if (icon->cwd)
|
||||
chdir(icon->cwd);
|
||||
execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL);
|
||||
fprintf(stderr, "Failed to execlp %s\n", icon->cmd);
|
||||
#if HAVE_SN
|
||||
@@ -455,66 +476,135 @@ void launcher_action(LauncherIcon *icon, XEvent *evt)
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Populates the list_icons list from the list_apps list
|
||||
void launcher_load_icons(Launcher *launcher)
|
||||
{
|
||||
// Load apps (.desktop style launcher items)
|
||||
GSList *app = launcher->list_apps;
|
||||
int index = 0;
|
||||
while (app != NULL) {
|
||||
DesktopEntry entry;
|
||||
read_desktop_file(app->data, &entry);
|
||||
if (entry.exec) {
|
||||
LauncherIcon *launcherIcon = calloc(1, sizeof(LauncherIcon));
|
||||
launcherIcon->area.panel = launcher->area.panel;
|
||||
snprintf(launcherIcon->area.name,
|
||||
sizeof(launcherIcon->area.name),
|
||||
"LauncherIcon %s",
|
||||
entry.name ? entry.name : "null");
|
||||
launcherIcon->area._draw_foreground = draw_launcher_icon;
|
||||
launcherIcon->area.size_mode = LAYOUT_FIXED;
|
||||
launcherIcon->area._resize = NULL;
|
||||
launcherIcon->area.resize_needed = 0;
|
||||
schedule_redraw(&launcherIcon->area);
|
||||
launcherIcon->area.has_mouse_over_effect = panel_config.mouse_effects;
|
||||
launcherIcon->area.has_mouse_press_effect = launcherIcon->area.has_mouse_over_effect;
|
||||
launcherIcon->area.bg = launcher_icon_bg;
|
||||
launcherIcon->area.on_screen = TRUE;
|
||||
launcherIcon->area._on_change_layout = launcher_icon_on_change_layout;
|
||||
launcherIcon->area._dump_geometry = launcher_icon_dump_geometry;
|
||||
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(DEFAULT_ICON);
|
||||
launcherIcon->icon_size = 1;
|
||||
if (entry.name) {
|
||||
if (entry.generic_name) {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s (%s)", entry.name, entry.generic_name);
|
||||
} else {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.name);
|
||||
}
|
||||
} else {
|
||||
if (entry.generic_name) {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.generic_name);
|
||||
} else if (entry.exec) {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.exec);
|
||||
}
|
||||
}
|
||||
launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon);
|
||||
add_area(&launcherIcon->area, (Area *)launcher);
|
||||
index++;
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)calloc(1, sizeof(LauncherIcon));
|
||||
launcherIcon->area.panel = launcher->area.panel;
|
||||
launcherIcon->area._draw_foreground = draw_launcher_icon;
|
||||
launcherIcon->area.size_mode = LAYOUT_FIXED;
|
||||
launcherIcon->area._resize = NULL;
|
||||
launcherIcon->area._compute_desired_size = launcher_icon_compute_desired_size;
|
||||
sprintf(launcherIcon->area.name, "LauncherIcon %d", index);
|
||||
launcherIcon->area.resize_needed = 0;
|
||||
launcherIcon->area.has_mouse_over_effect = panel_config.mouse_effects;
|
||||
launcherIcon->area.has_mouse_press_effect = launcherIcon->area.has_mouse_over_effect;
|
||||
launcherIcon->area.bg = launcher_icon_bg;
|
||||
launcherIcon->area.on_screen = TRUE;
|
||||
launcherIcon->area.posx = -1;
|
||||
launcherIcon->area._on_change_layout = launcher_icon_on_change_layout;
|
||||
launcherIcon->area._dump_geometry = launcher_icon_dump_geometry;
|
||||
if (launcher_tooltip_enabled) {
|
||||
launcherIcon->area._get_tooltip_text = launcher_icon_get_tooltip_text;
|
||||
} else {
|
||||
launcherIcon->area._get_tooltip_text = NULL;
|
||||
}
|
||||
free_desktop_entry(&entry);
|
||||
launcherIcon->config_path = strdup(app->data);
|
||||
add_area(&launcherIcon->area, (Area *)launcher);
|
||||
launcher->list_icons = g_slist_append(launcher->list_icons, launcherIcon);
|
||||
launcherIcon->icon_size = launcher->icon_size;
|
||||
launcher_reload_icon(launcher, launcherIcon);
|
||||
instantiate_area_gradients(&launcherIcon->area);
|
||||
app = g_slist_next(app);
|
||||
}
|
||||
}
|
||||
|
||||
// Populates the icon_theme_wrapper list
|
||||
void launcher_load_themes(Launcher *launcher)
|
||||
void launcher_reload_icon(Launcher *launcher, LauncherIcon *launcherIcon)
|
||||
{
|
||||
launcher->icon_theme_wrapper =
|
||||
DesktopEntry entry;
|
||||
if (read_desktop_file(launcherIcon->config_path, &entry) && entry.exec) {
|
||||
schedule_redraw(&launcherIcon->area);
|
||||
if (launcherIcon->cmd)
|
||||
free(launcherIcon->cmd);
|
||||
launcherIcon->cmd = strdup(entry.exec);
|
||||
if (launcherIcon->cwd)
|
||||
free(launcherIcon->cwd);
|
||||
if (entry.cwd)
|
||||
launcherIcon->cwd = strdup(entry.cwd);
|
||||
else
|
||||
launcherIcon->cwd = NULL;
|
||||
if (launcherIcon->icon_name)
|
||||
free(launcherIcon->icon_name);
|
||||
launcherIcon->icon_name = entry.icon ? strdup(entry.icon) : strdup(DEFAULT_ICON);
|
||||
if (entry.name) {
|
||||
if (entry.generic_name) {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s (%s)", entry.name, entry.generic_name);
|
||||
} else {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.name);
|
||||
}
|
||||
} else {
|
||||
if (entry.generic_name) {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.generic_name);
|
||||
} else if (entry.exec) {
|
||||
launcherIcon->icon_tooltip = g_strdup_printf("%s", entry.exec);
|
||||
}
|
||||
}
|
||||
launcher_reload_icon_image(launcher, launcherIcon);
|
||||
show(&launcherIcon->area);
|
||||
} else {
|
||||
hide(&launcherIcon->area);
|
||||
}
|
||||
free_desktop_entry(&entry);
|
||||
}
|
||||
|
||||
void launcher_reload_hidden_icons(Launcher *launcher)
|
||||
{
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (!launcherIcon->area.on_screen)
|
||||
launcher_reload_icon(launcher, launcherIcon);
|
||||
}
|
||||
}
|
||||
|
||||
void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon)
|
||||
{
|
||||
free_icon(launcherIcon->image);
|
||||
free_icon(launcherIcon->image_hover);
|
||||
free_icon(launcherIcon->image_pressed);
|
||||
launcherIcon->image = NULL;
|
||||
|
||||
char *new_icon_path = get_icon_path(icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size, TRUE);
|
||||
if (new_icon_path)
|
||||
launcherIcon->image = load_image(new_icon_path, TRUE);
|
||||
// On loading error, fallback to default
|
||||
if (!launcherIcon->image) {
|
||||
free(new_icon_path);
|
||||
new_icon_path = get_icon_path(icon_theme_wrapper, DEFAULT_ICON, launcherIcon->icon_size, TRUE);
|
||||
if (new_icon_path)
|
||||
launcherIcon->image = load_image(new_icon_path, TRUE);
|
||||
}
|
||||
Imlib_Image original = launcherIcon->image;
|
||||
launcherIcon->image = scale_icon(launcherIcon->image, launcherIcon->icon_size);
|
||||
free_icon(original);
|
||||
free(launcherIcon->icon_path);
|
||||
launcherIcon->icon_path = new_icon_path;
|
||||
// fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
|
||||
|
||||
if (panel_config.mouse_effects) {
|
||||
launcherIcon->image_hover = adjust_icon(launcherIcon->image,
|
||||
panel_config.mouse_over_alpha,
|
||||
panel_config.mouse_over_saturation,
|
||||
panel_config.mouse_over_brightness);
|
||||
launcherIcon->image_pressed = adjust_icon(launcherIcon->image,
|
||||
panel_config.mouse_pressed_alpha,
|
||||
panel_config.mouse_pressed_saturation,
|
||||
panel_config.mouse_pressed_brightness);
|
||||
}
|
||||
schedule_redraw(&launcherIcon->area);
|
||||
}
|
||||
|
||||
void load_icon_themes()
|
||||
{
|
||||
if (icon_theme_wrapper)
|
||||
return;
|
||||
icon_theme_wrapper =
|
||||
load_themes(launcher_icon_theme_override
|
||||
? (icon_theme_name_config ? icon_theme_name_config
|
||||
: icon_theme_name_xsettings ? icon_theme_name_xsettings : "hicolor")
|
||||
@@ -524,16 +614,11 @@ void launcher_load_themes(Launcher *launcher)
|
||||
|
||||
void launcher_default_icon_theme_changed()
|
||||
{
|
||||
if (!launcher_enabled)
|
||||
return;
|
||||
if (launcher_icon_theme_override && icon_theme_name_config)
|
||||
return;
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
Launcher *launcher = &panels[i].launcher;
|
||||
cleanup_launcher_theme(launcher);
|
||||
launcher_load_themes(launcher);
|
||||
launcher_load_icons(launcher);
|
||||
launcher->area.resize_needed = 1;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
@@ -12,26 +12,31 @@
|
||||
#include "xsettings-client.h"
|
||||
#include "icon-theme-common.h"
|
||||
|
||||
extern IconThemeWrapper *icon_theme_wrapper;
|
||||
void load_icon_themes();
|
||||
void free_icon_themes();
|
||||
|
||||
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*
|
||||
IconThemeWrapper *icon_theme_wrapper;
|
||||
int icon_size;
|
||||
} Launcher;
|
||||
|
||||
typedef struct LauncherIcon {
|
||||
// always start with area
|
||||
Area area;
|
||||
char *config_path;
|
||||
Imlib_Image image;
|
||||
Imlib_Image image_hover;
|
||||
Imlib_Image image_pressed;
|
||||
char *cmd;
|
||||
char *cwd;
|
||||
char *icon_name;
|
||||
char *icon_path;
|
||||
char *icon_tooltip;
|
||||
int icon_size;
|
||||
int is_app_desktop;
|
||||
int x, y;
|
||||
} LauncherIcon;
|
||||
|
||||
@@ -46,6 +51,7 @@ extern char *icon_theme_name_config;
|
||||
extern int launcher_icon_theme_override;
|
||||
extern int startup_notifications;
|
||||
extern Background *launcher_icon_bg;
|
||||
extern GList *launcher_icon_gradients;
|
||||
|
||||
// default global data
|
||||
void default_launcher();
|
||||
@@ -62,8 +68,6 @@ void launcher_default_icon_theme_changed();
|
||||
|
||||
// Populates the list_icons list
|
||||
void launcher_load_icons(Launcher *launcher);
|
||||
// Populates the list_themes list
|
||||
void launcher_load_themes(Launcher *launcher);
|
||||
void launcher_action(LauncherIcon *icon, XEvent *e);
|
||||
|
||||
void test_launcher_read_desktop_file();
|
||||
|
||||
455
src/panel.c
455
src/panel.c
@@ -56,11 +56,13 @@ gboolean panel_refresh;
|
||||
gboolean task_dragged;
|
||||
char *panel_window_name = NULL;
|
||||
gboolean debug_geometry;
|
||||
gboolean debug_gradients;
|
||||
|
||||
gboolean panel_autohide;
|
||||
int panel_autohide_show_timeout;
|
||||
int panel_autohide_hide_timeout;
|
||||
int panel_autohide_height;
|
||||
gboolean panel_shrink;
|
||||
Strut panel_strut_policy;
|
||||
char *panel_items_order;
|
||||
|
||||
@@ -73,6 +75,7 @@ Panel *panels;
|
||||
int num_panels;
|
||||
|
||||
GArray *backgrounds;
|
||||
GArray *gradients;
|
||||
|
||||
Imlib_Image default_icon;
|
||||
char *default_font = NULL;
|
||||
@@ -90,6 +93,7 @@ void default_panel()
|
||||
panel_autohide_show_timeout = 0;
|
||||
panel_autohide_hide_timeout = 0;
|
||||
panel_autohide_height = 5; // for vertical panels this is of course the width
|
||||
panel_shrink = FALSE;
|
||||
panel_strut_policy = STRUT_FOLLOW_SIZE;
|
||||
panel_dock = FALSE; // default not in the dock
|
||||
panel_layer = BOTTOM_LAYER; // default is bottom layer
|
||||
@@ -98,6 +102,7 @@ void default_panel()
|
||||
max_tick_urgent = 14;
|
||||
mouse_left = TOGGLE_ICONIFY;
|
||||
backgrounds = g_array_new(0, 0, sizeof(Background));
|
||||
gradients = g_array_new(0, 0, sizeof(GradientClass));
|
||||
|
||||
memset(&panel_config, 0, sizeof(Panel));
|
||||
snprintf(panel_config.area.name, sizeof(panel_config.area.name), "Panel");
|
||||
@@ -113,6 +118,9 @@ void default_panel()
|
||||
Background transparent_bg;
|
||||
init_background(&transparent_bg);
|
||||
g_array_append_val(backgrounds, transparent_bg);
|
||||
GradientClass transparent_gradient;
|
||||
init_gradient(&transparent_gradient, GRADIENT_VERTICAL);
|
||||
g_array_append_val(gradients, transparent_gradient);
|
||||
}
|
||||
|
||||
void cleanup_panel()
|
||||
@@ -136,6 +144,7 @@ void cleanup_panel()
|
||||
XDestroyWindow(server.display, p->main_win);
|
||||
p->main_win = 0;
|
||||
stop_timeout(p->autohide_timeout);
|
||||
cleanup_freespace(p);
|
||||
}
|
||||
|
||||
free(panel_items_order);
|
||||
@@ -144,9 +153,17 @@ void cleanup_panel()
|
||||
panel_window_name = NULL;
|
||||
free(panels);
|
||||
panels = NULL;
|
||||
if (backgrounds)
|
||||
g_array_free(backgrounds, 1);
|
||||
|
||||
free_area(&panel_config.area);
|
||||
|
||||
g_array_free(backgrounds, TRUE);
|
||||
backgrounds = NULL;
|
||||
if (gradients) {
|
||||
for (guint i = 0; i < gradients->len; i++)
|
||||
cleanup_gradient(&g_array_index(gradients, GradientClass, i));
|
||||
g_array_free(gradients, TRUE);
|
||||
}
|
||||
gradients = NULL;
|
||||
pango_font_description_free(panel_config.g_task.font_desc);
|
||||
panel_config.g_task.font_desc = NULL;
|
||||
pango_font_description_free(panel_config.taskbarname_font_desc);
|
||||
@@ -163,6 +180,8 @@ void init_panel()
|
||||
|
||||
fprintf(stderr, "panel items: %s\n", panel_items_order);
|
||||
|
||||
icon_theme_wrapper = NULL;
|
||||
|
||||
init_tooltip();
|
||||
init_systray();
|
||||
init_launcher();
|
||||
@@ -171,7 +190,9 @@ void init_panel()
|
||||
init_battery();
|
||||
#endif
|
||||
init_taskbar();
|
||||
init_separator();
|
||||
init_execp();
|
||||
init_button();
|
||||
|
||||
// number of panels (one monitor or 'all' monitors)
|
||||
if (panel_config.monitor >= 0)
|
||||
@@ -204,7 +225,9 @@ void init_panel()
|
||||
p->area.size_mode = LAYOUT_DYNAMIC;
|
||||
p->area._resize = resize_panel;
|
||||
p->area._clear = panel_clear_background;
|
||||
p->separator_list = NULL;
|
||||
init_panel_size_and_position(p);
|
||||
instantiate_area_gradients(&p->area);
|
||||
// add children according to panel_items
|
||||
for (int k = 0; k < strlen(panel_items_order); k++) {
|
||||
if (panel_items_order[k] == 'L')
|
||||
@@ -223,8 +246,12 @@ void init_panel()
|
||||
init_clock_panel(p);
|
||||
if (panel_items_order[k] == 'F' && !strstr(panel_items_order, "T"))
|
||||
init_freespace_panel(p);
|
||||
if (panel_items_order[k] == ':')
|
||||
init_separator_panel(p);
|
||||
if (panel_items_order[k] == 'E')
|
||||
init_execp_panel(p);
|
||||
if (panel_items_order[k] == 'P')
|
||||
init_button_panel(p);
|
||||
}
|
||||
set_panel_items_order(p);
|
||||
|
||||
@@ -269,17 +296,15 @@ void init_panel()
|
||||
|
||||
if (panel_autohide)
|
||||
autohide_trigger_hide(p);
|
||||
|
||||
update_taskbar_visibility(p);
|
||||
}
|
||||
|
||||
taskbar_refresh_tasklist();
|
||||
reset_active_task();
|
||||
update_all_taskbars_visibility();
|
||||
}
|
||||
|
||||
void init_panel_size_and_position(Panel *panel)
|
||||
void panel_compute_size(Panel *panel)
|
||||
{
|
||||
// detect panel size
|
||||
if (panel_horizontal) {
|
||||
if (panel->area.width == 0) {
|
||||
panel->fractional_width = TRUE;
|
||||
@@ -332,6 +357,11 @@ void init_panel_size_and_position(Panel *panel)
|
||||
if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height)
|
||||
panel->area.height = server.monitors[panel->monitor].height - panel->marginy;
|
||||
|
||||
panel->max_size = panel_horizontal ? panel->area.width : panel->area.height;
|
||||
}
|
||||
|
||||
void panel_compute_position(Panel *panel)
|
||||
{
|
||||
// panel position determined here
|
||||
if (panel_position & LEFT) {
|
||||
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
|
||||
@@ -372,6 +402,12 @@ void init_panel_size_and_position(Panel *panel)
|
||||
// panel->area.height);
|
||||
}
|
||||
|
||||
void init_panel_size_and_position(Panel *panel)
|
||||
{
|
||||
panel_compute_size(panel);
|
||||
panel_compute_position(panel);
|
||||
}
|
||||
|
||||
gboolean resize_panel(void *obj)
|
||||
{
|
||||
Panel *panel = (Panel *)obj;
|
||||
@@ -383,94 +419,117 @@ gboolean resize_panel(void *obj)
|
||||
int width = panel->taskbar[server.desktop].area.width;
|
||||
int height = panel->taskbar[server.desktop].area.height;
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
panel->taskbar[i].area.resize_needed =
|
||||
panel->taskbar[i].area.width != width || panel->taskbar[i].area.height != height;
|
||||
panel->taskbar[i].area.width = width;
|
||||
panel->taskbar[i].area.height = height;
|
||||
panel->taskbar[i].area.resize_needed = 1;
|
||||
}
|
||||
}
|
||||
if (taskbar_mode == MULTI_DESKTOP && taskbar_enabled && taskbar_distribute_size) {
|
||||
// Distribute the available space between taskbars
|
||||
|
||||
// Compute the total available size, and the total size requested by the taskbars
|
||||
int total_size = 0;
|
||||
int total_name_size = 0;
|
||||
int total_items = 0;
|
||||
} else if (taskbar_mode == MULTI_DESKTOP && taskbar_enabled && taskbar_distribute_size) {
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
if (panel_horizontal) {
|
||||
total_size += panel->taskbar[i].area.width;
|
||||
} else {
|
||||
total_size += panel->taskbar[i].area.height;
|
||||
}
|
||||
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
GList *l;
|
||||
for (l = taskbar->area.children; l; l = l->next) {
|
||||
taskbar->area.old_width = taskbar->area.width;
|
||||
taskbar->area.old_height = taskbar->area.height;
|
||||
}
|
||||
|
||||
// The total available size
|
||||
int total_size = 0;
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
total_size += panel_horizontal ? taskbar->area.width : taskbar->area.height;
|
||||
}
|
||||
|
||||
// Reserve size for padding, taskbarname and spacings
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width = 2 * taskbar->area.paddingxlr;
|
||||
else
|
||||
taskbar->area.height = 2 * taskbar->area.paddingxlr;
|
||||
if (taskbarname_enabled && taskbar->area.children) {
|
||||
Area *name = (Area *)taskbar->area.children->data;
|
||||
if (name->on_screen) {
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += name->width;
|
||||
else
|
||||
taskbar->area.height += name->height;
|
||||
}
|
||||
}
|
||||
gboolean first_child = TRUE;
|
||||
for (GList *l = taskbar->area.children; l; l = l->next) {
|
||||
Area *child = (Area *)l->data;
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
total_items++;
|
||||
}
|
||||
if (taskbarname_enabled) {
|
||||
if (taskbar->area.children) {
|
||||
total_items--;
|
||||
Area *name = (Area *)taskbar->area.children->data;
|
||||
if (panel_horizontal) {
|
||||
total_name_size += name->width;
|
||||
} else {
|
||||
total_name_size += name->height;
|
||||
}
|
||||
if (!first_child) {
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += taskbar->area.paddingx;
|
||||
else
|
||||
taskbar->area.height += taskbar->area.paddingy;
|
||||
}
|
||||
first_child = FALSE;
|
||||
}
|
||||
total_size -= panel_horizontal ? taskbar->area.width : taskbar->area.height;
|
||||
}
|
||||
|
||||
// Compute the total number of tasks
|
||||
int num_tasks = 0;
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
for (GList *l = taskbar->area.children; l; l = l->next) {
|
||||
Area *child = (Area *)l->data;
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
if (taskbarname_enabled && l == taskbar->area.children)
|
||||
continue;
|
||||
num_tasks++;
|
||||
}
|
||||
}
|
||||
// Distribute the space proportionally to the requested size (that is, to the
|
||||
// number of tasks in each taskbar)
|
||||
if (total_items) {
|
||||
int actual_name_size;
|
||||
if (total_name_size <= total_size) {
|
||||
actual_name_size = total_name_size / panel->num_desktops;
|
||||
} else {
|
||||
actual_name_size = total_size / panel->num_desktops;
|
||||
}
|
||||
total_size -= total_name_size;
|
||||
|
||||
// Distribute the remaining size between tasks
|
||||
if (num_tasks > 0) {
|
||||
int task_size = total_size / num_tasks;
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
|
||||
int requested_size = (panel_horizontal ? left_right_border_width(&taskbar->area)
|
||||
: top_bottom_border_width(&taskbar->area)) +
|
||||
2 * taskbar->area.paddingxlr;
|
||||
int items = 0;
|
||||
GList *l = taskbar->area.children;
|
||||
if (taskbarname_enabled)
|
||||
l = l->next;
|
||||
for (; l; l = l->next) {
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
for (GList *l = taskbar->area.children; l; l = l->next) {
|
||||
Area *child = (Area *)l->data;
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
items++;
|
||||
if (panel_horizontal) {
|
||||
requested_size += child->width + taskbar->area.paddingy;
|
||||
} else {
|
||||
requested_size += child->height + taskbar->area.paddingx;
|
||||
}
|
||||
if (taskbarname_enabled && l == taskbar->area.children)
|
||||
continue;
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += task_size;
|
||||
else
|
||||
taskbar->area.height += task_size;
|
||||
}
|
||||
if (panel_horizontal) {
|
||||
requested_size -= taskbar->area.paddingy;
|
||||
} else {
|
||||
requested_size -= taskbar->area.paddingx;
|
||||
}
|
||||
|
||||
if (panel_horizontal) {
|
||||
taskbar->area.width = actual_name_size + items / (float)total_items * total_size;
|
||||
} else {
|
||||
taskbar->area.height = actual_name_size + items / (float)total_items * total_size;
|
||||
}
|
||||
taskbar->area.resize_needed = 1;
|
||||
}
|
||||
} else {
|
||||
// No tasks => expand the first visible taskbar
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += total_size;
|
||||
else
|
||||
taskbar->area.height += total_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
taskbar->area.resize_needed =
|
||||
taskbar->area.old_width != taskbar->area.width || taskbar->area.old_height != taskbar->area.height;
|
||||
}
|
||||
}
|
||||
if (panel->freespace.area.on_screen)
|
||||
resize_freespace(&panel->freespace);
|
||||
for (GList *l = panel->freespace_list; l; l = g_list_next(l))
|
||||
resize_freespace(l->data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -491,7 +550,7 @@ void update_strut(Panel *p)
|
||||
long struts[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
if (panel_horizontal) {
|
||||
int height = p->area.height + p->marginy;
|
||||
if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && p->is_hidden))
|
||||
if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && panel_autohide))
|
||||
height = p->hidden_height;
|
||||
if (panel_position & TOP) {
|
||||
struts[2] = height + monitor.y;
|
||||
@@ -506,7 +565,7 @@ void update_strut(Panel *p)
|
||||
}
|
||||
} else {
|
||||
int width = p->area.width + p->marginx;
|
||||
if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && p->is_hidden))
|
||||
if (panel_strut_policy == STRUT_MINIMUM || (panel_strut_policy == STRUT_FOLLOW_SIZE && panel_autohide))
|
||||
width = p->hidden_width;
|
||||
if (panel_position & LEFT) {
|
||||
struts[0] = width + monitor.x;
|
||||
@@ -547,6 +606,9 @@ void set_panel_items_order(Panel *p)
|
||||
}
|
||||
|
||||
int i_execp = 0;
|
||||
int i_separator = 0;
|
||||
int i_freespace = 0;
|
||||
int i_button = 0;
|
||||
for (int k = 0; k < strlen(panel_items_order); k++) {
|
||||
if (panel_items_order[k] == 'L') {
|
||||
p->area.children = g_list_append(p->area.children, &p->launcher);
|
||||
@@ -566,14 +628,30 @@ void set_panel_items_order(Panel *p)
|
||||
}
|
||||
if (panel_items_order[k] == 'C')
|
||||
p->area.children = g_list_append(p->area.children, &p->clock);
|
||||
if (panel_items_order[k] == 'F')
|
||||
p->area.children = g_list_append(p->area.children, &p->freespace);
|
||||
if (panel_items_order[k] == 'F') {
|
||||
GList *item = g_list_nth(p->freespace_list, i_freespace);
|
||||
i_freespace++;
|
||||
if (item)
|
||||
p->area.children = g_list_append(p->area.children, (Area *)item->data);
|
||||
}
|
||||
if (panel_items_order[k] == ':') {
|
||||
GList *item = g_list_nth(p->separator_list, i_separator);
|
||||
i_separator++;
|
||||
if (item)
|
||||
p->area.children = g_list_append(p->area.children, (Area *)item->data);
|
||||
}
|
||||
if (panel_items_order[k] == 'E') {
|
||||
GList *item = g_list_nth(p->execp_list, i_execp);
|
||||
i_execp++;
|
||||
if (item)
|
||||
p->area.children = g_list_append(p->area.children, (Area *)item->data);
|
||||
}
|
||||
if (panel_items_order[k] == 'P') {
|
||||
GList *item = g_list_nth(p->button_list, i_button);
|
||||
i_button++;
|
||||
if (item)
|
||||
p->area.children = g_list_append(p->area.children, (Area *)item->data);
|
||||
}
|
||||
}
|
||||
initialize_positions(&p->area, 0);
|
||||
}
|
||||
@@ -589,13 +667,16 @@ void place_panel_all_desktops(Panel *p)
|
||||
PropModeReplace,
|
||||
(unsigned char *)&val,
|
||||
1);
|
||||
}
|
||||
|
||||
void set_panel_layer(Panel *p, Layer layer)
|
||||
{
|
||||
Atom state[4];
|
||||
state[0] = server.atom._NET_WM_STATE_SKIP_PAGER;
|
||||
state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR;
|
||||
state[2] = server.atom._NET_WM_STATE_STICKY;
|
||||
state[3] = panel_layer == BOTTOM_LAYER ? server.atom._NET_WM_STATE_BELOW : server.atom._NET_WM_STATE_ABOVE;
|
||||
int num_atoms = panel_layer == NORMAL_LAYER ? 3 : 4;
|
||||
state[3] = layer == BOTTOM_LAYER ? server.atom._NET_WM_STATE_BELOW : server.atom._NET_WM_STATE_ABOVE;
|
||||
int num_atoms = layer == NORMAL_LAYER ? 3 : 4;
|
||||
XChangeProperty(server.display,
|
||||
p->main_win,
|
||||
server.atom._NET_WM_STATE,
|
||||
@@ -621,6 +702,90 @@ void replace_panel_all_desktops(Panel *p)
|
||||
XSync(server.display, False);
|
||||
}
|
||||
|
||||
void set_panel_window_geometry(Panel *panel)
|
||||
{
|
||||
update_strut(panel);
|
||||
|
||||
// Fixed position and non-resizable window
|
||||
// Allow panel move and resize when tint2 reload config file
|
||||
int minwidth = panel_autohide ? panel->hidden_width : panel->area.width;
|
||||
int minheight = panel_autohide ? panel->hidden_height : panel->area.height;
|
||||
XSizeHints size_hints;
|
||||
size_hints.flags = PPosition | PMinSize | PMaxSize;
|
||||
size_hints.min_width = minwidth;
|
||||
size_hints.max_width = panel->area.width;
|
||||
size_hints.min_height = minheight;
|
||||
size_hints.max_height = panel->area.height;
|
||||
XSetWMNormalHints(server.display, panel->main_win, &size_hints);
|
||||
|
||||
if (!panel->is_hidden) {
|
||||
if (panel_horizontal) {
|
||||
if (panel_position & TOP)
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->area.width,
|
||||
panel->area.height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->area.width,
|
||||
panel->area.height);
|
||||
} else {
|
||||
if (panel_position & LEFT)
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->area.width,
|
||||
panel->area.height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->area.width,
|
||||
panel->area.height);
|
||||
}
|
||||
} else {
|
||||
int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height;
|
||||
if (panel_horizontal) {
|
||||
if (panel_position & TOP)
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->hidden_width,
|
||||
panel->hidden_height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy + diff,
|
||||
panel->hidden_width,
|
||||
panel->hidden_height);
|
||||
} else {
|
||||
if (panel_position & LEFT)
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->hidden_width,
|
||||
panel->hidden_height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx + diff,
|
||||
panel->posy,
|
||||
panel->hidden_width,
|
||||
panel->hidden_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_panel_properties(Panel *p)
|
||||
{
|
||||
XStoreName(server.display, p->main_win, panel_window_name);
|
||||
@@ -660,6 +825,7 @@ void set_panel_properties(Panel *p)
|
||||
1);
|
||||
|
||||
place_panel_all_desktops(p);
|
||||
set_panel_layer(p, panel_layer);
|
||||
|
||||
XWMHints wmhints;
|
||||
memset(&wmhints, 0, sizeof(wmhints));
|
||||
@@ -697,26 +863,14 @@ void set_panel_properties(Panel *p)
|
||||
(unsigned char *)&version,
|
||||
1);
|
||||
|
||||
update_strut(p);
|
||||
|
||||
// Fixed position and non-resizable window
|
||||
// Allow panel move and resize when tint2 reload config file
|
||||
int minwidth = panel_autohide ? p->hidden_width : p->area.width;
|
||||
int minheight = panel_autohide ? p->hidden_height : p->area.height;
|
||||
XSizeHints size_hints;
|
||||
size_hints.flags = PPosition | PMinSize | PMaxSize;
|
||||
size_hints.min_width = minwidth;
|
||||
size_hints.max_width = p->area.width;
|
||||
size_hints.min_height = minheight;
|
||||
size_hints.max_height = p->area.height;
|
||||
XSetWMNormalHints(server.display, p->main_win, &size_hints);
|
||||
|
||||
// Set WM_CLASS
|
||||
XClassHint *classhint = XAllocClassHint();
|
||||
classhint->res_name = (char *)"tint2";
|
||||
classhint->res_class = (char *)"Tint2";
|
||||
XSetClassHint(server.display, p->main_win, classhint);
|
||||
XFree(classhint);
|
||||
|
||||
set_panel_window_geometry(p);
|
||||
}
|
||||
|
||||
void panel_clear_background(void *obj)
|
||||
@@ -844,6 +998,16 @@ Execp *click_execp(Panel *panel, int x, int y)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Button *click_button(Panel *panel, int x, int y)
|
||||
{
|
||||
for (GList *l = panel->button_list; l; l = l->next) {
|
||||
Button *button = (Button *)l->data;
|
||||
if (area_is_under_mouse(button, x, y))
|
||||
return button;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void stop_autohide_timeout(Panel *p)
|
||||
{
|
||||
stop_timeout(p->autohide_timeout);
|
||||
@@ -854,68 +1018,22 @@ void autohide_show(void *p)
|
||||
Panel *panel = (Panel *)p;
|
||||
stop_autohide_timeout(panel);
|
||||
panel->is_hidden = 0;
|
||||
|
||||
XMapSubwindows(server.display, panel->main_win); // systray windows
|
||||
if (panel_horizontal) {
|
||||
if (panel_position & TOP)
|
||||
XResizeWindow(server.display, panel->main_win, panel->area.width, panel->area.height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->area.width,
|
||||
panel->area.height);
|
||||
} else {
|
||||
if (panel_position & LEFT)
|
||||
XResizeWindow(server.display, panel->main_win, panel->area.width, panel->area.height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy,
|
||||
panel->area.width,
|
||||
panel->area.height);
|
||||
}
|
||||
if (panel_strut_policy == STRUT_FOLLOW_SIZE)
|
||||
update_strut(panel);
|
||||
set_panel_window_geometry(panel);
|
||||
set_panel_layer(panel, TOP_LAYER);
|
||||
refresh_systray = TRUE; // ugly hack, because we actually only need to call XSetBackgroundPixmap
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void autohide_hide(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
stop_autohide_timeout(panel);
|
||||
set_panel_layer(panel, panel_layer);
|
||||
panel->is_hidden = TRUE;
|
||||
if (panel_strut_policy == STRUT_FOLLOW_SIZE)
|
||||
update_strut(panel);
|
||||
|
||||
XUnmapSubwindows(server.display, panel->main_win); // systray windows
|
||||
int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height;
|
||||
// printf("autohide_hide : diff %d, w %d, h %d\n", diff, panel->hidden_width, panel->hidden_height);
|
||||
if (panel_horizontal) {
|
||||
if (panel_position & TOP)
|
||||
XResizeWindow(server.display, panel->main_win, panel->hidden_width, panel->hidden_height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx,
|
||||
panel->posy + diff,
|
||||
panel->hidden_width,
|
||||
panel->hidden_height);
|
||||
} else {
|
||||
if (panel_position & LEFT)
|
||||
XResizeWindow(server.display, panel->main_win, panel->hidden_width, panel->hidden_height);
|
||||
else
|
||||
XMoveResizeWindow(server.display,
|
||||
panel->main_win,
|
||||
panel->posx + diff,
|
||||
panel->posy,
|
||||
panel->hidden_width,
|
||||
panel->hidden_height);
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
set_panel_window_geometry(panel);
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void autohide_trigger_show(Panel *p)
|
||||
@@ -940,11 +1058,40 @@ void autohide_trigger_hide(Panel *p)
|
||||
change_timeout(&p->autohide_timeout, panel_autohide_hide_timeout, 0, autohide_hide, p);
|
||||
}
|
||||
|
||||
void shrink_panel(Panel *panel)
|
||||
{
|
||||
if (!panel_shrink)
|
||||
return;
|
||||
int size = MIN(compute_desired_size(&panel->area), panel->max_size);
|
||||
gboolean update = FALSE;
|
||||
if (panel_horizontal) {
|
||||
if (panel->area.width != size) {
|
||||
panel->area.width = size;
|
||||
update = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (panel->area.height != size) {
|
||||
panel->area.height = size;
|
||||
update = TRUE;
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
panel_compute_position(panel);
|
||||
set_panel_window_geometry(panel);
|
||||
set_panel_background(panel);
|
||||
panel->area.resize_needed = TRUE;
|
||||
systray.area.resize_needed = TRUE;
|
||||
schedule_redraw(&systray.area);
|
||||
refresh_systray = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void render_panel(Panel *panel)
|
||||
{
|
||||
relayout(&panel->area);
|
||||
if (debug_geometry)
|
||||
area_dump_geometry(&panel->area, 0);
|
||||
update_dependent_gradients(&panel->area);
|
||||
draw_tree(&panel->area);
|
||||
}
|
||||
|
||||
@@ -957,7 +1104,16 @@ const char *get_default_font()
|
||||
|
||||
void default_icon_theme_changed()
|
||||
{
|
||||
if (!launcher_enabled && !panel_config.button_list)
|
||||
return;
|
||||
if (launcher_icon_theme_override && icon_theme_name_config)
|
||||
return;
|
||||
|
||||
free_icon_themes();
|
||||
load_icon_themes();
|
||||
|
||||
launcher_default_icon_theme_changed();
|
||||
button_default_icon_theme_changed();
|
||||
}
|
||||
|
||||
void default_font_changed()
|
||||
@@ -967,7 +1123,16 @@ void default_font_changed()
|
||||
#endif
|
||||
clock_default_font_changed();
|
||||
execp_default_font_changed();
|
||||
button_default_font_changed();
|
||||
taskbar_default_font_changed();
|
||||
taskbarname_default_font_changed();
|
||||
tooltip_default_font_changed();
|
||||
}
|
||||
|
||||
void _schedule_panel_redraw(const char *file, const char *function, const int line)
|
||||
{
|
||||
panel_refresh = TRUE;
|
||||
if (debug_fps) {
|
||||
fprintf(stderr, YELLOW "%s %s %d: triggering panel redraw" RESET "\n", file, function, line);
|
||||
}
|
||||
}
|
||||
|
||||
20
src/panel.h
20
src/panel.h
@@ -22,6 +22,8 @@
|
||||
#include "launcher.h"
|
||||
#include "freespace.h"
|
||||
#include "execplugin.h"
|
||||
#include "separator.h"
|
||||
#include "button.h"
|
||||
|
||||
#ifdef ENABLE_BATTERY
|
||||
#include "battery.h"
|
||||
@@ -78,15 +80,19 @@ extern gboolean panel_autohide;
|
||||
extern int panel_autohide_show_timeout;
|
||||
extern int panel_autohide_hide_timeout;
|
||||
extern int panel_autohide_height; // for vertical panels this is of course the width
|
||||
extern gboolean panel_shrink;
|
||||
extern Strut panel_strut_policy;
|
||||
extern char *panel_items_order;
|
||||
extern int max_tick_urgent;
|
||||
extern GArray *backgrounds;
|
||||
extern GArray *gradients;
|
||||
extern Imlib_Image default_icon;
|
||||
#define DEFAULT_FONT "sans 10"
|
||||
extern char *default_font;
|
||||
extern XSettingsClient *xsettings_client;
|
||||
extern gboolean debug_geometry;
|
||||
extern gboolean debug_fps;
|
||||
extern gboolean debug_frames;
|
||||
|
||||
typedef struct Panel {
|
||||
Area area;
|
||||
@@ -98,6 +104,7 @@ typedef struct Panel {
|
||||
int posx, posy;
|
||||
int marginx, marginy;
|
||||
gboolean fractional_width, fractional_height;
|
||||
int max_size;
|
||||
int monitor;
|
||||
int font_shadow;
|
||||
gboolean mouse_effects;
|
||||
@@ -126,8 +133,10 @@ typedef struct Panel {
|
||||
#endif
|
||||
|
||||
Launcher launcher;
|
||||
FreeSpace freespace;
|
||||
GList *freespace_list;
|
||||
GList *separator_list;
|
||||
GList *execp_list;
|
||||
GList *button_list;
|
||||
|
||||
// Autohide
|
||||
gboolean is_hidden;
|
||||
@@ -153,11 +162,16 @@ void init_panel();
|
||||
void init_panel_size_and_position(Panel *panel);
|
||||
gboolean resize_panel(void *obj);
|
||||
void render_panel(Panel *panel);
|
||||
void shrink_panel(Panel *panel);
|
||||
void _schedule_panel_redraw(const char *file, const char *function, const int line);
|
||||
#define schedule_panel_redraw() _schedule_panel_redraw(__FILE__, __FUNCTION__, __LINE__)
|
||||
|
||||
void set_panel_items_order(Panel *p);
|
||||
void place_panel_all_desktops(Panel *p);
|
||||
void replace_panel_all_desktops(Panel *p);
|
||||
void set_panel_properties(Panel *p);
|
||||
void set_panel_window_geometry(Panel *panel);
|
||||
void set_panel_layer(Panel *p, Layer layer);
|
||||
|
||||
// draw background panel
|
||||
void set_panel_background(Panel *p);
|
||||
@@ -177,6 +191,7 @@ Battery *click_battery(Panel *panel, int x, int y);
|
||||
|
||||
Area *click_area(Panel *panel, int x, int y);
|
||||
Execp *click_execp(Panel *panel, int x, int y);
|
||||
Button *click_button(Panel *panel, int x, int y);
|
||||
|
||||
void autohide_show(void *p);
|
||||
void autohide_hide(void *p);
|
||||
@@ -188,4 +203,7 @@ const char *get_default_font();
|
||||
void default_icon_theme_changed();
|
||||
void default_font_changed();
|
||||
|
||||
void free_icon(Imlib_Image icon);
|
||||
Imlib_Image scale_icon(Imlib_Image original, int icon_size);
|
||||
|
||||
#endif
|
||||
|
||||
231
src/separator/separator.c
Normal file
231
src/separator/separator.c
Normal file
@@ -0,0 +1,231 @@
|
||||
// Tint2 : Separator plugin
|
||||
// Author: Oskari Rauta
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <cairo.h>
|
||||
#include <cairo-xlib.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "window.h"
|
||||
#include "server.h"
|
||||
#include "panel.h"
|
||||
#include "common.h"
|
||||
#include "separator.h"
|
||||
|
||||
int separator_compute_desired_size(void *obj);
|
||||
|
||||
Separator *create_separator()
|
||||
{
|
||||
Separator *separator = (Separator *)calloc(1, sizeof(Separator));
|
||||
separator->color.rgb[0] = 0.5;
|
||||
separator->color.rgb[1] = 0.5;
|
||||
separator->color.rgb[2] = 0.5;
|
||||
separator->color.alpha = 0.9;
|
||||
separator->style = SEPARATOR_DOTS;
|
||||
separator->thickness = 3;
|
||||
separator->area.paddingxlr = 1;
|
||||
return separator;
|
||||
}
|
||||
|
||||
void destroy_separator(void *obj)
|
||||
{
|
||||
Separator *separator = (Separator *)obj;
|
||||
remove_area(&separator->area);
|
||||
free_area(&separator->area);
|
||||
free_and_null(separator);
|
||||
}
|
||||
|
||||
gpointer copy_separator(gconstpointer arg, gpointer data)
|
||||
{
|
||||
Separator *old = (Separator *)arg;
|
||||
Separator *copy = (Separator *)calloc(1, sizeof(Separator));
|
||||
memcpy(copy, old, sizeof(Separator));
|
||||
return copy;
|
||||
}
|
||||
|
||||
void init_separator()
|
||||
{
|
||||
GList *to_remove = panel_config.separator_list;
|
||||
for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) {
|
||||
if (panel_items_order[k] == ':') {
|
||||
to_remove = to_remove->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_remove) {
|
||||
if (to_remove == panel_config.separator_list) {
|
||||
g_list_free_full(to_remove, destroy_separator);
|
||||
panel_config.separator_list = NULL;
|
||||
} else {
|
||||
// Cut panel_config.separator_list
|
||||
if (to_remove->prev)
|
||||
to_remove->prev->next = NULL;
|
||||
to_remove->prev = NULL;
|
||||
// Remove all elements of to_remove and to_remove itself
|
||||
g_list_free_full(to_remove, destroy_separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_separator_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
|
||||
// Make sure this is only done once if there are multiple items
|
||||
if (panel->separator_list)
|
||||
return;
|
||||
|
||||
// panel->separator_list is now a copy of the pointer panel_config.separator_list
|
||||
// We make it a deep copy
|
||||
panel->separator_list = g_list_copy_deep(panel_config.separator_list, copy_separator, NULL);
|
||||
|
||||
for (GList *l = panel->separator_list; l; l = l->next) {
|
||||
Separator *separator = (Separator *)l->data;
|
||||
if (!separator->area.bg)
|
||||
separator->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
separator->area.parent = p;
|
||||
separator->area.panel = p;
|
||||
snprintf(separator->area.name, sizeof(separator->area.name), "separator");
|
||||
separator->area.size_mode = LAYOUT_FIXED;
|
||||
separator->area.resize_needed = 1;
|
||||
separator->area.on_screen = TRUE;
|
||||
separator->area._resize = resize_separator;
|
||||
separator->area._compute_desired_size = separator_compute_desired_size;
|
||||
separator->area._draw_foreground = draw_separator;
|
||||
instantiate_area_gradients(&separator->area);
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup_separator()
|
||||
{
|
||||
// Cleanup frontends
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
g_list_free_full(panels[i].separator_list, destroy_separator);
|
||||
panels[i].separator_list = NULL;
|
||||
}
|
||||
|
||||
// Cleanup backends
|
||||
g_list_free_full(panel_config.separator_list, destroy_separator);
|
||||
panel_config.separator_list = NULL;
|
||||
}
|
||||
|
||||
int separator_compute_desired_size(void *obj)
|
||||
{
|
||||
Separator *separator = (Separator *)obj;
|
||||
if (!separator->area.on_screen)
|
||||
return 0;
|
||||
|
||||
if (panel_horizontal)
|
||||
return separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area);
|
||||
else
|
||||
return separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area);
|
||||
}
|
||||
|
||||
gboolean resize_separator(void *obj)
|
||||
{
|
||||
Separator *separator = (Separator *)obj;
|
||||
if (!separator->area.on_screen)
|
||||
return FALSE;
|
||||
|
||||
if (panel_horizontal) {
|
||||
separator->area.width =
|
||||
separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area);
|
||||
separator->length =
|
||||
separator->area.height - 2 * separator->area.paddingy - top_bottom_border_width(&separator->area);
|
||||
} else {
|
||||
separator->area.height =
|
||||
separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area);
|
||||
separator->length =
|
||||
separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area);
|
||||
}
|
||||
|
||||
schedule_redraw(&separator->area);
|
||||
schedule_panel_redraw();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void draw_separator_line(void *obj, cairo_t *c);
|
||||
void draw_separator_dots(void *obj, cairo_t *c);
|
||||
|
||||
void draw_separator(void *obj, cairo_t *c)
|
||||
{
|
||||
Separator *separator = (Separator *)obj;
|
||||
|
||||
if (separator->style == SEPARATOR_EMPTY)
|
||||
return;
|
||||
else if (separator->style == SEPARATOR_LINE)
|
||||
draw_separator_line(separator, c);
|
||||
else if (separator->style == SEPARATOR_DOTS)
|
||||
draw_separator_dots(separator, c);
|
||||
}
|
||||
|
||||
void draw_separator_line(void *obj, cairo_t *c)
|
||||
{
|
||||
Separator *separator = (Separator *)obj;
|
||||
|
||||
if (separator->thickness <= 0)
|
||||
return;
|
||||
|
||||
cairo_set_source_rgba(c,
|
||||
separator->color.rgb[0],
|
||||
separator->color.rgb[1],
|
||||
separator->color.rgb[2],
|
||||
separator->color.alpha);
|
||||
cairo_set_line_width(c, separator->thickness);
|
||||
cairo_set_line_cap(c, CAIRO_LINE_CAP_ROUND);
|
||||
if (panel_horizontal) {
|
||||
cairo_move_to(c, separator->area.width / 2.0, separator->area.height / 2.0 - separator->length / 2.0);
|
||||
cairo_line_to(c, separator->area.width / 2.0, separator->area.height / 2.0 + separator->length / 2.0);
|
||||
} else {
|
||||
cairo_move_to(c, separator->area.width / 2.0 - separator->length / 2.0, separator->area.height / 2.0);
|
||||
cairo_line_to(c, separator->area.width / 2.0 + separator->length / 2.0, separator->area.height / 2.0);
|
||||
}
|
||||
cairo_stroke(c);
|
||||
}
|
||||
|
||||
void draw_separator_dots(void *obj, cairo_t *c)
|
||||
{
|
||||
const double PI = 3.14159265359;
|
||||
Separator *separator = (Separator *)obj;
|
||||
if (separator->thickness <= 0)
|
||||
return;
|
||||
|
||||
cairo_set_source_rgba(c,
|
||||
separator->color.rgb[0],
|
||||
separator->color.rgb[1],
|
||||
separator->color.rgb[2],
|
||||
separator->color.alpha);
|
||||
cairo_set_line_width(c, 0);
|
||||
|
||||
int num_circles = separator->length / (1.618 * separator->thickness - 1);
|
||||
double spacing = (separator->length - num_circles * separator->thickness) / MAX(1.0, num_circles - 1.0);
|
||||
if (spacing > separator->thickness)
|
||||
num_circles++;
|
||||
spacing = (separator->length - num_circles * separator->thickness) / MAX(1.0, num_circles - 1.0);
|
||||
double offset = (panel_horizontal ? separator->area.height : separator->area.width) / 2.0 - separator->length / 2.0;
|
||||
if (num_circles == 1)
|
||||
offset += spacing / 2.0;
|
||||
for (int i = 0; i < num_circles; i++) {
|
||||
if (panel_horizontal) {
|
||||
cairo_arc(c,
|
||||
separator->area.width / 2.0,
|
||||
offset + separator->thickness / 2.0,
|
||||
separator->thickness / 2.0,
|
||||
0,
|
||||
2 * PI);
|
||||
} else {
|
||||
cairo_arc(c,
|
||||
offset + separator->thickness / 2.0,
|
||||
separator->area.height / 2.0,
|
||||
separator->thickness / 2.0,
|
||||
0,
|
||||
2 * PI);
|
||||
}
|
||||
cairo_stroke_preserve(c);
|
||||
cairo_fill(c);
|
||||
offset += separator->thickness + spacing;
|
||||
}
|
||||
}
|
||||
32
src/separator/separator.h
Normal file
32
src/separator/separator.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// Tint2 : Separator
|
||||
// Author: Oskari Rauta <oskari.rauta@gmail.com>
|
||||
|
||||
#ifndef SEPARATOR_H
|
||||
#define SEPARATOR_H
|
||||
|
||||
#include "common.h"
|
||||
#include "area.h"
|
||||
|
||||
typedef enum SeparatorStyle {
|
||||
SEPARATOR_EMPTY = 0,
|
||||
SEPARATOR_LINE,
|
||||
SEPARATOR_DOTS
|
||||
} SeparatorStyle;
|
||||
|
||||
typedef struct Separator {
|
||||
Area area;
|
||||
SeparatorStyle style;
|
||||
Color color;
|
||||
int thickness;
|
||||
int length;
|
||||
} Separator;
|
||||
|
||||
Separator *create_separator();
|
||||
void destroy_separator(void *obj);
|
||||
void init_separator();
|
||||
void init_separator_panel(void *p);
|
||||
void cleanup_separator();
|
||||
gboolean resize_separator(void *obj);
|
||||
void draw_separator(void *obj, cairo_t *c);
|
||||
|
||||
#endif
|
||||
52
src/server.c
52
src/server.c
@@ -140,6 +140,11 @@ void cleanup_server()
|
||||
XFreeGC(server.display, server.gc);
|
||||
server.gc = NULL;
|
||||
server.disable_transparency = FALSE;
|
||||
#ifdef HAVE_SN
|
||||
if (server.pids)
|
||||
g_tree_destroy(server.pids);
|
||||
server.pids = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_event32(Window win, Atom at, long data1, long data2, long data3)
|
||||
@@ -251,7 +256,7 @@ void get_root_pixmap()
|
||||
gcv.ts_x_origin = 0;
|
||||
gcv.ts_y_origin = 0;
|
||||
gcv.fill_style = FillTiled;
|
||||
uint mask = GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle | GCTile;
|
||||
unsigned mask = GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle | GCTile;
|
||||
|
||||
gcv.tile = server.root_pmap;
|
||||
XChangeGC(server.display, server.gc, mask, &gcv);
|
||||
@@ -297,6 +302,11 @@ int monitor_includes_monitor(const void *monitor1, const void *monitor2)
|
||||
}
|
||||
}
|
||||
|
||||
void sort_monitors()
|
||||
{
|
||||
qsort(server.monitors, server.num_monitors, sizeof(Monitor), compare_monitor_pos);
|
||||
}
|
||||
|
||||
void get_monitors()
|
||||
{
|
||||
if (XineramaIsActive(server.display)) {
|
||||
@@ -307,38 +317,34 @@ void get_monitors()
|
||||
|
||||
if (res && res->ncrtc >= num_monitors) {
|
||||
// use xrandr to identify monitors (does not work with proprietery nvidia drivers)
|
||||
|
||||
// Workaround for issue https://gitlab.com/o9000/tint2/issues/353
|
||||
// on some recent configs, XRRGetScreenResourcesCurrent returns a fantom monitor at last position
|
||||
{
|
||||
int i = res->ncrtc - 1;
|
||||
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]);
|
||||
if (!(crtc_info->x || crtc_info->y || crtc_info->width || crtc_info->height)) {
|
||||
res->ncrtc -= 1;
|
||||
}
|
||||
XRRFreeCrtcInfo(crtc_info);
|
||||
}
|
||||
|
||||
printf("xRandr: Found crtc's: %d\n", res->ncrtc);
|
||||
server.monitors = calloc(res->ncrtc, sizeof(Monitor));
|
||||
num_monitors = 0;
|
||||
for (int i = 0; i < res->ncrtc; ++i) {
|
||||
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]);
|
||||
server.monitors[i].x = crtc_info->x;
|
||||
server.monitors[i].y = crtc_info->y;
|
||||
server.monitors[i].width = crtc_info->width;
|
||||
server.monitors[i].height = crtc_info->height;
|
||||
server.monitors[i].names = calloc((crtc_info->noutput + 1), sizeof(gchar *));
|
||||
// Ignore empty crtc
|
||||
if (!crtc_info->width || !crtc_info->height) {
|
||||
printf("xRandr: crtc %d seems disabled\n", i);
|
||||
XRRFreeCrtcInfo(crtc_info);
|
||||
continue;
|
||||
}
|
||||
int i_monitor = num_monitors;
|
||||
num_monitors++;
|
||||
server.monitors[i_monitor].x = crtc_info->x;
|
||||
server.monitors[i_monitor].y = crtc_info->y;
|
||||
server.monitors[i_monitor].width = crtc_info->width;
|
||||
server.monitors[i_monitor].height = crtc_info->height;
|
||||
server.monitors[i_monitor].names = calloc((crtc_info->noutput + 1), sizeof(gchar *));
|
||||
for (int j = 0; j < crtc_info->noutput; ++j) {
|
||||
XRROutputInfo *output_info = XRRGetOutputInfo(server.display, res, crtc_info->outputs[j]);
|
||||
printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i);
|
||||
server.monitors[i].names[j] = g_strdup(output_info->name);
|
||||
server.monitors[i_monitor].names[j] = g_strdup(output_info->name);
|
||||
XRRFreeOutputInfo(output_info);
|
||||
server.monitors[i].primary = crtc_info->outputs[j] == primary_output;
|
||||
server.monitors[i_monitor].primary = crtc_info->outputs[j] == primary_output;
|
||||
}
|
||||
server.monitors[i].names[crtc_info->noutput] = NULL;
|
||||
server.monitors[i_monitor].names[crtc_info->noutput] = NULL;
|
||||
XRRFreeCrtcInfo(crtc_info);
|
||||
}
|
||||
num_monitors = res->ncrtc;
|
||||
} else if (info && num_monitors > 0) {
|
||||
server.monitors = calloc(num_monitors, sizeof(Monitor));
|
||||
for (int i = 0; i < num_monitors; i++) {
|
||||
@@ -346,7 +352,7 @@ void get_monitors()
|
||||
server.monitors[i].y = info[i].y_org;
|
||||
server.monitors[i].width = info[i].width;
|
||||
server.monitors[i].height = info[i].height;
|
||||
server.monitors[i].names = 0;
|
||||
server.monitors[i].names = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@ void get_root_pixmap();
|
||||
|
||||
// detect monitors and desktops
|
||||
void get_monitors();
|
||||
void sort_monitors();
|
||||
void print_monitors();
|
||||
void get_desktops();
|
||||
void server_get_number_of_desktops();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -54,6 +55,8 @@ int systray_monitor;
|
||||
int chrono;
|
||||
int systray_composited;
|
||||
int systray_profile;
|
||||
char *systray_hide_name_filter;
|
||||
regex_t *systray_hide_name_regex;
|
||||
// background pixmap if we render ourselves the icons
|
||||
static Pixmap render_background;
|
||||
|
||||
@@ -65,6 +68,7 @@ const int slow_resize_period = 5000;
|
||||
const int min_bad_resize_events = 3;
|
||||
const int max_bad_resize_events = 10;
|
||||
|
||||
int systray_compute_desired_size(void *obj);
|
||||
void systray_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_systray()
|
||||
@@ -80,6 +84,8 @@ void default_systray()
|
||||
systray.area.size_mode = LAYOUT_FIXED;
|
||||
systray.area._resize = resize_systray;
|
||||
systray_profile = getenv("SYSTRAY_PROFILING") != NULL;
|
||||
systray_hide_name_filter = NULL;
|
||||
systray_hide_name_regex = NULL;
|
||||
}
|
||||
|
||||
void cleanup_systray()
|
||||
@@ -94,6 +100,12 @@ void cleanup_systray()
|
||||
XFreePixmap(server.display, render_background);
|
||||
render_background = 0;
|
||||
}
|
||||
if (systray_hide_name_regex) {
|
||||
regfree(systray_hide_name_regex);
|
||||
free_and_null(systray_hide_name_regex);
|
||||
}
|
||||
if (systray_hide_name_filter)
|
||||
free_and_null(systray_hide_name_filter);
|
||||
}
|
||||
|
||||
void init_systray()
|
||||
@@ -117,12 +129,57 @@ void init_systray_panel(void *p)
|
||||
systray.area.parent = panel;
|
||||
systray.area.panel = panel;
|
||||
systray.area._dump_geometry = systray_dump_geometry;
|
||||
systray.area._compute_desired_size = systray_compute_desired_size;
|
||||
snprintf(systray.area.name, sizeof(systray.area.name), "Systray");
|
||||
if (!systray.area.bg)
|
||||
systray.area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
show(&systray.area);
|
||||
schedule_redraw(&systray.area);
|
||||
refresh_systray = TRUE;
|
||||
instantiate_area_gradients(&systray.area);
|
||||
}
|
||||
|
||||
void systray_compute_geometry(int *size)
|
||||
{
|
||||
systray.icon_size = panel_horizontal ? systray.area.height : systray.area.width;
|
||||
systray.icon_size -= MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) +
|
||||
2 * systray.area.paddingy;
|
||||
if (systray_max_icon_size > 0)
|
||||
systray.icon_size = MIN(systray.icon_size, systray_max_icon_size);
|
||||
|
||||
int count = 0;
|
||||
for (GSList *l = systray.list_icons; l; l = l->next) {
|
||||
count++;
|
||||
}
|
||||
|
||||
if (panel_horizontal) {
|
||||
int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy;
|
||||
// here icons_per_column always higher than 0
|
||||
systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
|
||||
systray.margin =
|
||||
height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
|
||||
systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0);
|
||||
*size = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr +
|
||||
(systray.icon_size * systray.icons_per_row) +
|
||||
((systray.icons_per_row - 1) * systray.area.paddingx);
|
||||
} else {
|
||||
int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy;
|
||||
// here icons_per_row always higher than 0
|
||||
systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
|
||||
systray.margin =
|
||||
width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
|
||||
systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0);
|
||||
*size = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) +
|
||||
(systray.icon_size * systray.icons_per_column) +
|
||||
((systray.icons_per_column - 1) * systray.area.paddingx);
|
||||
}
|
||||
}
|
||||
|
||||
int systray_compute_desired_size(void *obj)
|
||||
{
|
||||
int size;
|
||||
systray_compute_geometry(&size);
|
||||
return size;
|
||||
}
|
||||
|
||||
gboolean resize_systray(void *obj)
|
||||
@@ -130,14 +187,8 @@ gboolean resize_systray(void *obj)
|
||||
if (systray_profile)
|
||||
fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
|
||||
if (panel_horizontal)
|
||||
systray.icon_size = systray.area.height;
|
||||
else
|
||||
systray.icon_size = systray.area.width;
|
||||
systray.icon_size -= MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) +
|
||||
2 * systray.area.paddingy;
|
||||
if (systray_max_icon_size > 0)
|
||||
systray.icon_size = MIN(systray.icon_size, systray_max_icon_size);
|
||||
int size;
|
||||
systray_compute_geometry(&size);
|
||||
|
||||
if (systray.icon_size > 0) {
|
||||
long icon_size = systray.icon_size;
|
||||
@@ -151,40 +202,27 @@ gboolean resize_systray(void *obj)
|
||||
1);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (GSList *l = systray.list_icons; l; l = l->next) {
|
||||
count++;
|
||||
}
|
||||
if (systray_profile)
|
||||
fprintf(stderr, BLUE "%s:%d number of icons = %d" RESET "\n", __FUNCTION__, __LINE__, count);
|
||||
|
||||
if (panel_horizontal) {
|
||||
int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy;
|
||||
// here icons_per_column always higher than 0
|
||||
systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
|
||||
systray.margin =
|
||||
height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
|
||||
systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0);
|
||||
systray.area.width = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr +
|
||||
(systray.icon_size * systray.icons_per_row) +
|
||||
((systray.icons_per_row - 1) * systray.area.paddingx);
|
||||
} else {
|
||||
int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy;
|
||||
// here icons_per_row always higher than 0
|
||||
systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
|
||||
systray.margin =
|
||||
width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
|
||||
systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0);
|
||||
systray.area.height = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) +
|
||||
(systray.icon_size * systray.icons_per_column) +
|
||||
((systray.icons_per_column - 1) * systray.area.paddingx);
|
||||
}
|
||||
|
||||
gboolean result = refresh_systray;
|
||||
if (net_sel_win == None) {
|
||||
start_net();
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
if (panel_horizontal) {
|
||||
if (systray.area.width != size) {
|
||||
systray.area.width = size;
|
||||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (systray.area.height != size) {
|
||||
systray.area.height = size;
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
on_change_systray(&systray.area);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void draw_systray(void *obj, cairo_t *c)
|
||||
@@ -546,6 +584,26 @@ void print_icons()
|
||||
}
|
||||
}
|
||||
|
||||
gboolean reject_icon(Window win)
|
||||
{
|
||||
if (systray_hide_name_filter && strlen(systray_hide_name_filter)) {
|
||||
if (!systray_hide_name_regex) {
|
||||
systray_hide_name_regex = (regex_t *) calloc(1, sizeof(*systray_hide_name_regex));
|
||||
if (regcomp(systray_hide_name_regex, systray_hide_name_filter, 0) != 0) {
|
||||
fprintf(stderr, RED "Could not compile regex %s" RESET "\n", systray_hide_name_filter);
|
||||
free_and_null(systray_hide_name_regex);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
char *name = get_window_name(win);
|
||||
if (regexec(systray_hide_name_regex, name, 0, NULL, 0) == 0) {
|
||||
fprintf(stderr, GREEN "Filtering out systray icon '%s'" RESET "\n", name);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean add_icon(Window win)
|
||||
{
|
||||
// Avoid duplicates
|
||||
@@ -556,6 +614,10 @@ gboolean add_icon(Window win)
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out systray_hide_by_icon_name
|
||||
if (reject_icon(win))
|
||||
return FALSE;
|
||||
|
||||
// Dangerous actions begin
|
||||
XSync(server.display, False);
|
||||
error = FALSE;
|
||||
@@ -674,8 +736,7 @@ gboolean add_icon(Window win)
|
||||
traywin->chrono = chrono;
|
||||
chrono++;
|
||||
|
||||
if (!systray.area.on_screen)
|
||||
show(&systray.area);
|
||||
show(&systray.area);
|
||||
|
||||
if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT)
|
||||
systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
|
||||
@@ -1080,7 +1141,7 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e)
|
||||
profiling_get_time(),
|
||||
__FUNCTION__,
|
||||
__LINE__);
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
refresh_systray = TRUE;
|
||||
}
|
||||
|
||||
@@ -1159,7 +1220,7 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e)
|
||||
profiling_get_time(),
|
||||
__FUNCTION__,
|
||||
__LINE__);
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
refresh_systray = TRUE;
|
||||
}
|
||||
|
||||
@@ -1367,7 +1428,7 @@ void systray_render_icon_composited(void *t)
|
||||
if (error)
|
||||
goto on_error;
|
||||
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
|
||||
if (systray_profile)
|
||||
fprintf(stderr,
|
||||
@@ -1406,29 +1467,31 @@ on_systray_error:
|
||||
void systray_render_icon(void *t)
|
||||
{
|
||||
TrayWindow *traywin = t;
|
||||
if (systray_profile)
|
||||
fprintf(stderr,
|
||||
"[%f] %s:%d win = %lu (%s)\n",
|
||||
profiling_get_time(),
|
||||
__FUNCTION__,
|
||||
__LINE__,
|
||||
traywin->win,
|
||||
traywin->name);
|
||||
if (!traywin->reparented || !traywin->embedded) {
|
||||
if (systray_profile)
|
||||
fprintf(stderr,
|
||||
YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n",
|
||||
profiling_get_time(),
|
||||
__FUNCTION__,
|
||||
__LINE__,
|
||||
traywin->win,
|
||||
traywin->name);
|
||||
// if (systray_profile)
|
||||
// fprintf(stderr,
|
||||
// YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n",
|
||||
// profiling_get_time(),
|
||||
// __FUNCTION__,
|
||||
// __LINE__,
|
||||
// traywin->win,
|
||||
// traywin->name);
|
||||
stop_timeout(traywin->render_timeout);
|
||||
traywin->render_timeout =
|
||||
add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout);
|
||||
return;
|
||||
}
|
||||
|
||||
if (systray_profile)
|
||||
fprintf(stderr,
|
||||
"[%f] %s:%d win = %lu (%s)\n",
|
||||
profiling_get_time(),
|
||||
__FUNCTION__,
|
||||
__LINE__,
|
||||
traywin->win,
|
||||
traywin->name);
|
||||
|
||||
|
||||
if (systray_composited) {
|
||||
XSync(server.display, False);
|
||||
error = FALSE;
|
||||
@@ -1500,9 +1563,9 @@ void refresh_systray_icons()
|
||||
}
|
||||
}
|
||||
|
||||
gboolean systray_on_monitor(int i_monitor, int num_panels)
|
||||
gboolean systray_on_monitor(int i_monitor, int n_panels)
|
||||
{
|
||||
return (i_monitor == systray_monitor) || (i_monitor == 0 && (systray_monitor >= num_panels || systray_monitor < 0));
|
||||
return (i_monitor == systray_monitor) || (i_monitor == 0 && (systray_monitor >= n_panels || systray_monitor < 0));
|
||||
}
|
||||
|
||||
TrayWindow *systray_find_icon(Window win)
|
||||
|
||||
@@ -75,6 +75,7 @@ extern gboolean systray_enabled;
|
||||
extern int systray_max_icon_size;
|
||||
extern int systray_monitor;
|
||||
extern gboolean systray_profile;
|
||||
extern char *systray_hide_name_filter;
|
||||
|
||||
// default global data
|
||||
void default_systray();
|
||||
|
||||
@@ -39,6 +39,7 @@ timeout *urgent_timeout;
|
||||
GSList *urgent_list;
|
||||
|
||||
void task_dump_geometry(void *obj, int indent);
|
||||
int task_compute_desired_size(void *obj);
|
||||
|
||||
char *task_get_tooltip(void *obj)
|
||||
{
|
||||
@@ -108,6 +109,7 @@ Task *add_task(Window win)
|
||||
task_instance->area.has_mouse_press_effect = panel_config.mouse_effects;
|
||||
task_instance->area._dump_geometry = task_dump_geometry;
|
||||
task_instance->area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
task_instance->area._compute_desired_size = task_compute_desired_size;
|
||||
task_instance->win = task_template.win;
|
||||
task_instance->desktop = task_template.desktop;
|
||||
task_instance->win_x = task_template.win_x;
|
||||
@@ -150,6 +152,9 @@ Task *add_task(Window win)
|
||||
add_urgent((Task *)g_ptr_array_index(task_buttons, 0));
|
||||
}
|
||||
|
||||
if (hide_taskbar_if_empty)
|
||||
update_all_taskbars_visibility();
|
||||
|
||||
return (Task *)g_ptr_array_index(task_buttons, 0);
|
||||
}
|
||||
|
||||
@@ -204,6 +209,8 @@ void remove_task(Task *task)
|
||||
free(task2);
|
||||
}
|
||||
g_hash_table_remove(win_to_task, &win);
|
||||
if (hide_taskbar_if_empty)
|
||||
update_all_taskbars_visibility();
|
||||
}
|
||||
|
||||
gboolean task_update_title(Task *task)
|
||||
@@ -268,41 +275,49 @@ void task_update_icon(Task *task)
|
||||
|
||||
Imlib_Image img = NULL;
|
||||
|
||||
int i;
|
||||
gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i);
|
||||
if (data) {
|
||||
// get ARGB icon
|
||||
int w, h;
|
||||
gulong *tmp_data;
|
||||
if (!img) {
|
||||
int i;
|
||||
gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i);
|
||||
if (data) {
|
||||
// get ARGB icon
|
||||
int w, h;
|
||||
gulong *tmp_data;
|
||||
|
||||
tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1);
|
||||
DATA32 icon_data[w * h];
|
||||
for (int j = 0; j < w * h; ++j)
|
||||
icon_data[j] = tmp_data[j];
|
||||
img = imlib_create_image_using_copied_data(w, h, icon_data);
|
||||
XFree(data);
|
||||
} else {
|
||||
// get Pixmap icon
|
||||
tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1);
|
||||
DATA32 icon_data[w * h];
|
||||
for (int j = 0; j < w * h; ++j)
|
||||
icon_data[j] = tmp_data[j];
|
||||
img = imlib_create_image_using_copied_data(w, h, icon_data);
|
||||
if (img)
|
||||
fprintf(stderr, "%s: Got %dx%d icon via _NET_WM_ICON for %s\n", __FUNCTION__, w, h, task->title ? task->title : "task");
|
||||
XFree(data);
|
||||
}
|
||||
}
|
||||
|
||||
if (!img) {
|
||||
XWMHints *hints = XGetWMHints(server.display, task->win);
|
||||
if (hints) {
|
||||
if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) {
|
||||
// get width, height and depth for the pixmap
|
||||
Window root;
|
||||
int icon_x, icon_y;
|
||||
uint border_width, bpp;
|
||||
uint w, h;
|
||||
unsigned border_width, bpp;
|
||||
unsigned w, h;
|
||||
|
||||
// printf(" get pixmap\n");
|
||||
XGetGeometry(server.display, hints->icon_pixmap, &root, &icon_x, &icon_y, &w, &h, &border_width, &bpp);
|
||||
imlib_context_set_drawable(hints->icon_pixmap);
|
||||
img = imlib_create_image_from_drawable(hints->icon_mask, 0, 0, w, h, 0);
|
||||
if (img)
|
||||
fprintf(stderr, "%s: Got %dx%d pixmap icon via WM_HINTS for %s\n", __FUNCTION__, w, h, task->title ? task->title : "task");
|
||||
}
|
||||
XFree(hints);
|
||||
}
|
||||
}
|
||||
|
||||
if (img == NULL) {
|
||||
imlib_context_set_image(default_icon);
|
||||
img = imlib_clone_image();
|
||||
fprintf(stderr, "%s: Using default icon for %s\n", __FUNCTION__, task->title ? task->title : "task");
|
||||
}
|
||||
|
||||
// transform icons
|
||||
@@ -348,7 +363,7 @@ void task_update_icon(Task *task)
|
||||
|
||||
GPtrArray *task_buttons = get_task_buttons(task->win);
|
||||
if (task_buttons) {
|
||||
for (i = 0; i < task_buttons->len; ++i) {
|
||||
for (int i = 0; i < task_buttons->len; ++i) {
|
||||
Task *task2 = g_ptr_array_index(task_buttons, i);
|
||||
task2->icon_width = task->icon_width;
|
||||
task2->icon_height = task->icon_height;
|
||||
@@ -457,6 +472,14 @@ void task_dump_geometry(void *obj, int indent)
|
||||
panel->g_task.icon_size1);
|
||||
}
|
||||
|
||||
int task_compute_desired_size(void *obj)
|
||||
{
|
||||
Task *task = (Task *)obj;
|
||||
Panel *panel = (Panel *)task->area.panel;
|
||||
int size = panel_horizontal ? panel->g_task.maximum_width : panel->g_task.maximum_height;
|
||||
return size;
|
||||
}
|
||||
|
||||
void on_change_task(void *obj)
|
||||
{
|
||||
Task *task = (Task *)obj;
|
||||
@@ -587,6 +610,8 @@ void set_task_state(Task *task, TaskState state)
|
||||
Task *task1 = g_ptr_array_index(task_buttons, i);
|
||||
task1->current_state = state;
|
||||
task1->area.bg = panels[0].g_task.background[state];
|
||||
free_area_gradient_instances(&task1->area);
|
||||
instantiate_area_gradients(&task1->area);
|
||||
schedule_redraw(&task1->area);
|
||||
if (state == TASK_ACTIVE && g_slist_find(urgent_list, task1))
|
||||
del_urgent(task1);
|
||||
@@ -615,7 +640,7 @@ void set_task_state(Task *task, TaskState state)
|
||||
p->area.resize_needed = TRUE;
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -633,7 +658,7 @@ void blink_urgent(void *arg)
|
||||
}
|
||||
urgent_task = urgent_task->next;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void add_urgent(Task *task)
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef struct GlobalTask {
|
||||
int brightness[TASK_STATE_COUNT];
|
||||
int config_asb_mask;
|
||||
Background *background[TASK_STATE_COUNT];
|
||||
GList *gradient[TASK_STATE_COUNT];
|
||||
int config_background_mask;
|
||||
// starting position for text ~ task_padding + task_border + icon_size
|
||||
double text_posx, text_height;
|
||||
|
||||
@@ -41,11 +41,13 @@ gboolean taskbar_enabled;
|
||||
gboolean taskbar_distribute_size;
|
||||
gboolean hide_inactive_tasks;
|
||||
gboolean hide_task_diff_monitor;
|
||||
gboolean hide_taskbar_if_empty;
|
||||
gboolean always_show_all_desktop_tasks;
|
||||
TaskbarSortMethod taskbar_sort_method;
|
||||
Alignment taskbar_alignment;
|
||||
|
||||
void taskbar_init_fonts();
|
||||
int taskbar_compute_desired_size(void *obj);
|
||||
|
||||
// Removes the task with &win = key. The other args are ignored.
|
||||
void taskbar_remove_task(Window *win);
|
||||
@@ -74,6 +76,7 @@ void default_taskbar()
|
||||
taskbar_distribute_size = FALSE;
|
||||
hide_inactive_tasks = FALSE;
|
||||
hide_task_diff_monitor = FALSE;
|
||||
hide_taskbar_if_empty = FALSE;
|
||||
always_show_all_desktop_tasks = FALSE;
|
||||
taskbar_sort_method = TASKBAR_NOSORT;
|
||||
taskbar_alignment = ALIGN_LEFT;
|
||||
@@ -82,7 +85,6 @@ void default_taskbar()
|
||||
|
||||
void cleanup_taskbar()
|
||||
{
|
||||
cleanup_taskbarname();
|
||||
if (win_to_task) {
|
||||
while (g_hash_table_size(win_to_task)) {
|
||||
GHashTableIter iter;
|
||||
@@ -96,6 +98,7 @@ void cleanup_taskbar()
|
||||
g_hash_table_destroy(win_to_task);
|
||||
win_to_task = NULL;
|
||||
}
|
||||
cleanup_taskbarname();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
Panel *panel = &panels[i];
|
||||
for (int j = 0; j < panel->num_desktops; j++) {
|
||||
@@ -114,6 +117,15 @@ void cleanup_taskbar()
|
||||
urgent_list = NULL;
|
||||
|
||||
stop_timeout(urgent_timeout);
|
||||
|
||||
for (int state = 0; state < TASK_STATE_COUNT; state++) {
|
||||
g_list_free(panel_config.g_task.gradient[state]);
|
||||
}
|
||||
|
||||
for (int state = 0; state < TASKBAR_STATE_COUNT; state++) {
|
||||
g_list_free(panel_config.g_taskbar.gradient[state]);
|
||||
g_list_free(panel_config.g_taskbar.gradient_name[state]);
|
||||
}
|
||||
}
|
||||
|
||||
void init_taskbar()
|
||||
@@ -163,13 +175,14 @@ void init_taskbar_panel(void *p)
|
||||
panel->g_taskbar.area.size_mode = LAYOUT_DYNAMIC;
|
||||
panel->g_taskbar.area.alignment = taskbar_alignment;
|
||||
panel->g_taskbar.area._resize = resize_taskbar;
|
||||
panel->g_taskbar.area._compute_desired_size = taskbar_compute_desired_size;
|
||||
panel->g_taskbar.area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
panel->g_taskbar.area.resize_needed = 1;
|
||||
panel->g_taskbar.area.on_screen = TRUE;
|
||||
if (panel_horizontal) {
|
||||
panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy;
|
||||
panel->g_taskbar.area.height =
|
||||
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
|
||||
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
|
||||
panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy;
|
||||
panel->g_taskbar.area_name.height = panel->g_taskbar.area.height;
|
||||
} else {
|
||||
@@ -302,10 +315,16 @@ void init_taskbar_panel(void *p)
|
||||
taskbar = &panel->taskbar[j];
|
||||
memcpy(&taskbar->area, &panel->g_taskbar.area, sizeof(Area));
|
||||
taskbar->desktop = j;
|
||||
if (j == server.desktop)
|
||||
if (j == server.desktop) {
|
||||
taskbar->area.bg = panel->g_taskbar.background[TASKBAR_ACTIVE];
|
||||
else
|
||||
free_area_gradient_instances(&taskbar->area);
|
||||
instantiate_area_gradients(&taskbar->area);
|
||||
} else {
|
||||
taskbar->area.bg = panel->g_taskbar.background[TASKBAR_NORMAL];
|
||||
free_area_gradient_instances(&taskbar->area);
|
||||
instantiate_area_gradients(&taskbar->area);
|
||||
}
|
||||
|
||||
}
|
||||
init_taskbarname_panel(panel);
|
||||
}
|
||||
@@ -347,7 +366,7 @@ void taskbar_default_font_changed()
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void taskbar_remove_task(Window *win)
|
||||
@@ -400,6 +419,22 @@ void taskbar_refresh_tasklist()
|
||||
XFree(win);
|
||||
}
|
||||
|
||||
int taskbar_compute_desired_size(void *obj)
|
||||
{
|
||||
Taskbar *taskbar = (Taskbar *)obj;
|
||||
Panel *panel = (Panel *)taskbar->area.panel;
|
||||
|
||||
if (taskbar_mode == MULTI_DESKTOP && !taskbar_distribute_size) {
|
||||
int result = 0;
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *t = &panel->taskbar[i];
|
||||
result = MAX(result, container_compute_desired_size(&t->area));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return container_compute_desired_size(&taskbar->area);
|
||||
}
|
||||
|
||||
gboolean resize_taskbar(void *obj)
|
||||
{
|
||||
Taskbar *taskbar = (Taskbar *)obj;
|
||||
@@ -430,18 +465,63 @@ gboolean resize_taskbar(void *obj)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean taskbar_is_empty(Taskbar *taskbar)
|
||||
{
|
||||
GList *l = taskbar->area.children;
|
||||
if (taskbarname_enabled)
|
||||
l = l->next;
|
||||
for (; l != NULL; l = l->next) {
|
||||
if (((Task *)l->data)->area.on_screen) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void update_taskbar_visibility(Taskbar *taskbar)
|
||||
{
|
||||
if (taskbar->desktop == server.desktop) {
|
||||
// Taskbar for current desktop is always shown
|
||||
show(&taskbar->area);
|
||||
} else if (taskbar_mode == MULTI_DESKTOP) {
|
||||
if (hide_taskbar_if_empty) {
|
||||
if (taskbar_is_empty(taskbar)) {
|
||||
hide(&taskbar->area);
|
||||
} else {
|
||||
show(&taskbar->area);
|
||||
}
|
||||
} else {
|
||||
show(&taskbar->area);
|
||||
}
|
||||
} else {
|
||||
hide(&taskbar->area);
|
||||
}
|
||||
}
|
||||
|
||||
void update_all_taskbars_visibility()
|
||||
{
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
Panel *panel = &panels[i];
|
||||
for (int j = 0; j < panel->num_desktops; j++) {
|
||||
update_taskbar_visibility(&panel->taskbar[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
|
||||
{
|
||||
taskbar->area.bg = panels[0].g_taskbar.background[state];
|
||||
free_area_gradient_instances(&taskbar->area);
|
||||
instantiate_area_gradients(&taskbar->area);
|
||||
|
||||
if (taskbarname_enabled) {
|
||||
taskbar->bar_name.area.bg = panels[0].g_taskbar.background_name[state];
|
||||
free_area_gradient_instances(&taskbar->bar_name.area);
|
||||
instantiate_area_gradients(&taskbar->bar_name.area);
|
||||
}
|
||||
if (taskbar_mode != MULTI_DESKTOP) {
|
||||
if (state == TASKBAR_NORMAL)
|
||||
taskbar->area.on_screen = FALSE;
|
||||
else
|
||||
taskbar->area.on_screen = TRUE;
|
||||
}
|
||||
|
||||
update_taskbar_visibility(taskbar);
|
||||
|
||||
if (taskbar->area.on_screen) {
|
||||
schedule_redraw(&taskbar->area);
|
||||
if (taskbarname_enabled) {
|
||||
@@ -456,23 +536,7 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
|
||||
schedule_redraw((Area *)l->data);
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void update_taskbar_visibility(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
|
||||
for (int j = 0; j < panel->num_desktops; j++) {
|
||||
Taskbar *taskbar = &panel->taskbar[j];
|
||||
if (taskbar_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) {
|
||||
// SINGLE_DESKTOP and not current desktop
|
||||
taskbar->area.on_screen = FALSE;
|
||||
} else {
|
||||
taskbar->area.on_screen = TRUE;
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
#define NONTRIVIAL 2
|
||||
@@ -585,7 +649,7 @@ void sort_tasks(Taskbar *taskbar)
|
||||
|
||||
taskbar->area.children = g_list_sort_with_data(taskbar->area.children, (GCompareDataFunc)compare_tasks, taskbar);
|
||||
taskbar->area.resize_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
((Panel *)taskbar->area.panel)->area.resize_needed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,12 +43,15 @@ typedef struct GlobalTaskbar {
|
||||
Area area_name;
|
||||
Background *background[TASKBAR_STATE_COUNT];
|
||||
Background *background_name[TASKBAR_STATE_COUNT];
|
||||
GList *gradient[TASKBAR_STATE_COUNT];
|
||||
GList *gradient_name[TASKBAR_STATE_COUNT];
|
||||
} GlobalTaskbar;
|
||||
|
||||
extern gboolean taskbar_enabled;
|
||||
extern gboolean taskbar_distribute_size;
|
||||
extern gboolean hide_inactive_tasks;
|
||||
extern gboolean hide_task_diff_monitor;
|
||||
extern gboolean hide_taskbar_if_empty;
|
||||
extern gboolean always_show_all_desktop_tasks;
|
||||
extern TaskbarSortMethod taskbar_sort_method;
|
||||
extern Alignment taskbar_alignment;
|
||||
@@ -79,10 +82,11 @@ Task *get_task(Window win);
|
||||
// However for windows shown on all desktops, there are multiple buttons, one for each taskbar.
|
||||
GPtrArray *get_task_buttons(Window win);
|
||||
|
||||
// Change state of a taskbar (ACTIVE or NORMAL)
|
||||
void set_taskbar_state(Taskbar *taskbar, TaskbarState state);
|
||||
|
||||
// Updates the visibility of each taskbar when the current desktop changes.
|
||||
void update_taskbar_visibility(void *p);
|
||||
// Updates the visibility of all taskbars
|
||||
void update_all_taskbars_visibility();
|
||||
|
||||
// Sorts the taskbar(s) on which the window is present.
|
||||
void sort_taskbar_for_win(Window win);
|
||||
|
||||
@@ -37,6 +37,7 @@ Color taskbarname_font;
|
||||
Color taskbarname_active_font;
|
||||
|
||||
void taskbarname_init_fonts();
|
||||
int taskbarname_compute_desired_size(void *obj);
|
||||
|
||||
void default_taskbarname()
|
||||
{
|
||||
@@ -60,10 +61,12 @@ void init_taskbarname_panel(void *p)
|
||||
taskbar->bar_name.area.parent = taskbar;
|
||||
taskbar->bar_name.area.has_mouse_over_effect = panel_config.mouse_effects;
|
||||
taskbar->bar_name.area.has_mouse_press_effect = panel_config.mouse_effects;
|
||||
if (j == server.desktop)
|
||||
taskbar->bar_name.area._compute_desired_size = taskbarname_compute_desired_size;
|
||||
if (j == server.desktop) {
|
||||
taskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_ACTIVE];
|
||||
else
|
||||
} else {
|
||||
taskbar->bar_name.area.bg = panel->g_taskbar.background_name[TASKBAR_NORMAL];
|
||||
}
|
||||
|
||||
// use desktop number if name is missing
|
||||
if (l) {
|
||||
@@ -75,6 +78,7 @@ void init_taskbarname_panel(void *p)
|
||||
|
||||
// append the name at the beginning of taskbar
|
||||
taskbar->area.children = g_list_append(taskbar->area.children, &taskbar->bar_name);
|
||||
instantiate_area_gradients(&taskbar->bar_name.area);
|
||||
}
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
@@ -109,7 +113,7 @@ void taskbarname_default_font_changed()
|
||||
schedule_redraw(&taskbar->bar_name.area);
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void cleanup_taskbarname()
|
||||
@@ -126,14 +130,11 @@ void cleanup_taskbarname()
|
||||
}
|
||||
}
|
||||
|
||||
gboolean resize_taskbarname(void *obj)
|
||||
int taskbarname_compute_desired_size(void *obj)
|
||||
{
|
||||
TaskbarName *taskbar_name = obj;
|
||||
Panel *panel = taskbar_name->area.panel;
|
||||
TaskbarName *taskbar_name = (TaskbarName *)obj;
|
||||
Panel *panel = (Panel *)taskbar_name->area.panel;
|
||||
int name_height, name_width, name_height_ink;
|
||||
gboolean result = FALSE;
|
||||
|
||||
schedule_redraw(&taskbar_name->area);
|
||||
get_text_size2(panel_config.taskbarname_font_desc,
|
||||
&name_height_ink,
|
||||
&name_height,
|
||||
@@ -147,14 +148,41 @@ gboolean resize_taskbarname(void *obj)
|
||||
FALSE);
|
||||
|
||||
if (panel_horizontal) {
|
||||
int new_size = name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area);
|
||||
return name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area);
|
||||
} else {
|
||||
return name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean resize_taskbarname(void *obj)
|
||||
{
|
||||
TaskbarName *taskbar_name = (TaskbarName *)obj;
|
||||
Panel *panel = (Panel *)taskbar_name->area.panel;
|
||||
|
||||
schedule_redraw(&taskbar_name->area);
|
||||
|
||||
int name_height, name_width, name_height_ink;
|
||||
get_text_size2(panel_config.taskbarname_font_desc,
|
||||
&name_height_ink,
|
||||
&name_height,
|
||||
&name_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
taskbar_name->name,
|
||||
strlen(taskbar_name->name),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
FALSE);
|
||||
|
||||
gboolean result = FALSE;
|
||||
int new_size = taskbarname_compute_desired_size(obj);
|
||||
if (panel_horizontal) {
|
||||
if (new_size != taskbar_name->area.width) {
|
||||
taskbar_name->area.width = new_size;
|
||||
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
|
||||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
int new_size = name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area);
|
||||
if (new_size != taskbar_name->area.height) {
|
||||
taskbar_name->area.height = new_size;
|
||||
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
|
||||
|
||||
580
src/tint.c
580
src/tint.c
File diff suppressed because it is too large
Load Diff
@@ -26,10 +26,13 @@ set(SOURCES ../util/common.c
|
||||
../server.c
|
||||
../launcher/apps-common.c
|
||||
../launcher/icon-theme-common.c
|
||||
md4.c
|
||||
main.c
|
||||
properties.c
|
||||
properties_rw.c
|
||||
theme_view.c )
|
||||
theme_view.c
|
||||
background_gui.c
|
||||
gradient_gui.c )
|
||||
|
||||
add_definitions( -DTINT2CONF )
|
||||
|
||||
@@ -57,19 +60,14 @@ target_link_libraries( tint2conf ${X11_T2C_LIBRARIES}
|
||||
${GTK2_LIBRARIES}
|
||||
${RSVG_LIBRARIES} )
|
||||
|
||||
if ( NOT DATADIR )
|
||||
set(DATADIR share)
|
||||
endif( NOT DATADIR )
|
||||
|
||||
add_definitions( -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" )
|
||||
add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${DATADIR}/locale\" )
|
||||
add_definitions( -DLOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\" )
|
||||
add_definitions( -DGETTEXT_PACKAGE=\"tint2conf\" )
|
||||
set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -pthread -std=c99" )
|
||||
set_target_properties( tint2conf PROPERTIES COMPILE_FLAGS "-Wall -pthread -std=c11" )
|
||||
set_target_properties( tint2conf PROPERTIES LINK_FLAGS "-pthread" )
|
||||
|
||||
add_subdirectory(po)
|
||||
|
||||
install( TARGETS tint2conf DESTINATION bin )
|
||||
install( FILES tint2conf.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})" )
|
||||
install( FILES tint2conf.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps )
|
||||
install( FILES tint2conf.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications )
|
||||
|
||||
1038
src/tint2conf/background_gui.c
Normal file
1038
src/tint2conf/background_gui.c
Normal file
File diff suppressed because it is too large
Load Diff
15
src/tint2conf/background_gui.h
Normal file
15
src/tint2conf/background_gui.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef BACKGROUND_GUI_H
|
||||
#define BACKGROUND_GUI_H
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
void create_background(GtkWidget *parent);
|
||||
void background_duplicate(GtkWidget *widget, gpointer data);
|
||||
void background_delete(GtkWidget *widget, gpointer data);
|
||||
void background_update_image(int index);
|
||||
void background_update(GtkWidget *widget, gpointer data);
|
||||
void current_background_changed(GtkWidget *widget, gpointer data);
|
||||
void background_combo_changed(GtkWidget *widget, gpointer data);
|
||||
GtkWidget *create_background_combo(const char *label);
|
||||
|
||||
#endif
|
||||
612
src/tint2conf/gradient_gui.c
Normal file
612
src/tint2conf/gradient_gui.c
Normal file
@@ -0,0 +1,612 @@
|
||||
#include "gradient_gui.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
GtkListStore *gradient_ids, *gradient_stop_ids;
|
||||
GList *gradients;
|
||||
GtkWidget *current_gradient, *gradient_combo_type, *gradient_start_color, *gradient_end_color, *current_gradient_stop,
|
||||
*gradient_stop_color, *gradient_stop_offset;
|
||||
|
||||
int gradient_index_safe(int index)
|
||||
{
|
||||
if (index <= 0)
|
||||
index = 0;
|
||||
if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids)))
|
||||
index = 0;
|
||||
return index;
|
||||
}
|
||||
|
||||
GtkWidget *create_gradient_combo()
|
||||
{
|
||||
GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gradient_ids));
|
||||
GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", grColPixbuf, NULL);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
g_object_set(renderer, "wrap-mode", PANGO_WRAP_WORD, NULL);
|
||||
g_object_set(renderer, "wrap-width", 300, NULL);
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", grColText, NULL);
|
||||
return combo;
|
||||
}
|
||||
|
||||
void create_gradient(GtkWidget *parent)
|
||||
{
|
||||
gradient_ids = gtk_list_store_new(grNumCols, GDK_TYPE_PIXBUF, GTK_TYPE_INT, GTK_TYPE_STRING);
|
||||
gradients = NULL;
|
||||
|
||||
gradient_stop_ids = gtk_list_store_new(grStopNumCols, GDK_TYPE_PIXBUF);
|
||||
|
||||
GtkWidget *table, *label, *button;
|
||||
int row, col;
|
||||
// GtkTooltips *tooltips = gtk_tooltips_new();
|
||||
|
||||
table = gtk_table_new(1, 4, 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);
|
||||
|
||||
row = 0, col = 0;
|
||||
label = gtk_label_new(_("<b>Gradient</b>"));
|
||||
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, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
current_gradient = create_gradient_combo();
|
||||
gtk_widget_show(current_gradient);
|
||||
gtk_table_attach(GTK_TABLE(table), current_gradient, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
button = gtk_button_new_from_stock("gtk-add");
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_duplicate), NULL);
|
||||
gtk_widget_show(button);
|
||||
gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
button = gtk_button_new_from_stock("gtk-remove");
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_delete), NULL);
|
||||
gtk_widget_show(button);
|
||||
gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
table = gtk_table_new(3, 4, 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);
|
||||
|
||||
row = 0, col = 2;
|
||||
label = gtk_label_new(_("Type"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
gradient_combo_type = gtk_combo_box_new_text();
|
||||
gtk_widget_show(gradient_combo_type);
|
||||
gtk_table_attach(GTK_TABLE(table), gradient_combo_type, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Vertical"));
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Horizontal"));
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(gradient_combo_type), _("Radial"));
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_combo_type), 0);
|
||||
|
||||
row++, col = 2;
|
||||
label = gtk_label_new(_("Start color"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
gradient_start_color = gtk_color_button_new();
|
||||
gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_start_color), TRUE);
|
||||
gtk_widget_show(gradient_start_color);
|
||||
gtk_table_attach(GTK_TABLE(table), gradient_start_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
row++, col = 2;
|
||||
label = gtk_label_new(_("End color"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
gradient_end_color = gtk_color_button_new();
|
||||
gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_end_color), TRUE);
|
||||
gtk_widget_show(gradient_end_color);
|
||||
gtk_table_attach(GTK_TABLE(table), gradient_end_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
change_paragraph(parent);
|
||||
|
||||
table = gtk_table_new(1, 4, 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);
|
||||
|
||||
row = 0, col = 0;
|
||||
label = gtk_label_new(_("<b>Color stop</b>"));
|
||||
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, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
current_gradient_stop = create_gradient_stop_combo(NULL);
|
||||
gtk_widget_show(current_gradient_stop);
|
||||
gtk_table_attach(GTK_TABLE(table), current_gradient_stop, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
button = gtk_button_new_from_stock("gtk-add");
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_stop_duplicate), NULL);
|
||||
gtk_widget_show(button);
|
||||
gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
button = gtk_button_new_from_stock("gtk-remove");
|
||||
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gradient_stop_delete), NULL);
|
||||
gtk_widget_show(button);
|
||||
gtk_table_attach(GTK_TABLE(table), button, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
table = gtk_table_new(3, 4, 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);
|
||||
|
||||
row = 0, col = 2;
|
||||
label = gtk_label_new(_("Color"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
gradient_stop_color = gtk_color_button_new();
|
||||
gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(gradient_stop_color), TRUE);
|
||||
gtk_widget_show(gradient_stop_color);
|
||||
gtk_table_attach(GTK_TABLE(table), gradient_stop_color, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
row++, col = 2;
|
||||
label = gtk_label_new(_("Position"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
gradient_stop_offset = gtk_spin_button_new_with_range(0, 100, 1);
|
||||
gtk_widget_show(gradient_stop_offset);
|
||||
gtk_table_attach(GTK_TABLE(table), gradient_stop_offset, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
|
||||
g_signal_connect(G_OBJECT(current_gradient), "changed", G_CALLBACK(current_gradient_changed), NULL);
|
||||
g_signal_connect(G_OBJECT(gradient_combo_type), "changed", G_CALLBACK(gradient_update), NULL);
|
||||
g_signal_connect(G_OBJECT(gradient_start_color), "color-set", G_CALLBACK(gradient_update), NULL);
|
||||
g_signal_connect(G_OBJECT(gradient_end_color), "color-set", G_CALLBACK(gradient_update), NULL);
|
||||
|
||||
g_signal_connect(G_OBJECT(current_gradient_stop), "changed", G_CALLBACK(current_gradient_stop_changed), NULL);
|
||||
g_signal_connect(G_OBJECT(gradient_stop_color), "color-set", G_CALLBACK(gradient_stop_update), NULL);
|
||||
g_signal_connect(G_OBJECT(gradient_stop_offset), "value-changed", G_CALLBACK(gradient_stop_update), NULL);
|
||||
|
||||
change_paragraph(parent);
|
||||
}
|
||||
|
||||
void gradient_create_new(GradientConfigType t)
|
||||
{
|
||||
int index = get_model_length(GTK_TREE_MODEL(gradient_ids));
|
||||
|
||||
GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig));
|
||||
g->type = t;
|
||||
gradients = g_list_append(gradients, g);
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(gradient_ids, &iter);
|
||||
gtk_list_store_set(gradient_ids, &iter,
|
||||
grColPixbuf, NULL,
|
||||
grColId, &index,
|
||||
grColText, index == 0 ? _("None") : "",
|
||||
-1);
|
||||
|
||||
gradient_update_image(index);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index);
|
||||
current_gradient_changed(0, 0);
|
||||
}
|
||||
|
||||
gpointer copy_GradientConfigColorStop(gconstpointer arg, gpointer data)
|
||||
{
|
||||
GradientConfigColorStop *old = (GradientConfigColorStop *)arg;
|
||||
|
||||
GradientConfigColorStop *copy = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop));
|
||||
memcpy(copy, old, sizeof(GradientConfigColorStop));
|
||||
return copy;
|
||||
}
|
||||
|
||||
void gradient_duplicate(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int old_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (old_index < 0) {
|
||||
gradient_create_new(GRADIENT_CONFIG_VERTICAL);
|
||||
return;
|
||||
}
|
||||
|
||||
GradientConfig *g_old = (GradientConfig*)g_list_nth(gradients, (guint)old_index)->data;
|
||||
|
||||
int index = get_model_length(GTK_TREE_MODEL(gradient_ids));
|
||||
|
||||
GradientConfig *g = (GradientConfig *)calloc(1, sizeof(GradientConfig));
|
||||
g->type = g_old->type;
|
||||
g->start_color = g_old->start_color;
|
||||
g->end_color = g_old->end_color;
|
||||
g->extra_color_stops = g_list_copy_deep(g->extra_color_stops, copy_GradientConfigColorStop, NULL);
|
||||
gradients = g_list_append(gradients, g);
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(gradient_ids, &iter);
|
||||
gtk_list_store_set(gradient_ids, &iter,
|
||||
grColPixbuf, NULL,
|
||||
grColId, &index,
|
||||
grColText, "",
|
||||
-1);
|
||||
|
||||
gradient_update_image(index);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index);
|
||||
current_gradient_changed(0, 0);
|
||||
}
|
||||
|
||||
void gradient_delete(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (get_model_length(GTK_TREE_MODEL(gradient_ids)) <= 1)
|
||||
return;
|
||||
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = gtk_tree_path_new_from_indices(index, -1);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
gradients = g_list_remove(gradients, g_list_nth(gradients, (guint)index)->data);
|
||||
gtk_list_store_remove(gradient_ids, &iter);
|
||||
|
||||
background_update_for_gradient(index);
|
||||
|
||||
if (index >= get_model_length(GTK_TREE_MODEL(gradient_ids)))
|
||||
index--;
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient), index);
|
||||
}
|
||||
|
||||
void gradient_draw(cairo_t *c, GradientConfig *g, int w, int h, gboolean preserve)
|
||||
{
|
||||
cairo_pattern_t *gpat;
|
||||
if (g->type == GRADIENT_CONFIG_VERTICAL)
|
||||
gpat = cairo_pattern_create_linear(0, 0, 0, h);
|
||||
else if (g->type == GRADIENT_CONFIG_HORIZONTAL)
|
||||
gpat = cairo_pattern_create_linear(0, 0, w, 0);
|
||||
else gpat = cairo_pattern_create_radial(w/2, h/2, 0, w/2, h/2, sqrt(w * w + h * h) / 2);
|
||||
cairo_pattern_add_color_stop_rgba(gpat, 0.0, g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], g->start_color.color.alpha);
|
||||
for (GList *l = g->extra_color_stops; l; l = l->next) {
|
||||
GradientConfigColorStop *stop = (GradientConfigColorStop *)l->data;
|
||||
cairo_pattern_add_color_stop_rgba(gpat,
|
||||
stop->offset,
|
||||
stop->color.rgb[0],
|
||||
stop->color.rgb[1],
|
||||
stop->color.rgb[2],
|
||||
stop->color.alpha);
|
||||
}
|
||||
cairo_pattern_add_color_stop_rgba(gpat, 1.0, g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], g->end_color.color.alpha);
|
||||
cairo_set_source(c, gpat);
|
||||
cairo_rectangle(c, 0, 0, w, h);
|
||||
if (preserve)
|
||||
cairo_fill_preserve(c);
|
||||
else
|
||||
cairo_fill(c);
|
||||
cairo_pattern_destroy(gpat);
|
||||
}
|
||||
|
||||
void gradient_update_image(int index)
|
||||
{
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data;
|
||||
|
||||
int w = 70;
|
||||
int h = 30;
|
||||
GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24);
|
||||
|
||||
cairo_t *cr = gdk_cairo_create(pixmap);
|
||||
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
|
||||
cairo_rectangle(cr, 0, 0, w, h);
|
||||
cairo_fill(cr);
|
||||
|
||||
gradient_draw(cr, g, w, h, FALSE);
|
||||
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h);
|
||||
if (pixmap)
|
||||
g_object_unref(pixmap);
|
||||
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = gtk_tree_path_new_from_indices(index, -1);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
gtk_list_store_set(gradient_ids, &iter,
|
||||
grColPixbuf, pixbuf,
|
||||
-1);
|
||||
if (pixbuf)
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
|
||||
void gradient_force_update()
|
||||
{
|
||||
gradient_update(NULL, NULL);
|
||||
}
|
||||
|
||||
static gboolean gradient_updates_disabled = FALSE;
|
||||
void gradient_update(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
if (gradient_updates_disabled)
|
||||
return;
|
||||
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (index <= 0)
|
||||
return;
|
||||
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = gtk_tree_path_new_from_indices(index, -1);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_ids), &iter, path);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data;
|
||||
|
||||
g->type = (GradientConfigType)MAX(0, gtk_combo_box_get_active(GTK_COMBO_BOX(gradient_combo_type)));
|
||||
|
||||
GdkColor color;
|
||||
int opacity;
|
||||
|
||||
gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_start_color), &color);
|
||||
opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_start_color)) * 100.0 / 0xffff);
|
||||
gdkColor2CairoColor(color, &g->start_color.color.rgb[0], &g->start_color.color.rgb[1], &g->start_color.color.rgb[2]);
|
||||
g->start_color.color.alpha = opacity / 100.0;
|
||||
|
||||
gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_end_color), &color);
|
||||
opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_end_color)) * 100.0 / 0xffff);
|
||||
gdkColor2CairoColor(color, &g->end_color.color.rgb[0], &g->end_color.color.rgb[1], &g->end_color.color.rgb[2]);
|
||||
g->end_color.color.alpha = opacity / 100.0;
|
||||
|
||||
gtk_list_store_set(gradient_ids, &iter,
|
||||
grColPixbuf, NULL,
|
||||
grColId, &index,
|
||||
grColText, "",
|
||||
-1);
|
||||
gradient_update_image(index);
|
||||
background_update_for_gradient(index);
|
||||
}
|
||||
|
||||
void current_gradient_changed(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
gtk_widget_set_sensitive(gradient_combo_type, index > 0);
|
||||
gtk_widget_set_sensitive(gradient_start_color, index > 0);
|
||||
gtk_widget_set_sensitive(gradient_end_color, index > 0);
|
||||
gtk_widget_set_sensitive(current_gradient_stop, index > 0);
|
||||
gtk_widget_set_sensitive(gradient_stop_color, index > 0);
|
||||
gtk_widget_set_sensitive(gradient_stop_offset, index > 0);
|
||||
|
||||
gradient_updates_disabled = TRUE;
|
||||
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)index)->data;
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gradient_combo_type), g->type);
|
||||
|
||||
GdkColor color;
|
||||
int opacity;
|
||||
|
||||
cairoColor2GdkColor(g->start_color.color.rgb[0], g->start_color.color.rgb[1], g->start_color.color.rgb[2], &color);
|
||||
opacity = g->start_color.color.alpha * 65535;
|
||||
gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_start_color), &color);
|
||||
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_start_color), opacity);
|
||||
|
||||
cairoColor2GdkColor(g->end_color.color.rgb[0], g->end_color.color.rgb[1], g->end_color.color.rgb[2], &color);
|
||||
opacity = g->end_color.color.alpha * 65535;
|
||||
gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_end_color), &color);
|
||||
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_end_color), opacity);
|
||||
|
||||
int old_stop_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop));
|
||||
gtk_list_store_clear(gradient_stop_ids);
|
||||
int stop_index = 0;
|
||||
for (GList *l = g->extra_color_stops; l; l = l->next, stop_index++) {
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(gradient_stop_ids, &iter);
|
||||
gtk_list_store_set(gradient_stop_ids, &iter,
|
||||
grStopColPixbuf, NULL,
|
||||
-1);
|
||||
gradient_stop_update_image(stop_index);
|
||||
}
|
||||
if (old_stop_index >= 0 && old_stop_index < stop_index)
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), old_stop_index);
|
||||
else
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), stop_index - 1);
|
||||
|
||||
gradient_updates_disabled = FALSE;
|
||||
gradient_update_image(index);
|
||||
}
|
||||
|
||||
//////// Gradient stops
|
||||
|
||||
GtkWidget *create_gradient_stop_combo()
|
||||
{
|
||||
GtkWidget *combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(gradient_stop_ids));
|
||||
GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", grStopColPixbuf, NULL);
|
||||
return combo;
|
||||
}
|
||||
|
||||
void gradient_stop_create_new()
|
||||
{
|
||||
int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (g_index < 0)
|
||||
return;
|
||||
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data;
|
||||
GradientConfigColorStop *stop = (GradientConfigColorStop *)calloc(1, sizeof(GradientConfigColorStop));
|
||||
if (g->extra_color_stops)
|
||||
memcpy(stop, g_list_last(g->extra_color_stops)->data, sizeof(GradientConfigColorStop));
|
||||
else
|
||||
memcpy(stop, &g->start_color, sizeof(GradientConfigColorStop));
|
||||
g->extra_color_stops = g_list_append(g->extra_color_stops, stop);
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(gradient_stop_ids, &iter);
|
||||
gtk_list_store_set(gradient_stop_ids, &iter,
|
||||
grStopColPixbuf, NULL,
|
||||
-1);
|
||||
|
||||
int stop_index = g_list_length(g->extra_color_stops) - 1;
|
||||
gradient_stop_update_image(stop_index);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), stop_index);
|
||||
current_gradient_stop_changed(0, 0);
|
||||
gradient_update_image(g_index);
|
||||
background_update_for_gradient(g_index);
|
||||
}
|
||||
|
||||
void gradient_stop_duplicate(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gradient_stop_create_new();
|
||||
}
|
||||
|
||||
void gradient_stop_delete(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (g_index < 0)
|
||||
return;
|
||||
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data;
|
||||
if (!g->extra_color_stops)
|
||||
return;
|
||||
|
||||
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop));
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = gtk_tree_path_new_from_indices(index, -1);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_stop_ids), &iter, path);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
g->extra_color_stops = g_list_remove(g->extra_color_stops, g_list_nth(g->extra_color_stops, (guint)index)->data);
|
||||
gtk_list_store_remove(gradient_stop_ids, &iter);
|
||||
|
||||
if (index >= get_model_length(GTK_TREE_MODEL(gradient_stop_ids)))
|
||||
index--;
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(current_gradient_stop), index);
|
||||
|
||||
gradient_update_image(g_index);
|
||||
background_update_for_gradient(g_index);
|
||||
}
|
||||
|
||||
void gradient_stop_update_image(int index)
|
||||
{
|
||||
int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (g_index < 0)
|
||||
return;
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data;
|
||||
GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data;
|
||||
|
||||
int w = 70;
|
||||
int h = 30;
|
||||
GdkPixmap *pixmap = gdk_pixmap_new(NULL, w, h, 24);
|
||||
|
||||
cairo_t *cr = gdk_cairo_create(pixmap);
|
||||
cairo_set_source_rgba(cr, stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], stop->color.alpha);
|
||||
cairo_rectangle(cr, 0, 0, w, h);
|
||||
cairo_fill(cr);
|
||||
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_colormap_get_system(), 0, 0, 0, 0, w, h);
|
||||
if (pixmap)
|
||||
g_object_unref(pixmap);
|
||||
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
path = gtk_tree_path_new_from_indices(index, -1);
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(gradient_stop_ids), &iter, path);
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
gtk_list_store_set(gradient_stop_ids, &iter,
|
||||
grStopColPixbuf, pixbuf,
|
||||
-1);
|
||||
if (pixbuf)
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
|
||||
void current_gradient_stop_changed(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (g_index < 0)
|
||||
return;
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data;
|
||||
|
||||
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop));
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data;
|
||||
|
||||
gradient_updates_disabled = TRUE;
|
||||
|
||||
GdkColor color;
|
||||
int opacity;
|
||||
|
||||
cairoColor2GdkColor(stop->color.rgb[0], stop->color.rgb[1], stop->color.rgb[2], &color);
|
||||
opacity = stop->color.alpha * 65535;
|
||||
gtk_color_button_set_color(GTK_COLOR_BUTTON(gradient_stop_color), &color);
|
||||
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(gradient_stop_color), opacity);
|
||||
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(gradient_stop_offset), stop->offset * 100);
|
||||
|
||||
gradient_updates_disabled = FALSE;
|
||||
}
|
||||
|
||||
void gradient_stop_update(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
if (gradient_updates_disabled)
|
||||
return;
|
||||
|
||||
int g_index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient));
|
||||
if (g_index < 0)
|
||||
return;
|
||||
GradientConfig *g = (GradientConfig *)g_list_nth(gradients, (guint)g_index)->data;
|
||||
|
||||
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(current_gradient_stop));
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
GradientConfigColorStop *stop = (GradientConfigColorStop *)g_list_nth(g->extra_color_stops, (guint)index)->data;
|
||||
|
||||
GdkColor color;
|
||||
int opacity;
|
||||
|
||||
gtk_color_button_get_color(GTK_COLOR_BUTTON(gradient_stop_color), &color);
|
||||
opacity = MIN(100, 0.5 + gtk_color_button_get_alpha(GTK_COLOR_BUTTON(gradient_stop_color)) * 100.0 / 0xffff);
|
||||
gdkColor2CairoColor(color, &stop->color.rgb[0], &stop->color.rgb[1], &stop->color.rgb[2]);
|
||||
stop->color.alpha = opacity / 100.0;
|
||||
|
||||
stop->offset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gradient_stop_offset)) / 100.;
|
||||
|
||||
gradient_stop_update_image(index);
|
||||
gradient_update_image(g_index);
|
||||
background_update_for_gradient(g_index);
|
||||
}
|
||||
47
src/tint2conf/gradient_gui.h
Normal file
47
src/tint2conf/gradient_gui.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef GRADIENT_GUI_H
|
||||
#define GRADIENT_GUI_H
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
int gradient_index_safe(int index);
|
||||
void create_gradient(GtkWidget *parent);
|
||||
GtkWidget *create_gradient_combo();
|
||||
void gradient_duplicate(GtkWidget *widget, gpointer data);
|
||||
void gradient_delete(GtkWidget *widget, gpointer data);
|
||||
void gradient_update_image(int index);
|
||||
void gradient_update(GtkWidget *widget, gpointer data);
|
||||
void gradient_force_update();
|
||||
void current_gradient_changed(GtkWidget *widget, gpointer data);
|
||||
void background_update_for_gradient(int gradient_id);
|
||||
|
||||
GtkWidget *create_gradient_stop_combo();
|
||||
void gradient_stop_duplicate(GtkWidget *widget, gpointer data);
|
||||
void gradient_stop_delete(GtkWidget *widget, gpointer data);
|
||||
void gradient_stop_update(GtkWidget *widget, gpointer data);
|
||||
void gradient_stop_update_image(int index);
|
||||
void current_gradient_stop_changed(GtkWidget *widget, gpointer data);
|
||||
|
||||
typedef enum GradientConfigType {
|
||||
GRADIENT_CONFIG_VERTICAL = 0,
|
||||
GRADIENT_CONFIG_HORIZONTAL,
|
||||
GRADIENT_CONFIG_RADIAL
|
||||
} GradientConfigType;
|
||||
|
||||
typedef struct GradientConfigColorStop {
|
||||
Color color;
|
||||
// offset in 0-1
|
||||
double offset;
|
||||
} GradientConfigColorStop;
|
||||
|
||||
typedef struct GradientConfig {
|
||||
GradientConfigType type;
|
||||
GradientConfigColorStop start_color;
|
||||
GradientConfigColorStop end_color;
|
||||
// Each element is a GradientConfigColorStop
|
||||
GList *extra_color_stops;
|
||||
} GradientConfig;
|
||||
|
||||
void gradient_create_new(GradientConfigType t);
|
||||
void gradient_draw(cairo_t *c, GradientConfig *g, int w, int h, gboolean preserve);
|
||||
|
||||
#endif
|
||||
20
src/tint2conf/gui.h
Normal file
20
src/tint2conf/gui.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "properties.h"
|
||||
#include "properties_rw.h"
|
||||
#include "../launcher/apps-common.h"
|
||||
#include "../launcher/icon-theme-common.h"
|
||||
#include "../util/common.h"
|
||||
#include "strnatcmp.h"
|
||||
|
||||
#define ROW_SPACING 10
|
||||
#define COL_SPACING 8
|
||||
#define DEFAULT_HOR_SPACING 5
|
||||
|
||||
gint compare_strings(gconstpointer a, gconstpointer b);
|
||||
void change_paragraph(GtkWidget *widget);
|
||||
int get_model_length(GtkTreeModel *model);
|
||||
void gdkColor2CairoColor(GdkColor color, double *red, double *green, double *blue);
|
||||
void cairoColor2GdkColor(double red, double green, double blue, GdkColor *color);
|
||||
@@ -34,6 +34,7 @@ void refresh_theme(const char *given_path);
|
||||
void remove_theme(const char *given_path);
|
||||
static void theme_selection_changed(GtkWidget *treeview, gpointer userdata);
|
||||
static gchar *find_theme_in_system_dirs(const gchar *given_name);
|
||||
static void load_specific_themes(char **paths, int count);
|
||||
|
||||
// ====== Utilities ======
|
||||
|
||||
@@ -118,7 +119,7 @@ gchar *import_no_overwrite(const char *filepath)
|
||||
if (!g_file_test(newpath, G_FILE_TEST_EXISTS)) {
|
||||
copy_file(filepath, newpath);
|
||||
theme_list_append(newpath);
|
||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
}
|
||||
|
||||
return newpath;
|
||||
@@ -137,7 +138,7 @@ void import_with_overwrite(const char *filepath, const char *newpath)
|
||||
if (theme_is_editable(newpath)) {
|
||||
if (!theme_existed) {
|
||||
theme_list_append(newpath);
|
||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
} else {
|
||||
int unused = system("killall -SIGUSR1 tint2 || pkill -SIGUSR1 -x tint2");
|
||||
(void)unused;
|
||||
@@ -157,7 +158,7 @@ static void menuImportFile();
|
||||
static void menuSaveAs();
|
||||
static void menuDelete();
|
||||
static void menuReset();
|
||||
static void edit_theme();
|
||||
static gboolean edit_theme(gpointer ignored);
|
||||
static void make_selected_theme_default();
|
||||
static void menuAbout();
|
||||
static gboolean view_onPopupMenu(GtkWidget *treeview, gpointer userdata);
|
||||
@@ -166,6 +167,7 @@ static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeV
|
||||
|
||||
static void select_first_theme();
|
||||
static void load_all_themes();
|
||||
static void reload_all_themes();
|
||||
|
||||
// ====== Globals ======
|
||||
|
||||
@@ -225,12 +227,12 @@ int main(int argc, char **argv)
|
||||
{
|
||||
gchar *tint2_config_dir = g_build_filename(g_get_user_config_dir(), "tint2", NULL);
|
||||
if (!g_file_test(tint2_config_dir, G_FILE_TEST_IS_DIR))
|
||||
g_mkdir(tint2_config_dir, 0777);
|
||||
g_mkdir(tint2_config_dir, 0700);
|
||||
g_free(tint2_config_dir);
|
||||
}
|
||||
|
||||
g_set_application_name(_("tint2conf"));
|
||||
gtk_window_set_default_icon_name("taskbar");
|
||||
gtk_window_set_default_icon_name("tint2conf");
|
||||
|
||||
// config file uses '.' as decimal separator
|
||||
setlocale(LC_NUMERIC, "POSIX");
|
||||
@@ -255,7 +257,7 @@ int main(int argc, char **argv)
|
||||
{"ThemeEdit", GTK_STOCK_PROPERTIES, _("_Edit theme..."), NULL, _("Edit the selected theme"), G_CALLBACK(edit_theme)},
|
||||
{"ThemeMakeDefault", GTK_STOCK_APPLY, _("_Make default"), NULL, _("Replace the default theme with the selected one"), G_CALLBACK(make_selected_theme_default)},
|
||||
{"ThemeRefresh", GTK_STOCK_REFRESH, _("Refresh"), NULL, _("Redraw the selected theme"), G_CALLBACK(refresh_current_theme)},
|
||||
{"RefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Redraw all themes"), G_CALLBACK(load_all_themes)},
|
||||
{"RefreshAll", GTK_STOCK_REFRESH, _("Refresh all"), NULL, _("Redraw all themes"), G_CALLBACK(reload_all_themes)},
|
||||
{"Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", _("Quit"), G_CALLBACK(gtk_main_quit)},
|
||||
{"HelpMenu", NULL, _("_Help"), NULL, NULL, NULL},
|
||||
{"HelpAbout", GTK_STOCK_ABOUT, _("_About"), "<Control>A", _("About"), G_CALLBACK(menuAbout)}};
|
||||
@@ -304,9 +306,15 @@ int main(int argc, char **argv)
|
||||
|
||||
// load themes
|
||||
load_all_themes();
|
||||
argc--, argv++;
|
||||
if (argc > 0) {
|
||||
load_specific_themes(argv, argc);
|
||||
g_timeout_add(SNAPSHOT_TICK, edit_theme, NULL);
|
||||
}
|
||||
|
||||
gtk_widget_show_all(g_window);
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -326,10 +334,10 @@ static void menuAbout()
|
||||
"version",
|
||||
VERSION_STRING,
|
||||
"copyright",
|
||||
_("Copyright 2009-2015 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU "
|
||||
_("Copyright 2009-2017 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU "
|
||||
"GPL version 3"),
|
||||
"logo-icon-name",
|
||||
"taskbar",
|
||||
"tint2conf",
|
||||
"authors",
|
||||
authors,
|
||||
/* Translators: translate "translator-credits" as your name to have it appear in the credits
|
||||
@@ -635,11 +643,11 @@ void select_theme(const char *given_path)
|
||||
}
|
||||
|
||||
// Edits the selected theme. If it is read-only, it copies first to ~.
|
||||
static void edit_theme()
|
||||
static gboolean edit_theme(gpointer ignored)
|
||||
{
|
||||
gchar *filepath = get_selected_theme_or_warn();
|
||||
if (!filepath)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
gboolean editable = theme_is_editable(filepath);
|
||||
if (!editable) {
|
||||
@@ -657,6 +665,8 @@ static void edit_theme()
|
||||
g_free(filepath);
|
||||
|
||||
destroy_please_wait();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void make_selected_theme_default()
|
||||
@@ -694,7 +704,7 @@ static void make_selected_theme_default()
|
||||
|
||||
static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
|
||||
{
|
||||
edit_theme();
|
||||
edit_theme(NULL);
|
||||
}
|
||||
|
||||
// ====== Theme load/reload ======
|
||||
@@ -826,7 +836,72 @@ static void load_all_themes()
|
||||
have_iter = gtk_tree_model_iter_next(model, &iter);
|
||||
}
|
||||
|
||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void reload_all_themes()
|
||||
{
|
||||
ensure_default_theme_exists();
|
||||
|
||||
gtk_list_store_clear(GTK_LIST_STORE(theme_list_store));
|
||||
theme_selection_changed(NULL, NULL);
|
||||
|
||||
gboolean found_themes = FALSE;
|
||||
if (load_user_themes())
|
||||
found_themes = TRUE;
|
||||
if (load_system_themes())
|
||||
found_themes = TRUE;
|
||||
|
||||
if (found_themes) {
|
||||
select_first_theme();
|
||||
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
gboolean have_iter;
|
||||
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
||||
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
||||
while (have_iter) {
|
||||
gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, COL_FORCE_REFRESH, TRUE, -1);
|
||||
have_iter = gtk_tree_model_iter_next(model, &iter);
|
||||
}
|
||||
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void load_specific_themes(char **paths, int count)
|
||||
{
|
||||
ensure_default_theme_exists();
|
||||
|
||||
gboolean found_themes = FALSE;
|
||||
while (count > 0) {
|
||||
// Load configs
|
||||
const char *file_name = paths[0];
|
||||
paths++, count--;
|
||||
if (g_file_test(file_name, G_FILE_TEST_IS_REGULAR) || g_file_test(file_name, G_FILE_TEST_IS_SYMLINK) ) {
|
||||
theme_list_append(file_name);
|
||||
if (!found_themes) {
|
||||
select_theme(file_name);
|
||||
found_themes = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found_themes) {
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
gboolean have_iter;
|
||||
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
||||
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
||||
while (have_iter) {
|
||||
gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1);
|
||||
have_iter = gtk_tree_model_iter_next(model, &iter);
|
||||
}
|
||||
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +912,7 @@ void refresh_current_theme()
|
||||
GtkTreeModel *model;
|
||||
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
|
||||
gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1);
|
||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,7 +927,7 @@ void refresh_theme(const char *given_path)
|
||||
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filepath, -1);
|
||||
if (g_str_equal(filepath, given_path)) {
|
||||
gtk_list_store_set(theme_list_store, &iter, COL_SNAPSHOT, NULL, -1);
|
||||
g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
|
||||
g_timeout_add(SNAPSHOT_TICK, update_snapshot, NULL);
|
||||
g_free(filepath);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#endif
|
||||
|
||||
#define SNAPSHOT_TICK 190
|
||||
gboolean update_snapshot();
|
||||
gboolean update_snapshot(gpointer ignored);
|
||||
void menuApply();
|
||||
void refresh_current_theme();
|
||||
extern GtkWidget *g_window;
|
||||
|
||||
274
src/tint2conf/md4.c
Normal file
274
src/tint2conf/md4.c
Normal file
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* MD4 Message Digest Algorithm (RFC1320).
|
||||
*
|
||||
* Implementation derived from Andrew Tridgell and Steve French's
|
||||
* CIFS MD4 implementation, and the cryptoapi implementation
|
||||
* originally based on the public domain implementation written
|
||||
* by Colin Plumb in 1993.
|
||||
*
|
||||
* Copyright (c) Andrew Tridgell 1997-1998.
|
||||
* Modified by Steve French (sfrench@us.ibm.com) 2002
|
||||
* Copyright (c) Cryptoapi developers.
|
||||
* Copyright (c) 2002 David S. Miller (davem@redhat.com)
|
||||
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef u_int8_t u8;
|
||||
typedef u_int32_t u32;
|
||||
typedef u_int64_t u64;
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define shash_desc md4_ctx
|
||||
#define shash_desc_ctx(x) (x)
|
||||
|
||||
#define MD4_DIGEST_SIZE 16
|
||||
#define MD4_HMAC_BLOCK_SIZE 64
|
||||
#define MD4_BLOCK_WORDS 16
|
||||
#define MD4_HASH_WORDS 4
|
||||
|
||||
struct md4_ctx {
|
||||
u32 hash[MD4_HASH_WORDS];
|
||||
u32 block[MD4_BLOCK_WORDS];
|
||||
u64 byte_count;
|
||||
};
|
||||
|
||||
static inline u32 lshift(u32 x, unsigned int s)
|
||||
{
|
||||
x &= 0xFFFFFFFF;
|
||||
return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
|
||||
}
|
||||
|
||||
static inline u32 F(u32 x, u32 y, u32 z)
|
||||
{
|
||||
return (x & y) | ((~x) & z);
|
||||
}
|
||||
|
||||
static inline u32 G(u32 x, u32 y, u32 z)
|
||||
{
|
||||
return (x & y) | (x & z) | (y & z);
|
||||
}
|
||||
|
||||
static inline u32 H(u32 x, u32 y, u32 z)
|
||||
{
|
||||
return x ^ y ^ z;
|
||||
}
|
||||
|
||||
#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
|
||||
#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (u32)0x5A827999,s))
|
||||
#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (u32)0x6ED9EBA1,s))
|
||||
|
||||
/* XXX: this stuff can be optimized */
|
||||
static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
|
||||
{
|
||||
while (words--) {
|
||||
*buf = ntohl(*buf);
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void cpu_to_le32_array(u32 *buf, unsigned int words)
|
||||
{
|
||||
while (words--) {
|
||||
*buf = htonl(*buf);
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
|
||||
static void md4_transform(u32 *hash, u32 const *in)
|
||||
{
|
||||
u32 a, b, c, d;
|
||||
|
||||
a = hash[0];
|
||||
b = hash[1];
|
||||
c = hash[2];
|
||||
d = hash[3];
|
||||
|
||||
ROUND1(a, b, c, d, in[0], 3);
|
||||
ROUND1(d, a, b, c, in[1], 7);
|
||||
ROUND1(c, d, a, b, in[2], 11);
|
||||
ROUND1(b, c, d, a, in[3], 19);
|
||||
ROUND1(a, b, c, d, in[4], 3);
|
||||
ROUND1(d, a, b, c, in[5], 7);
|
||||
ROUND1(c, d, a, b, in[6], 11);
|
||||
ROUND1(b, c, d, a, in[7], 19);
|
||||
ROUND1(a, b, c, d, in[8], 3);
|
||||
ROUND1(d, a, b, c, in[9], 7);
|
||||
ROUND1(c, d, a, b, in[10], 11);
|
||||
ROUND1(b, c, d, a, in[11], 19);
|
||||
ROUND1(a, b, c, d, in[12], 3);
|
||||
ROUND1(d, a, b, c, in[13], 7);
|
||||
ROUND1(c, d, a, b, in[14], 11);
|
||||
ROUND1(b, c, d, a, in[15], 19);
|
||||
|
||||
ROUND2(a, b, c, d,in[ 0], 3);
|
||||
ROUND2(d, a, b, c, in[4], 5);
|
||||
ROUND2(c, d, a, b, in[8], 9);
|
||||
ROUND2(b, c, d, a, in[12], 13);
|
||||
ROUND2(a, b, c, d, in[1], 3);
|
||||
ROUND2(d, a, b, c, in[5], 5);
|
||||
ROUND2(c, d, a, b, in[9], 9);
|
||||
ROUND2(b, c, d, a, in[13], 13);
|
||||
ROUND2(a, b, c, d, in[2], 3);
|
||||
ROUND2(d, a, b, c, in[6], 5);
|
||||
ROUND2(c, d, a, b, in[10], 9);
|
||||
ROUND2(b, c, d, a, in[14], 13);
|
||||
ROUND2(a, b, c, d, in[3], 3);
|
||||
ROUND2(d, a, b, c, in[7], 5);
|
||||
ROUND2(c, d, a, b, in[11], 9);
|
||||
ROUND2(b, c, d, a, in[15], 13);
|
||||
|
||||
ROUND3(a, b, c, d,in[ 0], 3);
|
||||
ROUND3(d, a, b, c, in[8], 9);
|
||||
ROUND3(c, d, a, b, in[4], 11);
|
||||
ROUND3(b, c, d, a, in[12], 15);
|
||||
ROUND3(a, b, c, d, in[2], 3);
|
||||
ROUND3(d, a, b, c, in[10], 9);
|
||||
ROUND3(c, d, a, b, in[6], 11);
|
||||
ROUND3(b, c, d, a, in[14], 15);
|
||||
ROUND3(a, b, c, d, in[1], 3);
|
||||
ROUND3(d, a, b, c, in[9], 9);
|
||||
ROUND3(c, d, a, b, in[5], 11);
|
||||
ROUND3(b, c, d, a, in[13], 15);
|
||||
ROUND3(a, b, c, d, in[3], 3);
|
||||
ROUND3(d, a, b, c, in[11], 9);
|
||||
ROUND3(c, d, a, b, in[7], 11);
|
||||
ROUND3(b, c, d, a, in[15], 15);
|
||||
|
||||
hash[0] += a;
|
||||
hash[1] += b;
|
||||
hash[2] += c;
|
||||
hash[3] += d;
|
||||
}
|
||||
|
||||
static inline void md4_transform_helper(struct md4_ctx *ctx)
|
||||
{
|
||||
le32_to_cpu_array(ctx->block, ARRAY_SIZE(ctx->block));
|
||||
md4_transform(ctx->hash, ctx->block);
|
||||
}
|
||||
|
||||
static int md4_init(struct shash_desc *desc)
|
||||
{
|
||||
struct md4_ctx *mctx = shash_desc_ctx(desc);
|
||||
|
||||
mctx->hash[0] = 0x67452301;
|
||||
mctx->hash[1] = 0xefcdab89;
|
||||
mctx->hash[2] = 0x98badcfe;
|
||||
mctx->hash[3] = 0x10325476;
|
||||
mctx->byte_count = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int md4_update(struct shash_desc *desc, const u8 *data, unsigned int len)
|
||||
{
|
||||
struct md4_ctx *mctx = shash_desc_ctx(desc);
|
||||
const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
|
||||
|
||||
mctx->byte_count += len;
|
||||
|
||||
if (avail > len) {
|
||||
memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
|
||||
data, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
|
||||
data, avail);
|
||||
|
||||
md4_transform_helper(mctx);
|
||||
data += avail;
|
||||
len -= avail;
|
||||
|
||||
while (len >= sizeof(mctx->block)) {
|
||||
memcpy(mctx->block, data, sizeof(mctx->block));
|
||||
md4_transform_helper(mctx);
|
||||
data += sizeof(mctx->block);
|
||||
len -= sizeof(mctx->block);
|
||||
}
|
||||
|
||||
memcpy(mctx->block, data, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int md4_final(struct shash_desc *desc, u8 *out)
|
||||
{
|
||||
struct md4_ctx *mctx = shash_desc_ctx(desc);
|
||||
const unsigned int offset = mctx->byte_count & 0x3f;
|
||||
char *p = (char *)mctx->block + offset;
|
||||
int padding = 56 - (offset + 1);
|
||||
|
||||
*p++ = 0x80;
|
||||
if (padding < 0) {
|
||||
memset(p, 0x00, padding + sizeof (u64));
|
||||
md4_transform_helper(mctx);
|
||||
p = (char *)mctx->block;
|
||||
padding = 56;
|
||||
}
|
||||
|
||||
memset(p, 0, padding);
|
||||
mctx->block[14] = mctx->byte_count << 3;
|
||||
mctx->block[15] = mctx->byte_count >> 29;
|
||||
le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
|
||||
sizeof(u64)) / sizeof(u32));
|
||||
md4_transform(mctx->hash, mctx->block);
|
||||
cpu_to_le32_array(mctx->hash, ARRAY_SIZE(mctx->hash));
|
||||
memcpy(out, mctx->hash, sizeof(mctx->hash));
|
||||
memset(mctx, 0, sizeof(*mctx));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char to_hex(u8 v)
|
||||
{
|
||||
v = v & 0xf;
|
||||
if (v < 0xa)
|
||||
return '0' + v;
|
||||
return 'a' + v - 0xa;
|
||||
}
|
||||
|
||||
void md4hexf(const char *path, char *hash)
|
||||
{
|
||||
struct md4_ctx mctx;
|
||||
md4_init(&mctx);
|
||||
|
||||
int fd = open(path, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
u8 buffer[MD4_HMAC_BLOCK_SIZE];
|
||||
while (1) {
|
||||
ssize_t count = read(fd, buffer, sizeof(buffer));
|
||||
if (count <= 0)
|
||||
break;
|
||||
md4_update(&mctx, buffer, (unsigned)count);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
u8 out[MD4_DIGEST_SIZE];
|
||||
md4_final(&mctx, out);
|
||||
|
||||
for (int i = 0; i < MD4_DIGEST_SIZE; i++) {
|
||||
hash[2*i+0] = to_hex(out[i] >> 4);
|
||||
hash[2*i+1] = to_hex(out[i] & 0xf);
|
||||
}
|
||||
hash[2*MD4_DIGEST_SIZE] = 0;
|
||||
}
|
||||
7
src/tint2conf/md4.h
Normal file
7
src/tint2conf/md4.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef MD4_H
|
||||
#define MD4_H
|
||||
|
||||
#define MD4_HEX_SIZE 33
|
||||
void md4hexf(const char *path, char *hash);
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@ if (GETTEXT_FOUND)
|
||||
foreach(LANG ${LANGUAGES})
|
||||
GETTEXT_PROCESS_PO_FILES(${LANG} ALL PO_FILES ${LANG}.po)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${DATADIR}/locale/${LANG}/LC_MESSAGES"
|
||||
DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES"
|
||||
RENAME "${GETTEXT_PACKAGE}.mo")
|
||||
endforeach ()
|
||||
endif()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ extern GtkWidget *panel_window_name, *disable_transparency;
|
||||
extern GtkWidget *panel_mouse_effects;
|
||||
extern GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness;
|
||||
extern GtkWidget *mouse_pressed_icon_opacity, *mouse_pressed_icon_saturation, *mouse_pressed_icon_brightness;
|
||||
extern GtkWidget *panel_primary_monitor_first;
|
||||
extern GtkWidget *panel_primary_monitor_first, *panel_shrink;
|
||||
|
||||
enum {
|
||||
itemsColName = 0,
|
||||
@@ -57,6 +57,7 @@ extern GtkWidget *taskbar_name_font, *taskbar_name_font_set;
|
||||
extern GtkWidget *taskbar_active_background, *taskbar_inactive_background;
|
||||
extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background;
|
||||
extern GtkWidget *taskbar_distribute_size, *taskbar_sort_order, *taskbar_alignment, *taskbar_always_show_all_desktop_tasks;
|
||||
extern GtkWidget *taskbar_hide_empty;
|
||||
|
||||
// task
|
||||
extern GtkWidget *task_mouse_left, *task_mouse_middle, *task_mouse_right, *task_mouse_scroll_up, *task_mouse_scroll_down;
|
||||
@@ -110,7 +111,7 @@ extern GtkWidget *ac_connected_cmd, *ac_disconnected_cmd;
|
||||
// systray
|
||||
extern GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing;
|
||||
extern GtkWidget *systray_icon_size, *systray_icon_opacity, *systray_icon_saturation, *systray_icon_brightness;
|
||||
extern GtkWidget *systray_background, *systray_monitor;
|
||||
extern GtkWidget *systray_background, *systray_monitor, *systray_name_filter;
|
||||
|
||||
// tooltip
|
||||
extern GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_set, *tooltip_font_color;
|
||||
@@ -118,6 +119,22 @@ extern GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
|
||||
extern GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
|
||||
extern GtkWidget *tooltip_background;
|
||||
|
||||
// Separator
|
||||
typedef struct Separator {
|
||||
char name[256];
|
||||
GtkWidget *container;
|
||||
GtkWidget *page_separator;
|
||||
GtkWidget *page_label;
|
||||
GtkWidget *separator_background;
|
||||
GtkWidget *separator_color;
|
||||
GtkWidget *separator_style;
|
||||
GtkWidget *separator_size;
|
||||
GtkWidget *separator_padding_x;
|
||||
GtkWidget *separator_padding_y;
|
||||
} Separator;
|
||||
|
||||
extern GArray *separators;
|
||||
|
||||
// Executor
|
||||
typedef struct Executor {
|
||||
char name[256];
|
||||
@@ -134,6 +151,21 @@ typedef struct Executor {
|
||||
|
||||
extern GArray *executors;
|
||||
|
||||
// Button
|
||||
typedef struct Button {
|
||||
char name[256];
|
||||
GtkWidget *container;
|
||||
GtkWidget *page_button;
|
||||
GtkWidget *page_label;
|
||||
GtkWidget *button_icon, *button_text, *button_tooltip;
|
||||
GtkWidget *button_left_command, *button_right_command;
|
||||
GtkWidget *button_mclick_command, *button_rclick_command, *button_uwheel_command, *button_dwheel_command;
|
||||
GtkWidget *button_font, *button_font_set, *button_font_color, *button_padding_x, *button_padding_y, *button_centered;
|
||||
GtkWidget *button_background, *button_max_icon_size;
|
||||
} Button;
|
||||
|
||||
extern GArray *buttons;
|
||||
|
||||
// launcher
|
||||
|
||||
enum {
|
||||
@@ -168,6 +200,7 @@ enum {
|
||||
bgColFillOpacity,
|
||||
bgColBorderColor,
|
||||
bgColBorderOpacity,
|
||||
bgColGradientId,
|
||||
bgColBorderWidth,
|
||||
bgColCornerRadius,
|
||||
bgColText,
|
||||
@@ -175,10 +208,12 @@ enum {
|
||||
bgColFillOpacityOver,
|
||||
bgColBorderColorOver,
|
||||
bgColBorderOpacityOver,
|
||||
bgColGradientIdOver,
|
||||
bgColFillColorPress,
|
||||
bgColFillOpacityPress,
|
||||
bgColBorderColorPress,
|
||||
bgColBorderOpacityPress,
|
||||
bgColGradientIdPress,
|
||||
bgColBorderSidesTop,
|
||||
bgColBorderSidesBottom,
|
||||
bgColBorderSidesLeft,
|
||||
@@ -190,10 +225,13 @@ extern GtkListStore *backgrounds;
|
||||
extern GtkWidget *current_background,
|
||||
*background_fill_color,
|
||||
*background_border_color,
|
||||
*background_gradient,
|
||||
*background_fill_color_over,
|
||||
*background_border_color_over,
|
||||
*background_gradient_over,
|
||||
*background_fill_color_press,
|
||||
*background_border_color_press,
|
||||
*background_gradient_press,
|
||||
*background_border_width,
|
||||
*background_border_sides_top,
|
||||
*background_border_sides_bottom,
|
||||
@@ -201,19 +239,55 @@ extern GtkWidget *current_background,
|
||||
*background_border_sides_right,
|
||||
*background_corner_radius;
|
||||
|
||||
// gradients
|
||||
enum {
|
||||
grColPixbuf = 0,
|
||||
grColId,
|
||||
grColText,
|
||||
grNumCols
|
||||
};
|
||||
|
||||
// gradient color stops
|
||||
enum {
|
||||
grStopColPixbuf = 0,
|
||||
grStopNumCols
|
||||
};
|
||||
extern GtkListStore *gradient_ids, *gradient_stop_ids;
|
||||
extern GList *gradients;
|
||||
|
||||
extern GtkWidget *current_gradient,
|
||||
*gradient_combo_type,
|
||||
*gradient_start_color,
|
||||
*gradient_end_color,
|
||||
*current_gradient_stop,
|
||||
*gradient_stop_color,
|
||||
*gradient_stop_offset;
|
||||
|
||||
void background_create_new();
|
||||
void background_force_update();
|
||||
int background_index_safe(int index);
|
||||
|
||||
GtkWidget *create_properties();
|
||||
|
||||
void separator_create_new();
|
||||
Separator *separator_get_last();
|
||||
void separator_remove(int i);
|
||||
void separator_update_indices();
|
||||
|
||||
void execp_create_new();
|
||||
Executor *execp_get_last();
|
||||
void execp_remove(int i);
|
||||
void execp_update_indices();
|
||||
|
||||
void button_create_new();
|
||||
Button *button_get_last();
|
||||
void button_remove(int i);
|
||||
void button_update_indices();
|
||||
|
||||
void create_please_wait(GtkWindow *parent);
|
||||
void process_events();
|
||||
void destroy_please_wait();
|
||||
|
||||
void hex2gdk(char *hex, GdkColor *color);
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@
|
||||
#include "strnatcmp.h"
|
||||
#include "theme_view.h"
|
||||
#include "common.h"
|
||||
#include "md4.h"
|
||||
|
||||
// The data columns that we export via the tree model interface
|
||||
GtkWidget *g_theme_view;
|
||||
@@ -37,7 +38,7 @@ GtkWidget *create_view()
|
||||
GtkCellRenderer *renderer;
|
||||
|
||||
theme_list_store =
|
||||
gtk_list_store_new(NB_COL, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);
|
||||
gtk_list_store_new(NB_COL, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT, G_TYPE_BOOLEAN);
|
||||
|
||||
GtkWidget *view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(theme_list_store));
|
||||
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
|
||||
@@ -147,13 +148,20 @@ void theme_list_append(const gchar *path)
|
||||
g_free(dir);
|
||||
|
||||
gchar *display_name = g_strdup_printf("%s\n(%s)", name, suffix);
|
||||
gtk_list_store_set(theme_list_store, &iter, COL_THEME_FILE, path, COL_THEME_NAME, display_name, -1);
|
||||
gtk_list_store_set(theme_list_store, &iter, COL_THEME_FILE, path, COL_THEME_NAME, display_name, COL_FORCE_REFRESH, FALSE, -1);
|
||||
g_free(display_name);
|
||||
g_free(suffix);
|
||||
}
|
||||
|
||||
gboolean update_snapshot()
|
||||
gboolean update_snapshot(gpointer ignored)
|
||||
{
|
||||
{
|
||||
gchar *tint2_cache_dir = g_build_filename(g_get_user_cache_dir(), "tint2", NULL);
|
||||
if (!g_file_test(tint2_cache_dir, G_FILE_TEST_IS_DIR))
|
||||
g_mkdir(tint2_cache_dir, 0700);
|
||||
g_free(tint2_cache_dir);
|
||||
}
|
||||
|
||||
const gint PADDING = 20;
|
||||
|
||||
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
|
||||
@@ -162,19 +170,7 @@ gboolean update_snapshot()
|
||||
gboolean have_iter;
|
||||
|
||||
int num_updates = 0;
|
||||
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
||||
while (have_iter) {
|
||||
GdkPixbuf *pixbuf;
|
||||
gtk_tree_model_get(model, &iter, COL_SNAPSHOT, &pixbuf, -1);
|
||||
if (pixbuf)
|
||||
g_object_unref(pixbuf);
|
||||
else
|
||||
num_updates++;
|
||||
have_iter = gtk_tree_model_iter_next(model, &iter);
|
||||
}
|
||||
gboolean need_pls_wait = num_updates > 3;
|
||||
if (need_pls_wait)
|
||||
create_please_wait(GTK_WINDOW(g_window));
|
||||
gboolean need_pls_wait = FALSE;
|
||||
|
||||
have_iter = gtk_tree_model_get_iter_first(model, &iter);
|
||||
while (have_iter) {
|
||||
@@ -186,27 +182,30 @@ gboolean update_snapshot()
|
||||
continue;
|
||||
}
|
||||
|
||||
// build panel's snapshot
|
||||
gchar *path;
|
||||
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, -1);
|
||||
gboolean force_refresh;
|
||||
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &path, COL_FORCE_REFRESH, &force_refresh, -1);
|
||||
|
||||
char fname[128];
|
||||
sprintf(fname, "tint2-%d.jpg", (int)getpid());
|
||||
char hash[MD4_HEX_SIZE + 4];
|
||||
md4hexf(path, hash);
|
||||
strcat(hash, ".png");
|
||||
|
||||
gchar *snap = g_build_filename(g_get_tmp_dir(), fname, NULL);
|
||||
g_remove(snap);
|
||||
|
||||
gchar *cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\' 1>/dev/null 2>/dev/null", path, snap);
|
||||
if (system(cmd) == 0) {
|
||||
// load
|
||||
pixbuf = gdk_pixbuf_new_from_file(snap, NULL);
|
||||
if (pixbuf == NULL) {
|
||||
printf("snapshot NULL : %s\n", cmd);
|
||||
gchar *snap = g_build_filename(g_get_user_cache_dir(), "tint2", hash, NULL);
|
||||
pixbuf = force_refresh ? NULL : gdk_pixbuf_new_from_file(snap, NULL);
|
||||
if (!pixbuf) {
|
||||
gchar *cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\' 1>/dev/null 2>/dev/null", path, snap);
|
||||
num_updates++;
|
||||
if (num_updates > 3 && !need_pls_wait) {
|
||||
need_pls_wait = TRUE;
|
||||
create_please_wait(GTK_WINDOW(g_window));
|
||||
}
|
||||
if (system(cmd) == 0) {
|
||||
// load
|
||||
pixbuf = gdk_pixbuf_new_from_file(snap, NULL);
|
||||
}
|
||||
g_free(cmd);
|
||||
}
|
||||
g_free(cmd);
|
||||
|
||||
g_remove(snap);
|
||||
g_free(snap);
|
||||
g_free(path);
|
||||
|
||||
@@ -218,6 +217,8 @@ gboolean update_snapshot()
|
||||
gdk_pixbuf_get_width(pixbuf) + PADDING,
|
||||
COL_HEIGHT,
|
||||
gdk_pixbuf_get_height(pixbuf) + PADDING,
|
||||
COL_FORCE_REFRESH,
|
||||
FALSE,
|
||||
-1);
|
||||
if (pixbuf)
|
||||
g_object_unref(pixbuf);
|
||||
|
||||
@@ -10,6 +10,7 @@ enum { COL_THEME_FILE = 0,
|
||||
COL_SNAPSHOT,
|
||||
COL_WIDTH,
|
||||
COL_HEIGHT,
|
||||
COL_FORCE_REFRESH,
|
||||
NB_COL, };
|
||||
|
||||
GtkWidget *create_view();
|
||||
|
||||
@@ -34,7 +34,7 @@ Name[nb]=Panelbehandler
|
||||
Name[nl]=Paneel Manager
|
||||
Name[nn]=Panelhandsamar
|
||||
Name[pa]=ਪੈਨਲ ਮੈਨੇਜਰ
|
||||
Name[pl]=Ustawienia panelu
|
||||
Name[pl]=Ustawienia panelu tint2
|
||||
Name[pt]=Gestor do Painel
|
||||
Name[pt_BR]=Gerenciador do painel
|
||||
Name[ro]=Manager de panouri
|
||||
@@ -86,7 +86,7 @@ GenericName[nb]=Panelbehandler
|
||||
GenericName[nl]=Paneel Manager
|
||||
GenericName[nn]=Panelhandsamar
|
||||
GenericName[pa]=ਪੈਨਲ ਮੈਨੇਜਰ
|
||||
GenericName[pl]=Ustawienia panelu
|
||||
GenericName[pl]=Ustawienia panelu tint2
|
||||
GenericName[pt]=Gestor do Painel
|
||||
GenericName[pt_BR]=Gerenciador do painel
|
||||
GenericName[ro]=Manager de panouri
|
||||
@@ -106,6 +106,7 @@ GenericName[zh_CN]=面板管理器
|
||||
GenericName[zh_TW]=面板管理程式
|
||||
|
||||
Comment=Tool to configure the tint2 panel
|
||||
Comment[pl]=Narzędzie do konfiguracji panelu tint2 configure the tint2 panel
|
||||
Comment[ru]=Инструмент конфигурирования панели tint2
|
||||
|
||||
Exec=tint2conf
|
||||
|
||||
411
src/tint2rc.c
Normal file
411
src/tint2rc.c
Normal file
@@ -0,0 +1,411 @@
|
||||
#include "tint2rc.h"
|
||||
|
||||
unsigned char themes_tint2rc[] = {
|
||||
0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61,
|
||||
0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x69, 0x6e, 0x74, 0x32,
|
||||
0x63, 0x6f, 0x6e, 0x66, 0x20, 0x32, 0x36, 0x34, 0x31, 0x20, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x53, 0x65, 0x65, 0x20, 0x68, 0x74, 0x74,
|
||||
0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x39, 0x30, 0x30, 0x30, 0x2f, 0x74, 0x69,
|
||||
0x6e, 0x74, 0x32, 0x2f, 0x77, 0x69, 0x6b, 0x69, 0x73, 0x2f, 0x43, 0x6f,
|
||||
0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20,
|
||||
0x0a, 0x23, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x64, 0x6f, 0x63, 0x75,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75,
|
||||
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2e, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x0a, 0x23, 0x20, 0x42,
|
||||
0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x31, 0x3a,
|
||||
0x20, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x65, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65,
|
||||
0x72, 0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x30, 0x0a,
|
||||
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
|
||||
0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64,
|
||||
0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76,
|
||||
0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x20, 0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75,
|
||||
0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65,
|
||||
0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x20, 0x36, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73,
|
||||
0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x20, 0x33, 0x30, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67,
|
||||
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x32, 0x3a, 0x20, 0x44, 0x65, 0x66,
|
||||
0x61, 0x75, 0x6c, 0x74, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x2c, 0x20, 0x49,
|
||||
0x63, 0x6f, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x74, 0x61, 0x73,
|
||||
0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69, 0x64,
|
||||
0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67,
|
||||
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20,
|
||||
0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, 0x32, 0x30,
|
||||
0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x20, 0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20,
|
||||
0x33, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e,
|
||||
0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65,
|
||||
0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x20,
|
||||
0x32, 0x32, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f,
|
||||
0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20,
|
||||
0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x62,
|
||||
0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f,
|
||||
0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20,
|
||||
0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x20, 0x34, 0x0a,
|
||||
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
|
||||
0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23,
|
||||
0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x0a, 0x23,
|
||||
0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20,
|
||||
0x33, 0x3a, 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x74, 0x61,
|
||||
0x73, 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x3d,
|
||||
0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77, 0x69,
|
||||
0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
|
||||
0x20, 0x3d, 0x20, 0x23, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x20, 0x32,
|
||||
0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
0x20, 0x34, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75,
|
||||
0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76,
|
||||
0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,
|
||||
0x20, 0x32, 0x32, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d,
|
||||
0x20, 0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a,
|
||||
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64,
|
||||
0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x20, 0x34,
|
||||
0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x23, 0x65, 0x61, 0x65, 0x61, 0x65, 0x61, 0x20, 0x34, 0x34, 0x0a, 0x0a,
|
||||
0x23, 0x20, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x20, 0x34, 0x3a, 0x20, 0x55, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x20, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65, 0x64, 0x20,
|
||||
0x3d, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x77,
|
||||
0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x34, 0x34, 0x30, 0x30, 0x20,
|
||||
0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37,
|
||||
0x33, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67,
|
||||
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f,
|
||||
0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x63, 0x63, 0x37,
|
||||
0x37, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64,
|
||||
0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68, 0x6f, 0x76,
|
||||
0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33,
|
||||
0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f,
|
||||
0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72,
|
||||
0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x35, 0x35, 0x35,
|
||||
0x35, 0x35, 0x35, 0x20, 0x34, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73,
|
||||
0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x61, 0x61, 0x37, 0x37, 0x33, 0x33,
|
||||
0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x35, 0x3a, 0x20, 0x54, 0x6f,
|
||||
0x6f, 0x6c, 0x74, 0x69, 0x70, 0x0a, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x65,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x5f, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62,
|
||||
0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f,
|
||||
0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x61,
|
||||
0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x5f, 0x68, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66,
|
||||
0x66, 0x66, 0x66, 0x61, 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x68,
|
||||
0x6f, 0x76, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67,
|
||||
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f,
|
||||
0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x66,
|
||||
0x66, 0x66, 0x66, 0x61, 0x61, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x62, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x70,
|
||||
0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x23, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a, 0x23, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x0a, 0x23, 0x20, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x0a, 0x70, 0x61, 0x6e,
|
||||
0x65, 0x6c, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x20, 0x3d, 0x20, 0x4c,
|
||||
0x54, 0x53, 0x43, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x73, 0x69,
|
||||
0x7a, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x25, 0x20, 0x33, 0x30,
|
||||
0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x6d, 0x61, 0x72, 0x67, 0x69,
|
||||
0x6e, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x70, 0x61, 0x6e, 0x65,
|
||||
0x6c, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20,
|
||||
0x32, 0x20, 0x30, 0x20, 0x32, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f,
|
||||
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x77, 0x6d, 0x5f, 0x6d, 0x65, 0x6e,
|
||||
0x75, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f,
|
||||
0x64, 0x6f, 0x63, 0x6b, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x70, 0x61, 0x6e,
|
||||
0x65, 0x6c, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20,
|
||||
0x3d, 0x20, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x20, 0x63, 0x65, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x20, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x6f, 0x6e, 0x74,
|
||||
0x61, 0x6c, 0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x6c, 0x61, 0x79,
|
||||
0x65, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x70, 0x0a, 0x70, 0x61, 0x6e,
|
||||
0x65, 0x6c, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d,
|
||||
0x20, 0x61, 0x6c, 0x6c, 0x0a, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79,
|
||||
0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x5f, 0x66, 0x69, 0x72,
|
||||
0x73, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68,
|
||||
0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75, 0x74, 0x6f,
|
||||
0x68, 0x69, 0x64, 0x65, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x61, 0x75,
|
||||
0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e,
|
||||
0x35, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x68,
|
||||
0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x20, 0x32, 0x0a, 0x73, 0x74,
|
||||
0x72, 0x75, 0x74, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x3d,
|
||||
0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x0a, 0x70, 0x61, 0x6e, 0x65, 0x6c, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f,
|
||||
0x77, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x69, 0x6e,
|
||||
0x74, 0x32, 0x0a, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74,
|
||||
0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20,
|
||||
0x3d, 0x20, 0x31, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x65, 0x66,
|
||||
0x66, 0x65, 0x63, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x20, 0x3d, 0x20,
|
||||
0x30, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x68, 0x6f, 0x76, 0x65,
|
||||
0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d,
|
||||
0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, 0x31, 0x30, 0x0a, 0x6d, 0x6f,
|
||||
0x75, 0x73, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x5f,
|
||||
0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31,
|
||||
0x30, 0x30, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23,
|
||||
0x20, 0x54, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x0a, 0x74, 0x61, 0x73,
|
||||
0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x20,
|
||||
0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x6b, 0x74,
|
||||
0x6f, 0x70, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x70,
|
||||
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x30, 0x20, 0x30,
|
||||
0x20, 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x62,
|
||||
0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64,
|
||||
0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72,
|
||||
0x5f, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62,
|
||||
0x61, 0x72, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x61, 0x63,
|
||||
0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x20, 0x3d,
|
||||
0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x68,
|
||||
0x69, 0x64, 0x65, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e,
|
||||
0x74, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20,
|
||||
0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x61, 0x6c,
|
||||
0x77, 0x61, 0x79, 0x73, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x61, 0x6c,
|
||||
0x6c, 0x5f, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x5f, 0x74, 0x61,
|
||||
0x73, 0x6b, 0x73, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b,
|
||||
0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, 0x64,
|
||||
0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f,
|
||||
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62, 0x61,
|
||||
0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x76,
|
||||
0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b,
|
||||
0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x66, 0x6f, 0x6e,
|
||||
0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x65,
|
||||
0x33, 0x65, 0x33, 0x65, 0x33, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61,
|
||||
0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x61,
|
||||
0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66,
|
||||
0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x62,
|
||||
0x61, 0x72, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
|
||||
0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x62, 0x61, 0x72, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x5f,
|
||||
0x6f, 0x72, 0x64, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x6e, 0x65,
|
||||
0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x20,
|
||||
0x3d, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23,
|
||||
0x20, 0x54, 0x61, 0x73, 0x6b, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x74,
|
||||
0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61, 0x73, 0x6b,
|
||||
0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x74, 0x61,
|
||||
0x73, 0x6b, 0x5f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x65, 0x64, 0x20,
|
||||
0x3d, 0x20, 0x31, 0x0a, 0x75, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x6e,
|
||||
0x62, 0x5f, 0x6f, 0x66, 0x5f, 0x62, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x3d,
|
||||
0x20, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b,
|
||||
0x5f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x20, 0x3d, 0x20, 0x31, 0x35, 0x30, 0x20, 0x33, 0x35, 0x0a, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20,
|
||||
0x3d, 0x20, 0x32, 0x20, 0x32, 0x20, 0x34, 0x0a, 0x74, 0x61, 0x73, 0x6b,
|
||||
0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31,
|
||||
0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66,
|
||||
0x66, 0x66, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f,
|
||||
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x32, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61,
|
||||
0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72,
|
||||
0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x33, 0x0a,
|
||||
0x74, 0x61, 0x73, 0x6b, 0x5f, 0x75, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x5f,
|
||||
0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x34, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69,
|
||||
0x63, 0x6f, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x62, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d,
|
||||
0x20, 0x32, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6c, 0x65, 0x66,
|
||||
0x74, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x5f, 0x69,
|
||||
0x63, 0x6f, 0x6e, 0x69, 0x66, 0x79, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65,
|
||||
0x5f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x6e, 0x6f,
|
||||
0x6e, 0x65, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x72, 0x69, 0x67,
|
||||
0x68, 0x74, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x0a, 0x6d,
|
||||
0x6f, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c, 0x5f,
|
||||
0x75, 0x70, 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x0a,
|
||||
0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x63, 0x72, 0x6f, 0x6c, 0x6c,
|
||||
0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x20, 0x3d, 0x20, 0x69, 0x63, 0x6f, 0x6e,
|
||||
0x69, 0x66, 0x79, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x53, 0x79,
|
||||
0x73, 0x74, 0x65, 0x6d, 0x20, 0x74, 0x72, 0x61, 0x79, 0x20, 0x28, 0x6e,
|
||||
0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20,
|
||||
0x61, 0x72, 0x65, 0x61, 0x29, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61,
|
||||
0x79, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20,
|
||||
0x30, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x73, 0x79, 0x73, 0x74, 0x72, 0x61,
|
||||
0x79, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x73, 0x79, 0x73, 0x74,
|
||||
0x72, 0x61, 0x79, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x20, 0x3d, 0x20, 0x61,
|
||||
0x73, 0x63, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x0a, 0x73, 0x79, 0x73,
|
||||
0x74, 0x72, 0x61, 0x79, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x69,
|
||||
0x7a, 0x65, 0x20, 0x3d, 0x20, 0x32, 0x34, 0x0a, 0x73, 0x79, 0x73, 0x74,
|
||||
0x72, 0x61, 0x79, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f, 0x61, 0x73, 0x62,
|
||||
0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20, 0x30, 0x0a, 0x73,
|
||||
0x79, 0x73, 0x74, 0x72, 0x61, 0x79, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74,
|
||||
0x6f, 0x72, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23,
|
||||
0x20, 0x4c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x0a, 0x6c, 0x61,
|
||||
0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69,
|
||||
0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x34, 0x20, 0x32, 0x0a, 0x6c,
|
||||
0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x62, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x30, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69,
|
||||
0x63, 0x6f, 0x6e, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75,
|
||||
0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x6c, 0x61,
|
||||
0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x32, 0x34, 0x0a, 0x6c, 0x61,
|
||||
0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x63, 0x6f, 0x6e, 0x5f,
|
||||
0x61, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x30, 0x20, 0x30, 0x20,
|
||||
0x30, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69,
|
||||
0x63, 0x6f, 0x6e, 0x5f, 0x74, 0x68, 0x65, 0x6d, 0x65, 0x5f, 0x6f, 0x76,
|
||||
0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x0a, 0x73,
|
||||
0x74, 0x61, 0x72, 0x74, 0x75, 0x70, 0x5f, 0x6e, 0x6f, 0x74, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x3d, 0x20, 0x31,
|
||||
0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x74, 0x6f,
|
||||
0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x6c, 0x61,
|
||||
0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f,
|
||||
0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73,
|
||||
0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x63,
|
||||
0x6f, 0x6e, 0x66, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a,
|
||||
0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65,
|
||||
0x6d, 0x5f, 0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72,
|
||||
0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65,
|
||||
0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x2f, 0x74, 0x69, 0x6e, 0x74, 0x32, 0x63, 0x6f, 0x6e, 0x66, 0x2e,
|
||||
0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70,
|
||||
0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61,
|
||||
0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x2f, 0x66, 0x69, 0x72, 0x65, 0x66, 0x6f, 0x78, 0x2e,
|
||||
0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70,
|
||||
0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61,
|
||||
0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x2f, 0x69, 0x63, 0x65, 0x77, 0x65, 0x61, 0x73, 0x65,
|
||||
0x6c, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61,
|
||||
0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f,
|
||||
0x61, 0x70, 0x70, 0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73,
|
||||
0x68, 0x61, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x69,
|
||||
0x75, 0x6d, 0x2d, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x2e, 0x64,
|
||||
0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x0a, 0x6c, 0x61, 0x75, 0x6e, 0x63,
|
||||
0x68, 0x65, 0x72, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x70, 0x70,
|
||||
0x20, 0x3d, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x2f, 0x73, 0x68, 0x61, 0x72,
|
||||
0x65, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2d, 0x63, 0x68,
|
||||
0x72, 0x6f, 0x6d, 0x65, 0x2e, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70,
|
||||
0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x43, 0x6c, 0x6f, 0x63, 0x6b,
|
||||
0x0a, 0x74, 0x69, 0x6d, 0x65, 0x31, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61,
|
||||
0x74, 0x20, 0x3d, 0x20, 0x25, 0x48, 0x3a, 0x25, 0x4d, 0x0a, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x32, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x3d,
|
||||
0x20, 0x25, 0x41, 0x20, 0x25, 0x64, 0x20, 0x25, 0x42, 0x0a, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x31, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65,
|
||||
0x20, 0x3d, 0x20, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x32, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
0x20, 0x31, 0x30, 0x30, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x70,
|
||||
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x30,
|
||||
0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67,
|
||||
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x30,
|
||||
0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x6f, 0x6f, 0x6c, 0x74,
|
||||
0x69, 0x70, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f,
|
||||
0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x7a, 0x6f, 0x6e, 0x65, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x5f, 0x6c, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d,
|
||||
0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x63, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x5f, 0x72, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d,
|
||||
0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x6f, 0x72, 0x61, 0x67, 0x65,
|
||||
0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6d, 0x63, 0x6c, 0x69, 0x63,
|
||||
0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x75, 0x77, 0x68, 0x65, 0x65,
|
||||
0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x64, 0x77, 0x68, 0x65, 0x65,
|
||||
0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x42, 0x61, 0x74, 0x74, 0x65,
|
||||
0x72, 0x79, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x74,
|
||||
0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x20, 0x3d, 0x20, 0x31, 0x0a, 0x62,
|
||||
0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x6f, 0x77, 0x5f, 0x73,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x0a, 0x62,
|
||||
0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x6f, 0x77, 0x5f, 0x63,
|
||||
0x6d, 0x64, 0x20, 0x3d, 0x20, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x2d,
|
||||
0x73, 0x65, 0x6e, 0x64, 0x20, 0x22, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72,
|
||||
0x79, 0x20, 0x6c, 0x6f, 0x77, 0x22, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65,
|
||||
0x72, 0x79, 0x5f, 0x66, 0x6f, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x20, 0x3d, 0x20, 0x23, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x20,
|
||||
0x31, 0x30, 0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f,
|
||||
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x31, 0x20,
|
||||
0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x62, 0x61,
|
||||
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20,
|
||||
0x3d, 0x20, 0x30, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f,
|
||||
0x68, 0x69, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x31, 0x30, 0x31, 0x0a, 0x62,
|
||||
0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6c, 0x63, 0x6c, 0x69, 0x63,
|
||||
0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20,
|
||||
0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x72, 0x63, 0x6c,
|
||||
0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20,
|
||||
0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x5f, 0x6d,
|
||||
0x63, 0x6c, 0x69, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79,
|
||||
0x5f, 0x75, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d,
|
||||
0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x62, 0x61, 0x74, 0x74, 0x65,
|
||||
0x72, 0x79, 0x5f, 0x64, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x5f, 0x63, 0x6f,
|
||||
0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x0a, 0x61, 0x63, 0x5f,
|
||||
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6d,
|
||||
0x64, 0x20, 0x3d, 0x20, 0x0a, 0x61, 0x63, 0x5f, 0x64, 0x69, 0x73, 0x63,
|
||||
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6d, 0x64,
|
||||
0x20, 0x3d, 0x20, 0x0a, 0x0a, 0x23, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
|
||||
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x23, 0x20, 0x54, 0x6f,
|
||||
0x6f, 0x6c, 0x74, 0x69, 0x70, 0x0a, 0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69,
|
||||
0x70, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f,
|
||||
0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x35, 0x0a, 0x74, 0x6f, 0x6f,
|
||||
0x6c, 0x74, 0x69, 0x70, 0x5f, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x31, 0x0a,
|
||||
0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x70, 0x61, 0x64, 0x64,
|
||||
0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x32, 0x20, 0x32, 0x0a, 0x74, 0x6f,
|
||||
0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72,
|
||||
0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x35, 0x0a,
|
||||
0x74, 0x6f, 0x6f, 0x6c, 0x74, 0x69, 0x70, 0x5f, 0x66, 0x6f, 0x6e, 0x74,
|
||||
0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x23, 0x32, 0x32,
|
||||
0x32, 0x32, 0x32, 0x32, 0x20, 0x31, 0x30, 0x30, 0x0a, 0x0a
|
||||
};
|
||||
unsigned int themes_tint2rc_len = 4870;
|
||||
10
src/tint2rc.h
Normal file
10
src/tint2rc.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef TINT2RC_H
|
||||
#define TINT2RC_H
|
||||
|
||||
// Content of .c file generated with xxd from the vim package:
|
||||
// echo '#include "tint2rc.h"' > src/tint2rc.c && xxd -i themes/tint2rc >> src/tint2rc.c
|
||||
|
||||
extern unsigned char themes_tint2rc[];
|
||||
extern unsigned int themes_tint2rc_len;
|
||||
|
||||
#endif
|
||||
423
src/util/area.c
423
src/util/area.c
@@ -17,10 +17,12 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -215,38 +217,41 @@ void relayout_dynamic(Area *a, int level)
|
||||
}
|
||||
}
|
||||
|
||||
int compute_desired_size(Area *a)
|
||||
{
|
||||
if (!a->on_screen)
|
||||
return 0;
|
||||
if (a->_compute_desired_size)
|
||||
return a->_compute_desired_size(a);
|
||||
if (a->size_mode == LAYOUT_FIXED)
|
||||
fprintf(stderr, YELLOW "Area %s does not set desired size!" RESET "\n", a->name);
|
||||
return container_compute_desired_size(a);
|
||||
}
|
||||
|
||||
int container_compute_desired_size(Area *a)
|
||||
{
|
||||
if (!a->on_screen)
|
||||
return 0;
|
||||
int result = 2 * a->paddingxlr + (panel_horizontal ? left_right_border_width(a) : top_bottom_border_width(a));
|
||||
int children_count = 0;
|
||||
for (GList *l = a->children; l != NULL; l = l->next) {
|
||||
Area *child = (Area *)l->data;
|
||||
if (child->on_screen) {
|
||||
result += compute_desired_size(child);
|
||||
children_count++;
|
||||
}
|
||||
}
|
||||
if (children_count > 0)
|
||||
result += (children_count - 1) * a->paddingx;
|
||||
return result;
|
||||
}
|
||||
|
||||
void relayout(Area *a)
|
||||
{
|
||||
relayout_fixed(a);
|
||||
relayout_dynamic(a, 1);
|
||||
}
|
||||
|
||||
void draw_tree(Area *a)
|
||||
{
|
||||
if (!a->on_screen)
|
||||
return;
|
||||
|
||||
if (a->_redraw_needed) {
|
||||
a->_redraw_needed = FALSE;
|
||||
draw(a);
|
||||
}
|
||||
|
||||
if (a->pix)
|
||||
XCopyArea(server.display,
|
||||
a->pix,
|
||||
((Panel *)a->panel)->temp_pmap,
|
||||
server.gc,
|
||||
0,
|
||||
0,
|
||||
a->width,
|
||||
a->height,
|
||||
a->posx,
|
||||
a->posy);
|
||||
|
||||
for (GList *l = a->children; l; l = l->next)
|
||||
draw_tree((Area *)l->data);
|
||||
}
|
||||
|
||||
int relayout_with_constraint(Area *a, int maximum_size)
|
||||
{
|
||||
int fixed_children_count = 0;
|
||||
@@ -355,13 +360,43 @@ void schedule_redraw(Area *a)
|
||||
|
||||
for (GList *l = a->children; l; l = l->next)
|
||||
schedule_redraw((Area *)l->data);
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void draw_tree(Area *a)
|
||||
{
|
||||
if (!a->on_screen)
|
||||
return;
|
||||
|
||||
if (a->_redraw_needed) {
|
||||
a->_redraw_needed = FALSE;
|
||||
draw(a);
|
||||
}
|
||||
|
||||
if (a->pix)
|
||||
XCopyArea(server.display,
|
||||
a->pix,
|
||||
((Panel *)a->panel)->temp_pmap,
|
||||
server.gc,
|
||||
0,
|
||||
0,
|
||||
a->width,
|
||||
a->height,
|
||||
a->posx,
|
||||
a->posy);
|
||||
else
|
||||
fprintf(stderr, RED "%s %d: area %s has no pixmap!!!" RESET "\n", __FILE__, __LINE__, a->name);
|
||||
|
||||
for (GList *l = a->children; l; l = l->next)
|
||||
draw_tree((Area *)l->data);
|
||||
}
|
||||
|
||||
void hide(Area *a)
|
||||
{
|
||||
Area *parent = (Area *)a->parent;
|
||||
|
||||
if (!a->on_screen)
|
||||
return;
|
||||
a->on_screen = FALSE;
|
||||
if (parent)
|
||||
parent->resize_needed = TRUE;
|
||||
@@ -375,10 +410,29 @@ void show(Area *a)
|
||||
{
|
||||
Area *parent = (Area *)a->parent;
|
||||
|
||||
if (a->on_screen)
|
||||
return;
|
||||
a->on_screen = TRUE;
|
||||
if (parent)
|
||||
parent->resize_needed = TRUE;
|
||||
a->resize_needed = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void update_dependent_gradients(Area *a)
|
||||
{
|
||||
if (!a->on_screen)
|
||||
return;
|
||||
if (a->_changed) {
|
||||
for (GList *l = a->dependent_gradients; l; l = l->next) {
|
||||
GradientInstance *gi = (GradientInstance *)l->data;
|
||||
update_gradient(gi);
|
||||
if (gi->area != a)
|
||||
schedule_redraw(gi->area);
|
||||
}
|
||||
}
|
||||
for (GList *l = a->children; l; l = l->next)
|
||||
update_dependent_gradients((Area *)l->data);
|
||||
}
|
||||
|
||||
void draw(Area *a)
|
||||
@@ -438,7 +492,7 @@ void draw(Area *a)
|
||||
|
||||
void draw_background(Area *a, cairo_t *c)
|
||||
{
|
||||
if (a->bg->fill_color.alpha > 0.0 ||
|
||||
if ((a->bg->fill_color.alpha > 0.0) ||
|
||||
(panel_config.mouse_effects && (a->has_mouse_over_effect || a->has_mouse_press_effect))) {
|
||||
if (a->mouse_state == MOUSE_OVER)
|
||||
cairo_set_source_rgba(c,
|
||||
@@ -468,6 +522,19 @@ void draw_background(Area *a, cairo_t *c)
|
||||
|
||||
cairo_fill(c);
|
||||
}
|
||||
for (GList *l = a->gradient_instances_by_state[a->mouse_state]; l; l = l->next) {
|
||||
GradientInstance *gi = (GradientInstance *)l->data;
|
||||
if (!gi->pattern)
|
||||
update_gradient(gi);
|
||||
cairo_set_source(c, gi->pattern);
|
||||
draw_rect(c,
|
||||
left_border_width(a),
|
||||
top_border_width(a),
|
||||
a->width - left_right_border_width(a),
|
||||
a->height - top_bottom_border_width(a),
|
||||
a->bg->border.radius - a->bg->border.width / 1.571);
|
||||
cairo_fill(c);
|
||||
}
|
||||
|
||||
if (a->bg->border.width > 0) {
|
||||
cairo_set_line_width(c, a->bg->border.width);
|
||||
@@ -508,10 +575,12 @@ void remove_area(Area *a)
|
||||
Area *area = (Area *)a;
|
||||
Area *parent = (Area *)area->parent;
|
||||
|
||||
free_area_gradient_instances(a);
|
||||
|
||||
if (parent) {
|
||||
parent->children = g_list_remove(parent->children, area);
|
||||
parent->resize_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
schedule_redraw(parent);
|
||||
}
|
||||
|
||||
@@ -529,7 +598,6 @@ void add_area(Area *a, Area *parent)
|
||||
parent->children = g_list_append(parent->children, a);
|
||||
parent->resize_needed = TRUE;
|
||||
schedule_redraw(parent);
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,6 +627,7 @@ void free_area(Area *a)
|
||||
if (mouse_over_area == a) {
|
||||
mouse_over_area = NULL;
|
||||
}
|
||||
free_area_gradient_instances(a);
|
||||
}
|
||||
|
||||
void mouse_over(Area *area, int pressed)
|
||||
@@ -584,11 +653,10 @@ void mouse_over(Area *area, int pressed)
|
||||
mouse_over_area = area;
|
||||
|
||||
mouse_over_area->mouse_state = new_state;
|
||||
mouse_over_area->pix =
|
||||
mouse_over_area->pix_by_state[mouse_over_area->has_mouse_over_effect ? mouse_over_area->mouse_state : 0];
|
||||
mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state];
|
||||
if (!mouse_over_area->pix)
|
||||
mouse_over_area->_redraw_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
}
|
||||
|
||||
void mouse_out()
|
||||
@@ -596,11 +664,10 @@ void mouse_out()
|
||||
if (!mouse_over_area)
|
||||
return;
|
||||
mouse_over_area->mouse_state = MOUSE_NORMAL;
|
||||
mouse_over_area->pix =
|
||||
mouse_over_area->pix_by_state[mouse_over_area->has_mouse_over_effect ? mouse_over_area->mouse_state : 0];
|
||||
mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state];
|
||||
if (!mouse_over_area->pix)
|
||||
mouse_over_area->_redraw_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
schedule_panel_redraw();
|
||||
mouse_over_area = NULL;
|
||||
}
|
||||
|
||||
@@ -783,28 +850,29 @@ void area_dump_geometry(Area *area, int indent)
|
||||
return;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"%*sBox: x = %d, y = %d, w = %d, h = %d\n",
|
||||
"%*sBox: x = %d, y = %d, w = %d, h = %d, desired size = %d\n",
|
||||
indent,
|
||||
"",
|
||||
area->posx,
|
||||
area->posy,
|
||||
area->width,
|
||||
area->height);
|
||||
area->height,
|
||||
compute_desired_size(area));
|
||||
fprintf(stderr,
|
||||
"%*sBorder: left = %d, right = %d, top = %d, bottom = %d\n",
|
||||
indent,
|
||||
"",
|
||||
left_border_width(area),
|
||||
right_border_width(area),
|
||||
top_border_width(area),
|
||||
bottom_border_width(area));
|
||||
"%*sBorder: left = %d, right = %d, top = %d, bottom = %d\n",
|
||||
indent,
|
||||
"",
|
||||
left_border_width(area),
|
||||
right_border_width(area),
|
||||
top_border_width(area),
|
||||
bottom_border_width(area));
|
||||
fprintf(stderr,
|
||||
"%*sPadding: left = right = %d, top = bottom = %d, spacing = %d\n",
|
||||
indent,
|
||||
"",
|
||||
area->paddingxlr,
|
||||
area->paddingy,
|
||||
area->paddingx);
|
||||
"%*sPadding: left = right = %d, top = bottom = %d, spacing = %d\n",
|
||||
indent,
|
||||
"",
|
||||
area->paddingxlr,
|
||||
area->paddingy,
|
||||
area->paddingx);
|
||||
if (area->_dump_geometry)
|
||||
area->_dump_geometry(area, indent);
|
||||
if (area->children) {
|
||||
@@ -814,3 +882,256 @@ void area_dump_geometry(Area *area, int indent)
|
||||
area_dump_geometry((Area *)l->data, indent);
|
||||
}
|
||||
}
|
||||
|
||||
Area *compute_element_area(Area *area, Element element)
|
||||
{
|
||||
if (element == ELEMENT_SELF)
|
||||
return area;
|
||||
if (element == ELEMENT_PARENT)
|
||||
return (Area *)area->parent;
|
||||
if (element == ELEMENT_PANEL)
|
||||
return (Area *)area->panel;
|
||||
g_assert_not_reached();
|
||||
return area;
|
||||
}
|
||||
|
||||
void instantiate_gradient_offsets(GradientInstance *gi, GList *offsets)
|
||||
{
|
||||
for (GList *l = offsets; l; l = l->next) {
|
||||
Offset *offset = (Offset *)l->data;
|
||||
if (!offset->constant) {
|
||||
Area *element_area = compute_element_area(gi->area, offset->element);
|
||||
element_area->dependent_gradients = g_list_append(element_area->dependent_gradients, gi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void free_gradient_offsets(GradientInstance *gi, GList **offsets)
|
||||
{
|
||||
for (GList *l = *offsets; l; l = l->next) {
|
||||
Offset *offset = (Offset *)l->data;
|
||||
if (!offset->constant) {
|
||||
Area *element_area = compute_element_area(gi->area, offset->element);
|
||||
element_area->dependent_gradients = g_list_remove_all(element_area->dependent_gradients, gi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void instantiate_gradient_point(GradientInstance *gi, ControlPoint *control)
|
||||
{
|
||||
instantiate_gradient_offsets(gi, control->offsets_x);
|
||||
instantiate_gradient_offsets(gi, control->offsets_y);
|
||||
instantiate_gradient_offsets(gi, control->offsets_r);
|
||||
}
|
||||
|
||||
void free_gradient_instance_point(GradientInstance *gi, ControlPoint *control)
|
||||
{
|
||||
free_gradient_offsets(gi, &control->offsets_x);
|
||||
free_gradient_offsets(gi, &control->offsets_y);
|
||||
free_gradient_offsets(gi, &control->offsets_r);
|
||||
}
|
||||
|
||||
void instantiate_gradient(Area *area, GradientClass *g, GradientInstance *gi)
|
||||
{
|
||||
g_assert_nonnull(area);
|
||||
g_assert_nonnull(g);
|
||||
gi->area = area;
|
||||
gi->gradient_class = g;
|
||||
instantiate_gradient_point(gi, &g->from);
|
||||
instantiate_gradient_point(gi, &g->to);
|
||||
}
|
||||
|
||||
void free_gradient_instance(GradientInstance *gi)
|
||||
{
|
||||
if (gi->pattern) {
|
||||
cairo_pattern_destroy(gi->pattern);
|
||||
gi->pattern = NULL;
|
||||
}
|
||||
free_gradient_instance_point(gi, &gi->gradient_class->from);
|
||||
free_gradient_instance_point(gi, &gi->gradient_class->to);
|
||||
gi->gradient_class = NULL;
|
||||
}
|
||||
|
||||
void instantiate_area_gradients(Area *area)
|
||||
{
|
||||
if (debug_gradients)
|
||||
fprintf(stderr, "Initializing gradients for area %s\n", area->name);
|
||||
for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
|
||||
g_assert_null(area->gradient_instances_by_state[i]);
|
||||
GradientClass *g = area->bg->gradients[i];
|
||||
if (!g)
|
||||
continue;
|
||||
GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance));
|
||||
instantiate_gradient(area, g, gi);
|
||||
area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi);
|
||||
}
|
||||
}
|
||||
|
||||
void free_area_gradient_instances(Area *area)
|
||||
{
|
||||
if (debug_gradients)
|
||||
fprintf(stderr, "Freeing gradients for area %s\n", area->name);
|
||||
for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
|
||||
for (GList *l = area->gradient_instances_by_state[i]; l; l = l->next) {
|
||||
GradientInstance *gi = (GradientInstance *)l->data;
|
||||
free_gradient_instance(gi);
|
||||
}
|
||||
g_list_free_full(area->gradient_instances_by_state[i], free);
|
||||
area->gradient_instances_by_state[i] = NULL;
|
||||
}
|
||||
g_assert_null(area->dependent_gradients);
|
||||
}
|
||||
|
||||
double compute_control_point_offset(Area *area, Offset *offset)
|
||||
{
|
||||
if (offset->constant)
|
||||
return offset->constant_value;
|
||||
|
||||
Area *element_area = compute_element_area(area, offset->element);
|
||||
Area *parent_area = ((Area *)area->parent);
|
||||
g_assert_nonnull(element_area);
|
||||
g_assert_nonnull(parent_area);
|
||||
|
||||
double width = element_area->width;
|
||||
double height = element_area->height;
|
||||
double radius = sqrt(element_area->width * element_area->width + element_area->height * element_area->height) / 2.0;
|
||||
|
||||
double left, top;
|
||||
if (offset->element == ELEMENT_SELF) {
|
||||
left = 0;
|
||||
top = 0;
|
||||
} else if (offset->element == ELEMENT_PARENT) {
|
||||
left = parent_area->posx - area->posx;
|
||||
top = parent_area->posy - area->posy;
|
||||
} else if (offset->element == ELEMENT_PANEL) {
|
||||
left = 0 - area->posx;
|
||||
top = 0 - area->posy;
|
||||
}
|
||||
|
||||
double right = left + width;
|
||||
double bottom = top + height;
|
||||
double center_x = left + 0.5 * width;
|
||||
double center_y = top + 0.5 * height;
|
||||
|
||||
if (offset->variable == SIZE_WIDTH)
|
||||
return width * offset->multiplier;
|
||||
if (offset->variable == SIZE_HEIGHT)
|
||||
return height * offset->multiplier;
|
||||
if (offset->variable == SIZE_RADIUS)
|
||||
return radius * offset->multiplier;
|
||||
if (offset->variable == SIZE_LEFT)
|
||||
return left * offset->multiplier;
|
||||
if (offset->variable == SIZE_RIGHT)
|
||||
return right * offset->multiplier;
|
||||
if (offset->variable == SIZE_TOP)
|
||||
return top * offset->multiplier;
|
||||
if (offset->variable == SIZE_BOTTOM)
|
||||
return bottom * offset->multiplier;
|
||||
if (offset->variable == SIZE_CENTERX)
|
||||
return center_x * offset->multiplier;
|
||||
if (offset->variable == SIZE_CENTERY)
|
||||
return center_y * offset->multiplier;
|
||||
|
||||
g_assert_not_reached();
|
||||
return 0;
|
||||
}
|
||||
|
||||
double compute_control_point_offsets(GradientInstance *gi, GList *offsets)
|
||||
{
|
||||
double result = 0;
|
||||
for (GList *l = offsets; l; l = l->next) {
|
||||
Offset *offset = (Offset *)l->data;
|
||||
result += compute_control_point_offset(gi->area, offset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void compute_control_point(GradientInstance *gi, ControlPoint *control, double *x, double *y, double *r)
|
||||
{
|
||||
*x = compute_control_point_offsets(gi, control->offsets_x);
|
||||
*y = compute_control_point_offsets(gi, control->offsets_y);
|
||||
*r = compute_control_point_offsets(gi, control->offsets_r);
|
||||
}
|
||||
|
||||
void update_gradient(GradientInstance *gi)
|
||||
{
|
||||
if (gi->pattern) {
|
||||
return;
|
||||
cairo_pattern_destroy(gi->pattern);
|
||||
gi->pattern = NULL;
|
||||
}
|
||||
double from_x, from_y, from_r;
|
||||
compute_control_point(gi, &gi->gradient_class->from, &from_x, &from_y, &from_r);
|
||||
double to_x, to_y, to_r;
|
||||
compute_control_point(gi, &gi->gradient_class->to, &to_x, &to_y, &to_r);
|
||||
if (gi->gradient_class->type == GRADIENT_VERTICAL || gi->gradient_class->type == GRADIENT_HORIZONTAL) {
|
||||
gi->pattern = cairo_pattern_create_linear(from_x, from_y, to_x, to_y);
|
||||
if (debug_gradients)
|
||||
fprintf(stderr,
|
||||
"Creating linear gradient for area %s: %f %f, %f %f\n",
|
||||
gi->area->name,
|
||||
from_x,
|
||||
from_y,
|
||||
to_x,
|
||||
to_y);
|
||||
} else if (gi->gradient_class->type == GRADIENT_CENTERED) {
|
||||
gi->pattern = cairo_pattern_create_radial(from_x, from_y, from_r, to_x, to_y, to_r);
|
||||
if (debug_gradients)
|
||||
fprintf(stderr,
|
||||
"Creating radial gradient for area %s: %f %f %f, %f %f %f\n",
|
||||
gi->area->name,
|
||||
from_x,
|
||||
from_y,
|
||||
from_r,
|
||||
to_x,
|
||||
to_y,
|
||||
to_r);
|
||||
} else {
|
||||
g_assert_not_reached();
|
||||
}
|
||||
if (debug_gradients)
|
||||
fprintf(stderr,
|
||||
"Adding color stop at offset %f: %f %f %f %f\n",
|
||||
0.0,
|
||||
gi->gradient_class->start_color.rgb[0],
|
||||
gi->gradient_class->start_color.rgb[1],
|
||||
gi->gradient_class->start_color.rgb[2],
|
||||
gi->gradient_class->start_color.alpha);
|
||||
cairo_pattern_add_color_stop_rgba(gi->pattern,
|
||||
0,
|
||||
gi->gradient_class->start_color.rgb[0],
|
||||
gi->gradient_class->start_color.rgb[1],
|
||||
gi->gradient_class->start_color.rgb[2],
|
||||
gi->gradient_class->start_color.alpha);
|
||||
for (GList *l = gi->gradient_class->extra_color_stops; l; l = l->next) {
|
||||
ColorStop *color_stop = (ColorStop *)l->data;
|
||||
if (debug_gradients)
|
||||
fprintf(stderr,
|
||||
"Adding color stop at offset %f: %f %f %f %f\n",
|
||||
color_stop->offset,
|
||||
color_stop->color.rgb[0],
|
||||
color_stop->color.rgb[1],
|
||||
color_stop->color.rgb[2],
|
||||
color_stop->color.alpha);
|
||||
cairo_pattern_add_color_stop_rgba(gi->pattern,
|
||||
color_stop->offset,
|
||||
color_stop->color.rgb[0],
|
||||
color_stop->color.rgb[1],
|
||||
color_stop->color.rgb[2],
|
||||
color_stop->color.alpha);
|
||||
}
|
||||
if (debug_gradients)
|
||||
fprintf(stderr,
|
||||
"Adding color stop at offset %f: %f %f %f %f\n",
|
||||
1.0,
|
||||
gi->gradient_class->end_color.rgb[0],
|
||||
gi->gradient_class->end_color.rgb[1],
|
||||
gi->gradient_class->end_color.rgb[2],
|
||||
gi->gradient_class->end_color.alpha);
|
||||
cairo_pattern_add_color_stop_rgba(gi->pattern,
|
||||
1.0,
|
||||
gi->gradient_class->end_color.rgb[0],
|
||||
gi->gradient_class->end_color.rgb[1],
|
||||
gi->gradient_class->end_color.rgb[2],
|
||||
gi->gradient_class->end_color.alpha);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include <cairo.h>
|
||||
#include <cairo-xlib.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "gradient.h"
|
||||
|
||||
// DATA ORGANISATION
|
||||
//
|
||||
// Areas in tint2 are similar to widgets in a GUI.
|
||||
@@ -117,13 +120,6 @@
|
||||
// The caller takes ownership of the pointer.
|
||||
// The Area's _get_tooltip_text member must point to this function.
|
||||
|
||||
typedef struct Color {
|
||||
// Values are in [0, 1], with 0 meaning no intensity.
|
||||
double rgb[3];
|
||||
// Values are in [0, 1], with 0 meaning fully transparent, 1 meaning fully opaque.
|
||||
double alpha;
|
||||
} Color;
|
||||
|
||||
typedef enum BorderMask {
|
||||
BORDER_TOP = 1 << 0,
|
||||
BORDER_BOTTOM = 1 << 1,
|
||||
@@ -144,6 +140,8 @@ typedef struct Border {
|
||||
int mask;
|
||||
} Border;
|
||||
|
||||
typedef enum MouseState { MOUSE_NORMAL = 0, MOUSE_OVER = 1, MOUSE_DOWN = 2, MOUSE_STATE_COUNT } MouseState;
|
||||
|
||||
typedef struct Background {
|
||||
// Normal state
|
||||
Color fill_color;
|
||||
@@ -154,6 +152,8 @@ typedef struct Background {
|
||||
// On mouse press
|
||||
Color fill_color_pressed;
|
||||
Color border_color_pressed;
|
||||
// Pointer to a GradientClass or NULL, no ownership
|
||||
GradientClass *gradients[MOUSE_STATE_COUNT];
|
||||
} Background;
|
||||
|
||||
typedef enum Layout {
|
||||
@@ -167,8 +167,6 @@ typedef enum Alignment {
|
||||
ALIGN_RIGHT = 2,
|
||||
} Alignment;
|
||||
|
||||
typedef enum MouseState { MOUSE_NORMAL = 0, MOUSE_OVER = 1, MOUSE_DOWN = 2, MOUSE_STATE_COUNT } MouseState;
|
||||
|
||||
struct Panel;
|
||||
|
||||
typedef struct Area {
|
||||
@@ -176,7 +174,12 @@ typedef struct Area {
|
||||
int posx, posy;
|
||||
// Size, including borders
|
||||
int width, height;
|
||||
int old_width, old_height;
|
||||
Background *bg;
|
||||
// Each element is a GradientInstance attached to this Area (list can be empty)
|
||||
GList *gradient_instances_by_state[MOUSE_STATE_COUNT];
|
||||
// Each element is a GradientInstance that depends on this Area's geometry (position or size)
|
||||
GList *dependent_gradients;
|
||||
// List of children, each one a pointer to Area
|
||||
GList *children;
|
||||
// Pointer to the parent Area or NULL
|
||||
@@ -219,6 +222,10 @@ typedef struct Area {
|
||||
// Returns 1 if the new size is different than the previous size.
|
||||
gboolean (*_resize)(void *obj);
|
||||
|
||||
// Called before resize, obj = pointer to the Area
|
||||
// Returns the desired size of the Area
|
||||
int (*_compute_desired_size)(void *obj);
|
||||
|
||||
// Implemented only to override the default layout algorithm for this widget.
|
||||
// For example, if this widget is a cell in a table, its position and size should be computed here.
|
||||
void (*_on_change_layout)(void *obj);
|
||||
@@ -253,6 +260,9 @@ void relayout(Area *a);
|
||||
// If maximum_size > 0, it is an upper limit for the child size.
|
||||
int relayout_with_constraint(Area *a, int maximum_size);
|
||||
|
||||
int compute_desired_size(Area *a);
|
||||
int container_compute_desired_size(Area *a);
|
||||
|
||||
int left_border_width(Area *a);
|
||||
int right_border_width(Area *a);
|
||||
int left_right_border_width(Area *a);
|
||||
@@ -309,9 +319,15 @@ gboolean area_is_under_mouse(void *obj, int x, int y);
|
||||
// they are outside the drawing area of the button.
|
||||
gboolean full_width_area_is_under_mouse(void *obj, int x, int y);
|
||||
|
||||
void instantiate_area_gradients(Area *area);
|
||||
void free_area_gradient_instances(Area *area);
|
||||
|
||||
void area_dump_geometry(Area *area, int indent);
|
||||
|
||||
void mouse_over(Area *area, int pressed);
|
||||
void mouse_out();
|
||||
|
||||
void update_gradient(GradientInstance *gi);
|
||||
void update_dependent_gradients(Area *a);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -86,6 +86,8 @@ void load_cache(Cache *cache, const gchar *cache_path)
|
||||
|
||||
if (parse_line(line, &key, &value)) {
|
||||
g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value));
|
||||
free(key);
|
||||
free(value);
|
||||
}
|
||||
}
|
||||
free(line);
|
||||
|
||||
2
src/util/color.c
Normal file
2
src/util/color.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "color.h"
|
||||
|
||||
11
src/util/color.h
Normal file
11
src/util/color.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
typedef struct Color {
|
||||
// Values are in [0, 1], with 0 meaning no intensity.
|
||||
double rgb[3];
|
||||
// Values are in [0, 1], with 0 meaning fully transparent, 1 meaning fully opaque.
|
||||
double alpha;
|
||||
} Color;
|
||||
|
||||
#endif // COLOR_H
|
||||
@@ -73,15 +73,15 @@ void copy_file(const char *path_src, const char *path_dest)
|
||||
fclose(file_src);
|
||||
}
|
||||
|
||||
int parse_line(const char *line, char **key, char **value)
|
||||
gboolean parse_line(const char *line, char **key, char **value)
|
||||
{
|
||||
char *a, *b;
|
||||
|
||||
/* Skip useless lines */
|
||||
if ((line[0] == '#') || (line[0] == '\n'))
|
||||
return 0;
|
||||
return FALSE;
|
||||
if (!(a = strchr(line, '=')))
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
/* overwrite '=' with '\0' */
|
||||
a[0] = '\0';
|
||||
@@ -96,7 +96,7 @@ int parse_line(const char *line, char **key, char **value)
|
||||
|
||||
g_strstrip(*key);
|
||||
g_strstrip(*value);
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void tint_exec(const char *command)
|
||||
@@ -199,43 +199,44 @@ void get_color(char *hex, double *rgb)
|
||||
rgb[2] = (b / 255.0);
|
||||
}
|
||||
|
||||
void extract_values(const char *value, char **value1, char **value2, char **value3)
|
||||
void extract_values(const char *str, 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;
|
||||
*value1 = NULL;
|
||||
*value2 = NULL;
|
||||
*value3 = NULL;
|
||||
char **tokens = g_strsplit(str, " ", 3);
|
||||
if (tokens[0]) {
|
||||
*value1 = strdup(tokens[0]);
|
||||
if (tokens[1]) {
|
||||
*value2 = strdup(tokens[1]);
|
||||
if (tokens[2]) {
|
||||
*value3 = strdup(tokens[2]);
|
||||
}
|
||||
}
|
||||
*value2 = strdup(b);
|
||||
g_strstrip(*value2);
|
||||
}
|
||||
g_strfreev(tokens);
|
||||
}
|
||||
|
||||
if (c) {
|
||||
*value3 = strdup(c);
|
||||
g_strstrip(*value3);
|
||||
void extract_values_4(const char *str, char **value1, char **value2, char **value3, char **value4)
|
||||
{
|
||||
*value1 = NULL;
|
||||
*value2 = NULL;
|
||||
*value3 = NULL;
|
||||
*value4 = NULL;
|
||||
char **tokens = g_strsplit(str, " ", 4);
|
||||
if (tokens[0]) {
|
||||
*value1 = strdup(tokens[0]);
|
||||
if (tokens[1]) {
|
||||
*value2 = strdup(tokens[1]);
|
||||
if (tokens[2]) {
|
||||
*value3 = strdup(tokens[2]);
|
||||
if (tokens[3]) {
|
||||
*value4 = strdup(tokens[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g_strfreev(tokens);
|
||||
}
|
||||
|
||||
void adjust_asb(DATA32 *data, int w, int h, float alpha_adjust, float satur_adjust, float bright_adjust)
|
||||
@@ -448,9 +449,9 @@ Imlib_Image load_image(const char *path, int cached)
|
||||
}
|
||||
if (!image && g_str_has_suffix(path, ".svg")) {
|
||||
char tmp_filename[128];
|
||||
sprintf(tmp_filename, "/tmp/tint2-%d-XXXXXX.png", (int)getpid());
|
||||
int fd = mkstemps(tmp_filename, 4);
|
||||
if (fd) {
|
||||
sprintf(tmp_filename, "/tmp/tint2-%d.png", (int)getpid());
|
||||
int fd = open(tmp_filename, O_CREAT | O_EXCL, 0600);
|
||||
if (fd >= 0) {
|
||||
// We fork here because librsvg allocates memory like crazy
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
@@ -468,6 +469,7 @@ Imlib_Image load_image(const char *path, int cached)
|
||||
exit(0);
|
||||
} else {
|
||||
// Parent
|
||||
close(fd);
|
||||
waitpid(pid, 0, 0);
|
||||
image = imlib_load_image_immediately_without_cache(tmp_filename);
|
||||
unlink(tmp_filename);
|
||||
@@ -617,7 +619,7 @@ void get_text_size2(PangoFontDescription *font,
|
||||
XFreePixmap(server.display, pmap);
|
||||
}
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2, 33, 4)
|
||||
#if !GLIB_CHECK_VERSION(2, 34, 0)
|
||||
GList *g_list_copy_deep(GList *list, GCopyFunc func, gpointer user_data)
|
||||
{
|
||||
list = g_list_copy(list);
|
||||
@@ -638,7 +640,8 @@ GSList *load_locations_from_env(GSList *locations, const char *var, ...)
|
||||
if (value) {
|
||||
value = strdup(value);
|
||||
char *p = value;
|
||||
for (char *token = strsep(&value, ":"); token; token = strsep(&value, ":")) {
|
||||
char *t;
|
||||
for (char *token = strtok_r(value, ":", &t); token; token = strtok_r(NULL, ":", &t)) {
|
||||
va_list ap;
|
||||
va_start(ap, var);
|
||||
for (const char *suffix = va_arg(ap, const char *); suffix; suffix = va_arg(ap, const char *)) {
|
||||
@@ -673,3 +676,13 @@ GSList *slist_remove_duplicates(GSList *list, GCompareFunc eq, GDestroyNotify fr
|
||||
|
||||
return new_list;
|
||||
}
|
||||
|
||||
gint cmp_ptr(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
if (a < b)
|
||||
return -1;
|
||||
else if (a == b)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,10 @@ void copy_file(const char *path_src, const char *path_dest);
|
||||
// Strips key and value.
|
||||
// Values may contain spaces and the equal sign.
|
||||
// Returns 1 if both key and value could be read, zero otherwise.
|
||||
int parse_line(const char *line, char **key, char **value);
|
||||
gboolean parse_line(const char *line, char **key, char **value);
|
||||
|
||||
void extract_values(const char *value, char **value1, char **value2, char **value3);
|
||||
void extract_values_4(const char *value, char **value1, char **value2, char **value3, char **value4);
|
||||
|
||||
// Executes a command in a shell.
|
||||
void tint_exec(const char *command);
|
||||
@@ -120,6 +121,9 @@ GSList *load_locations_from_env(GSList *locations, const char *var, ...);
|
||||
|
||||
GSList *slist_remove_duplicates(GSList *list, GCompareFunc eq, GDestroyNotify fr);
|
||||
|
||||
// A trivial pointer comparator.
|
||||
gint cmp_ptr(gconstpointer a, gconstpointer b);
|
||||
|
||||
#define free_and_null(p) \
|
||||
{ \
|
||||
free(p); \
|
||||
|
||||
123
src/util/gradient.c
Normal file
123
src/util/gradient.c
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "gradient.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
gboolean read_double(const char *str, double *value)
|
||||
{
|
||||
if (!str[0])
|
||||
return FALSE;
|
||||
char *end;
|
||||
*value = strtod(str, &end);
|
||||
if (end[0])
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean read_double_with_percent(const char *str, double *value)
|
||||
{
|
||||
if (!str[0])
|
||||
return FALSE;
|
||||
char *end;
|
||||
*value = strtod(str, &end);
|
||||
if (end[0] == '%' && !end[1]) {
|
||||
*value *= 0.01;
|
||||
return TRUE;
|
||||
}
|
||||
if (end[0])
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GradientType gradient_type_from_string(const char *str)
|
||||
{
|
||||
if (g_str_equal(str, "horizontal"))
|
||||
return GRADIENT_HORIZONTAL;
|
||||
if (g_str_equal(str, "vertical"))
|
||||
return GRADIENT_VERTICAL;
|
||||
if (g_str_equal(str, "radial"))
|
||||
return GRADIENT_CENTERED;
|
||||
fprintf(stderr, RED "Invalid gradient type: %s" RESET "\n", str);
|
||||
return GRADIENT_VERTICAL;
|
||||
}
|
||||
|
||||
void init_gradient(GradientClass *g, GradientType type)
|
||||
{
|
||||
memset(g, 0, sizeof(*g));
|
||||
g->type = type;
|
||||
if (g->type == GRADIENT_VERTICAL) {
|
||||
Offset *offset_top = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_top->constant = TRUE;
|
||||
offset_top->constant_value = 0;
|
||||
g->from.offsets_y = g_list_append(g->from.offsets_y, offset_top);
|
||||
Offset *offset_bottom = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_bottom->constant = FALSE;
|
||||
offset_bottom->element = ELEMENT_SELF;
|
||||
offset_bottom->variable = SIZE_HEIGHT;
|
||||
offset_bottom->multiplier = 1.0;
|
||||
g->to.offsets_y = g_list_append(g->to.offsets_y, offset_bottom);
|
||||
} else if (g->type == GRADIENT_HORIZONTAL) {
|
||||
Offset *offset_left = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_left->constant = TRUE;
|
||||
offset_left->constant_value = 0;
|
||||
g->from.offsets_x = g_list_append(g->from.offsets_x, offset_left);
|
||||
Offset *offset_right = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_right->constant = FALSE;
|
||||
offset_right->element = ELEMENT_SELF;
|
||||
offset_right->variable = SIZE_WIDTH;
|
||||
offset_right->multiplier = 1.0;
|
||||
g->to.offsets_x = g_list_append(g->to.offsets_x, offset_right);
|
||||
} else if (g->type == GRADIENT_CENTERED) {
|
||||
// from
|
||||
Offset *offset_center_x = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_center_x->constant = FALSE;
|
||||
offset_center_x->element = ELEMENT_SELF;
|
||||
offset_center_x->variable = SIZE_CENTERX;
|
||||
offset_center_x->multiplier = 1.0;
|
||||
g->from.offsets_x = g_list_append(g->from.offsets_x, offset_center_x);
|
||||
Offset *offset_center_y = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_center_y->constant = FALSE;
|
||||
offset_center_y->element = ELEMENT_SELF;
|
||||
offset_center_y->variable = SIZE_CENTERY;
|
||||
offset_center_y->multiplier = 1.0;
|
||||
g->from.offsets_y = g_list_append(g->from.offsets_y, offset_center_y);
|
||||
Offset *offset_center_r = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_center_r->constant = TRUE;
|
||||
offset_center_r->constant_value = 0;
|
||||
g->from.offsets_r = g_list_append(g->from.offsets_r, offset_center_r);
|
||||
// to
|
||||
offset_center_x = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_center_x->constant = FALSE;
|
||||
offset_center_x->element = ELEMENT_SELF;
|
||||
offset_center_x->variable = SIZE_CENTERX;
|
||||
offset_center_x->multiplier = 1.0;
|
||||
g->to.offsets_x = g_list_append(g->to.offsets_x, offset_center_x);
|
||||
offset_center_y = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_center_y->constant = FALSE;
|
||||
offset_center_y->element = ELEMENT_SELF;
|
||||
offset_center_y->variable = SIZE_CENTERY;
|
||||
offset_center_y->multiplier = 1.0;
|
||||
g->to.offsets_y = g_list_append(g->to.offsets_y, offset_center_y);
|
||||
offset_center_r = (Offset *)calloc(1, sizeof(Offset));
|
||||
offset_center_r->constant = FALSE;
|
||||
offset_center_r->element = ELEMENT_SELF;
|
||||
offset_center_r->variable = SIZE_RADIUS;
|
||||
offset_center_r->multiplier = 1.0;
|
||||
g->to.offsets_r = g_list_append(g->to.offsets_r, offset_center_r);
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup_gradient(GradientClass *g)
|
||||
{
|
||||
g_list_free_full(g->extra_color_stops, free);
|
||||
g_list_free_full(g->from.offsets_x, free);
|
||||
g_list_free_full(g->from.offsets_y, free);
|
||||
g_list_free_full(g->from.offsets_r, free);
|
||||
g_list_free_full(g->to.offsets_x, free);
|
||||
g_list_free_full(g->to.offsets_y, free);
|
||||
g_list_free_full(g->to.offsets_r, free);
|
||||
bzero(g, sizeof(*g));
|
||||
}
|
||||
88
src/util/gradient.h
Normal file
88
src/util/gradient.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef GRADIENT_H
|
||||
#define GRADIENT_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#include "color.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Gradient types read from config options, not associated to any area
|
||||
|
||||
typedef enum GradientType {
|
||||
GRADIENT_VERTICAL = 0,
|
||||
GRADIENT_HORIZONTAL,
|
||||
GRADIENT_CENTERED
|
||||
} GradientType;
|
||||
|
||||
typedef struct ColorStop {
|
||||
Color color;
|
||||
// offset in 0-1
|
||||
double offset;
|
||||
} ColorStop;
|
||||
|
||||
typedef enum Element {
|
||||
ELEMENT_SELF = 0,
|
||||
ELEMENT_PARENT,
|
||||
ELEMENT_PANEL
|
||||
} Element;
|
||||
|
||||
typedef enum SizeVariable {
|
||||
SIZE_WIDTH = 0,
|
||||
SIZE_HEIGHT,
|
||||
SIZE_RADIUS,
|
||||
SIZE_LEFT,
|
||||
SIZE_RIGHT,
|
||||
SIZE_TOP,
|
||||
SIZE_BOTTOM,
|
||||
SIZE_CENTERX,
|
||||
SIZE_CENTERY
|
||||
} SizeVariable;
|
||||
|
||||
typedef struct Offset {
|
||||
gboolean constant;
|
||||
// if constant == true
|
||||
double constant_value;
|
||||
// else
|
||||
Element element;
|
||||
SizeVariable variable;
|
||||
double multiplier;
|
||||
} Offset;
|
||||
|
||||
typedef struct ControlPoint {
|
||||
// Each element is an Offset
|
||||
GList *offsets_x;
|
||||
GList *offsets_y;
|
||||
// Defined only for radial gradients
|
||||
GList *offsets_r;
|
||||
} ControlPoint;
|
||||
|
||||
typedef struct GradientClass {
|
||||
GradientType type;
|
||||
Color start_color;
|
||||
Color end_color;
|
||||
// Each element is a ColorStop
|
||||
GList *extra_color_stops;
|
||||
ControlPoint from;
|
||||
ControlPoint to;
|
||||
} GradientClass;
|
||||
|
||||
GradientType gradient_type_from_string(const char *str);
|
||||
void init_gradient(GradientClass *g, GradientType type);
|
||||
void cleanup_gradient(GradientClass *g);
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Gradient instances associated to Areas
|
||||
|
||||
struct Area;
|
||||
typedef struct Area Area;
|
||||
|
||||
typedef struct GradientInstance {
|
||||
GradientClass *gradient_class;
|
||||
Area *area;
|
||||
cairo_pattern_t *pattern;
|
||||
} GradientInstance;
|
||||
|
||||
extern gboolean debug_gradients;
|
||||
|
||||
#endif // GRADIENT_H
|
||||
163
test/acer-chromebook-c100pa/out.txt
Normal file
163
test/acer-chromebook-c100pa/out.txt
Normal file
@@ -0,0 +1,163 @@
|
||||
/sys/class/power_supply/bq27500-0/
|
||||
cat: /sys/class/power_supply/bq27500-0/: Is a directory
|
||||
/sys/class/power_supply/bq27500-0/temp
|
||||
236
|
||||
/sys/class/power_supply/bq27500-0/type
|
||||
Battery
|
||||
/sys/class/power_supply/bq27500-0/power_avg
|
||||
65324
|
||||
/sys/class/power_supply/bq27500-0/power
|
||||
cat: /sys/class/power_supply/bq27500-0/power: Is a directory
|
||||
/sys/class/power_supply/bq27500-0/power/control
|
||||
auto
|
||||
/sys/class/power_supply/bq27500-0/power/async
|
||||
disabled
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_abort_count
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_active
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_type
|
||||
unknown
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_total_time_ms
|
||||
46
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_active_count
|
||||
3
|
||||
/sys/class/power_supply/bq27500-0/power/runtime_enabled
|
||||
disabled
|
||||
/sys/class/power_supply/bq27500-0/power/runtime_active_kids
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/power/runtime_active_time
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_max_time_ms
|
||||
16
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_count
|
||||
3
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_last_time_ms
|
||||
264291
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup
|
||||
enabled
|
||||
/sys/class/power_supply/bq27500-0/power/autosuspend_delay_ms
|
||||
cat: /sys/class/power_supply/bq27500-0/power/autosuspend_delay_ms: Input/output error
|
||||
/sys/class/power_supply/bq27500-0/power/runtime_status
|
||||
unsupported
|
||||
/sys/class/power_supply/bq27500-0/power/runtime_usage
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/power/wakeup_expire_count
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/power/runtime_suspended_time
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/charge_full_design
|
||||
8180000
|
||||
/sys/class/power_supply/bq27500-0/current_now
|
||||
-498000
|
||||
/sys/class/power_supply/bq27500-0/charge_now
|
||||
7253000
|
||||
/sys/class/power_supply/bq27500-0/charge_full
|
||||
7323000
|
||||
/sys/class/power_supply/bq27500-0/device
|
||||
cat: /sys/class/power_supply/bq27500-0/device: Is a directory
|
||||
/sys/class/power_supply/bq27500-0/capacity
|
||||
98
|
||||
/sys/class/power_supply/bq27500-0/health
|
||||
Good
|
||||
/sys/class/power_supply/bq27500-0/subsystem
|
||||
cat: /sys/class/power_supply/bq27500-0/subsystem: Is a directory
|
||||
/sys/class/power_supply/bq27500-0/capacity_level
|
||||
Normal
|
||||
/sys/class/power_supply/bq27500-0/status
|
||||
Discharging
|
||||
/sys/class/power_supply/bq27500-0/voltage_now
|
||||
4260000
|
||||
/sys/class/power_supply/bq27500-0/uevent
|
||||
POWER_SUPPLY_NAME=bq27500-0
|
||||
POWER_SUPPLY_STATUS=Discharging
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_VOLTAGE_NOW=4260000
|
||||
POWER_SUPPLY_CURRENT_NOW=-498000
|
||||
POWER_SUPPLY_CAPACITY=98
|
||||
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||
POWER_SUPPLY_TEMP=236
|
||||
POWER_SUPPLY_TIME_TO_EMPTY_NOW=40980
|
||||
POWER_SUPPLY_TIME_TO_EMPTY_AVG=0
|
||||
POWER_SUPPLY_TIME_TO_FULL_NOW=441780
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CHARGE_FULL=7323000
|
||||
POWER_SUPPLY_CHARGE_NOW=7253000
|
||||
POWER_SUPPLY_CHARGE_FULL_DESIGN=8180000
|
||||
POWER_SUPPLY_CYCLE_COUNT=46
|
||||
POWER_SUPPLY_ENERGY_NOW=7253000
|
||||
POWER_SUPPLY_POWER_AVG=65324
|
||||
POWER_SUPPLY_HEALTH=Good
|
||||
POWER_SUPPLY_MANUFACTURER=Texas Instruments
|
||||
POWER_SUPPLY_MODEL_NAME=C100-80
|
||||
/sys/class/power_supply/bq27500-0/energy_now
|
||||
7253000
|
||||
/sys/class/power_supply/bq27500-0/model_name
|
||||
C100-80
|
||||
/sys/class/power_supply/bq27500-0/manufacturer
|
||||
Texas Instruments
|
||||
/sys/class/power_supply/bq27500-0/technology
|
||||
Li-ion
|
||||
/sys/class/power_supply/bq27500-0/cycle_count
|
||||
46
|
||||
/sys/class/power_supply/bq27500-0/time_to_full_now
|
||||
441780
|
||||
/sys/class/power_supply/bq27500-0/time_to_empty_avg
|
||||
0
|
||||
/sys/class/power_supply/bq27500-0/time_to_empty_now
|
||||
40980
|
||||
/sys/class/power_supply/bq27500-0/present
|
||||
1
|
||||
/sys/class/power_supply/gpio-charger/
|
||||
cat: /sys/class/power_supply/gpio-charger/: Is a directory
|
||||
/sys/class/power_supply/gpio-charger/type
|
||||
Mains
|
||||
/sys/class/power_supply/gpio-charger/power
|
||||
cat: /sys/class/power_supply/gpio-charger/power: Is a directory
|
||||
/sys/class/power_supply/gpio-charger/power/control
|
||||
auto
|
||||
/sys/class/power_supply/gpio-charger/power/async
|
||||
disabled
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_abort_count
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_active
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_type
|
||||
unknown
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_total_time_ms
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_active_count
|
||||
1
|
||||
/sys/class/power_supply/gpio-charger/power/runtime_enabled
|
||||
disabled
|
||||
/sys/class/power_supply/gpio-charger/power/runtime_active_kids
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/runtime_active_time
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_max_time_ms
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_count
|
||||
1
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_last_time_ms
|
||||
349
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup
|
||||
enabled
|
||||
/sys/class/power_supply/gpio-charger/power/autosuspend_delay_ms
|
||||
cat: /sys/class/power_supply/gpio-charger/power/autosuspend_delay_ms: Input/output error
|
||||
/sys/class/power_supply/gpio-charger/power/runtime_status
|
||||
unsupported
|
||||
/sys/class/power_supply/gpio-charger/power/runtime_usage
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/wakeup_expire_count
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/power/runtime_suspended_time
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/device
|
||||
cat: /sys/class/power_supply/gpio-charger/device: Is a directory
|
||||
/sys/class/power_supply/gpio-charger/subsystem
|
||||
cat: /sys/class/power_supply/gpio-charger/subsystem: Is a directory
|
||||
/sys/class/power_supply/gpio-charger/online
|
||||
0
|
||||
/sys/class/power_supply/gpio-charger/uevent
|
||||
POWER_SUPPLY_NAME=gpio-charger
|
||||
POWER_SUPPLY_ONLINE=0
|
||||
@@ -0,0 +1 @@
|
||||
98
|
||||
@@ -0,0 +1 @@
|
||||
Normal
|
||||
@@ -0,0 +1 @@
|
||||
7323000
|
||||
@@ -0,0 +1 @@
|
||||
8180000
|
||||
@@ -0,0 +1 @@
|
||||
7253000
|
||||
@@ -0,0 +1 @@
|
||||
-498000
|
||||
@@ -0,0 +1 @@
|
||||
46
|
||||
@@ -0,0 +1 @@
|
||||
7253000
|
||||
@@ -0,0 +1 @@
|
||||
Good
|
||||
@@ -0,0 +1 @@
|
||||
Texas Instruments
|
||||
@@ -0,0 +1 @@
|
||||
C100-80
|
||||
@@ -0,0 +1 @@
|
||||
disabled
|
||||
@@ -0,0 +1 @@
|
||||
auto
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
disabled
|
||||
@@ -0,0 +1 @@
|
||||
unsupported
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
enabled
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user