git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kde-guidance@1102646 283d02a7-25f6-0310-bc7c-ecb5cbfe19dav3.5.13-sru
@ -0,0 +1,334 @@
|
|||||||
|
- Handle "ain't got no cpufreq" more gracefully (Malone bug # 99198)
|
||||||
|
- Fix typo in mountconfig that lead to a crash (Malone bug # 87861)
|
||||||
|
- BUG: Fix detection of the nvidia proprietary driver (Malone bug #104860)
|
||||||
|
- BUG: Displayconfig and displayconfig-restore.py would crash in combination
|
||||||
|
with later versions Xorg if the xrandr extension was not available.
|
||||||
|
(Malone bug #91545)
|
||||||
|
|
||||||
|
* Wednesday 29 March 2007 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.8
|
||||||
|
- Deal with AttributeError in displayconfigabstraction (Malone bug #94108)
|
||||||
|
- Add menu to choose CPU frequency policy manually
|
||||||
|
- Handle problems not being able to read the filesystem label gracefully
|
||||||
|
- Make displayconfig-restore not crash on incorrect modelines (Malone bug # 76393)
|
||||||
|
- Make displayconfig a little smarter when the preferred resolution can't be found
|
||||||
|
- Make wineconfig not crash on empty fstab lines
|
||||||
|
- Fix the fuser frontend in mountconfig to actually work again.
|
||||||
|
- Handle ZeroDivisionError in displayconfig gracefully (Malone bug #77844)
|
||||||
|
- Support for LABEL in fstab added to mountconfig, improved support for
|
||||||
|
UUID.
|
||||||
|
- Support for changing CPU frequency policy with HAL added to powermanager.
|
||||||
|
- Suspend after N minutes idle added to powermanager
|
||||||
|
- Added an option to not lock screen on resume (Malone bug # 64650)
|
||||||
|
- Handle crash in userconfig due to problems with locale (Malone bug #65739)
|
||||||
|
- Support for UUIDs in fstab added to mountconfig.
|
||||||
|
- grubconfig added. (Martin Böhm)
|
||||||
|
|
||||||
|
* Tuesday 6 March 2007 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.7.1
|
||||||
|
- BUG: Fixed typo in userconfig.py. (thanks to Rocco Stanzione)
|
||||||
|
- BUG: Fix double hibernate call on lid close. (Malone bug #65885)
|
||||||
|
- BUG: Change CHARGE_LEVEL_THRESHOLD to 10% (was 50%) to better workaround
|
||||||
|
acpi issue. when remaining_time is not reported correctly. Also use
|
||||||
|
threshold for battery low notification warning. (Malone bug #64752,
|
||||||
|
#67081)
|
||||||
|
- BUG: Handle error in locale.getpreferredencoding gracefully. (Malone bug
|
||||||
|
#65739)
|
||||||
|
- BUG: DPMS settings had not been saved on Apply, do that.
|
||||||
|
- BUG: Fix crash where cpu frequency scaling is not readable.
|
||||||
|
- BUG: Fix unicode and localisation handling in targetgamma, do a better job
|
||||||
|
choosing the right resolutions for example for nvidia twinview and other
|
||||||
|
unusual resolutions.
|
||||||
|
- BUG: Powermanager, first read config, then adapt the state of the UI from
|
||||||
|
those values.
|
||||||
|
- BUG: Don't crash displayconfig-restore when screenwidth and height are
|
||||||
|
bogus, use a sensible value of 96 instead. (Malone bug #77844)
|
||||||
|
- BUG: Make displayconfig-restore not crash on unknown modelines.
|
||||||
|
- BUG: Make tempfile handling more robust by using Python's tempfile.
|
||||||
|
- BUG: Check for None groupids in userconfig.
|
||||||
|
- BUG: Clear password edit after exiting the edit dialog in userconfig.
|
||||||
|
- BUG: Make AC adapter detection more robust to potential failure of
|
||||||
|
actions. (Malone bug #77091)
|
||||||
|
- BUG: permissions on groupfile should've been read, before they can be set.
|
||||||
|
- BUG: Check for valid groupid when selecting in userconfig.
|
||||||
|
- BUG: gamma settings were not being restored after logging in.
|
||||||
|
- BUG: A rounding error was causing problems in displayconfig when filtering
|
||||||
|
resolutions by the selected monitor.
|
||||||
|
- BUG: Displayconfig, userconfig and wineconfig didn't handle RTL desktops
|
||||||
|
correctly. (Diego lastrubni)
|
||||||
|
- BUG: Displayconfig would sometimes consider some widescreen modes as being
|
||||||
|
standand aspect ratio.
|
||||||
|
- BUG: Displayconfig would sometimes fail to set Display virtual size in
|
||||||
|
xorg.conf.
|
||||||
|
- BUG: Stopped displayconfig from stacktracing when it encounters a
|
||||||
|
degenerate gfx card + monitor combination that has no valid resolutions.
|
||||||
|
|
||||||
|
* Thursday 12 October 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.7
|
||||||
|
- BUG: Don't bail out of laptop-detect is not there (Malone bug #60309)
|
||||||
|
- BUG: mountconfig.py didn't handle USB disks correctly. (KDE bug #132390)
|
||||||
|
- BUG: Disable double click opening items in mountconfig if the user is not
|
||||||
|
root.
|
||||||
|
- BUG: Don't bail out if the device section is already there (Malone bug #50411)
|
||||||
|
- BUG: Don't show new_user in the secondary groups (Malone bug #44203)
|
||||||
|
- BUG: userconfig set wrong uid for new users (Malone bug #56275)
|
||||||
|
- BUG: serviceconfig.py would sometimes fail on non-English systems.
|
||||||
|
(Malone bug #43313).
|
||||||
|
- BUG: userconfig would sometimes fail when writing the shadow password file.
|
||||||
|
(Malone bug #47090)
|
||||||
|
- BUG: userconfig would fail if the password warning field in /etc/shadow was
|
||||||
|
empty. (Malone bug #47317)
|
||||||
|
- Changed a couple of labels in order to match the new system-settings spec:
|
||||||
|
https://wiki.kubuntu.org/KubuntuSystemSettingsUsability
|
||||||
|
- mountconfig now uses CIFS for Windows Shares instead of obsolete smbfs.
|
||||||
|
(Martin Böhm)
|
||||||
|
- Displayconfig now hides useless Monitor Orientation and Second Screen group
|
||||||
|
box options which can never be activated without changing hardware or the
|
||||||
|
X driver.
|
||||||
|
- Simplified the color and gamma tab in displayconfig.
|
||||||
|
- BUG: Better detection for dualhead intel chips in displayconfig.
|
||||||
|
- Updated the data files for displayconfig from
|
||||||
|
http://cvs.mandriva.com/cgi-bin/viewvc.cgi/soft/ldetect-lst/trunk/lst/?root=svn
|
||||||
|
- wineconfig added for configuring Wine. (Yuriy Kozlov)
|
||||||
|
- powermanager applet added for monitoring laptop power levels (Sebastian
|
||||||
|
Kügler)
|
||||||
|
|
||||||
|
* Saturday 13 May 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.7
|
||||||
|
- Dutch translation added (Rinse de Vries)
|
||||||
|
- BUG: Displayconfig would fail if the monitor frequency settings in xorg.conf
|
||||||
|
contained extra spaces. (Malong bug #38692)
|
||||||
|
- BUG: Displayconfig would not add the lowest screen resolution available to
|
||||||
|
the modes list in the xorg.conf's Screen section/Display subsection.
|
||||||
|
- French translation added from Launchpad Rossetta.
|
||||||
|
|
||||||
|
* Friday 28 April 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.6
|
||||||
|
- BUG: Serviceconfig didn't correctly remove links in runlevel directories.
|
||||||
|
(Malone bug #39404)
|
||||||
|
- BUG: In Serviceconfig, toggling the "Start during boot" checkbox using the
|
||||||
|
context menu would fail. (Malone bug #34252)
|
||||||
|
- BUG: displayconfig-restore.py was would fail with "global name 'syslog'
|
||||||
|
undefined". (Malone bug #40683)
|
||||||
|
- BUG: Displayconfig had trouble picking a driver gfxcard model entry instead
|
||||||
|
of the detected default (e.g. VESA). (Malone bug #41127)
|
||||||
|
- BUG: Displayconfig would fail when writing out a xorg.conf that contained
|
||||||
|
non-ascii characters. (Malone bug #41474)
|
||||||
|
- Work around for an annoying bug in PyQt/PyKDE that causes the tools to
|
||||||
|
crash on exit if a dialog window has been used.
|
||||||
|
- BUG: The file paths used in displayconfig for checking for the proprietary
|
||||||
|
nvidia driver were wrong or out of date.
|
||||||
|
|
||||||
|
* Tuesday 18 April 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.5
|
||||||
|
- BUG: services that have not been installed via apt would cause long loops
|
||||||
|
a lot of dpkg queries. Only query dpkg db once.
|
||||||
|
- BUG: Serviceconfig's Apply button doesn't work. It should actually be Close
|
||||||
|
(Malone #38582)
|
||||||
|
- BUG: Changing an user's password can change another password for a different
|
||||||
|
user (Malone bug #39444)
|
||||||
|
- BUG: Displayconfig would fail at startup on systems with an nVidia 7800 GTX.
|
||||||
|
(Malone bug #32915 for Rob Hughes)
|
||||||
|
- BUG: Serviceconfig would crash if the windows is closed quickly after
|
||||||
|
serviceconfig appears.
|
||||||
|
- BUG: userconfig would fail at startup if an entry in /etc/passwd refered to
|
||||||
|
a group that is not defined in /etc/group. (Malone bug #34311)
|
||||||
|
- BUG: Userconifg. Manually typing in or editing the list of secondary groups
|
||||||
|
for a user had no effect. (Malone bug #37212)
|
||||||
|
- BUG: Displayconfig fails to detect the presence of the proprietary ATI and
|
||||||
|
nVidia drivers. (The location of some of the driver files had been recently
|
||||||
|
changed).
|
||||||
|
- BUG: displayconfig-restore.py would calculated the needed DPI at login using
|
||||||
|
stale screen information which would sometimes result in the wrong DPI.
|
||||||
|
- BUG: Numerious small bugs and compatibility problems in mountconfig.
|
||||||
|
- BUG: When browsing for a SMB share, mountconfig now correctly catches the
|
||||||
|
authentication information entered by the user into the smaller popup from
|
||||||
|
kio.
|
||||||
|
- Displayconfig now assumes that dualhead/clone mode is supported if the
|
||||||
|
laptop-detect script detects a laptop.
|
||||||
|
- Displayconfig now uses the clone mode support in the i810 driver.
|
||||||
|
- Displayconfig now only offers resolutions that both monitors support when
|
||||||
|
using clone mode.
|
||||||
|
- Displayconfig now supports clone mode on any setup that also supports
|
||||||
|
xinerama.
|
||||||
|
- BUG: Mountconfig failed to take into account that the order of the
|
||||||
|
user/users, exec/noexc, suid/nosuid etc options in /etc/fstab is significant.
|
||||||
|
(thanks Christoph Wiesen)
|
||||||
|
- French translations added to the desktop files. (Anthony Mercatante)
|
||||||
|
|
||||||
|
* Sunday 2 April 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.4
|
||||||
|
- BUG: All of the tools no longer write out config files under ~/.kde when
|
||||||
|
running as root. This should stop the annoying creation of config files
|
||||||
|
that can't be overwritten by the normal user.
|
||||||
|
- Userconfig is now by default not quite as tall. This should help stop
|
||||||
|
it from appearing too big in systemsettings.
|
||||||
|
- Displayconfig updated to also recognise late model nVidia chipsets.
|
||||||
|
- BUG: Displayconfig didn't support Clone mode for the proprietary nVidia
|
||||||
|
driver.
|
||||||
|
- BUG: The tools now correctly specify which translation catalogue to use for
|
||||||
|
translations.
|
||||||
|
- The screen images in the dualhead widget make better use of available widget
|
||||||
|
space.
|
||||||
|
- Displayconfig: The 40guidance-displayconfig_restore script which is used by
|
||||||
|
the Xsession script during login via KDM/xdm, has now been fixed to not stop
|
||||||
|
the login in case of failure.
|
||||||
|
- BUG: Displayconfig was getting confused by unknown graphics cards and
|
||||||
|
crashing. (Malone bug #32915)
|
||||||
|
- BUG: Displayconfig still can't handling unicode in xorg.conf. (Malone bug
|
||||||
|
#34437).
|
||||||
|
- BUG: Displayconfig is now more forgiving when xorg.conf contains characters
|
||||||
|
that are illegal with respect to the system character encoding. (Malone bug
|
||||||
|
#36590).
|
||||||
|
- BUG: Displayconfig would have trouble detecting hardware on the PCI bus on
|
||||||
|
big endian architectures. (raphink)
|
||||||
|
- BUG: Displayconfig did not correctly handle situations where the X RandR
|
||||||
|
extension is missing.
|
||||||
|
- BUG: Displayconfig would fail when loading some xorg.conf files containing
|
||||||
|
multiple graphics card specifications. (Malone bug #37275, patch applied)
|
||||||
|
- BUG: Userconfig didn't respect the entered UID when creating a account.
|
||||||
|
(Malone bug #37722).
|
||||||
|
- Displayconfig: Added 1280x960 modes (60 & 75Hz).
|
||||||
|
|
||||||
|
* Friday 17 March 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.3
|
||||||
|
- BUG: userconfig and unixauthdb didn't respect the ownership of system files
|
||||||
|
when update /etc/passwd and friends. (Malone bug #26175).
|
||||||
|
- BUG: userconfig and unixauthdb would fail if /etc/passwd, /etc/groups or
|
||||||
|
/etc/shadow contained blank lines.
|
||||||
|
- BUG: displayconfig now does a better job of detecting graphics PCI devices
|
||||||
|
and handling non-detected graphics cards. Instead of crashing, "generic
|
||||||
|
VESA" is used when the type of card can't be found. (Malone bug #32915)
|
||||||
|
- The DPI that displayconfig-restore.py uses at login time can now be
|
||||||
|
controlled by adding a line to ~/.kde/share/config/displayconfigrc
|
||||||
|
in the [General] section. Add "dpi=xserver" to use the default DPI
|
||||||
|
from the X server, or "dpi=100" to use 100 DPI for example.
|
||||||
|
- BUG: Widescreen modes were missing in displayconfig.
|
||||||
|
- Displayconfig: Monitors can now be specified as being standard aspect ratio
|
||||||
|
or widescreen.
|
||||||
|
- BUG: Using the xresprobe command in displayconfig would crash some people's
|
||||||
|
machines. The much more safer ddcprobe command is now used.
|
||||||
|
(Malone bug #33943)
|
||||||
|
- BUG: A bug is displayconfig stopped monitor model detection. The xresprobe
|
||||||
|
command didn't actually return the eisa ID of the connected monitor.
|
||||||
|
ddcprobe does though (see above).
|
||||||
|
- BUG: Displayconfig. Changes to the monitor model or image format are
|
||||||
|
shown immediately on the "Size & Orientation" tab, even if the screen is
|
||||||
|
currently being used.
|
||||||
|
- BUG: When userconfig asks about whether the home directory should be created
|
||||||
|
when creating a new account, sometimes the wrong directory name was shown in
|
||||||
|
the dialog.
|
||||||
|
- BUG: Powerbook screen mode "1280x854" add to displayconfig. (Malone bug
|
||||||
|
#34383).
|
||||||
|
- BUG: Displayconfig would throw an exception if the current display didn't
|
||||||
|
support DPMS. (Malone bug #34316).
|
||||||
|
- BUG: Most utilities would fail if they came across UTF-8 or unicode
|
||||||
|
characters. (Malone bug #34194).
|
||||||
|
- BUG: Displayconfig wouldn't correctly detect the presence of installed
|
||||||
|
proprietary drivers. (OculusAquilae)
|
||||||
|
- BUG: Displayconfig had trouble handling BusID rows in xorg.conf. This would
|
||||||
|
cause the xorg.conf to be incorrectly read. (Tonio)
|
||||||
|
- Added some extra methods to ScanPCI.py to aid debugging.
|
||||||
|
- BUG: Displayconfig would not save the user's display settings when running
|
||||||
|
in kcontrol or systemsettings. (Malone bug #35257)
|
||||||
|
|
||||||
|
* Wednesday 1 March 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.2
|
||||||
|
- BUG: Small bug in displayconfig that caused it to bug out around the
|
||||||
|
newCustomMonitor() method.
|
||||||
|
- BUG: userconfig had space character just before the she-bang which really
|
||||||
|
caused some trouble the for the shell.
|
||||||
|
- BUG: Displayconfig: Selecting the "Plug n Play" monitor directly without
|
||||||
|
clicking on "Detect" meant that only a very small set of resolutions would
|
||||||
|
be written to xorg.conf.
|
||||||
|
- BUG: The DPI calculations in displayconfig-restore.py where broken. This
|
||||||
|
resulted in the wrong DPI being used.
|
||||||
|
- BUG: Displayconfig: The clone mode option is now correctly disabled for
|
||||||
|
Matrox cards (mga driver).
|
||||||
|
- BUG: Displayconfig would bug out if the monitor model in the xorg.conf was
|
||||||
|
anything other than Plug n Play.
|
||||||
|
- BUG: Displayconfig would bug out if the DPMS Standby setting was 0 and DPMS
|
||||||
|
enabled.
|
||||||
|
- Displayconfig is now shown in kcontrol under settings/hardware instead of
|
||||||
|
settings/system.
|
||||||
|
- BUG: Small bug in displayconfig that will causes displayconfig to bug out
|
||||||
|
when trying to detect the monitor and no EDID info is available.
|
||||||
|
- BUG: Small cosmetic bug in displayconfig where the some tabs were missing
|
||||||
|
margins when shown in kcontrol/system settings.
|
||||||
|
- BUG: displayconfig would bug out when detecting ATI dualhead cards.
|
||||||
|
(pci_device.text was None).
|
||||||
|
|
||||||
|
* Monday 20 February 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.1
|
||||||
|
- displayconfig-hwprobe.py now saves its scan info in
|
||||||
|
/var/lib/guidance/guidance-gfxhardware-snapshot.
|
||||||
|
- "Details..." button added to mountconfig in addition to the context menu for
|
||||||
|
opening the disk info dialog.
|
||||||
|
- BUG: serviceconfig: When starting and stopping daemons, the scripts expect a
|
||||||
|
terminal that understands colours. The command runner dialog doesn't, and
|
||||||
|
you end up seeing garbage characters. TERM is now set to vt100 when running
|
||||||
|
commands.
|
||||||
|
- BUG: displayconfig: Reset button didn't reset all of the parts/fields in the
|
||||||
|
GUI.
|
||||||
|
- Detect dualhead Matrox cards.
|
||||||
|
- displayconfig-restore.py now at login time also chooses and sets a 'sane'
|
||||||
|
DPI setting used by applications for fonts. More info is in the
|
||||||
|
displayconfig-restore.py source file.
|
||||||
|
- BUG: displayconfig-restore.py wasn't restoring the user's display resolution
|
||||||
|
at login.
|
||||||
|
- Plug N Play monitors are handled much better and are automatically probed
|
||||||
|
when neccessary.
|
||||||
|
|
||||||
|
* Tuesday 14 February 2006 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.6.0
|
||||||
|
- Right mousebutton action for most listviews.
|
||||||
|
- mountconfig can now handle multi-fs entries.
|
||||||
|
- i18n() all over the place.
|
||||||
|
- Dualhead support added to displayconfig.
|
||||||
|
- displayconfig's hardware database files updated from Mandriva.
|
||||||
|
- numerous bug fixes.
|
||||||
|
- displayconfig-hwprobe.py add. This is Ubuntu specific right now, but
|
||||||
|
what it does is detect hardware changes at boottime and automatically
|
||||||
|
run "dpkg-reconfigure" to generate a xorg.conf file that will get Xorg
|
||||||
|
running.
|
||||||
|
|
||||||
|
* Tuesday 29 November 2005 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.5.0
|
||||||
|
- displayconfig should now work for single head configurations.
|
||||||
|
- displayconfig has a shiney new preview.
|
||||||
|
- displayconfig is now usable on low resolution screens.
|
||||||
|
- DPMS tab cleaned up in displayconfig.
|
||||||
|
- displayconfig's hardware database files updated from Mandriva.
|
||||||
|
|
||||||
|
* Monday 12 September 2005 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.4.0
|
||||||
|
- displayconfig has been massively restructured internally.
|
||||||
|
- numerous bug fixes.
|
||||||
|
- start of dualhead support in displayconfig.
|
||||||
|
- When umount fails in mountconfig the option to killing blocking processes
|
||||||
|
has been added.
|
||||||
|
- better Debian support in serviceconfig. It now uses apt and dpkg to get
|
||||||
|
service descriptions.
|
||||||
|
- ext3 added to mountconfig. :)
|
||||||
|
- userconfig now respects /etc/useradd.conf
|
||||||
|
- Now uses PyKDE Extensions for building and installation.
|
||||||
|
http://www.simonzone.com/software/pykdeextensions/
|
||||||
|
- DPMS tab added to displayconfig.
|
||||||
|
|
||||||
|
* Tuesday 5 April 2005 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.3.0
|
||||||
|
- Displayconfig working and also feature complete.
|
||||||
|
- xf86config C module has been removed and replaced with pure Python.
|
||||||
|
- Numerous little bugs fixed in the userconfig, mountconfig and serviceconfig.
|
||||||
|
|
||||||
|
* Thursday 9 December 2004 Simon Edwards <simon@simonzone.com>
|
||||||
|
- version 0.2.0
|
||||||
|
- mountconfig added, beta quality, feature complete.
|
||||||
|
- displayconfig added, alpha quality, not feature complete.
|
||||||
|
- userconfig, beta quality, feature complete.
|
||||||
|
- serviceconfig, beta quality, feature complete.
|
||||||
|
|
||||||
|
* Thursday 20 November 2003 Simon Edwards <simon@simonzone.com>
|
||||||
|
|
||||||
|
- version 0.1.0
|
||||||
|
- Initial release.
|
@ -0,0 +1,21 @@
|
|||||||
|
recursive-include kde *.png *.svg
|
||||||
|
recursive-include doc *.docbook *.png
|
||||||
|
graft package
|
||||||
|
prune package/.svn
|
||||||
|
graft package/mandrake
|
||||||
|
graft debian
|
||||||
|
prune package/mandrake/.svn
|
||||||
|
include README COPYING ChangeLog MANIFEST.in TODO
|
||||||
|
global-include *.desktop *.py *.pot *.po *.ui
|
||||||
|
global-exclude *~ .svn
|
||||||
|
include displayconfig/40guidance-displayconfig_restore
|
||||||
|
include displayconfig/vesamodes
|
||||||
|
include displayconfig/extramodes
|
||||||
|
include displayconfig/widescreenmodes
|
||||||
|
include displayconfig/ldetect-lst/Cards+
|
||||||
|
include displayconfig/ldetect-lst/MonitorsDB
|
||||||
|
include displayconfig/ldetect-lst/pcitable
|
||||||
|
exclude displayconfig/test.py
|
||||||
|
exclude displayconfig/xconfig-test.py
|
||||||
|
exclude displayconfig/popentest.py
|
||||||
|
exclude displayconfig/guidance_bug_reporter.py
|
@ -0,0 +1,15 @@
|
|||||||
|
messagesold:
|
||||||
|
LIST=`find . -name \*.py`; \
|
||||||
|
if test -n "$$LIST"; then \
|
||||||
|
xgettext -ki18n -LPython $$LIST -o po/guidance.pot; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
sh /usr/lib/kubuntu-desktop-i18n/findfiles LIST
|
||||||
|
perl /usr/lib/kubuntu-desktop-i18n/createdesktop.pl --file-list=LIST --base-dir=. > desktop.guidance.tmp
|
||||||
|
msguniq --to-code=UTF-8 --no-wrap -o desktop.guidance desktop.guidance.tmp 2>/dev/null
|
||||||
|
python /usr/lib/kubuntu-desktop-i18n/msgsplit desktop.guidance
|
||||||
|
mv desktop.guidance po/desktop_guidance.pot
|
||||||
|
rm -f desktop.guidance desktop.guidance.tmp
|
||||||
|
|
||||||
|
messages:
|
||||||
|
true
|
@ -0,0 +1,189 @@
|
|||||||
|
!!! Warning: Read this through to the end. These tools can be dangerous. !!!
|
||||||
|
|
||||||
|
Guidance 0.8.0
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
by Simon Edwards <simon@simonzone.com>, Sebastian Kügler <sebas@vizzzion.org>
|
||||||
|
& Yuriy Kozlov <yuriy.kozlov@gmail.com>, Martin Böhm <martin.bohm@kubuntu.org>
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
Guidance is a collection of system administration tools for Linux/KDE systems
|
||||||
|
that is designed to be:
|
||||||
|
|
||||||
|
* Update to date
|
||||||
|
* High quality, designed with user friendliness as high priority. (That is
|
||||||
|
to say that the tools should get the job done quickly, accurately and with
|
||||||
|
as little effort as possible.)
|
||||||
|
* Use KDE and "fit in" with KDE.
|
||||||
|
* Maintainable.
|
||||||
|
* Free Software
|
||||||
|
|
||||||
|
|
||||||
|
Warning
|
||||||
|
-------
|
||||||
|
These tools often require root access and modify important system files in
|
||||||
|
order to do their job. There is a very real chance that these tools can
|
||||||
|
destroy your computer and your data. Backup your data! Also especially
|
||||||
|
backup up /etc/passwd, /etc/shadow and /etc/fstab. If you don't know what
|
||||||
|
I'm talking about now then you probably shouldn't try using Guidance yet.
|
||||||
|
You should have some idea how to fix
|
||||||
|
|
||||||
|
We accept no responsibility in the event that something goes terribly wrong.
|
||||||
|
You have been warned.
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
The tools that make up Guidance are in different stages of development and
|
||||||
|
have only been tested on Mandrake.
|
||||||
|
|
||||||
|
* userconfig - User & Group configuration. Supports /etc/passwd and
|
||||||
|
/etc/shadow right now.
|
||||||
|
|
||||||
|
* serviceconfig - System services configuration utility. Feature complete.
|
||||||
|
Works on Mandrake, Debian, (K)ubuntu Gentoo and maybe Red Hat out of the box.
|
||||||
|
|
||||||
|
* mountconfig - Mount point configuration utility. Feature complete and
|
||||||
|
stable.
|
||||||
|
|
||||||
|
* displayconfig - Display and graphics card configuration utility. Feature
|
||||||
|
complete but it only tested on Kubuntu right now.
|
||||||
|
|
||||||
|
* wineconfig - Wine configuration utility.
|
||||||
|
|
||||||
|
* grubconfig - Grub boot loader configuration utility. beta quality now.
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
* Linux.
|
||||||
|
|
||||||
|
* Python. 2.4 recommended. You probably already have Python installed, and if
|
||||||
|
not then it will most definately be available for you distribution of choice.
|
||||||
|
|
||||||
|
* PyQt / PyKDE. Version 3.7 or higher. PyQt and PyKDE are distributed with
|
||||||
|
KDE as part of kde-bindings since version 3.3.
|
||||||
|
|
||||||
|
For versions of KDE before 3.3 it is possible to install PyQt/PyKDE
|
||||||
|
directly. The homepage for PyQt and PyKDE is:
|
||||||
|
|
||||||
|
http://www.riverbankcomputing.co.uk/pykde/index.php
|
||||||
|
|
||||||
|
Packages for most popular distributions are available here:
|
||||||
|
|
||||||
|
http://sourceforge.net/project/showfiles.php?group_id=61057
|
||||||
|
|
||||||
|
* KDE 3.
|
||||||
|
|
||||||
|
* "PyKDE Extensions" is needed for installation. It is available here:
|
||||||
|
http://www.simonzone.com/software/pykdeextensions/
|
||||||
|
This is also a runtime requirement!
|
||||||
|
|
||||||
|
* libpythonize. If you don't want the tools to appear on the KDE Control
|
||||||
|
Center of you just don't want to bother with libpythonize, then you can
|
||||||
|
build Guidance with this command:
|
||||||
|
|
||||||
|
python setup.py install build_kcm --no-kcontrol
|
||||||
|
|
||||||
|
libpythonize is only needed for the KDE Control Center.
|
||||||
|
|
||||||
|
* You also need to have the development files from your X-server installed,
|
||||||
|
XFree86 or Xorg. Most distributions package these files up in a package
|
||||||
|
called XFree86-devel, or Xorg-devel, or libxorg-X11-devel or some similar.
|
||||||
|
|
||||||
|
* Specifically, the following packages are needed on Kubuntu:
|
||||||
|
|
||||||
|
build-essential
|
||||||
|
python-sip4-dev
|
||||||
|
libxxf86vm-dev
|
||||||
|
libxrender-dev
|
||||||
|
libxrandr-dev
|
||||||
|
libpythonize0-dev
|
||||||
|
pyqt-tools
|
||||||
|
libtool
|
||||||
|
kde-devel
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
As root run:
|
||||||
|
|
||||||
|
./setup.py install
|
||||||
|
|
||||||
|
This will test for a working installation of PyQt/PyKDE and automatically
|
||||||
|
install the files using the same installation prefix as KDE. You will need
|
||||||
|
to have a working Python install before you can even run the setup.py script.
|
||||||
|
|
||||||
|
displayconfig-hwprobe installation
|
||||||
|
----------------------------------
|
||||||
|
displayconfig-hwprobe.py is a small program that should be run at boottime
|
||||||
|
before Xorg is started. It scans the PCI bus looking for graphics cards and
|
||||||
|
compares the list it finds to the previous time it was run. If the two lists
|
||||||
|
of hardware are different then "dpkg-reconfigure xserver-xorg" is automatically
|
||||||
|
run in non-interactive mode to generate a new xorg.conf based on the new
|
||||||
|
hardware.
|
||||||
|
|
||||||
|
The philosophy is that it is better to have a system with a raw but working
|
||||||
|
xorg.conf and X server, than to keep the old configuration and a Xorg that
|
||||||
|
won't startup. Swapping a graphics card should not "break" the OS.
|
||||||
|
|
||||||
|
The setup.py script currently does not install displayconfig-hwprobe.py by
|
||||||
|
itself. For now this must be done by the packager. displayconfig-hwprobe.py
|
||||||
|
should be put in /etc/init.d and installed to run at boot time with a command
|
||||||
|
like this:
|
||||||
|
|
||||||
|
update-rc.d displayconfig-hwprobe.py start 18 3 .
|
||||||
|
|
||||||
|
displayconfig-hwprobe.py only supports Kubuntu right now. Perhaps in the
|
||||||
|
future displayconfig-hwprobe will be expanded to detect hardware and generate
|
||||||
|
an xorg.conf by itself.
|
||||||
|
|
||||||
|
More information about displayconfig-hwprobe.py and the files it uses is
|
||||||
|
inside displayconfig-hwprobe.py. Currently the hardware data is written to
|
||||||
|
/var/lib/guidance/guidance-gfxhardware-snapshot. IMPORTANT: The directory
|
||||||
|
/var/lib/guidance/ should be created before using displayconfig-hwprobe.py.
|
||||||
|
|
||||||
|
|
||||||
|
Running
|
||||||
|
-------
|
||||||
|
Installation should add a couple of entries to the KDE Control Center in the
|
||||||
|
System section (displayconfig will show up in Peripherals). It is also possible
|
||||||
|
to run the commands outside of the KDE Control Center from the shell as root:
|
||||||
|
|
||||||
|
* serviceconfig
|
||||||
|
* userconfig
|
||||||
|
* mountconfig
|
||||||
|
* displayconfig
|
||||||
|
* wineconfig
|
||||||
|
* grubconfig
|
||||||
|
|
||||||
|
Reporting Bugs
|
||||||
|
--------------
|
||||||
|
Bug reports and feedback can be sent to simon@simonzone.com . Do make sure
|
||||||
|
that say which version of Guidance you are using and also what Linux
|
||||||
|
distribution you are using, and also how you installed SIP, PyQt, PyKDE. Also
|
||||||
|
if any error messages are printing to the console, email those too. By
|
||||||
|
running these tools from the command line you can often get useful (to me)
|
||||||
|
debug information. That kind of information is valuable.
|
||||||
|
|
||||||
|
|
||||||
|
Deinstallation
|
||||||
|
--------------
|
||||||
|
As root run:
|
||||||
|
|
||||||
|
./setup.py uninstall
|
||||||
|
|
||||||
|
|
||||||
|
Thanks go to
|
||||||
|
------------
|
||||||
|
Jim Bublitz
|
||||||
|
David Boddie
|
||||||
|
Sebastian Kügler
|
||||||
|
Theo Houtman
|
||||||
|
Pete Andrews (gamma correction system)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
Simon Edwards
|
||||||
|
<simon@simonzone.com>
|
@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
Intro
|
||||||
|
~~~~~
|
||||||
|
In this file I want to try to explain some practical things about Guidance
|
||||||
|
the "project" and some basic (and hopefully not too heavy) policies about how
|
||||||
|
things work organisationally.
|
||||||
|
|
||||||
|
-- 11 Feb 2007, Simon Edwards <simon@simonzone.com>
|
||||||
|
|
||||||
|
|
||||||
|
Developers
|
||||||
|
~~~~~~~~~~
|
||||||
|
The list of developers as of 11 Feb 2007:
|
||||||
|
|
||||||
|
Simon Edwards <simon@simonzone.com>, SVN username: sedwards, IRC: sime (unregistered)
|
||||||
|
Sebastian Kügler <sebas@kde.nl>, SVN username: sebas, IRC: sebas
|
||||||
|
Yuriy Kozlov <yuriy.kozlov@gmail.com>, SVN username: ykozlov, IRC: yuriy
|
||||||
|
Martin Böhm <martin.bohm@kubuntu.org>, SVN username: martinbohm, IRC: ???
|
||||||
|
|
||||||
|
"Lure" on #kubuntu-devel will join this list whether he likes it or not if he keeps
|
||||||
|
on committing stuff to powermanager. ;-)
|
||||||
|
|
||||||
|
|
||||||
|
Subversion
|
||||||
|
~~~~~~~~~~
|
||||||
|
Main development occurs in KDE's subversion repository in
|
||||||
|
/trunk/kdereview/guidance. Branches of the stable releases can be found
|
||||||
|
in svn under /kde/branches/guidance/. 0.6 was used in the Kubuntu Dapper, 0.7
|
||||||
|
was in Edgy.
|
||||||
|
|
||||||
|
|
||||||
|
Python source code
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
Use 4 spaces for indentation, for the simple reason that it is very common
|
||||||
|
and mixing indentation styles is a PITA.
|
||||||
|
|
||||||
|
I (Simon) use Qt/KDE style naming conventions for methods. For variable
|
||||||
|
names I'm a bit inconsistent but it is usually lower case of lower case
|
||||||
|
with underscores. All I ask is that variable names be descriptive and
|
||||||
|
understandable.
|
||||||
|
|
||||||
|
TIP: When dealing with translated strings, use uncide() and not str(),
|
||||||
|
otherwise things will break on translated desktops.
|
||||||
|
|
||||||
|
|
||||||
|
Release procedure
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
[TODO: explain how a release tarball is created.]
|
@ -0,0 +1,294 @@
|
|||||||
|
TODO
|
||||||
|
====
|
||||||
|
|
||||||
|
BUG: Mountconfig has no "enable/disable" in the context menu.
|
||||||
|
|
||||||
|
BUG: Mountconfig: "enable/disable" can sometime be available for normal users.
|
||||||
|
|
||||||
|
BUG: mountconfig: The disk details dialog (sizeview.py) doesn't show *unpartioned* free space.
|
||||||
|
|
||||||
|
BUG: Live gamma changes didn't seem to work on one of the S3s.
|
||||||
|
|
||||||
|
BUG: mountconfig. Authentication details in the SMSShareSelectDialog are sometimes not
|
||||||
|
correctly used when browsing.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TODO: Some S3 cards need to have the video ram specified, and some later model don't.
|
||||||
|
It would be good if we could tell the difference and only offer the ram pulldown
|
||||||
|
when strictly needed.
|
||||||
|
|
||||||
|
|
||||||
|
TODO: Monitor type selection (CRT, lcd etc). needed for clone mode on ATI at least.
|
||||||
|
|
||||||
|
TODO: When using the proprietary nVidia driver, choose between the nVidia AGP
|
||||||
|
and kernel agpgart based on what is best the of the machine's chipset.
|
||||||
|
|
||||||
|
TODO: The proprietary ATI drivers have a 'Option "BusType" "PCI"' thing which may
|
||||||
|
of may not need to be set for PCI based ATI cards.
|
||||||
|
|
||||||
|
TODO: 3D accel on the 9250 with open source drivers.
|
||||||
|
|
||||||
|
|
||||||
|
Future TODO
|
||||||
|
===========
|
||||||
|
|
||||||
|
setup.py
|
||||||
|
~~~~~~~~
|
||||||
|
.
|
||||||
|
|
||||||
|
userconfig
|
||||||
|
~~~~~~~~~~
|
||||||
|
.
|
||||||
|
|
||||||
|
unixauthdb.py
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
* LDAP (post-1.0) in-progress
|
||||||
|
* (others?) (post-1.0)
|
||||||
|
|
||||||
|
serviceconfig
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
* Change os.system() to the calls Simon uses in some cases.
|
||||||
|
* Some services are running, but not in /var/run, implement special treatment. :>
|
||||||
|
* Remove commented line from /etc/shells in userconfig -> Modify -> Shell.
|
||||||
|
|
||||||
|
mountconfig
|
||||||
|
~~~~~~~~~~~
|
||||||
|
* Add 'proper' GUIs for editing some of the more common FS types.
|
||||||
|
- NFS.
|
||||||
|
* AttributeError when mounting Samba volume
|
||||||
|
* Handle the 'managed' mount entry options. See http://www.die.net/doc/linux/man/man8/fstab-sync.8.html
|
||||||
|
This is stand on Mandriva 2005.
|
||||||
|
* Implement "real" HAL backend.
|
||||||
|
|
||||||
|
displayconfig
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
* Use HAL for fetching PCI and card info? alongside existing systems (ldetect)?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Extra?
|
||||||
|
~~~~~~
|
||||||
|
* Swap/kernel config:
|
||||||
|
http://kerneltrap.org/node/view/3000
|
||||||
|
"To tune, simply echo a value from 0 to 100 onto /proc/sys/vm/swappiness."
|
||||||
|
|
||||||
|
* Hardware detection info:
|
||||||
|
|
||||||
|
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=lyit5wc14g.fsf%40leia.mandrakesoft.com&rnum=1&prev=/groups%3Fq%3Ddebian%2520ldetect%2520hardware%2520detection%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
From: Pixel (pixel@mandrakesoft.com)
|
||||||
|
Subject: Re: Why so many HW detection packages?
|
||||||
|
Newsgroups: linux.debian.devel
|
||||||
|
Date: 2002-05-09 17:20:07 PST
|
||||||
|
|
||||||
|
On Fre, 26 Apr 2002, Petter Reinholdtsen wrote:
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
> The reson is that there are 3 hardware detection system:
|
||||||
|
> - Mandrake (libdetect, old)
|
||||||
|
|
||||||
|
truly libdetect is old and deprecated
|
||||||
|
(harddrake (was lothar) used to use it)
|
||||||
|
|
||||||
|
we (mandrake) are now mostly using ldetect & ldetect-lst
|
||||||
|
|
||||||
|
AFAIK here are the various free software hardware databases:
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
- pci ----------
|
||||||
|
|
||||||
|
- pci.ids (in pciutils)
|
||||||
|
maps vendor+device -> description
|
||||||
|
and vendor+device+subvendor+subdevice -> description
|
||||||
|
also has device classes names
|
||||||
|
|
||||||
|
- modules.pcimap (in kernel /lib/modules/2.4*/)
|
||||||
|
maps vendor+device -> module
|
||||||
|
and vendor+device+subvendor+subdevice -> module
|
||||||
|
|
||||||
|
- XFree's xf86PciInfo.h (in XFree's source: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h)
|
||||||
|
maps vendor+device -> description
|
||||||
|
|
||||||
|
- RedHat's pcitable (in hwdata)
|
||||||
|
maps vendor+device -> module+description
|
||||||
|
and a few vendor+device+subvendor+subdevice -> module+description
|
||||||
|
when needed
|
||||||
|
module can also be "Card:xxxx" for XFree (using Cards, see below)
|
||||||
|
|
||||||
|
- Mandrake's pcitable (in ldetect-lst)
|
||||||
|
same format as RedHat's (except for a few syntactical changes since mandrake kept old RedHat's format)
|
||||||
|
module can also be
|
||||||
|
"Card:xxxx" for XFree (using Cards+, see below)
|
||||||
|
"Server:xxxx" for XFree3
|
||||||
|
"ISDN:xxxx" for hisax special parameters
|
||||||
|
"Bad:xxxx" for warning about unhandled devices (mainly winmodems)
|
||||||
|
|
||||||
|
- Mandrake old detect's pci.lst (in detect-lst)
|
||||||
|
maps vendor+device -> class+module+description
|
||||||
|
|
||||||
|
- Progeny's pci.lst (in discover-data)
|
||||||
|
same format as detect
|
||||||
|
maps vendor+device -> class+module+description
|
||||||
|
module can also be
|
||||||
|
"Server:XFree86(module)" for XFree4
|
||||||
|
"Server:XF86_xxx" for XFree3
|
||||||
|
|
||||||
|
some comments:
|
||||||
|
|
||||||
|
- the "class" in pci.lst is not useful when "module" is given since
|
||||||
|
from the module name, one can have the "class"
|
||||||
|
|
||||||
|
- the subvendor+subdevice distinction is sometimes useful
|
||||||
|
(not very often though)
|
||||||
|
|
||||||
|
- hopefully one day modules.pcimap will be the reference :)
|
||||||
|
(except for XFree of course)
|
||||||
|
|
||||||
|
tools using those databases:
|
||||||
|
|
||||||
|
- kudzu and anaconda are using pcitable from hwdata
|
||||||
|
|
||||||
|
- library ldetect accesses pcitable from ldetect-lst,
|
||||||
|
this library is used by DrakX and drakxtools.
|
||||||
|
Mandrake's patched kudzu uses pcitable from ldetect-lst
|
||||||
|
|
||||||
|
- discover uses pci.ids from discover-data
|
||||||
|
|
||||||
|
- i don't know if tools are using modules.pcimap
|
||||||
|
|
||||||
|
- XFree --------------------
|
||||||
|
|
||||||
|
- XFree comes with Cards
|
||||||
|
|
||||||
|
- Redhat has its own version (in hwdata)
|
||||||
|
|
||||||
|
- Mandrake has its own version Cards+ & CardsNames (in ldetect-lst)
|
||||||
|
(mainly a merge of XF3 Cards and XF4 Cards)
|
||||||
|
|
||||||
|
- discover doesn't need it since it's precising the server name
|
||||||
|
(XF3) or the module name (XF4) (?)
|
||||||
|
this is usually enough (except if you want to propose the choice,
|
||||||
|
but who wants XF3 nowadays :)
|
||||||
|
|
||||||
|
|
||||||
|
- usb --------------------
|
||||||
|
|
||||||
|
- usbutils's usb.ids
|
||||||
|
maps vendor+device -> description
|
||||||
|
also has device classes names and some more stuff
|
||||||
|
|
||||||
|
- modules.usbmap (in kernel /lib/modules/2.4*/)
|
||||||
|
maps vendor+device -> module (?)
|
||||||
|
|
||||||
|
- Mandrake's usbtable (in ldetect-lst)
|
||||||
|
maps vendor+device -> module+description
|
||||||
|
module can also be
|
||||||
|
"Mouse:xxxx" for mouse configuration (fed to mousedrake)
|
||||||
|
"Tablet:wacom" for wacom tablet configuration
|
||||||
|
"Flag:xxxx" for DrakX package choosing
|
||||||
|
"Floppy:normal"
|
||||||
|
|
||||||
|
- Progeny's usb.lst (in discover-data)
|
||||||
|
maps vendor+device -> class+module+description
|
||||||
|
(but current's version only have module=unknown, so what's it
|
||||||
|
for, why not usb.ids?)
|
||||||
|
|
||||||
|
|
||||||
|
tools using those databases:
|
||||||
|
|
||||||
|
- library ldetect accesses usbtable from ldetect-lst
|
||||||
|
this library is used by DrakX and drakxtools
|
||||||
|
|
||||||
|
- i don't know if tools are using modules.usbmap
|
||||||
|
|
||||||
|
- scanner --------------------
|
||||||
|
|
||||||
|
- ScannerDB (in ldetect-lst)
|
||||||
|
maps name -> driver+kind(usb,scsi,serial,parallel)+options+various
|
||||||
|
(i don't know much about it, i don't know if yves made it from
|
||||||
|
scratch or what. ask yduret@mandrakesoft.com for more)
|
||||||
|
|
||||||
|
- isdn --------------------
|
||||||
|
|
||||||
|
- isdn.db (in ldetect-lst)
|
||||||
|
list of internet providers by country
|
||||||
|
-> phone number + domainname + dns1 (ip) + dns2
|
||||||
|
|
||||||
|
- old or small databases ----------
|
||||||
|
|
||||||
|
- isa.lst (detect), isatable (ldetect-lst), modules.isapnpmap (kernel)
|
||||||
|
- pcmcia.lst (detect, discover-data), pcmciatable (ldetect-lst)
|
||||||
|
- modules.parportmap (kernel but empty?)
|
||||||
|
- modules.ieee1394map (kernel but empty?)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
There may be some errors, or some missing stuff, please correct me!
|
||||||
|
|
||||||
|
I've written a tool to keep in sync with as many databases as
|
||||||
|
possible. see merge2pcitable.pl in
|
||||||
|
http://www.mandrakelinux.com/cgi-bin/cvsweb.cgi/soft/ldetect-lst/convert/
|
||||||
|
|
||||||
|
Maybe some common mailing list could be set up to deal with this?
|
||||||
|
|
||||||
|
*but* note that the database is quite kernel dependent.
|
||||||
|
- our pcitable doesn't handle this nicely
|
||||||
|
- redhat has "upgradelist" in hwdata to partly handle this
|
||||||
|
- i know we handle some pbs via /lib/modutils/macros with things like
|
||||||
|
"if `kernelversion` = 2.4", debian seems to have it in
|
||||||
|
/etc/modutils/arch
|
||||||
|
|
||||||
|
|
||||||
|
Once again, hopefully one day modules.pcimap and modules.usbmap will
|
||||||
|
be the reference! :)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
> Mandrake switched from libdetect to kudzu, afaik
|
||||||
|
> (latest mandrake (8.2) version is using kudzu for HW detection).
|
||||||
|
|
||||||
|
well, mandrake has many tools doing more or less the same thing (and
|
||||||
|
alas, not exactly always the same thing): DrakX (during install),
|
||||||
|
drakxtools (when called, after install), kudzu (at boot, usually
|
||||||
|
calling a drakxtools)
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
List of hardware probing tools to use for displayconfig:
|
||||||
|
--------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
[1] xvinfo - Print out X-Video extension adaptor information
|
||||||
|
|
||||||
|
xvinfo prints out the capabilities of any video adaptors
|
||||||
|
associated with the display
|
||||||
|
that are accesible through the X-Video extension.
|
||||||
|
|
||||||
|
[2] xresprobe - Prints out resolutions, frequency and displaytype.
|
||||||
|
Doesn't work in all cases. Works via ddc, I guess.
|
||||||
|
|
||||||
|
[3] ddcprobe - Uses VESA BIOS Extension
|
||||||
|
Detects VGA + OEM, modes (only set up modes?), vid mem (kudzu)
|
||||||
|
|
||||||
|
[3] read-edid
|
||||||
|
get-edid|parse-edid prints out a "good-looking" Monitor Section for
|
||||||
|
xorg.conf, not reliable (failed on notebook)
|
||||||
|
|
||||||
|
[4] ddcxinfo - prints out modelines, hsync and vsync (kudzu)
|
||||||
|
|
||||||
|
[5] svgamodes - prints out supported video modes (kudzu)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
Pixel
|
||||||
|
programming languages addict http://merd.net/pixel/language-study/
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------
|
@ -0,0 +1,135 @@
|
|||||||
|
* How many cards do we have? autodetection?
|
||||||
|
* Is our card a dualhead card?
|
||||||
|
* How many monitors are connected?
|
||||||
|
|
||||||
|
* difference between one and two card is different device sections
|
||||||
|
* twinview has one device, one screen, one serverlayout
|
||||||
|
* xinerama has two devices, two screens, two monitors
|
||||||
|
|
||||||
|
twinview <> xinerama:
|
||||||
|
all sections double
|
||||||
|
|
||||||
|
one or two cards:
|
||||||
|
different device sections
|
||||||
|
|
||||||
|
one or two monitors
|
||||||
|
?? one or two cards
|
||||||
|
?? twinview or xinerama (driver? different resolutions?)
|
||||||
|
|
||||||
|
|
||||||
|
class XSetup(Object):
|
||||||
|
Screens[] getScreens()
|
||||||
|
bool maySetDualhead()
|
||||||
|
getUseDualhead()
|
||||||
|
setUseDualhead(bool)
|
||||||
|
(xoff,yoff) getDualheadPosition() # offset from screen 1 top left corner.
|
||||||
|
setDualheadOrientation(xoff,yoff)
|
||||||
|
|
||||||
|
bool is3DAccelerated()
|
||||||
|
|
||||||
|
GFXCard[] getGFXCards()
|
||||||
|
|
||||||
|
|
||||||
|
class Screen(Object):
|
||||||
|
maySetResolution()
|
||||||
|
Resolution[] getAvailableResolutions()
|
||||||
|
getResolution()
|
||||||
|
setResolution(Resolution)
|
||||||
|
|
||||||
|
maySetRefresh()
|
||||||
|
int getRefreshRate()
|
||||||
|
setRefreshRate(int)
|
||||||
|
|
||||||
|
maySetRotation()
|
||||||
|
getRotation()
|
||||||
|
getAvailableRotations()
|
||||||
|
setRotation()
|
||||||
|
|
||||||
|
bool isAvailableMirrorHorizontal()
|
||||||
|
getMirrorHorizontal()
|
||||||
|
setMirrorHorizontal()
|
||||||
|
bool isAvailableMirrorVertical()
|
||||||
|
getMirrorVertical()
|
||||||
|
setMirrorVertical()
|
||||||
|
|
||||||
|
class Resolution(Object):
|
||||||
|
int getWidth()
|
||||||
|
int getHeight()
|
||||||
|
int[] getRefreshRates():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* What is the current setup? (Xinerama? Singlehead? Twinview?)
|
||||||
|
|
||||||
|
- Warning: Xinerama vs. DRI
|
||||||
|
* "unlinking" the sliders will yield a warning "Using different
|
||||||
|
resolutions on the screens will disable 3D hardware acceleration on
|
||||||
|
the second head", which is a Xinerama deficiency).
|
||||||
|
|
||||||
|
Note: Probably only Ati and nvidia do support mergedFB properly, other
|
||||||
|
drivers might lose xinerama features like placement and maximize
|
||||||
|
|
||||||
|
- Drag and drop widget
|
||||||
|
* The fun part: implementing a Drag and Drop widget where the (resizing)
|
||||||
|
screens can be dragged into their respective relative position,
|
||||||
|
"snapping" in the more obvious ones, i.e. plain "left of" and "right
|
||||||
|
of", "above" and "under" (without offset).
|
||||||
|
|
||||||
|
|
||||||
|
- displayconfig.MonitorPreview:
|
||||||
|
Singleheadpreview: Monitor keeps size
|
||||||
|
DualheadPreview: like now, monitor resizes to show relative screen size
|
||||||
|
|
||||||
|
Displayconfig; Notes abstractielaag
|
||||||
|
-------------------------------------
|
||||||
|
* een XSetup heeft N gfxcards.
|
||||||
|
* een GfxCard heeft N Monitors
|
||||||
|
* XSetup is een container voor alle objecten uit de abstractielaag.
|
||||||
|
* XSetup.addMonitor(monitor,gfxcard) waarbij gfxcard al in XSetup zit en een
|
||||||
|
referentie naar de kaart vormt waarop monitor is aangesloten.
|
||||||
|
* Een Adaptor heeft een 1:1 relatie met een monitor, en is 'onderdeel' van
|
||||||
|
een "Screen" (in de zin van Screen section uit xorg.conf)
|
||||||
|
* Controls zoals resize en de rotatie / mirroring widgets manipuleren een
|
||||||
|
Adaptor, die intern de Screen manipuleert
|
||||||
|
* Singlehead resolutie verandert via xrandr en slaat settings op via
|
||||||
|
displayconfig-restore.py
|
||||||
|
* Dualhead resolutie aanpassen pakt intern een passende metamode (bij twinview)
|
||||||
|
en checkt of alle zinvolle metamodes beschikbaar zijn, anders wordt de user
|
||||||
|
gewaarschuwd dat dit eerst moet gebeuren.
|
||||||
|
* Adaptor in dualhead / twinview modus worden dus naar een screen vertaald
|
||||||
|
metamodes heeft.
|
||||||
|
* Screen moet dan nog support voor metamodes krijgen.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
displayconfig:
|
||||||
|
===============
|
||||||
|
* Current resolution doesn't get recognized if current != highest resolution
|
||||||
|
* new tab display powermanagement, just like the existing tab, we need to be
|
||||||
|
able to at least replace existing functionality
|
||||||
|
|
||||||
|
|
||||||
|
New Widgets:
|
||||||
|
-------------
|
||||||
|
* DualheadPreview
|
||||||
|
* RadioButtons instead of dropdown for Positioning
|
||||||
|
|
||||||
|
* Detect if we're already running on dualhead, (en|dis)able widgets accordingly
|
||||||
|
* Nvidia MergedFB
|
||||||
|
- Make preview of dualhead more clear (only xinerama or also mergedFB?)
|
||||||
|
- Generate list of Metamodes from resolutions available
|
||||||
|
- write dualhead settings to xorg.conf
|
||||||
|
* Compare dualhead with different drivers WRT xorg.conf
|
||||||
|
- generic Xinerama (Matrox, others?)
|
||||||
|
- dualhead for fglrx, SiS ...
|
||||||
|
- MergedFB as special case for nvidia (sis?)
|
||||||
|
* Preview should be rotatable (and|or) resizable (and|or) DualHeadpreview?
|
||||||
|
* Add missing elements to DualHeadTab
|
||||||
|
- [ ] Use MergedFB (binds two resolution sliders)
|
||||||
|
- label with warning "You can only use DRI on one head with different resolutions blahblah"
|
||||||
|
FIXME: enabling Dualhead should:
|
||||||
|
- Update resolutions with "metamodes"
|
||||||
|
- disable Rotation/mirroring stuff
|
||||||
|
- Add ServerLayout to xorg.conf
|
||||||
|
- Add second Screen to xorg.conf
|
||||||
|
- Alternatively (if both resolutions are the same enable MergedFB
|
@ -0,0 +1,11 @@
|
|||||||
|
# Set the X server resolution to that selected by the user.
|
||||||
|
#
|
||||||
|
# This needs to be done before windows managers or X clients start,
|
||||||
|
# otherwise the DPI and fonts sizes get all screwed up.
|
||||||
|
#
|
||||||
|
# http://www.simonzone.com/software/guidance
|
||||||
|
#
|
||||||
|
# This file is sourced by Xsession(5), not executed.
|
||||||
|
# The "|| true" is to ensure that the Xsession script does not terminate
|
||||||
|
# and stop the login if something fails in the Python program.
|
||||||
|
/opt/kde3/bin/displayconfig-restore || true
|
@ -0,0 +1,340 @@
|
|||||||
|
###########################################################################
|
||||||
|
# ScanPCI.py - #
|
||||||
|
# ------------------------------ #
|
||||||
|
# copyright : (C) 2005 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
"""Provides information about the devices attached to the PCI bus.
|
||||||
|
"""
|
||||||
|
import struct
|
||||||
|
import csv
|
||||||
|
import os.path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
class PCIDevice(object):
|
||||||
|
def __init__(self,line=None):
|
||||||
|
self.vendor = None # PCI vendor id
|
||||||
|
self.device = None
|
||||||
|
|
||||||
|
self.subvendor = None # 0xffff if not probe_type'd or no subid
|
||||||
|
self.subdevice = None # 0xffff if not probe_type'd or no subid
|
||||||
|
self.pci_class = None # 'None' if not probe_type'd
|
||||||
|
|
||||||
|
self.pci_bus = None # pci bus id 8 bits wide
|
||||||
|
self.pci_device = None # pci device id 5 bits wide
|
||||||
|
self.pci_function = None# pci function id 3 bits wide
|
||||||
|
|
||||||
|
self.module = None
|
||||||
|
self.text = None
|
||||||
|
self.already_found = False
|
||||||
|
|
||||||
|
if line is not None:
|
||||||
|
self.loadFromString(line)
|
||||||
|
|
||||||
|
def isGfxCard(self):
|
||||||
|
if self.module is not None and \
|
||||||
|
(self.module.startswith("Card:") or self.module.startswith("Server:XFree86(")):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return (self.pci_class & PCIBus.PCI_BASE_CLASS_MASK)==PCIBus.PCI_BASE_CLASS_DISPLAY
|
||||||
|
|
||||||
|
def getModule(self):
|
||||||
|
if self.module is not None:
|
||||||
|
if self.module.startswith("Server:XFree86("):
|
||||||
|
return self.module[15:-1]
|
||||||
|
elif self.module.startswith("Card:"):
|
||||||
|
return self.module[5:]
|
||||||
|
return self.module
|
||||||
|
|
||||||
|
def isModuleXorgDriver(self):
|
||||||
|
return self.module is not None and \
|
||||||
|
(self.module.startswith("Server:XFree86(") or self.module.startswith("Card:"))
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
s = "PCI:%i:%i:%i, " % (self.pci_bus,self.pci_device,self.pci_function)
|
||||||
|
s += "Vendor:%x, Device:%x," % (self.vendor,self.device)
|
||||||
|
if self.subvendor is not None:
|
||||||
|
s += " Subvendor:%x," % self.subvendor
|
||||||
|
if self.subdevice is not None:
|
||||||
|
s += " Subdevice:%x," % self.subdevice
|
||||||
|
if self.pci_class is not None:
|
||||||
|
s += " Class:%x," % self.pci_class
|
||||||
|
if self.module is not None:
|
||||||
|
s += " Module:%s," % self.module
|
||||||
|
if self.text is not None:
|
||||||
|
s += " Text:%s" % self.text
|
||||||
|
return s
|
||||||
|
|
||||||
|
def loadFromString(self,line):
|
||||||
|
parts = line.split(",")
|
||||||
|
for i in range(len(parts)):
|
||||||
|
bit = parts[i].strip()
|
||||||
|
if bit.startswith("PCI:"):
|
||||||
|
pci_code = bit[4:].split(":")
|
||||||
|
self.pci_bus = int(pci_code[0])
|
||||||
|
self.pci_device = int(pci_code[1])
|
||||||
|
self.pci_function = int(pci_code[2])
|
||||||
|
elif bit.startswith("Vendor:"):
|
||||||
|
self.vendor = int(bit[7:],16)
|
||||||
|
elif bit.startswith("Device:"):
|
||||||
|
self.device = int(bit[7:],16)
|
||||||
|
elif bit.startswith("Subvendor:"):
|
||||||
|
self.subvendor = int(bit[10:],16)
|
||||||
|
elif bit.startswith("Subdevice:"):
|
||||||
|
self.subdevice = int(bit[10:],16)
|
||||||
|
elif bit.startswith("Class:"):
|
||||||
|
self.pci_class = int(bit[6:],16)
|
||||||
|
elif bit.startswith("Module:"):
|
||||||
|
self.module = bit[7:]
|
||||||
|
elif bit.startswith("Text:"):
|
||||||
|
self.text = " ".join(parts[i:]).strip()[5:]
|
||||||
|
break
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class PCIBus(object):
|
||||||
|
PCI_CLASS_SERIAL_USB = 0x0c03
|
||||||
|
PCI_CLASS_SERIAL_FIREWIRE = 0x0c00
|
||||||
|
PCI_BASE_CLASS_MASK = 0xff00
|
||||||
|
PCI_BASE_CLASS_DISPLAY = 0x0300
|
||||||
|
|
||||||
|
def __init__(self, data_file_dir="."):
|
||||||
|
self.devices = []
|
||||||
|
self.data_file_dir = data_file_dir
|
||||||
|
|
||||||
|
def detect(self,device_data="/proc/bus/pci/devices"):
|
||||||
|
# Shamelessly translated from ldetect's pci.c.
|
||||||
|
fhandle = open(device_data)
|
||||||
|
for line in fhandle.readlines():
|
||||||
|
#print "L:",line
|
||||||
|
entry = PCIDevice()
|
||||||
|
self.devices.append(entry)
|
||||||
|
parts = line.split()
|
||||||
|
|
||||||
|
devbusfn = int(parts[0],16)
|
||||||
|
idbits = int(parts[1],16)
|
||||||
|
entry.vendor = idbits >> 16
|
||||||
|
entry.device = idbits & 0xffff
|
||||||
|
entry.pci_bus = devbusfn >> 8
|
||||||
|
entry.pci_device = (devbusfn & 0xff) >> 3
|
||||||
|
entry.pci_function = (devbusfn & 0xff) & 0x07
|
||||||
|
|
||||||
|
try:
|
||||||
|
infohandle = open("/proc/bus/pci/%02x/%02x.%d" % (
|
||||||
|
entry.pci_bus, entry.pci_device, entry.pci_function),"r")
|
||||||
|
# these files are 256 bytes but we only need first 48 bytes
|
||||||
|
buf = infohandle.read(48)
|
||||||
|
(class_prog, entry.pci_class, entry.subvendor, entry.subdevice) = \
|
||||||
|
struct.unpack("<xxxxxxxxxBHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHH",buf)
|
||||||
|
#print "STRUCT: ",struct.unpack("@xxxxxxxxxBHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHH",buf)
|
||||||
|
if (entry.subvendor==0 and entry.subdevice==0) or \
|
||||||
|
(entry.subvendor==entry.vendor and entry.subdevice==entry.device):
|
||||||
|
entry.subvendor = 0xffff
|
||||||
|
entry.subdevice = 0xffff
|
||||||
|
if entry.pci_class == PCIBus.PCI_CLASS_SERIAL_USB:
|
||||||
|
# taken from kudzu's pci.c
|
||||||
|
if class_prog == 0:
|
||||||
|
entry.module = "usb-uhci"
|
||||||
|
elif class_prog == 0x10:
|
||||||
|
entry.module = "usb-ohci"
|
||||||
|
elif class_prog == 0x20:
|
||||||
|
entry.module = "ehci-hcd"
|
||||||
|
if entry.pci_class == PCIBus.PCI_CLASS_SERIAL_FIREWIRE:
|
||||||
|
# taken from kudzu's pci.c
|
||||||
|
if class_prog == 0x10:
|
||||||
|
entry.module = "ohci1394"
|
||||||
|
infohandle.close()
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
#if False or os.path.exists("/usr/share/ldetect-lst/pcitable"):
|
||||||
|
#self._resolveDevicesWithLdetect()
|
||||||
|
#else:
|
||||||
|
self._resolveDevicesWithHwdata()
|
||||||
|
#self._resolveDevicesWithDiscover()
|
||||||
|
|
||||||
|
def _resolveDevicesWithLdetect(self):
|
||||||
|
# Scan the PCI database.
|
||||||
|
#fhandle = open(os.path.join(self.data_file_dir,"pcitable"),"r")
|
||||||
|
fhandle = open(os.path.join("/opt/kde3/share/apps/guidance/","pcitable"),"r")
|
||||||
|
|
||||||
|
# This class is just for skipping comment lines in the database file.
|
||||||
|
# This whole class is just an iterator wrapper that we put around our file iterator.
|
||||||
|
class commentskipperiterator(object):
|
||||||
|
def __init__(self,fhandle):
|
||||||
|
self.fhandle = iter(fhandle)
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
def next(self):
|
||||||
|
line = self.fhandle.next()
|
||||||
|
while line[0]=="#":
|
||||||
|
line = self.fhandle.next()
|
||||||
|
return line
|
||||||
|
|
||||||
|
unknowndevices = self.devices[:]
|
||||||
|
|
||||||
|
# Process each row of the DB.
|
||||||
|
for row in csv.reader(commentskipperiterator(fhandle),delimiter='\t'):
|
||||||
|
if len(row)==4:
|
||||||
|
(vendor,device,module,text) = row
|
||||||
|
elif len(row)==6:
|
||||||
|
(vendor, device, subvendor, subdevice, module, text) = row
|
||||||
|
subvendor = int(subvendor[2:],16)
|
||||||
|
subdevice = int(subdevice[2:],16)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
vendor = int(vendor[2:],16) # parse hex numbers of the form 0x1abc
|
||||||
|
device = int(device[2:],16)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while i<len(unknowndevices):
|
||||||
|
pcidevice = unknowndevices[i]
|
||||||
|
if pcidevice.vendor==vendor and pcidevice.device==device \
|
||||||
|
and (len(row)==4 \
|
||||||
|
or (pcidevice.subvendor==subvendor and pcidevice.subdevice==subdevice)):
|
||||||
|
if module!="unknown":
|
||||||
|
pcidevice.module = module
|
||||||
|
pcidevice.text = text
|
||||||
|
if len(row)==6: # Close match, also matched on subdevice/subvendor ids.
|
||||||
|
del unknowndevices[i]
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
def _resolveDevicesWithDiscover(self):
|
||||||
|
|
||||||
|
unknown_devices = self.devices[:]
|
||||||
|
self._resolveDevicesWithDiscoverFile("/usr/share/discover/pci-26.lst",unknown_devices)
|
||||||
|
self._resolveDevicesWithDiscoverFile("/usr/share/discover/pci.lst",unknown_devices)
|
||||||
|
|
||||||
|
def _resolveDevicesWithDiscoverFile(self,filename,unknown_devices):
|
||||||
|
# Scan the PCI database.
|
||||||
|
fhandle = open(filename,"r")
|
||||||
|
|
||||||
|
# Process each row of the DB.
|
||||||
|
for line in fhandle:
|
||||||
|
row = line.replace("\t"," ").split(" ")
|
||||||
|
if len(row) >= 1 and row[0] != '':
|
||||||
|
# Skip manufacturer info lines.
|
||||||
|
continue
|
||||||
|
|
||||||
|
vendor = int(row[1][:4],16)
|
||||||
|
device = int(row[1][4:],16)
|
||||||
|
module = row[3]
|
||||||
|
text = ' '.join(row[4:]).strip()
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while i<len(unknown_devices):
|
||||||
|
pcidevice = unknown_devices[i]
|
||||||
|
if pcidevice.vendor==vendor and pcidevice.device==device:
|
||||||
|
pcidevice.module = module
|
||||||
|
pcidevice.text = text
|
||||||
|
del unknown_devices[i]
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
def _resolveDevicesWithHwdata(self):
|
||||||
|
# Scan the PCI database.
|
||||||
|
fhandle = open("/usr/share/hwdata/pci.ids","r")
|
||||||
|
|
||||||
|
# This class is just for skipping comment lines in the database file.
|
||||||
|
# This whole class is just an iterator wrapper that we put around our file iterator.
|
||||||
|
class commentskipperiterator(object):
|
||||||
|
def __init__(self,fhandle):
|
||||||
|
self.fhandle = iter(fhandle)
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
def next(self):
|
||||||
|
line = self.fhandle.next()
|
||||||
|
while line[0]=="#":
|
||||||
|
line = self.fhandle.next()
|
||||||
|
return line
|
||||||
|
|
||||||
|
unknowndevices = self.devices[:]
|
||||||
|
|
||||||
|
# Process each row of the DB.
|
||||||
|
for row in fhandle:
|
||||||
|
stripped_row = row.strip()
|
||||||
|
|
||||||
|
if stripped_row=='' or stripped_row[0]=='#':
|
||||||
|
continue # Comment or blank line, skip it.
|
||||||
|
|
||||||
|
if stripped_row[0]=='C':
|
||||||
|
# Reached the device class data, stop.
|
||||||
|
break
|
||||||
|
|
||||||
|
if row[0]!='\t':
|
||||||
|
# Vendor line
|
||||||
|
vendor_parts = stripped_row.split(' ')
|
||||||
|
vendor = int(vendor_parts[0],16)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if row[1]!='\t':
|
||||||
|
# Device line
|
||||||
|
device_parts = stripped_row.split(' ')
|
||||||
|
device = int(device_parts[0],16)
|
||||||
|
subvendor = None
|
||||||
|
subdevice = None
|
||||||
|
else:
|
||||||
|
# Subvendor line
|
||||||
|
subvendor_parts = stripped_row.split(' ')
|
||||||
|
subvendor = int(subvendor_parts[0],16)
|
||||||
|
subdevice = int(subvendor_parts[1],16)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while i<len(unknowndevices):
|
||||||
|
pcidevice = unknowndevices[i]
|
||||||
|
if pcidevice.vendor==vendor and pcidevice.device==device \
|
||||||
|
and (subvendor is None \
|
||||||
|
or (pcidevice.subvendor==subvendor and pcidevice.subdevice==subdevice)):
|
||||||
|
#pcidevice.module = module
|
||||||
|
if subvendor is None:
|
||||||
|
pcidevice.text = ' '.join(vendor_parts[1:]) + '|' + ' '.join(device_parts[1:]).strip()
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
pcidevice.text = ' '.join(vendor_parts[1:]) + '|' + ' '.join(device_parts[1:]+subvendor_parts[2:]).strip()
|
||||||
|
del unknowndevices[i] # Perfect match, finished with this device.
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "\n".join([str(x) for x in self.devices])
|
||||||
|
|
||||||
|
def loadFromFile(self,filename):
|
||||||
|
fhandle = open(filename,'r')
|
||||||
|
for line in fhandle.readlines():
|
||||||
|
if line.strip()!="":
|
||||||
|
entry = PCIDevice(line=line)
|
||||||
|
self.devices.append(entry)
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def main():
|
||||||
|
bus = PCIBus("ldetect-lst/")
|
||||||
|
if len(sys.argv)>1:
|
||||||
|
if sys.argv[1]=="--help" or sys.argv[1]=="-h":
|
||||||
|
print "Usage:\n ScanPCI.py <pci device file name>"
|
||||||
|
sys.exit(0)
|
||||||
|
bus.detect(sys.argv[1])
|
||||||
|
else:
|
||||||
|
bus.detect()
|
||||||
|
print bus
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
main()
|
@ -0,0 +1,132 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# displayconfig-hwprobe.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Sun Jan 22 2006 #
|
||||||
|
# copyright : (C) 2006 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
# This program should be run during boot time. It quickly examines the
|
||||||
|
# graphics cards (read: PCI devices) in the computer and compares they to
|
||||||
|
# the list in the file $hardware_info_filename. If the two lists differ
|
||||||
|
# then the Debian package manager is automatically called to regenerate
|
||||||
|
# /etc/X11/xorg.conf. This hopefully should mean that people can swap gfx
|
||||||
|
# cards in and out and always have a system that will run Xorg. (even
|
||||||
|
# though the config will be most likely be suboptimal. Suboptimal is better
|
||||||
|
# than no X server).
|
||||||
|
|
||||||
|
import ScanPCI
|
||||||
|
import os
|
||||||
|
import syslog
|
||||||
|
import select
|
||||||
|
|
||||||
|
hardware_info_filename = "/var/lib/guidance/guidance-gfxhardware-snapshot"
|
||||||
|
data_file_dir = "/usr/share/apps/guidance/"
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Scan the PCI bus.
|
||||||
|
pci_bus = ScanPCI.PCIBus(data_file_dir)
|
||||||
|
pci_bus.detect()
|
||||||
|
|
||||||
|
# Stuff our device info in to a string.
|
||||||
|
hardware_config = ""
|
||||||
|
for pci_device in pci_bus.devices:
|
||||||
|
if pci_device.isGfxCard():
|
||||||
|
hardware_config += "PCI:%i:%i:%i Vendor:%x Device:%x Subvendor:%x Subdevice:%x\n" % \
|
||||||
|
(pci_device.pci_bus, pci_device.pci_device, pci_device.pci_function,
|
||||||
|
pci_device.vendor, pci_device.device,
|
||||||
|
pci_device.subvendor, pci_device.subdevice)
|
||||||
|
|
||||||
|
# Read in the old gfx hardware info in.
|
||||||
|
previous_hardware = None
|
||||||
|
try:
|
||||||
|
fhandle = open(hardware_info_filename)
|
||||||
|
previous_hardware = fhandle.read()
|
||||||
|
fhandle.close()
|
||||||
|
except IOError:
|
||||||
|
previous_hardware = None
|
||||||
|
|
||||||
|
if previous_hardware is not None and previous_hardware!=hardware_config:
|
||||||
|
# Run dpkg and configure the new hardware.
|
||||||
|
syslog.syslog(syslog.LOG_INFO, "Graphics card hardware has changed. Reconfiguring xorg.conf using 'dpkg-reconfigure xserver-xorg'.")
|
||||||
|
cmd = ['dpkg-reconfigure','xserver-xorg']
|
||||||
|
environ = os.environ.copy()
|
||||||
|
environ['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||||
|
#os.spawnvpe(os.P_WAIT, 'dpkg-reconfigure', cmd, environ)
|
||||||
|
result = ExecWithCapture('/usr/sbin/dpkg-reconfigure', cmd, 0, '/', 0,1, -1, environ)
|
||||||
|
for line in result.split('\n'):
|
||||||
|
syslog.syslog(syslog.LOG_INFO,"dpkg-reconfigure:"+line)
|
||||||
|
|
||||||
|
# [21:18] <Riddell> you are brave indeed
|
||||||
|
# [21:21] <Sime> I figured some kind of non-interactive "dpkg-reconfigure xorg" might be enough.
|
||||||
|
# [21:22] <Riddell> yep
|
||||||
|
|
||||||
|
if previous_hardware is None or previous_hardware!=hardware_config:
|
||||||
|
syslog.syslog(syslog.LOG_INFO, "Writing graphics card hardware list to "+hardware_info_filename)
|
||||||
|
# Write out the gfx hardware info
|
||||||
|
tmp_filename = hardware_info_filename + ".tmp"
|
||||||
|
fhandle = open(tmp_filename,'w')
|
||||||
|
fhandle.write(hardware_config)
|
||||||
|
fhandle.close()
|
||||||
|
os.rename(tmp_filename, hardware_info_filename)
|
||||||
|
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def ExecWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0,
|
||||||
|
catchfd = 1, closefd = -1, environ = None):
|
||||||
|
|
||||||
|
if not os.access(root + command, os.X_OK) and not searchPath:
|
||||||
|
raise RuntimeError, command + " can not be run"
|
||||||
|
|
||||||
|
(read, write) = os.pipe()
|
||||||
|
childpid = os.fork()
|
||||||
|
if (not childpid):
|
||||||
|
if (root and root != '/'): os.chroot(root)
|
||||||
|
os.dup2(write, catchfd)
|
||||||
|
os.close(write)
|
||||||
|
os.close(read)
|
||||||
|
|
||||||
|
if closefd != -1:
|
||||||
|
os.close(closefd)
|
||||||
|
if stdin:
|
||||||
|
os.dup2(stdin, 0)
|
||||||
|
os.close(stdin)
|
||||||
|
|
||||||
|
# Replace the environment
|
||||||
|
if environ is not None:
|
||||||
|
os.environ.clear()
|
||||||
|
os.environ.update(environ)
|
||||||
|
|
||||||
|
if searchPath:
|
||||||
|
os.execvp(command, argv)
|
||||||
|
else:
|
||||||
|
os.execv(command, argv)
|
||||||
|
sys.exit(1)
|
||||||
|
os.close(write)
|
||||||
|
|
||||||
|
rc = ""
|
||||||
|
s = "1"
|
||||||
|
while s:
|
||||||
|
select.select([read], [], [])
|
||||||
|
s = os.read(read, 1000)
|
||||||
|
rc = rc + s
|
||||||
|
|
||||||
|
os.close(read)
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.waitpid(childpid, 0)
|
||||||
|
except OSError, (errno, msg):
|
||||||
|
print __name__, "waitpid:", msg
|
||||||
|
|
||||||
|
return rc
|
||||||
|
|
||||||
|
main()
|
@ -0,0 +1,324 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# displayconfig-restore.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Wed Dec 15 2004 #
|
||||||
|
# copyright : (C) 2004-2006 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import subprocess
|
||||||
|
import ixf86misc
|
||||||
|
import xf86misc
|
||||||
|
|
||||||
|
from execwithcapture import *
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def FindXorgConfig(self):
|
||||||
|
# Lookup location of X configfile
|
||||||
|
for line in ExecWithCapture("xset", ["xset","q"],True).split('\n'):
|
||||||
|
if line.strip().startswith("Config file"):
|
||||||
|
return line.split(":")[1].strip()
|
||||||
|
# Sometimes, xset doesn't know about the configfile location, hence ...
|
||||||
|
if os.path.isfile("/etc/X11/xorg.conf"):
|
||||||
|
return "/etc/X11/xorg.conf"
|
||||||
|
return None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
# FixXorgDPI
|
||||||
|
# ==========
|
||||||
|
# The idea here is to ensure that applications use a sensible DPI setting
|
||||||
|
# for fonts. When Xorg starts up it tries to detect the size of the attached
|
||||||
|
# monitor and calculate the real DPI from there and use that. Problems are:
|
||||||
|
#
|
||||||
|
# * if the monitor size can not be detect then Xorg uses 75dpi. This is
|
||||||
|
# usually far too low.
|
||||||
|
#
|
||||||
|
# * if the monitor size is not accurately detected then you get bad a DPI.
|
||||||
|
#
|
||||||
|
# * most fonts are optimised to work at a handful of standard DPIs. 96dpi,
|
||||||
|
# 120dpi and printer resolution 300dpi and 600dpi. Fonts rendered in
|
||||||
|
# non-standard DPIs often look bad and jagged. This is a real problem
|
||||||
|
# when rendering fonts on low resolution devices. (i.e. a computer
|
||||||
|
# monitor).
|
||||||
|
#
|
||||||
|
# Although it is desirable in theory to use the real DPI of the monitor, in
|
||||||
|
# practice it is more important to ensure that fonts are well rendered even
|
||||||
|
# if the DPI in use is not correct.
|
||||||
|
#
|
||||||
|
# What this function does is read the display size from the X server and
|
||||||
|
# if it is lower than 140dpi then 'round' it to either 96dpi or 120dpi.
|
||||||
|
# (A dpi greater or equal to 140 is assumed to be high enough to render fonts
|
||||||
|
# well.) The new dpi is then loaded with the xrdb command into the X server
|
||||||
|
# resource database. Most X applications (Qt and GTK apps at least) will then
|
||||||
|
# use this DPI for font rendering.
|
||||||
|
#
|
||||||
|
def FixXorgDPI(desiredDPI):
|
||||||
|
# dpi is:
|
||||||
|
# None - round the DPI.
|
||||||
|
# xserver - Use the X server's DPI.
|
||||||
|
# <number> - DPI to use.
|
||||||
|
if desiredDPI=="xserver":
|
||||||
|
return
|
||||||
|
|
||||||
|
dpi = 96
|
||||||
|
try:
|
||||||
|
if desiredDPI is not None:
|
||||||
|
dpi = int(desiredDPI)
|
||||||
|
except ValueError:
|
||||||
|
desiredDPI = None
|
||||||
|
|
||||||
|
if desiredDPI is None:
|
||||||
|
xserver = xf86misc.XF86Server()
|
||||||
|
if len(xserver.getScreens())!=0:
|
||||||
|
(width,height,width_mm,height_mm) = xserver.getScreens()[0].getDimensions()
|
||||||
|
if not float(width_mm) == 0:
|
||||||
|
w_dpi = float(width)/(float(width_mm)/25.4)
|
||||||
|
else:
|
||||||
|
w_dpi = 96
|
||||||
|
if not float(height_mm) == 0:
|
||||||
|
h_dpi = float(height)/(float(height_mm)/25.4)
|
||||||
|
else:
|
||||||
|
h_dpi = 96
|
||||||
|
dpi = (w_dpi+h_dpi)/2.0 # Average the two possible DPIs.
|
||||||
|
|
||||||
|
if dpi >= 140: # Anything above 140 is ok.
|
||||||
|
dpi = int(dpi)
|
||||||
|
else:
|
||||||
|
if abs(96-dpi) < abs(120-dpi): # Rounding to 96 is best.
|
||||||
|
dpi = 96
|
||||||
|
else:
|
||||||
|
dpi = 120
|
||||||
|
|
||||||
|
# work around for LP beastie 151311
|
||||||
|
if ((w_dpi < 200) and (h_dpi > 900)):
|
||||||
|
dpi = 96
|
||||||
|
|
||||||
|
try:
|
||||||
|
xrdb = subprocess.Popen(["xrdb","-nocpp","-merge"],stdin=subprocess.PIPE)
|
||||||
|
xrdb.communicate("Xft.dpi: %i\n" % dpi)
|
||||||
|
xrdb.wait()
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Other common, but now used settingsfor xrdb:
|
||||||
|
# Xft.antialias:
|
||||||
|
# Xft.hinting:
|
||||||
|
# Xft.hintstyle:
|
||||||
|
# Xft.rgba:
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def ReadDisplayConfigRC():
|
||||||
|
screens = None
|
||||||
|
dpi = None
|
||||||
|
dpms_seconds = None
|
||||||
|
dpms_enabled = None
|
||||||
|
|
||||||
|
configpath = ExecWithCapture("kde-config",['kde-config','--path','config'],True)
|
||||||
|
|
||||||
|
# Hunt down the user's displayconfigrc file and adjust the resolution
|
||||||
|
# on the fly to match. (Non-root Users can independantly specify their own settings.)
|
||||||
|
dirs = configpath.strip().split(":")
|
||||||
|
for dir in dirs:
|
||||||
|
if dir!="":
|
||||||
|
configpath = os.path.join(dir,"displayconfigrc")
|
||||||
|
if os.path.exists(configpath):
|
||||||
|
# Parse the config file.
|
||||||
|
fhandle = open(configpath)
|
||||||
|
screens = []
|
||||||
|
currentscreen = None
|
||||||
|
for line in fhandle.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
if line.startswith("[Screen"):
|
||||||
|
# Screen, width, height, refresh, reflectx, reflecty, rotate, redgamma, greengamma,bluegamma
|
||||||
|
currentscreen = [int(line[7:-1]), None, None, None, False, False, "0", None, None, None]
|
||||||
|
screens.append(currentscreen)
|
||||||
|
elif line.startswith("["):
|
||||||
|
currentscreen = None
|
||||||
|
elif line.startswith("dpi="):
|
||||||
|
dpi = line[4:]
|
||||||
|
elif currentscreen is not None:
|
||||||
|
if line.startswith("width="):
|
||||||
|
currentscreen[1] = int(line[6:])
|
||||||
|
elif line.startswith("height="):
|
||||||
|
currentscreen[2] = int(line[7:])
|
||||||
|
elif line.startswith("refresh="):
|
||||||
|
currentscreen[3] = int(line[8:])
|
||||||
|
elif line.startswith("reflectX="):
|
||||||
|
currentscreen[4] = line[9:]=="1"
|
||||||
|
elif line.startswith("reflectY="):
|
||||||
|
currentscreen[5] = line[9:]=="1"
|
||||||
|
elif line.startswith("rotate="):
|
||||||
|
currentscreen[6] = line[7:]
|
||||||
|
elif line.startswith("redgamma="):
|
||||||
|
currentscreen[7] = line[9:]
|
||||||
|
elif line.startswith("greengamma="):
|
||||||
|
currentscreen[8] = line[11:]
|
||||||
|
elif line.startswith("bluegamma="):
|
||||||
|
currentscreen[9] = line[10:]
|
||||||
|
elif line.startswith("dpmsEnabled"):
|
||||||
|
dpms_enabled = line.split("=")[1]
|
||||||
|
elif line.startswith("dpmsSeconds"):
|
||||||
|
dpms_seconds = int(line.split("=")[1])
|
||||||
|
fhandle.close()
|
||||||
|
break
|
||||||
|
|
||||||
|
return (screens,dpi,dpms_enabled,dpms_seconds)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def main():
|
||||||
|
(screens,dpi,dpms_enabled,dpms_seconds) = ReadDisplayConfigRC()
|
||||||
|
|
||||||
|
if dpms_enabled:
|
||||||
|
if dpms_enabled == "on":
|
||||||
|
if not dpms_seconds:
|
||||||
|
dpms_seconds = 900
|
||||||
|
cmd = "xset dpms %i %i %i" % (dpms_seconds,dpms_seconds,dpms_seconds)
|
||||||
|
os.system(cmd)
|
||||||
|
else:
|
||||||
|
cmd = "xset -dpms"
|
||||||
|
os.system(cmd)
|
||||||
|
|
||||||
|
if screens is not None:
|
||||||
|
# Set the X server.
|
||||||
|
try:
|
||||||
|
xserver = xf86misc.XF86Server()
|
||||||
|
if len(screens)!=0:
|
||||||
|
|
||||||
|
for screen in screens:
|
||||||
|
(id,width,height,refresh,reflectx,reflecty,rotate,redgamma,greengamma,bluegamma) = screen
|
||||||
|
|
||||||
|
# Convert the stuff into RandR's rotation bitfield thingy.
|
||||||
|
if rotate=="0":
|
||||||
|
rotation = xf86misc.XF86Screen.RR_Rotate_0
|
||||||
|
elif rotate=="90":
|
||||||
|
rotation = xf86misc.XF86Screen.RR_Rotate_90
|
||||||
|
elif rotate=="180":
|
||||||
|
rotation = xf86misc.XF86Screen.RR_Rotate_180
|
||||||
|
elif rotate=="270":
|
||||||
|
rotation = xf86misc.XF86Screen.RR_Rotate_270
|
||||||
|
if reflectx:
|
||||||
|
rotation |= xf86misc.XF86Screen.RR_Reflect_X
|
||||||
|
if reflecty:
|
||||||
|
rotation |= xf86misc.XF86Screen.RR_Reflect_Y
|
||||||
|
|
||||||
|
if id<len(xserver.getScreens()):
|
||||||
|
xscreen = xserver.getScreens()[id]
|
||||||
|
|
||||||
|
if xscreen.resolutionSupportAvailable():
|
||||||
|
available_sizes = xscreen.getAvailableSizes()
|
||||||
|
|
||||||
|
# Find the closest matching resolution
|
||||||
|
best_score = 1000000
|
||||||
|
best_size_id = 0
|
||||||
|
for size_id in range(len(available_sizes)):
|
||||||
|
size = available_sizes[size_id]
|
||||||
|
score = abs(size[0]-width)+abs(size[1]-height)
|
||||||
|
if score < best_score:
|
||||||
|
best_size_id = size_id
|
||||||
|
best_score = score
|
||||||
|
|
||||||
|
# Now find the best refresh for this resolution
|
||||||
|
best_score = 1000000
|
||||||
|
best_refresh = 50
|
||||||
|
for available_refresh in xscreen.getAvailableRefreshRates(best_size_id):
|
||||||
|
score = abs(refresh-available_refresh)
|
||||||
|
if score < best_score:
|
||||||
|
best_refresh = available_refresh
|
||||||
|
best_score = score
|
||||||
|
|
||||||
|
# Mask out any unsupported rotations.
|
||||||
|
rotation &= xscreen.getAvailableRotations()
|
||||||
|
xscreen.setScreenConfigAndRate(best_size_id, rotation, best_refresh)
|
||||||
|
|
||||||
|
# Restore the gamma settings.
|
||||||
|
if redgamma is not None and greengamma is not None and bluegamma is not None:
|
||||||
|
try:
|
||||||
|
xscreen.setGamma( (float(redgamma), float(greengamma), float(bluegamma)) )
|
||||||
|
except ValueError,e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
FixXorgDPI(dpi)
|
||||||
|
except xf86misc.XF86Error,err:
|
||||||
|
print err
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Ensure that the xorgs virtual screen size matches the default resolution
|
||||||
|
# of the server. Why does this matter? When Xorg starts up it reads its
|
||||||
|
# config file chooses the first mode in the "modes" line of the active
|
||||||
|
# Screen section and uses it as the virtual screen size and as the
|
||||||
|
# screen resolution (ie 1024x768 resolution screen showing a 1024x768 gfx
|
||||||
|
# buffer). But, this means that you can't use RandR to get to any higher
|
||||||
|
# screen resolutions (ie 1280x1024) because Xorg requires that the virtual
|
||||||
|
# screen size 'cover' the screen resolution being displayed.
|
||||||
|
#
|
||||||
|
# So, to get around this problem and make it possible for people to select
|
||||||
|
# a lower resolution screen *and* still have the option later to use
|
||||||
|
# RandR/displayconfig to switch to higher resolution, displayconfig
|
||||||
|
# explicitly sets the virtual screen size in xorg.conf to the largest
|
||||||
|
# resoluution that the monitor/gfx card can support. The down side to
|
||||||
|
# this is that the X server and kdm get the correct resolution but the
|
||||||
|
# wrong (virtual) screen size. The user can now scroll around on the
|
||||||
|
# greater virtual screen. Kind of annoying for kdm, unacceptable once
|
||||||
|
# the user has logged in.
|
||||||
|
#
|
||||||
|
# What we do now as the user's KDE session is being started up is check
|
||||||
|
# what the real virtual screen size is meant to be (=same as the real
|
||||||
|
# resolution being used) and then use the RandR extension to explicitly
|
||||||
|
# set the correct resolution. This has the effect of changing the virtual
|
||||||
|
# screeen size to what we really want. (RandR can change the virtual
|
||||||
|
# screen size, thankfully)
|
||||||
|
import displayconfigabstraction
|
||||||
|
|
||||||
|
try:
|
||||||
|
xserver = xf86misc.XF86Server()
|
||||||
|
|
||||||
|
for xscreen in xserver.getScreens():
|
||||||
|
if xscreen.resolutionSupportAvailable():
|
||||||
|
mode_line = ixf86misc.XF86VidModeGetModeLine(xserver.getDisplay(),xscreen.getScreenId())
|
||||||
|
|
||||||
|
hdisplay = mode_line[1]
|
||||||
|
vdisplay = mode_line[5]
|
||||||
|
|
||||||
|
live_refresh_rate = xscreen.getRefreshRate()
|
||||||
|
try:
|
||||||
|
(live_width,live_height,x,x) = xscreen.getAvailableSizes()[xscreen.getSizeID()]
|
||||||
|
except IndexError, errmsg:
|
||||||
|
print "IndexError:", errmsg, "in displayconfig-restore getting live screen size - trying screen 0."
|
||||||
|
(live_width,live_height,x,x) = xscreen.getAvailableSizes()[0]
|
||||||
|
|
||||||
|
if (hdisplay,vdisplay) != (live_width,live_height):
|
||||||
|
# The screen resolution doesn't match the virtual screen size.
|
||||||
|
screen_sizes = xscreen.getAvailableSizes()
|
||||||
|
for size_id in range(len(screen_sizes)):
|
||||||
|
screen_size = screen_sizes[size_id]
|
||||||
|
if screen_size[0]==hdisplay and screen_size[1]==vdisplay:
|
||||||
|
|
||||||
|
# Find the closest matching refresh rate.
|
||||||
|
best_refresh = 0
|
||||||
|
best_score = 1000000
|
||||||
|
for rate in xscreen.getAvailableRefreshRates(size_id):
|
||||||
|
score = abs(rate-live_refresh_rate)
|
||||||
|
if score < best_score:
|
||||||
|
best_refresh = rate
|
||||||
|
best_score = score
|
||||||
|
|
||||||
|
# Reset the screen mode and virtual screen size.
|
||||||
|
xscreen.setScreenConfigAndRate(size_id,xscreen.getRotation(),best_refresh)
|
||||||
|
break
|
||||||
|
FixXorgDPI(dpi)
|
||||||
|
except (xf86misc.XF86Error,TypeError),err:
|
||||||
|
print err
|
||||||
|
|
||||||
|
main()
|
@ -0,0 +1,49 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Monitor & Display
|
||||||
|
Name[el]=Οθόνη & εμφάνιση
|
||||||
|
Name[es]=Monitor y pantalla
|
||||||
|
Name[et]=Monitor ja kuva
|
||||||
|
Name[it]=Schermo
|
||||||
|
Name[ja]=モニタとディスプレイ
|
||||||
|
Name[nl]=Monitor en beeldscherm
|
||||||
|
Name[pt]=Monitor & Ecrã
|
||||||
|
Name[pt_BR]=Monitor & Visualização
|
||||||
|
Name[sr]=Монитор и приказ
|
||||||
|
Name[sr@Latn]=Monitor i prikaz
|
||||||
|
Name[sv]=Bildskärm och skärm
|
||||||
|
Name[xx]=xxMonitor & Displayxx
|
||||||
|
Comment=Display and Monitor Configuration
|
||||||
|
Comment[el]=Ρυθμίσεις εμφάνισης και οθόνης
|
||||||
|
Comment[es]=Configuración de la pantalla y el monitor
|
||||||
|
Comment[et]=Monitori ja kuva seadistamine
|
||||||
|
Comment[it]=Configurazione dello schermo
|
||||||
|
Comment[ja]=モニタとディスプレイの設定
|
||||||
|
Comment[nl]=Configuratie van beeldscherm en monitor
|
||||||
|
Comment[pt]=Configuração do Monitor e Ecrã
|
||||||
|
Comment[pt_BR]=Configuração do Monitor e da Visualização
|
||||||
|
Comment[sr]=Подешавање приказа и монитора
|
||||||
|
Comment[sr@Latn]=Podešavanje prikaza i monitora
|
||||||
|
Comment[sv]=Skärm- och bildskärmsinställning
|
||||||
|
Comment[xx]=xxDisplay and Monitor Configurationxx
|
||||||
|
Icon=displayconfig.png
|
||||||
|
Encoding=UTF-8
|
||||||
|
X-KDE-ModuleType=Library
|
||||||
|
X-KDE-Library=displayconfig
|
||||||
|
X-KDE-FactoryName=displayconfig
|
||||||
|
X-KDE-RootOnly=true
|
||||||
|
Type=Application
|
||||||
|
Exec=kcmshell Peripherals/displayconfig
|
||||||
|
Categories=Qt;KDE;X-KDE-settings-hardware;
|
||||||
|
GenericName=Screen Configuration Editor
|
||||||
|
GenericName[el]=Επεξεργαστής ρυθμίσεων οθόνης
|
||||||
|
GenericName[es]=Editor de la configuración de la pantalla
|
||||||
|
GenericName[et]=Ekraani seadistamise redaktor
|
||||||
|
GenericName[it]=Editor della configurazione dello schermo
|
||||||
|
GenericName[ja]=スクリーン設定エディタ
|
||||||
|
GenericName[nl]=Scherminstellingen bewerken
|
||||||
|
GenericName[pt]=Editor da Configuração do Ecrã
|
||||||
|
GenericName[pt_BR]=Editor de Configuração da Tela
|
||||||
|
GenericName[sr]=Уређивач подешавања екрана
|
||||||
|
GenericName[sr@Latn]=Uređivač podešavanja ekrana
|
||||||
|
GenericName[sv]=Editor för skärminställning
|
||||||
|
GenericName[xx]=xxScreen Configuration Editorxx
|
@ -0,0 +1,741 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file '/home/sebas/dev/guidance/trunk/displayconfig/displayconfighardwaretab.ui'
|
||||||
|
#
|
||||||
|
# Created: Sat Apr 23 14:39:39 2005
|
||||||
|
# by: The PyQt User Interface Compiler (pyuic) 3.13
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from qt import *
|
||||||
|
|
||||||
|
image0_data = [
|
||||||
|
"32 32 522 2",
|
||||||
|
"Qt c None",
|
||||||
|
".i c #000000",
|
||||||
|
"bA c #0037a6",
|
||||||
|
"bU c #0038a6",
|
||||||
|
"ch c #0038a7",
|
||||||
|
"bo c #003ba8",
|
||||||
|
"cA c #003ba9",
|
||||||
|
"bT c #003ca8",
|
||||||
|
"bG c #003ca9",
|
||||||
|
"fp c #020202",
|
||||||
|
"cS c #0242ae",
|
||||||
|
"fq c #030303",
|
||||||
|
"bH c #0341ab",
|
||||||
|
"cg c #0441ab",
|
||||||
|
"b1 c #0443ae",
|
||||||
|
"fo c #050505",
|
||||||
|
"fB c #060606",
|
||||||
|
"bS c #0642ad",
|
||||||
|
"a7 c #0740a5",
|
||||||
|
"cf c #0744ad",
|
||||||
|
"fC c #080808",
|
||||||
|
".5 c #083fa5",
|
||||||
|
"bn c #0841a5",
|
||||||
|
"d# c #0848b2",
|
||||||
|
"bF c #0942a6",
|
||||||
|
"bh c #0949b1",
|
||||||
|
".h c #0a0a0a",
|
||||||
|
"cz c #0a47b0",
|
||||||
|
"ce c #0a48b0",
|
||||||
|
"dY c #0a4fb7",
|
||||||
|
"fI c #0b0b0b",
|
||||||
|
"b0 c #0b44a9",
|
||||||
|
"cm c #0b4ab2",
|
||||||
|
"b2 c #0c4ab1",
|
||||||
|
"fA c #0e0e0e",
|
||||||
|
"dk c #0e4eb5",
|
||||||
|
"bz c #0f4db2",
|
||||||
|
"b3 c #0f4db3",
|
||||||
|
"bI c #0f4db4",
|
||||||
|
".A c #111111",
|
||||||
|
"cl c #114bad",
|
||||||
|
"cR c #114eb4",
|
||||||
|
"cd c #114fb4",
|
||||||
|
"b4 c #1250b5",
|
||||||
|
"cG c #1250b6",
|
||||||
|
"fr c #131313",
|
||||||
|
"cy c #1351b5",
|
||||||
|
"dA c #1353b8",
|
||||||
|
"cn c #1452b6",
|
||||||
|
"aJ c #1550af",
|
||||||
|
"bR c #1552b7",
|
||||||
|
"eR c #161616",
|
||||||
|
"cQ c #1653b7",
|
||||||
|
"bp c #1654b7",
|
||||||
|
"d. c #1654b8",
|
||||||
|
"a8 c #1656b9",
|
||||||
|
"cx c #1756b8",
|
||||||
|
"cF c #1852b2",
|
||||||
|
"b5 c #1857b9",
|
||||||
|
"cZ c #1857ba",
|
||||||
|
".2 c #191919",
|
||||||
|
"dX c #195cbf",
|
||||||
|
"cP c #1a58ba",
|
||||||
|
"cc c #1a59ba",
|
||||||
|
"#p c #1a5dbf",
|
||||||
|
"cH c #1b59bb",
|
||||||
|
"co c #1b5abb",
|
||||||
|
"ag c #1c1c1c",
|
||||||
|
"c9 c #1c5abb",
|
||||||
|
"dH c #1c60c2",
|
||||||
|
"dg c #1d5ebf",
|
||||||
|
"a3 c #1e1e1e",
|
||||||
|
"cY c #1e58b6",
|
||||||
|
"bJ c #1e5dbd",
|
||||||
|
"dG c #1f5ebc",
|
||||||
|
"cp c #1f5ebd",
|
||||||
|
"aY c #1f5fbf",
|
||||||
|
"cI c #205ebd",
|
||||||
|
"b6 c #205fbe",
|
||||||
|
"dW c #2063c3",
|
||||||
|
"bX c #212121",
|
||||||
|
"c8 c #215fbe",
|
||||||
|
"c0 c #2160bf",
|
||||||
|
"cb c #2161bf",
|
||||||
|
"#v c #225db7",
|
||||||
|
"cq c #2261c0",
|
||||||
|
"cw c #2262c0",
|
||||||
|
"df c #235db9",
|
||||||
|
"by c #2362c0",
|
||||||
|
"ds c #2364c2",
|
||||||
|
"cD c #242424",
|
||||||
|
"bQ c #2463c0",
|
||||||
|
"cr c #2464c1",
|
||||||
|
"aj c #2560b9",
|
||||||
|
"dp c #262626",
|
||||||
|
"cv c #2665c1",
|
||||||
|
"c1 c #2665c2",
|
||||||
|
"aB c #2667c4",
|
||||||
|
"dI c #266ac7",
|
||||||
|
".# c #272727",
|
||||||
|
"dr c #2763bc",
|
||||||
|
"b7 c #2766c2",
|
||||||
|
"cJ c #2766c3",
|
||||||
|
"cs c #2767c2",
|
||||||
|
"ca c #2767c3",
|
||||||
|
"eq c #282828",
|
||||||
|
"cO c #2867c3",
|
||||||
|
"bg c #2968c3",
|
||||||
|
"ct c #2968c4",
|
||||||
|
"cu c #2969c4",
|
||||||
|
"ab c #296bc7",
|
||||||
|
"bK c #2a69c5",
|
||||||
|
"b8 c #2a6ac5",
|
||||||
|
".6 c #2a6eca",
|
||||||
|
"#V c #2b66bc",
|
||||||
|
"cK c #2b6ac6",
|
||||||
|
"bq c #2b6bc5",
|
||||||
|
"c7 c #2b6bc6",
|
||||||
|
".o c #2c2c2c",
|
||||||
|
"#q c #2c5cb7",
|
||||||
|
"bi c #2c5eb7",
|
||||||
|
"bx c #2c6bc6",
|
||||||
|
"bP c #2c6cc6",
|
||||||
|
"aK c #2c6cc7",
|
||||||
|
"#P c #2c6ec8",
|
||||||
|
"g. c #2d2d2d",
|
||||||
|
"bB c #2d60b9",
|
||||||
|
"c# c #2d6dc7",
|
||||||
|
"cL c #2d6ec7",
|
||||||
|
"dJ c #2d71cb",
|
||||||
|
"dV c #2d71cc",
|
||||||
|
"aX c #2e6dc7",
|
||||||
|
"b9 c #2e6ec7",
|
||||||
|
"c. c #2e6ec8",
|
||||||
|
"fb c #2f2f2f",
|
||||||
|
"c2 c #2f6ec8",
|
||||||
|
"a9 c #2f6fc8",
|
||||||
|
"cT c #3063bb",
|
||||||
|
"cM c #3070c8",
|
||||||
|
"bw c #3070c9",
|
||||||
|
"ak c #3072cb",
|
||||||
|
"bf c #3171c9",
|
||||||
|
"br c #3171ca",
|
||||||
|
"aA c #3271c9",
|
||||||
|
"cN c #3272c9",
|
||||||
|
"aW c #3272ca",
|
||||||
|
"c3 c #3372ca",
|
||||||
|
"dt c #3372cb",
|
||||||
|
"dz c #3373ca",
|
||||||
|
"b. c #3373cb",
|
||||||
|
"bL c #3374cb",
|
||||||
|
"dK c #3377cf",
|
||||||
|
"dU c #3379d0",
|
||||||
|
"aZ c #3467be",
|
||||||
|
"aL c #3474cb",
|
||||||
|
"#o c #3478d0",
|
||||||
|
"da c #3567bf",
|
||||||
|
"dZ c #356cc3",
|
||||||
|
"aa c #3575cc",
|
||||||
|
"bO c #3576cc",
|
||||||
|
"#W c #3576ce",
|
||||||
|
".B c #363636",
|
||||||
|
"bM c #3676cc",
|
||||||
|
"be c #3676cd",
|
||||||
|
"c6 c #3677cd",
|
||||||
|
"fJ c #373737",
|
||||||
|
"az c #3777cd",
|
||||||
|
"bN c #3778cd",
|
||||||
|
"#T c #383838",
|
||||||
|
"bv c #3878cd",
|
||||||
|
"bs c #3878ce",
|
||||||
|
"#O c #3879ce",
|
||||||
|
"fZ c #393939",
|
||||||
|
"dl c #396cc1",
|
||||||
|
"aM c #3979ce",
|
||||||
|
"#w c #397bd1",
|
||||||
|
"dL c #397dd3",
|
||||||
|
"#n c #397ed3",
|
||||||
|
"fz c #3a3a3a",
|
||||||
|
"c4 c #3a7bcf",
|
||||||
|
"bu c #3a7bd0",
|
||||||
|
"dT c #3a7fd4",
|
||||||
|
"aG c #3b3b3b",
|
||||||
|
"c5 c #3b7bcf",
|
||||||
|
"bd c #3b7bd0",
|
||||||
|
"a# c #3b7cd0",
|
||||||
|
".7 c #3b80d5",
|
||||||
|
"gh c #3c3c3c",
|
||||||
|
"dB c #3c70c3",
|
||||||
|
"ay c #3c7cd1",
|
||||||
|
"aV c #3c7dd1",
|
||||||
|
"a4 c #3d3d3d",
|
||||||
|
"#X c #3d7dd1",
|
||||||
|
"aN c #3d7ed1",
|
||||||
|
"dy c #3d7ed2",
|
||||||
|
"bt c #3e7fd1",
|
||||||
|
"dh c #3e7fd2",
|
||||||
|
"dM c #3e83d7",
|
||||||
|
"bk c #3f3f3f",
|
||||||
|
"#Q c #3f73c5",
|
||||||
|
"al c #3f7fd2",
|
||||||
|
"#N c #3f80d2",
|
||||||
|
"b# c #3f80d3",
|
||||||
|
"dS c #3f85d7",
|
||||||
|
"#x c #4081d3",
|
||||||
|
"#m c #4084d7",
|
||||||
|
"f5 c #414141",
|
||||||
|
"a. c #4182d3",
|
||||||
|
"aU c #4182d4",
|
||||||
|
"bY c #424242",
|
||||||
|
"aC c #4276c6",
|
||||||
|
"aO c #4282d4",
|
||||||
|
"ax c #4283d4",
|
||||||
|
"bc c #4283d5",
|
||||||
|
"di c #4284d4",
|
||||||
|
".8 c #4287d9",
|
||||||
|
"#Y c #4384d5",
|
||||||
|
"dN c #4389da",
|
||||||
|
"cW c #444444",
|
||||||
|
"dj c #4484d5",
|
||||||
|
"dR c #4489db",
|
||||||
|
"g# c #454545",
|
||||||
|
"#M c #4586d6",
|
||||||
|
"bb c #4587d6",
|
||||||
|
"dd c #464646",
|
||||||
|
"ac c #467ac9",
|
||||||
|
"aT c #4687d7",
|
||||||
|
"aP c #4788d7",
|
||||||
|
"#y c #4788d8",
|
||||||
|
"#l c #478ddc",
|
||||||
|
"dO c #478ddd",
|
||||||
|
"er c #484848",
|
||||||
|
"ba c #4889d7",
|
||||||
|
"aw c #4889d8",
|
||||||
|
"am c #488ad8",
|
||||||
|
".9 c #488edd",
|
||||||
|
"dE c #494949",
|
||||||
|
"#Z c #498ad8",
|
||||||
|
"dx c #498bd9",
|
||||||
|
"d2 c #4a4a4a",
|
||||||
|
"aS c #4a8bd9",
|
||||||
|
"dP c #4a90de",
|
||||||
|
"aQ c #4b8cda",
|
||||||
|
"du c #4b8dda",
|
||||||
|
"#L c #4b8ddb",
|
||||||
|
"fU c #4c4c4c",
|
||||||
|
"dw c #4c8eda",
|
||||||
|
"dv c #4c8edb",
|
||||||
|
"dQ c #4c92df",
|
||||||
|
"av c #4d8edb",
|
||||||
|
"#z c #4d8fdb",
|
||||||
|
"an c #4d8fdc",
|
||||||
|
"#9 c #4e8fdc",
|
||||||
|
"#0 c #4e90dc",
|
||||||
|
"#k c #4f94e1",
|
||||||
|
"#. c #4f95e2",
|
||||||
|
"aR c #5092dd",
|
||||||
|
"au c #5193de",
|
||||||
|
"ao c #5294de",
|
||||||
|
"#K c #5294df",
|
||||||
|
"#A c #5395df",
|
||||||
|
"#1 c #5395e0",
|
||||||
|
"ap c #5597e0",
|
||||||
|
"at c #5597e1",
|
||||||
|
"#j c #559ce6",
|
||||||
|
"## c #579de6",
|
||||||
|
"#8 c #589ae2",
|
||||||
|
"aq c #589be2",
|
||||||
|
"fs c #595959",
|
||||||
|
"#B c #599be3",
|
||||||
|
"as c #599ce3",
|
||||||
|
"ar c #5a9ce3",
|
||||||
|
"#7 c #5c9fe6",
|
||||||
|
"#2 c #5d9fe5",
|
||||||
|
"#i c #5da3ea",
|
||||||
|
"fH c #5e5e5e",
|
||||||
|
"#C c #5ea2e7",
|
||||||
|
"#a c #5ea4eb",
|
||||||
|
"#J c #5fa1e6",
|
||||||
|
"gg c #606060",
|
||||||
|
"#6 c #60a3e7",
|
||||||
|
"#3 c #60a3e8",
|
||||||
|
"#5 c #62a4e9",
|
||||||
|
"#4 c #62a5e9",
|
||||||
|
"#I c #63a7ea",
|
||||||
|
"#h c #63aaef",
|
||||||
|
"#D c #64a7ea",
|
||||||
|
"#b c #64abef",
|
||||||
|
".g c #666666",
|
||||||
|
"f4 c #686868",
|
||||||
|
"#E c #68abed",
|
||||||
|
"#g c #69b1f2",
|
||||||
|
"#H c #6aaeee",
|
||||||
|
"#F c #6aaeef",
|
||||||
|
"#c c #6ab1f3",
|
||||||
|
"#G c #6bafef",
|
||||||
|
"#f c #6db4f5",
|
||||||
|
"#d c #6eb5f5",
|
||||||
|
"#e c #6eb6f6",
|
||||||
|
".E c #7087ae",
|
||||||
|
".n c #717171",
|
||||||
|
"f9 c #757575",
|
||||||
|
".Y c #758fb7",
|
||||||
|
"fO c #787878",
|
||||||
|
"el c #7ba0d7",
|
||||||
|
".F c #7d98be",
|
||||||
|
"gf c #7e7e7e",
|
||||||
|
"f0 c #808080",
|
||||||
|
"ek c #83a7dc",
|
||||||
|
"ga c #848484",
|
||||||
|
".X c #85a2c7",
|
||||||
|
".a c #868686",
|
||||||
|
"d5 c #86abdf",
|
||||||
|
"fy c #878787",
|
||||||
|
".W c #87a5c9",
|
||||||
|
"ej c #87abdd",
|
||||||
|
"d4 c #88aadc",
|
||||||
|
"f6 c #898989",
|
||||||
|
".Z c #899cc0",
|
||||||
|
".G c #8aa7ca",
|
||||||
|
"ei c #8aafe0",
|
||||||
|
"fD c #8b8b8b",
|
||||||
|
".V c #8ba8ca",
|
||||||
|
".H c #8ca9cb",
|
||||||
|
"d6 c #8cb1e2",
|
||||||
|
".U c #8eaccd",
|
||||||
|
"eh c #8eb3e3",
|
||||||
|
".I c #8faccd",
|
||||||
|
"d7 c #90b5e4",
|
||||||
|
".T c #92afcf",
|
||||||
|
"em c #92afdd",
|
||||||
|
".J c #92b0d0",
|
||||||
|
"eg c #92b7e5",
|
||||||
|
"d8 c #93b8e6",
|
||||||
|
".j c #949494",
|
||||||
|
".S c #95b3d1",
|
||||||
|
".K c #95b3d2",
|
||||||
|
"d9 c #96bbe8",
|
||||||
|
"ge c #979797",
|
||||||
|
".R c #98b6d3",
|
||||||
|
".L c #98b6d4",
|
||||||
|
"e. c #99bfea",
|
||||||
|
".f c #9a9a9a",
|
||||||
|
".e c #9b9b9b",
|
||||||
|
".Q c #9bb9d4",
|
||||||
|
".M c #9bb9d6",
|
||||||
|
".d c #9c9c9c",
|
||||||
|
"ef c #9cc2ec",
|
||||||
|
".c c #9d9d9d",
|
||||||
|
"e# c #9dc2eb",
|
||||||
|
".b c #9e9e9e",
|
||||||
|
".N c #9ebcd7",
|
||||||
|
"ee c #9ec4ed",
|
||||||
|
"ea c #9fc4ee",
|
||||||
|
".O c #a0bed8",
|
||||||
|
".P c #a0bfd8",
|
||||||
|
"ed c #a0c5ee",
|
||||||
|
"eb c #a0c6ee",
|
||||||
|
"ec c #a1c6ef",
|
||||||
|
"gd c #a3a3a3",
|
||||||
|
"gb c #a4a4a4",
|
||||||
|
"fa c #a5a5a5",
|
||||||
|
"gc c #a6a6a6",
|
||||||
|
"fN c #a8a8a8",
|
||||||
|
"fc c #acacac",
|
||||||
|
"fi c #b4b4b4",
|
||||||
|
"f8 c #b5b5b5",
|
||||||
|
"fm c #b8b8b8",
|
||||||
|
"fj c #b9b9b9",
|
||||||
|
"fl c #bababa",
|
||||||
|
"fk c #bbbbbb",
|
||||||
|
"fn c #bcbcbc",
|
||||||
|
"fx c #bebebe",
|
||||||
|
"fw c #bfbfbf",
|
||||||
|
"fh c #c1c1c1",
|
||||||
|
"fv c #c2c2c2",
|
||||||
|
"fu c #c3c3c3",
|
||||||
|
"eQ c #c4c4c4",
|
||||||
|
"eo c #c6c6c5",
|
||||||
|
"fE c #c6c6c6",
|
||||||
|
".4 c #c6c9d0",
|
||||||
|
"fe c #c7c7c7",
|
||||||
|
".z c #c8c8c8",
|
||||||
|
"#u c #c8ccd3",
|
||||||
|
"fd c #c9c9c9",
|
||||||
|
"d1 c #cac9c8",
|
||||||
|
"aF c #cacaca",
|
||||||
|
"f# c #cbcac9",
|
||||||
|
"ep c #cbcbcb",
|
||||||
|
"a2 c #cccccc",
|
||||||
|
"dD c #cdccca",
|
||||||
|
"do c #cdcdcd",
|
||||||
|
"#U c #cdd0d7",
|
||||||
|
"f. c #cecccc",
|
||||||
|
"af c #cecece",
|
||||||
|
"ai c #ced1d8",
|
||||||
|
"aI c #ced2d9",
|
||||||
|
"dn c #cfcecd",
|
||||||
|
"eP c #cfcfcf",
|
||||||
|
"e9 c #d0cfcf",
|
||||||
|
"ft c #d0d0d0",
|
||||||
|
"eO c #d0d0d1",
|
||||||
|
"dc c #d1d1cf",
|
||||||
|
"fg c #d1d1d1",
|
||||||
|
"e8 c #d2d2d1",
|
||||||
|
"#s c #d2d2d2",
|
||||||
|
"a6 c #d2d6dc",
|
||||||
|
".1 c #d3d3d3",
|
||||||
|
"cV c #d4d3d2",
|
||||||
|
"eN c #d4d3d3",
|
||||||
|
"e7 c #d4d4d3",
|
||||||
|
"f7 c #d4d4d4",
|
||||||
|
"bm c #d4d7de",
|
||||||
|
"ff c #d5d5d5",
|
||||||
|
"eM c #d5d6d6",
|
||||||
|
"d0 c #d5d7da",
|
||||||
|
"cC c #d6d5d4",
|
||||||
|
"e6 c #d6d6d5",
|
||||||
|
"f3 c #d6d6d6",
|
||||||
|
"en c #d6d7d9",
|
||||||
|
"dC c #d6d8db",
|
||||||
|
"bE c #d6d9e0",
|
||||||
|
"fY c #d7d7d7",
|
||||||
|
"eL c #d7d8d7",
|
||||||
|
".D c #d7d8db",
|
||||||
|
"bZ c #d7dbe2",
|
||||||
|
"fX c #d8d8d8",
|
||||||
|
"e5 c #d8d9d8",
|
||||||
|
"dm c #d8d9dc",
|
||||||
|
"cj c #d9d8d7",
|
||||||
|
"eK c #d9d9d9",
|
||||||
|
"db c #d9dbde",
|
||||||
|
"ck c #d9dde4",
|
||||||
|
"fM c #dadada",
|
||||||
|
"cU c #dadcdf",
|
||||||
|
"e4 c #dbdbda",
|
||||||
|
"eJ c #dbdbdb",
|
||||||
|
"cB c #dbdde0",
|
||||||
|
"dF c #dbdfe5",
|
||||||
|
"bW c #dcdbda",
|
||||||
|
"eI c #dcdcdc",
|
||||||
|
"cE c #dce0e6",
|
||||||
|
"fQ c #dddddd",
|
||||||
|
"cX c #dde1e8",
|
||||||
|
"e3 c #dedddc",
|
||||||
|
"fT c #dedede",
|
||||||
|
"ci c #dedfe2",
|
||||||
|
"dq c #dee1e7",
|
||||||
|
"de c #dee2e8",
|
||||||
|
"bD c #dfdedc",
|
||||||
|
"eH c #dfdfdf",
|
||||||
|
"bV c #dfe1e4",
|
||||||
|
"e2 c #e0dfdd",
|
||||||
|
"bC c #e0e2e5",
|
||||||
|
"bj c #e1e0df",
|
||||||
|
"eG c #e1e1e1",
|
||||||
|
"a0 c #e1e3e6",
|
||||||
|
"aD c #e1e3e7",
|
||||||
|
"e1 c #e2e1e0",
|
||||||
|
"eF c #e2e2e2",
|
||||||
|
"a1 c #e3e2e1",
|
||||||
|
"eE c #e3e3e3",
|
||||||
|
"e0 c #e4e2e3",
|
||||||
|
"aE c #e4e3e1",
|
||||||
|
"fS c #e4e4e4",
|
||||||
|
"fR c #e5e5e5",
|
||||||
|
"eZ c #e6e5e5",
|
||||||
|
"eD c #e6e6e6",
|
||||||
|
"fF c #e7e7e7",
|
||||||
|
"eY c #e8e7e7",
|
||||||
|
"eC c #e8e8e8",
|
||||||
|
"eX c #e9e9e8",
|
||||||
|
"eB c #e9eaea",
|
||||||
|
"d3 c #e9ecef",
|
||||||
|
".p c #eaeaea",
|
||||||
|
"ad c #eaebef",
|
||||||
|
"eA c #ebebeb",
|
||||||
|
"eW c #ecebea",
|
||||||
|
"fP c #ececec",
|
||||||
|
"ez c #ededec",
|
||||||
|
"fW c #ededed",
|
||||||
|
"f2 c #eeeeee",
|
||||||
|
"ey c #efeeef",
|
||||||
|
"f1 c #efefef",
|
||||||
|
"ex c #f0f0f0",
|
||||||
|
"#R c #f0f2f6",
|
||||||
|
"ae c #f1f0ef",
|
||||||
|
".m c #f1f1f1",
|
||||||
|
"ew c #f1f2f2",
|
||||||
|
"fL c #f2f2f2",
|
||||||
|
"fG c #f3f3f3",
|
||||||
|
"#r c #f3f5f8",
|
||||||
|
"ev c #f4f3f3",
|
||||||
|
"eV c #f4f4f3",
|
||||||
|
".3 c #f4f4f4",
|
||||||
|
"et c #f4f6f8",
|
||||||
|
".C c #f5f5f5",
|
||||||
|
"eU c #f6f6f4",
|
||||||
|
"#t c #f6f6f6",
|
||||||
|
"eu c #f6f7f8",
|
||||||
|
"fV c #f7f7f7",
|
||||||
|
"ah c #f8f8f8",
|
||||||
|
".0 c #f8f9fa",
|
||||||
|
"eT c #f9f7f7",
|
||||||
|
"aH c #f9f9f9",
|
||||||
|
"fK c #fafafa",
|
||||||
|
"eS c #fbfafa",
|
||||||
|
"a5 c #fbfbfb",
|
||||||
|
"bl c #fcfcfc",
|
||||||
|
"es c #fdfdfc",
|
||||||
|
".k c #fdfdfd",
|
||||||
|
".y c #fefefe",
|
||||||
|
".x c #fffcf8",
|
||||||
|
".w c #fffcf9",
|
||||||
|
".v c #fffdf9",
|
||||||
|
".u c #fffef9",
|
||||||
|
".t c #fffefa",
|
||||||
|
"#S c #fffefd",
|
||||||
|
".s c #fffffa",
|
||||||
|
".r c #fffffc",
|
||||||
|
".q c #fffffd",
|
||||||
|
".l c #ffffff",
|
||||||
|
"Qt.#.a.b.c.c.c.c.c.c.c.c.c.d.d.d.d.d.d.d.d.d.e.e.e.f.f.f.e.g.hQt",
|
||||||
|
".i.j.k.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.l.m.n.i",
|
||||||
|
".o.p.l.l.q.r.s.s.s.t.u.v.v.w.x.x.x.v.v.v.v.u.u.u.u.u.s.r.y.l.z.A",
|
||||||
|
".B.C.l.D.E.F.G.H.I.J.K.L.M.N.O.P.O.N.Q.R.S.T.U.V.W.X.Y.Z.0.l.1.2",
|
||||||
|
".B.3.l.4.5.6.7.8.9#.###a#b#c#d#e#f#g#h#i#j#k#l#m#n#o#p#q#r.l#s.2",
|
||||||
|
".B#t.l#u#v#w#x#y#z#A#B#C#D#E#F#G#H#E#I#J#B#K#L#M#N#O#P#Q#R#S#s.2",
|
||||||
|
"#T#t.l#U#V#W#X#Y#Z#0#1#B#2#3#4#4#5#6#7#8#A#9#ya.a#aaabacadaeafag",
|
||||||
|
"#Tah.laiajak#Oal#Yamanaoapaqararas#8atauavawaxayazaAaBaCaDaEaFag",
|
||||||
|
"aGaH.laIaJaKaLaMaNaOaPaQanaRauauauaR#zaSaTaUaVazaWaXaYaZa0a1a2a3",
|
||||||
|
"a4a5.la6a7a8a9b.aza#b##Y#M#y#Z#Z#Zbabbbc#NbdbebfaXbgbhbia0bja2a3",
|
||||||
|
"bkbl.lbmbnbobpbqbraabsa#bt#N#x#x#x#NaNbubvaLbwbxbybzbAbBbCbDa2a3",
|
||||||
|
"bkbl.lbEbFbGbHbIbJbKbwbLbMbNbsbsbvazbOb.bwbPbQbRbSbTbUbBbVbWa2bX",
|
||||||
|
"bY.k.lbZb0b1b2b3b4b5b6b7b8aXb9c.c.c#bqcacbcccdcecfcgchbBcicja2bX",
|
||||||
|
"bY.y.lckclcmcnb5cocpcqcrcsctcucuctcacvcwcpcocxcyb3czcAbBcBcCa2cD",
|
||||||
|
"bY.l.lcEcFcGcHcIbycJcKcLcMbfcNcNbfcMaXbqcObQcpcPcQcRcScTcUcVa2cD",
|
||||||
|
"cW.l.lcXcYcZc0c1b8c2c3bMaMc4c5c5c4aMc6b.a9c7c1c8c9d.d#dadbdca2cD",
|
||||||
|
"dd.l.ldedfdgcac#bfbec4dh#xdidjdjdiaUdhbdazbrbPcJcbc9dkdldmdndodp",
|
||||||
|
"dd.l.ldqdrdsaKdtbv#XaxaTamdudvdwaQdxaTaxdy#OdzbPcJc0dAdBdCdDa2dp",
|
||||||
|
"dE.l.ldFdGdHdIdJdKdLdMdNdOdPdQdQdP.9dRdSdTdUdVdIdWdXdYdZd0d1a2dp",
|
||||||
|
"d2.l.ld3d4d5d6d7d8d9e.e#eaebececedeeefe.d9egeheiejekelemeneoepeq",
|
||||||
|
"er.leseteu#tevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeN#seOeP.zeQa2.#",
|
||||||
|
"eRaf.l.yeseSeTeUeVaeeWeXeYeZe0e1e2e3e4e5e6cCcCe7e8e9f.f#.zeJfa.i",
|
||||||
|
"Qtfbfc#sdoa2epfdeQfeff.1#sfgePafdoa2epaFaFfhfifjfkflfjfmfn.jag.i",
|
||||||
|
"Qt.i.ifofofpfqfqfrfsfeftepfdfeeQfufvfwfxfxfyfzfA.ifBfCfCfC.i.iQt",
|
||||||
|
"QtQtQtQtQtQtfzfDfEeAfteDeAeCeCeCfFfFeCeAffeDfGfifHfIQtQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtfJfg.l.l.l.meJeA.CaHaHfKahfLfM.1aH.l.l.lfNfCQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtfO.l.ka5aH#tfPfQeHfReDfSeIaffda2fTbla5.l.lfUQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtfHfVfVfLfL.mfW.peEeIeJfXfYeJeHfF.mfLfLfKfPfZQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtfBf0eFf1f1fP.p.p.p.p.p.p.peAfPfPfWf1f2f3f4.iQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtQt.if5f6fkfYeFeEeEfSfSfSfSeEeEeFf7f8f9g..i.iQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtQtQt.i.i.2g#.gga.fgbgcgcgdgegfgggh.A.i.iQtQtQtQtQtQtQt",
|
||||||
|
"QtQtQtQtQtQtQtQtQtQt.i.i.ifqfofpfpfofq.i.i.i.iQtQtQtQtQtQtQtQtQt"
|
||||||
|
]
|
||||||
|
|
||||||
|
class Form1(QDialog):
|
||||||
|
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
|
||||||
|
QDialog.__init__(self,parent,name,modal,fl)
|
||||||
|
|
||||||
|
self.image0 = QPixmap(image0_data)
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
self.setName("Form1")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.groupBox3 = QGroupBox(self,"groupBox3")
|
||||||
|
self.groupBox3.setGeometry(QRect(10,320,680,133))
|
||||||
|
self.groupBox3.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.groupBox3.layout().setSpacing(6)
|
||||||
|
self.groupBox3.layout().setMargin(11)
|
||||||
|
groupBox3Layout = QHBoxLayout(self.groupBox3.layout())
|
||||||
|
groupBox3Layout.setAlignment(Qt.AlignTop)
|
||||||
|
|
||||||
|
layout92 = QGridLayout(None,1,1,0,6,"layout92")
|
||||||
|
|
||||||
|
self.textLabel2_4 = QLabel(self.groupBox3,"textLabel2_4")
|
||||||
|
|
||||||
|
layout92.addWidget(self.textLabel2_4,0,1)
|
||||||
|
|
||||||
|
self.textLabel5 = QLabel(self.groupBox3,"textLabel5")
|
||||||
|
|
||||||
|
layout92.addWidget(self.textLabel5,1,2)
|
||||||
|
|
||||||
|
self.textLabel1_4 = QLabel(self.groupBox3,"textLabel1_4")
|
||||||
|
self.textLabel1_4.setAlignment(QLabel.WordBreak | QLabel.AlignVCenter)
|
||||||
|
|
||||||
|
layout92.addMultiCellWidget(self.textLabel1_4,2,2,0,3)
|
||||||
|
|
||||||
|
self.comboBox4 = QComboBox(0,self.groupBox3,"comboBox4")
|
||||||
|
|
||||||
|
layout92.addWidget(self.comboBox4,1,3)
|
||||||
|
|
||||||
|
self.comboBox2 = QComboBox(0,self.groupBox3,"comboBox2")
|
||||||
|
|
||||||
|
layout92.addWidget(self.comboBox2,0,3)
|
||||||
|
|
||||||
|
self.textLabel3 = QLabel(self.groupBox3,"textLabel3")
|
||||||
|
|
||||||
|
layout92.addWidget(self.textLabel3,0,0)
|
||||||
|
|
||||||
|
self.kPushButton1 = KPushButton(self.groupBox3,"kPushButton1")
|
||||||
|
|
||||||
|
layout92.addMultiCellWidget(self.kPushButton1,1,1,0,1)
|
||||||
|
|
||||||
|
self.textLabel4 = QLabel(self.groupBox3,"textLabel4")
|
||||||
|
|
||||||
|
layout92.addWidget(self.textLabel4,0,2)
|
||||||
|
groupBox3Layout.addLayout(layout92)
|
||||||
|
|
||||||
|
self.groupBox1 = QGroupBox(self,"groupBox1")
|
||||||
|
self.groupBox1.setGeometry(QRect(10,10,320,300))
|
||||||
|
self.groupBox1.setSizePolicy(QSizePolicy(7,1,0,0,self.groupBox1.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.pixmapLabel1 = QLabel(self.groupBox1,"pixmapLabel1")
|
||||||
|
self.pixmapLabel1.setGeometry(QRect(11,33,16,17))
|
||||||
|
self.pixmapLabel1.setSizePolicy(QSizePolicy(0,0,0,0,self.pixmapLabel1.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.pixmapLabel1.setScaledContents(1)
|
||||||
|
|
||||||
|
self.textLabel2 = QLabel(self.groupBox1,"textLabel2")
|
||||||
|
self.textLabel2.setGeometry(QRect(19,45,60,17))
|
||||||
|
self.textLabel2.setSizePolicy(QSizePolicy(1,1,0,0,self.textLabel2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.textLabel2_3 = QLabel(self.groupBox1,"textLabel2_3")
|
||||||
|
self.textLabel2_3.setGeometry(QRect(85,45,213,17))
|
||||||
|
self.textLabel2_3.setSizePolicy(QSizePolicy(3,1,0,0,self.textLabel2_3.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.textLabel1_3 = QLabel(self.groupBox1,"textLabel1_3")
|
||||||
|
self.textLabel1_3.setGeometry(QRect(80,20,213,17))
|
||||||
|
self.textLabel1_3.setSizePolicy(QSizePolicy(3,1,0,0,self.textLabel1_3.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.textLabel1 = QLabel(self.groupBox1,"textLabel1")
|
||||||
|
self.textLabel1.setGeometry(QRect(19,22,60,17))
|
||||||
|
self.textLabel1.setSizePolicy(QSizePolicy(1,1,0,0,self.textLabel1.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.pushButton2 = QPushButton(self.groupBox1,"pushButton2")
|
||||||
|
self.pushButton2.setGeometry(QRect(160,70,144,26))
|
||||||
|
self.pushButton2.setSizePolicy(QSizePolicy(5,1,0,0,self.pushButton2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.groupBox2 = QGroupBox(self,"groupBox2")
|
||||||
|
self.groupBox2.setGeometry(QRect(350,10,348,300))
|
||||||
|
self.groupBox2.setSizePolicy(QSizePolicy(5,1,0,0,self.groupBox2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
LayoutWidget = QWidget(self.groupBox2,"layout11")
|
||||||
|
LayoutWidget.setGeometry(QRect(12,24,324,44))
|
||||||
|
layout11 = QHBoxLayout(LayoutWidget,11,6,"layout11")
|
||||||
|
|
||||||
|
self.pixmapLabel3 = QLabel(LayoutWidget,"pixmapLabel3")
|
||||||
|
self.pixmapLabel3.setSizePolicy(QSizePolicy(0,0,0,0,self.pixmapLabel3.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.pixmapLabel3.setPixmap(self.image0)
|
||||||
|
self.pixmapLabel3.setScaledContents(1)
|
||||||
|
layout11.addWidget(self.pixmapLabel3)
|
||||||
|
|
||||||
|
layout10 = QGridLayout(None,1,1,0,6,"layout10")
|
||||||
|
|
||||||
|
self.textLabel2_2_2 = QLabel(LayoutWidget,"textLabel2_2_2")
|
||||||
|
self.textLabel2_2_2.setSizePolicy(QSizePolicy(3,1,0,0,self.textLabel2_2_2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
layout10.addWidget(self.textLabel2_2_2,1,1)
|
||||||
|
|
||||||
|
self.textLabel1_2_2 = QLabel(LayoutWidget,"textLabel1_2_2")
|
||||||
|
self.textLabel1_2_2.setSizePolicy(QSizePolicy(4,1,0,0,self.textLabel1_2_2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
layout10.addWidget(self.textLabel1_2_2,0,1)
|
||||||
|
|
||||||
|
self.textLabel1_2 = QLabel(LayoutWidget,"textLabel1_2")
|
||||||
|
self.textLabel1_2.setSizePolicy(QSizePolicy(1,1,0,0,self.textLabel1_2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
layout10.addWidget(self.textLabel1_2,0,0)
|
||||||
|
|
||||||
|
self.textLabel2_2 = QLabel(LayoutWidget,"textLabel2_2")
|
||||||
|
self.textLabel2_2.setSizePolicy(QSizePolicy(1,1,0,0,self.textLabel2_2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
layout10.addWidget(self.textLabel2_2,1,0)
|
||||||
|
layout11.addLayout(layout10)
|
||||||
|
|
||||||
|
self.pushButton2_2 = QPushButton(self.groupBox2,"pushButton2_2")
|
||||||
|
self.pushButton2_2.setGeometry(QRect(180,70,158,26))
|
||||||
|
self.pushButton2_2.setSizePolicy(QSizePolicy(5,1,0,0,self.pushButton2_2.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
self.languageChange()
|
||||||
|
|
||||||
|
self.resize(QSize(702,472).expandedTo(self.minimumSizeHint()))
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
|
||||||
|
def languageChange(self):
|
||||||
|
self.setCaption(self.__tr("Form1"))
|
||||||
|
self.groupBox3.setTitle(self.__tr("Default Display Settings"))
|
||||||
|
self.textLabel2_4.setText(self.__tr("1280x1024 @ 60Hz"))
|
||||||
|
self.textLabel5.setText(self.__tr("DPI:"))
|
||||||
|
self.textLabel1_4.setText(self.__tr("These settings are defaults. Each user of this computer may specify their own personal settings."))
|
||||||
|
self.comboBox4.clear()
|
||||||
|
self.comboBox4.insertItem(self.__tr("75 DPI (small fonts)"))
|
||||||
|
self.comboBox4.insertItem(self.__tr("100 DPI (large fonts)"))
|
||||||
|
self.comboBox4.insertItem(self.__tr("Auto (84 DPI)"))
|
||||||
|
self.comboBox2.clear()
|
||||||
|
self.comboBox2.insertItem(self.__tr("Millions (24bit)"))
|
||||||
|
self.textLabel3.setText(self.__tr("Screen size:"))
|
||||||
|
self.kPushButton1.setText(self.__tr("Use current settings as system default"))
|
||||||
|
self.textLabel4.setText(self.__tr("Colors:"))
|
||||||
|
self.groupBox1.setTitle(self.__tr("Graphics Card"))
|
||||||
|
self.textLabel2.setText(self.__tr("Memory:"))
|
||||||
|
self.textLabel2_3.setText(self.__tr("32 Mb"))
|
||||||
|
self.textLabel1_3.setText(self.__tr("GeForce 2"))
|
||||||
|
self.textLabel1.setText(self.__tr("Name:"))
|
||||||
|
self.pushButton2.setText(self.__tr("Configure..."))
|
||||||
|
self.groupBox2.setTitle(self.__tr("Monitor"))
|
||||||
|
self.textLabel2_2_2.setText(self.__tr("1600x1200 @ 60Hz"))
|
||||||
|
self.textLabel1_2_2.setText(self.__tr("Philips 107S"))
|
||||||
|
self.textLabel1_2.setText(self.__tr("Name:"))
|
||||||
|
self.textLabel2_2.setText(self.__tr("Max. Resolution:"))
|
||||||
|
self.pushButton2_2.setText(self.__tr("Configure..."))
|
||||||
|
|
||||||
|
|
||||||
|
def __tr(self,s,c = None):
|
||||||
|
return qApp.translate("Form1",s,c)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
a = QApplication(sys.argv)
|
||||||
|
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
|
||||||
|
w = Form1()
|
||||||
|
a.setMainWidget(w)
|
||||||
|
w.show()
|
||||||
|
a.exec_loop()
|
@ -0,0 +1,809 @@
|
|||||||
|
|
||||||
|
from qt import *
|
||||||
|
from kdecore import *
|
||||||
|
from kdeui import *
|
||||||
|
import os
|
||||||
|
from displayconfigabstraction import *
|
||||||
|
|
||||||
|
# Running as the root user or not?
|
||||||
|
isroot = os.getuid()==0
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ResizeSlider(QVGroupBox):
|
||||||
|
""" An abstracted QSlider in a nice box to change the resolution of a screen """
|
||||||
|
def __init__(self,parent):
|
||||||
|
# Screen size group
|
||||||
|
QVGroupBox.__init__(self,parent)
|
||||||
|
self.updating_gui = True
|
||||||
|
self._buildGUI()
|
||||||
|
self.updating_gui = False
|
||||||
|
|
||||||
|
def _buildGUI(self):
|
||||||
|
self.setTitle(i18n("Screen Size"))
|
||||||
|
self.setInsideSpacing(KDialog.spacingHint())
|
||||||
|
self.setInsideMargin(KDialog.marginHint())
|
||||||
|
|
||||||
|
hbox3 = QHBox(self)
|
||||||
|
hbox3.setSpacing(KDialog.spacingHint())
|
||||||
|
label = QLabel(hbox3,"textLabel2_4")
|
||||||
|
label.setText(i18n("Lower"))
|
||||||
|
self.screensizeslider = QSlider(hbox3,"slider1")
|
||||||
|
self.screensizeslider.setMinValue(0)
|
||||||
|
self.screensizeslider.setMaxValue(4)
|
||||||
|
self.screensizeslider.setPageStep(1)
|
||||||
|
self.screensizeslider.setOrientation(QSlider.Horizontal)
|
||||||
|
self.screensizeslider.setTickmarks(QSlider.Below)
|
||||||
|
self.connect(self.screensizeslider,SIGNAL("valueChanged(int)"),self.slotResolutionChange)
|
||||||
|
label = QLabel(hbox3)
|
||||||
|
label.setText(i18n("Higher"))
|
||||||
|
|
||||||
|
self.resolutionlabel = QLabel(self)
|
||||||
|
self.resolutionlabel.setText("640x400")
|
||||||
|
|
||||||
|
def setScreen(self, screen):
|
||||||
|
self.updating_gui = True
|
||||||
|
self.screen = screen
|
||||||
|
self.screensizeslider.setMaxValue(len(screen.getAvailableResolutions())-1)
|
||||||
|
self.screensizeslider.setValue(screen.getResolutionIndex())
|
||||||
|
self.updating_gui = False
|
||||||
|
self.setResolutionIndex(screen.getResolutionIndex())
|
||||||
|
|
||||||
|
def slotResolutionChange(self,i):
|
||||||
|
""" Pass signal from slider through to App """
|
||||||
|
if self.updating_gui:
|
||||||
|
return
|
||||||
|
self.setResolutionIndex(i)
|
||||||
|
self.emit(PYSIGNAL("resolutionChange(int)"),(i,))
|
||||||
|
|
||||||
|
def setMaxValue(self,value):
|
||||||
|
self.updating_gui = True
|
||||||
|
self.screensizeslider.setMaxValue(value)
|
||||||
|
self.updating_gui = False
|
||||||
|
|
||||||
|
def setMinValue(self,value):
|
||||||
|
self.updating_gui = True
|
||||||
|
self.screensizeslider.setMinValue(value)
|
||||||
|
self.updating_gui = False
|
||||||
|
|
||||||
|
def setValue(self,value):
|
||||||
|
self.updating_gui = True
|
||||||
|
self.screensizeslider.setValue(value)
|
||||||
|
self.updating_gui = False
|
||||||
|
|
||||||
|
def value(self):
|
||||||
|
return self.screensizeslider.value()
|
||||||
|
|
||||||
|
def setResolutionLabel(self,text):
|
||||||
|
self.resolutionlabel.setText(text)
|
||||||
|
|
||||||
|
def setResolutionIndex(self,i):
|
||||||
|
self.updating_gui = True
|
||||||
|
width,height = self.screen.getAvailableResolutions()[i]
|
||||||
|
self.setResolutionLabel(i18n("%1 x %2").arg(width).arg(height))
|
||||||
|
self.updating_gui = False
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class MonitorPreview(QWidget):
|
||||||
|
""" A ResizableMonitor is an Image in a grid which has resizable edges,
|
||||||
|
fixed-size corners and is thus expandable. """
|
||||||
|
ROTATE_0 = 0
|
||||||
|
ROTATE_90 = 1
|
||||||
|
ROTATE_180 = 2
|
||||||
|
ROTATE_270 = 3
|
||||||
|
|
||||||
|
def __init__(self, parent=None, imagedir="", name=None):
|
||||||
|
QWidget.__init__(self,parent)
|
||||||
|
|
||||||
|
self.rotation = MonitorPreview.ROTATE_0
|
||||||
|
|
||||||
|
self.screen_width = 1280
|
||||||
|
self.screen_height = 1024
|
||||||
|
|
||||||
|
self.reflect_x = False
|
||||||
|
self.reflect_y = False
|
||||||
|
|
||||||
|
self.setBackgroundMode(Qt.NoBackground)
|
||||||
|
|
||||||
|
self.imagedir = imagedir + "monitor_resizable/"
|
||||||
|
|
||||||
|
self.image_monitor = QPixmap(self.imagedir+"monitor.png")
|
||||||
|
self.image_monitor_wide = QPixmap(self.imagedir+"monitor_wide.png")
|
||||||
|
self.image_monitor_r90 = QPixmap(self.imagedir+"monitor_r90.png")
|
||||||
|
self.image_monitor_wide_r90 = QPixmap(self.imagedir+"monitor_wide_r90.png")
|
||||||
|
|
||||||
|
self.image_background = QPixmap(self.imagedir+"background.png")
|
||||||
|
self.image_background_wide = QPixmap(self.imagedir+"background_wide.png")
|
||||||
|
self.image_background_r90 = QPixmap(self.imagedir+"background_r90.png")
|
||||||
|
self.image_background_wide_r90 = QPixmap(self.imagedir+"background_wide_r90.png")
|
||||||
|
|
||||||
|
self.image_window = QPixmap(self.imagedir+"window_4th.png")
|
||||||
|
self.image_window_bottom_left = QPixmap(self.imagedir+"window_bottom_left_4th.png")
|
||||||
|
self.image_window_bottom_right = QPixmap(self.imagedir+"window_bottom_right_4th.png")
|
||||||
|
|
||||||
|
def sizeHint(self):
|
||||||
|
max_width = max(self.image_monitor.width(), self.image_monitor_wide.width(),
|
||||||
|
self.image_monitor_r90.width(), self.image_monitor_wide_r90.width())
|
||||||
|
max_height = max(self.image_monitor.height(), self.image_monitor_wide.height(),
|
||||||
|
self.image_monitor_r90.height(), self.image_monitor_wide_r90.height())
|
||||||
|
return QSize(max_width, max_height)
|
||||||
|
|
||||||
|
def sizePolicy(self):
|
||||||
|
return QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||||
|
|
||||||
|
def paintEvent(self,paint_event):
|
||||||
|
screen_width = self.screen_width
|
||||||
|
screen_height = self.screen_height
|
||||||
|
|
||||||
|
# Widescreen format: preview width: 176, height: 99, 16:9
|
||||||
|
is_wide = abs(float(screen_width)/float(screen_height)-16.0/9.0) < 0.2
|
||||||
|
|
||||||
|
if not is_wide:
|
||||||
|
preview_screen_width = 152
|
||||||
|
preview_screen_height = 114
|
||||||
|
else:
|
||||||
|
preview_screen_width = 176
|
||||||
|
preview_screen_height = 99
|
||||||
|
|
||||||
|
if self.rotation==MonitorPreview.ROTATE_0 or self.rotation==MonitorPreview.ROTATE_180:
|
||||||
|
# Normal, landscape orientation.
|
||||||
|
if not is_wide:
|
||||||
|
screen_x_offset = 23
|
||||||
|
screen_y_offset = 15
|
||||||
|
image_background = self.image_background
|
||||||
|
else:
|
||||||
|
screen_x_offset = 23
|
||||||
|
screen_y_offset = 29
|
||||||
|
image_background = self.image_background_wide
|
||||||
|
else:
|
||||||
|
# Portrait orientation. Swap some values around.
|
||||||
|
t = preview_screen_width
|
||||||
|
preview_screen_width = preview_screen_height
|
||||||
|
preview_screen_height = t
|
||||||
|
|
||||||
|
t = screen_width
|
||||||
|
screen_width = screen_height
|
||||||
|
screen_height = t
|
||||||
|
|
||||||
|
if not is_wide:
|
||||||
|
screen_x_offset = 42
|
||||||
|
screen_y_offset = 15
|
||||||
|
image_background = self.image_background_r90
|
||||||
|
else:
|
||||||
|
screen_x_offset = 50
|
||||||
|
screen_y_offset = 15
|
||||||
|
image_background = self.image_background_wide_r90
|
||||||
|
|
||||||
|
# Draw everything off screen in a buffer
|
||||||
|
preview_buffer = QPixmap(preview_screen_width,preview_screen_height)
|
||||||
|
painter = QPainter(preview_buffer)
|
||||||
|
|
||||||
|
# Draw the background on the monitor's screen
|
||||||
|
painter.drawPixmap(0, 0, image_background)
|
||||||
|
|
||||||
|
# Work out the scaling factor for the eye candy in the preview winodw.
|
||||||
|
scale_factor = 4.0*float(preview_screen_width) / float(screen_width)
|
||||||
|
transform_matrix = QWMatrix().scale(scale_factor,scale_factor)
|
||||||
|
|
||||||
|
# Draw the little window on the background
|
||||||
|
scaled_window = self.image_window.xForm(transform_matrix)
|
||||||
|
|
||||||
|
sx = (preview_screen_width-scaled_window.width())/2
|
||||||
|
sy = (preview_screen_height-scaled_window.height())/2
|
||||||
|
if sx < 0:
|
||||||
|
sx = 0
|
||||||
|
if sy < 0:
|
||||||
|
sy = 0
|
||||||
|
sw = scaled_window.width()
|
||||||
|
if sw>preview_screen_width:
|
||||||
|
sw = preview_screen_width
|
||||||
|
|
||||||
|
sh = scaled_window.height()
|
||||||
|
if sh>preview_screen_height:
|
||||||
|
sh = preview_screen_height
|
||||||
|
|
||||||
|
painter.drawPixmap(sx, sy, scaled_window, 0, 0, sw, sh)
|
||||||
|
|
||||||
|
# Now draw the clock in the lower right corner
|
||||||
|
scaled_window = self.image_window_bottom_right.xForm(transform_matrix)
|
||||||
|
|
||||||
|
sx = preview_screen_width - scaled_window.width()
|
||||||
|
sy = preview_screen_height - scaled_window.height()
|
||||||
|
sw = scaled_window.width()#preview_screen_width/2
|
||||||
|
sh = scaled_window.height()
|
||||||
|
|
||||||
|
sx_offset = 0
|
||||||
|
if sx<0: # Some simple clipping for the left edge
|
||||||
|
sx_offset = -sx
|
||||||
|
sw = preview_screen_width
|
||||||
|
sx = 0
|
||||||
|
|
||||||
|
painter.drawPixmap(sx, sy, scaled_window, sx_offset, 0, sw, sh)
|
||||||
|
|
||||||
|
# Now draw the k menu in the lower left corner
|
||||||
|
scaled_window = self.image_window_bottom_left.xForm(transform_matrix)
|
||||||
|
|
||||||
|
sx = 0
|
||||||
|
sy = preview_screen_height - scaled_window.height()
|
||||||
|
sw = preview_screen_width/2 # Just draw on the left side of the preview.
|
||||||
|
sh = scaled_window.height()
|
||||||
|
painter.drawPixmap(sx, sy, scaled_window, 0, 0, sw, sh)
|
||||||
|
painter.end()
|
||||||
|
|
||||||
|
# Transform the preview image. Do reflections.
|
||||||
|
reflect_x = 1
|
||||||
|
if self.reflect_x:
|
||||||
|
reflect_x = -1
|
||||||
|
reflect_y = 1
|
||||||
|
if self.reflect_y:
|
||||||
|
reflect_y = -1
|
||||||
|
|
||||||
|
preview_buffer = preview_buffer.xForm(QWMatrix().scale(reflect_x,reflect_y))
|
||||||
|
|
||||||
|
# Draw the monitor on another buffer.
|
||||||
|
off_screen_buffer = QPixmap(self.width(),self.height())
|
||||||
|
off_screen_painter = QPainter(off_screen_buffer)
|
||||||
|
|
||||||
|
# Erase the buffer first
|
||||||
|
off_screen_painter.setBackgroundColor(self.paletteBackgroundColor())
|
||||||
|
off_screen_painter.eraseRect(0, 0, off_screen_buffer.width(), off_screen_buffer.height())
|
||||||
|
|
||||||
|
if self.rotation==MonitorPreview.ROTATE_0 or self.rotation==MonitorPreview.ROTATE_180:
|
||||||
|
if not is_wide:
|
||||||
|
image_monitor = self.image_monitor
|
||||||
|
else:
|
||||||
|
image_monitor = self.image_monitor_wide
|
||||||
|
else:
|
||||||
|
if not is_wide:
|
||||||
|
image_monitor = self.image_monitor_r90
|
||||||
|
else:
|
||||||
|
image_monitor = self.image_monitor_wide_r90
|
||||||
|
|
||||||
|
top_edge = self.height()-image_monitor.height()
|
||||||
|
left_edge = (self.width()-image_monitor.width())/2
|
||||||
|
|
||||||
|
# Draw the monitor
|
||||||
|
off_screen_painter.drawPixmap(left_edge, top_edge, image_monitor)
|
||||||
|
off_screen_painter.end()
|
||||||
|
|
||||||
|
# Copy the preview onto the off screen buffer with the monitor.
|
||||||
|
bitBlt(off_screen_buffer, left_edge+screen_x_offset, top_edge+screen_y_offset, preview_buffer,
|
||||||
|
0, 0, preview_buffer.width(), preview_buffer.height(),Qt.CopyROP, False)
|
||||||
|
|
||||||
|
# Update the widget
|
||||||
|
bitBlt(self, 0, 0, off_screen_buffer, 0, 0, self.width(), self.height(), Qt.CopyROP, False)
|
||||||
|
|
||||||
|
def setResolution(self,width,height):
|
||||||
|
self.screen_width = width
|
||||||
|
self.screen_height = height
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def setRotation(self, rotation):
|
||||||
|
self.rotation = rotation
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def setReflectX(self, enable):
|
||||||
|
self.reflect_x = enable
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def setReflectY(self, enable):
|
||||||
|
self.reflect_y = enable
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class DualMonitorPreview(QWidget):
|
||||||
|
""" This is the Widget to use elsewhere. It consists of a canvas and an
|
||||||
|
arbitrary number of gizmos on the canvas. The gizmos can be dragged and
|
||||||
|
dropped around. Painting is double-buffered so flickering should not occur.
|
||||||
|
"""
|
||||||
|
def __init__(self, parent, size, imagedir):
|
||||||
|
QWidget.__init__(self,parent)
|
||||||
|
self.setBackgroundMode(Qt.NoBackground)
|
||||||
|
|
||||||
|
self.imagedir = imagedir + "dualhead/"
|
||||||
|
self.snap_distance = 25
|
||||||
|
self.snapping = True
|
||||||
|
self.size = size
|
||||||
|
self.position = XSetup.POSITION_LEFTOF
|
||||||
|
|
||||||
|
self.current_screen = 0
|
||||||
|
|
||||||
|
self.resize(size,size)
|
||||||
|
self.setMouseTracking(True)
|
||||||
|
|
||||||
|
self.gizmos = []
|
||||||
|
self.gizmos.append(MovingGizmo("Monitor 1","monitor_1.png",QPoint(20,50),self.imagedir))
|
||||||
|
self.gizmos.append(MovingGizmo("Monitor 2","monitor_2.png",QPoint(180,50),self.imagedir))
|
||||||
|
|
||||||
|
self.gizmos[0].setWidth(1280)
|
||||||
|
self.gizmos[0].setHeight(1024)
|
||||||
|
self.gizmos[0].setHighlightColor(self.colorGroup().highlight())
|
||||||
|
self.gizmos[1].setWidth(1280)
|
||||||
|
self.gizmos[1].setHeight(1024)
|
||||||
|
self.gizmos[1].setHighlightColor(self.colorGroup().highlight())
|
||||||
|
|
||||||
|
self.dragging = False
|
||||||
|
self.dragging_gizmo = 0
|
||||||
|
self.drag_handle = None
|
||||||
|
|
||||||
|
self._positionGizmos()
|
||||||
|
self.setCurrentScreen(0)
|
||||||
|
|
||||||
|
def minimumSizeHint(self):
|
||||||
|
return QSize(self.size,self.size)
|
||||||
|
|
||||||
|
def setCurrentScreen(self,screen):
|
||||||
|
self.current_screen = screen
|
||||||
|
self.gizmos[0].setHighlight(screen==0)
|
||||||
|
self.gizmos[1].setHighlight(screen==1)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def getCurrentScreen(self):
|
||||||
|
return self.current_screen
|
||||||
|
|
||||||
|
def setPosition(self,position):
|
||||||
|
self.position = position
|
||||||
|
self._positionGizmos()
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def getPosition(self):
|
||||||
|
"""Returns one of XSetup.POSITION_LEFTOF, XSetup.POSITION_RIGHTOF,
|
||||||
|
XSetup.POSITION_ABOVE or XSetup.POSITION_BELOW.
|
||||||
|
"""
|
||||||
|
return self.position
|
||||||
|
|
||||||
|
def setScreenResolution(self,screenNumber,width,height):
|
||||||
|
self.gizmos[screenNumber].setWidth(width)
|
||||||
|
self.gizmos[screenNumber].setHeight(height)
|
||||||
|
self.setPosition(self.position) # Reposition and force update.
|
||||||
|
|
||||||
|
def _positionGizmos(self):
|
||||||
|
g1 = self.gizmos[0]
|
||||||
|
g2 = self.gizmos[1]
|
||||||
|
|
||||||
|
# Treat POSITION_RIGHTOF and POSITION_BELOW as LEFTOF and ABOVE with the
|
||||||
|
# gizmos swapped around.
|
||||||
|
if self.position==XSetup.POSITION_RIGHTOF or self.position==XSetup.POSITION_BELOW:
|
||||||
|
tmp = g1
|
||||||
|
g1 = g2
|
||||||
|
g2 = tmp
|
||||||
|
|
||||||
|
if self.position==XSetup.POSITION_LEFTOF or self.position==XSetup.POSITION_RIGHTOF:
|
||||||
|
x = -g1.getWidth()
|
||||||
|
y = -max(g1.getHeight(), g2.getHeight())/2
|
||||||
|
g1.setPosition(QPoint(x,y))
|
||||||
|
|
||||||
|
x = 0
|
||||||
|
g2.setPosition(QPoint(x,y))
|
||||||
|
|
||||||
|
else:
|
||||||
|
x = -max(g1.getWidth(), g2.getWidth())/2
|
||||||
|
y = -g1.getHeight()
|
||||||
|
g1.setPosition(QPoint(x,y))
|
||||||
|
|
||||||
|
y = 0
|
||||||
|
g2.setPosition(QPoint(x,y))
|
||||||
|
|
||||||
|
def mousePressEvent(self,event):
|
||||||
|
# Translate the point in the window into our gizmo space.
|
||||||
|
world_point = self._getGizmoMatrix().invert()[0].map(event.pos())
|
||||||
|
|
||||||
|
# If the mouse is in the air space of a gizmo, then we change the cursor to
|
||||||
|
# indicate that the gizmo can be dragged.
|
||||||
|
for giz in self.gizmos:
|
||||||
|
if giz.getRect().contains(world_point):
|
||||||
|
self.setCurrentScreen(self.gizmos.index(giz))
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Pressing down the mouse button on a gizmo also starts a drag operation.
|
||||||
|
self.dragging = True
|
||||||
|
self.dragging_gizmo = self.getCurrentScreen()
|
||||||
|
self.drag_handle = world_point - self.gizmos[self.dragging_gizmo].getPosition()
|
||||||
|
|
||||||
|
# Let other people know that a gizmo has been selected.
|
||||||
|
self.emit(PYSIGNAL("pressed()"), (self.current_screen,) )
|
||||||
|
|
||||||
|
def mouseReleaseEvent(self,event):
|
||||||
|
if not self.dragging:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Translate the point in the window into our gizmo space.
|
||||||
|
world_point = self._getGizmoMatrix().invert()[0].map(event.pos())
|
||||||
|
|
||||||
|
if self._moveGizmo(world_point):
|
||||||
|
self.setPosition(self.drag_position)
|
||||||
|
self.emit(PYSIGNAL("positionChanged()"), (self.position,) )
|
||||||
|
else:
|
||||||
|
self.setPosition(self.position)
|
||||||
|
self.dragging = False
|
||||||
|
|
||||||
|
def mouseMoveEvent(self,event):
|
||||||
|
# Translate the point in the window into our gizmo space.
|
||||||
|
world_point = self._getGizmoMatrix().invert()[0].map(event.pos())
|
||||||
|
|
||||||
|
# If the mouse is in the air space of a gizmo, then we change the cursor to
|
||||||
|
# indicate that the gizmo can be dragged.
|
||||||
|
for giz in self.gizmos:
|
||||||
|
if giz.getRect().contains(world_point):
|
||||||
|
self.setCursor(QCursor(Qt.SizeAllCursor))
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.unsetCursor()
|
||||||
|
|
||||||
|
if self.dragging:
|
||||||
|
self._moveGizmo(world_point)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def _moveGizmo(self,worldPoint):
|
||||||
|
new_drag_position = worldPoint-self.drag_handle
|
||||||
|
|
||||||
|
# Drag gizmo is simply the thing being dragged.
|
||||||
|
drag_gizmo = self.gizmos[self.dragging_gizmo]
|
||||||
|
drag_x = new_drag_position.x()
|
||||||
|
drag_y = new_drag_position.y()
|
||||||
|
|
||||||
|
# Snap gizmo is other (stationary) thing that we "snap" against.
|
||||||
|
snap_gizmo = self.gizmos[1-self.dragging_gizmo]
|
||||||
|
snap_x = snap_gizmo.getPosition().x()
|
||||||
|
snap_y = snap_gizmo.getPosition().y()
|
||||||
|
|
||||||
|
# Calculate the list of "snap points".
|
||||||
|
snap_points = [
|
||||||
|
(snap_x-drag_gizmo.getWidth(), snap_y), # Left of
|
||||||
|
(snap_x+snap_gizmo.getWidth(), snap_y), # Right of
|
||||||
|
(snap_x, snap_y-drag_gizmo.getHeight()), # Above
|
||||||
|
(snap_x, snap_y+snap_gizmo.getHeight())] # Below
|
||||||
|
|
||||||
|
# Find the snap point that the drag gizmo is closest to.
|
||||||
|
best_index = -1
|
||||||
|
best_distance = 0
|
||||||
|
i = 0
|
||||||
|
for snap_point in snap_points:
|
||||||
|
dx = snap_point[0] - drag_x
|
||||||
|
dy = snap_point[1] - drag_y
|
||||||
|
distance_squared = dx*dx + dy*dy
|
||||||
|
if best_index==-1 or distance_squared < best_distance:
|
||||||
|
best_index = i
|
||||||
|
best_distance = distance_squared
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
# Lookup the best dualhead position that this configuration matches.
|
||||||
|
if self.dragging_gizmo==0:
|
||||||
|
self.drag_position = [
|
||||||
|
XSetup.POSITION_LEFTOF,
|
||||||
|
XSetup.POSITION_RIGHTOF,
|
||||||
|
XSetup.POSITION_ABOVE,
|
||||||
|
XSetup.POSITION_BELOW][best_index]
|
||||||
|
else:
|
||||||
|
self.drag_position = [
|
||||||
|
XSetup.POSITION_RIGHTOF,
|
||||||
|
XSetup.POSITION_LEFTOF,
|
||||||
|
XSetup.POSITION_BELOW,
|
||||||
|
XSetup.POSITION_ABOVE][best_index]
|
||||||
|
|
||||||
|
# Convert the auto-snap distance in pixels into a distance in the gizmo coordinate system.
|
||||||
|
world_snap_distance = self.snap_distance / self._getGizmoToPixelsScaleFactor()
|
||||||
|
|
||||||
|
# Should this drag gizmo visually snap?
|
||||||
|
snapped = False
|
||||||
|
if best_distance <= (world_snap_distance*world_snap_distance):
|
||||||
|
new_drag_position = QPoint(snap_points[best_index][0],snap_points[best_index][1])
|
||||||
|
snapped = True
|
||||||
|
|
||||||
|
# Move the gizmo
|
||||||
|
self.gizmos[self.dragging_gizmo].setPosition(new_drag_position)
|
||||||
|
|
||||||
|
return snapped
|
||||||
|
|
||||||
|
def paintEvent(self,event=None):
|
||||||
|
QWidget.paintEvent(self,event)
|
||||||
|
|
||||||
|
# Paint to an off screen buffer first. Later we copy it to widget => flicker free.
|
||||||
|
off_screen_buffer = QPixmap(self.width(),self.height())
|
||||||
|
off_screen_painter = QPainter(off_screen_buffer)
|
||||||
|
|
||||||
|
# Erase the buffer first
|
||||||
|
off_screen_painter.setBackgroundColor(self.colorGroup().mid() )
|
||||||
|
off_screen_painter.eraseRect(0, 0, off_screen_buffer.width(), off_screen_buffer.height())
|
||||||
|
|
||||||
|
#
|
||||||
|
off_screen_painter.setWorldMatrix(self._getGizmoMatrix())
|
||||||
|
|
||||||
|
# Paint the non-selected gizmo first.
|
||||||
|
self.gizmos[ 1-self.current_screen ].paint(off_screen_painter)
|
||||||
|
|
||||||
|
# Now paint the selected gizmo
|
||||||
|
self.gizmos[self.current_screen].paint(off_screen_painter)
|
||||||
|
|
||||||
|
# Turn off the world matrix transform.
|
||||||
|
off_screen_painter.setWorldXForm(False)
|
||||||
|
|
||||||
|
# Draw the rounded border
|
||||||
|
off_screen_painter.setPen(QPen(self.colorGroup().dark(),1))
|
||||||
|
off_screen_painter.drawRoundRect(0,0,self.width(),self.height(),2,2)
|
||||||
|
|
||||||
|
off_screen_painter.end()
|
||||||
|
|
||||||
|
# Update the widget
|
||||||
|
bitBlt(self, 0, 0, off_screen_buffer, 0, 0, self.width(), self.height(), Qt.CopyROP, False)
|
||||||
|
|
||||||
|
def _getGizmoMatrix(self):
|
||||||
|
matrix = QWMatrix()
|
||||||
|
matrix.translate(self.width()/2,self.height()/2)
|
||||||
|
|
||||||
|
scale_factor = self._getGizmoToPixelsScaleFactor()
|
||||||
|
matrix.scale(scale_factor,scale_factor)
|
||||||
|
return matrix
|
||||||
|
|
||||||
|
def _getGizmoToPixelsScaleFactor(self):
|
||||||
|
g1 = self.gizmos[0]
|
||||||
|
g2 = self.gizmos[1]
|
||||||
|
size = min(self.width(),self.height())
|
||||||
|
vscale = float(self.height()) / (2.1 * (g1.getHeight()+g2.getHeight()))
|
||||||
|
hscale = float(self.width()) / (2.1 * (g1.getWidth()+g2.getWidth()))
|
||||||
|
return min(vscale,hscale)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class MovingGizmo(object):
|
||||||
|
"""A gizmo represents a screen/monitor. It also has a width and height that
|
||||||
|
correspond to the resolution of screen."""
|
||||||
|
|
||||||
|
def __init__(self,label,filename,initial_pos=QPoint(0,0),imagedir="."):
|
||||||
|
self.width = 100
|
||||||
|
self.height = 100
|
||||||
|
self.pixmap = QPixmap(imagedir+filename)
|
||||||
|
|
||||||
|
self.highlight = False
|
||||||
|
self.highlight_color = QColor(255,0,0)
|
||||||
|
|
||||||
|
self.setPosition(initial_pos)
|
||||||
|
|
||||||
|
# Used for caching the scaled pixmap.
|
||||||
|
self.scaled_width = -1
|
||||||
|
self.scaled_height = -1
|
||||||
|
|
||||||
|
def setHighlight(self,enable):
|
||||||
|
self.highlight = enable
|
||||||
|
|
||||||
|
def setHighlightColor(self,color):
|
||||||
|
self.highlight_color = color
|
||||||
|
|
||||||
|
def setPosition(self,position):
|
||||||
|
self.position = position
|
||||||
|
|
||||||
|
def getSize(self):
|
||||||
|
return QSize(self.width,self.height)
|
||||||
|
|
||||||
|
def getPosition(self):
|
||||||
|
return self.position
|
||||||
|
|
||||||
|
def getRect(self):
|
||||||
|
return QRect(self.position,self.getSize())
|
||||||
|
|
||||||
|
def setWidth(self,width):
|
||||||
|
self.width = width
|
||||||
|
|
||||||
|
def getWidth(self):
|
||||||
|
return self.width
|
||||||
|
|
||||||
|
def setHeight(self,height):
|
||||||
|
self.height = height
|
||||||
|
|
||||||
|
def getHeight(self):
|
||||||
|
return self.height
|
||||||
|
|
||||||
|
def paint(self,painter):
|
||||||
|
painter.save()
|
||||||
|
if self.highlight:
|
||||||
|
pen = QPen(self.highlight_color,6)
|
||||||
|
painter.setPen(pen)
|
||||||
|
|
||||||
|
painter.drawRect(self.position.x(), self.position.y(), self.width, self.height)
|
||||||
|
|
||||||
|
to_pixels_matrix = painter.worldMatrix()
|
||||||
|
top_left_pixels = to_pixels_matrix.map(self.position)
|
||||||
|
bottom_right_pixels = to_pixels_matrix.map( QPoint(self.position.x()+self.width, self.position.y()+self.height) )
|
||||||
|
|
||||||
|
# Scale the pixmap.
|
||||||
|
scaled_width = bottom_right_pixels.x() - top_left_pixels.x()
|
||||||
|
scaled_height = bottom_right_pixels.y() - top_left_pixels.y()
|
||||||
|
|
||||||
|
if (scaled_width,scaled_height) != (self.scaled_width,self.scaled_height):
|
||||||
|
scale_matrix = QWMatrix()
|
||||||
|
scale_matrix.scale(
|
||||||
|
float(scaled_width)/float(self.pixmap.width()),
|
||||||
|
float(scaled_height)/float(self.pixmap.height()) )
|
||||||
|
|
||||||
|
self.scaled_pixmap = self.pixmap.xForm(scale_matrix)
|
||||||
|
(self.scaled_width,self.scaled_height) = (scaled_width,scaled_height)
|
||||||
|
|
||||||
|
# Paste in the scaled pixmap.
|
||||||
|
bitBlt(painter.device(), top_left_pixels.x(), top_left_pixels.y(), self.scaled_pixmap, 0, 0,
|
||||||
|
self.scaled_pixmap.width(), self.scaled_pixmap.height(),Qt.CopyROP, False)
|
||||||
|
|
||||||
|
painter.restore()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class GfxCardWidget(QVGroupBox):
|
||||||
|
def __init__(self, parent, xsetup, gfxcard, gfxcarddialog, monitordialog):
|
||||||
|
global imagedir
|
||||||
|
QVGroupBox.__init__(self,parent)
|
||||||
|
|
||||||
|
self.xsetup = xsetup
|
||||||
|
self.gfxcard = gfxcard
|
||||||
|
self.gfxcarddialog = gfxcarddialog
|
||||||
|
self.monitordialog = monitordialog
|
||||||
|
self._buildGUI()
|
||||||
|
self._syncGUI()
|
||||||
|
|
||||||
|
def _buildGUI(self):
|
||||||
|
# Create the GUI
|
||||||
|
|
||||||
|
gridwidget = QWidget(self)
|
||||||
|
grid = QGridLayout(gridwidget,2+3*len(self.gfxcard.getScreens()))
|
||||||
|
grid.setSpacing(KDialog.spacingHint())
|
||||||
|
grid.setColStretch(0,0)
|
||||||
|
grid.setColStretch(1,0)
|
||||||
|
grid.setColStretch(2,0)
|
||||||
|
grid.setColStretch(3,1)
|
||||||
|
grid.setColStretch(4,0)
|
||||||
|
|
||||||
|
gfxcardpic = QLabel(gridwidget)
|
||||||
|
gfxcardpic.setPixmap(UserIcon('hi32-gfxcard'))
|
||||||
|
grid.addMultiCellWidget(gfxcardpic,0,1,0,0)
|
||||||
|
|
||||||
|
label = QLabel(gridwidget)
|
||||||
|
label.setText(i18n("Graphics card:"))
|
||||||
|
grid.addWidget(label,0,1)
|
||||||
|
|
||||||
|
self.gfxcardlabel = QLabel(gridwidget)
|
||||||
|
grid.addWidget(self.gfxcardlabel,0,2)
|
||||||
|
|
||||||
|
label = QLabel(gridwidget)
|
||||||
|
label.setText(i18n("Driver:"))
|
||||||
|
grid.addWidget(label,1,1)
|
||||||
|
|
||||||
|
self.driverlabel = QLabel(gridwidget)
|
||||||
|
grid.addMultiCellWidget(self.driverlabel,1,1,2,3)
|
||||||
|
|
||||||
|
gfxbutton = QPushButton(gridwidget)
|
||||||
|
gfxbutton.setText(i18n("Configure..."))
|
||||||
|
self.connect(gfxbutton,SIGNAL("clicked()"),self.slotGfxCardConfigureClicked)
|
||||||
|
grid.addWidget(gfxbutton,0,4)
|
||||||
|
gfxbutton.setEnabled(self.xsetup.mayModifyXorgConfig())
|
||||||
|
|
||||||
|
# Add all of the screens
|
||||||
|
row = 2
|
||||||
|
count = 1
|
||||||
|
self.monitorlabels = []
|
||||||
|
self.monitor_buttons = []
|
||||||
|
self.monitor_roles = []
|
||||||
|
for screen in self.gfxcard.getScreens():
|
||||||
|
frame = QFrame(gridwidget)
|
||||||
|
frame.setFrameShape(QFrame.HLine)
|
||||||
|
frame.setFrameShadow(QFrame.Sunken)
|
||||||
|
grid.addMultiCellWidget(frame,row,row,0,4)
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
monitorpic = QLabel(gridwidget)
|
||||||
|
monitorpic.setPixmap(UserIcon('hi32-display'))
|
||||||
|
grid.addMultiCellWidget(monitorpic,row,row+1,0,0)
|
||||||
|
|
||||||
|
# Monitor label
|
||||||
|
label = QLabel(gridwidget)
|
||||||
|
if len(self.gfxcard.getScreens())==1:
|
||||||
|
label.setText(i18n("Monitor:"))
|
||||||
|
else:
|
||||||
|
label.setText(i18n("Monitor #%1:").arg(count))
|
||||||
|
grid.addWidget(label,row,1)
|
||||||
|
|
||||||
|
self.monitorlabels.append(QLabel(gridwidget))
|
||||||
|
grid.addMultiCellWidget(self.monitorlabels[-1],row,row,2,3)
|
||||||
|
|
||||||
|
# Role pulldown
|
||||||
|
if len(self.xsetup.getAllScreens())!=1:
|
||||||
|
label = QLabel(gridwidget)
|
||||||
|
label.setText(i18n("Role:"))
|
||||||
|
grid.addWidget(label,row+1,1)
|
||||||
|
|
||||||
|
role_combo = KComboBox(False,gridwidget)
|
||||||
|
role_combo.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||||
|
self.monitor_roles.append(role_combo)
|
||||||
|
role_combo.insertItem(i18n("Primary (1)"))
|
||||||
|
role_combo.insertItem(i18n("Secondary (2)"))
|
||||||
|
if len(self.xsetup.getAllScreens())>=3:
|
||||||
|
role_combo.insertItem(i18n("Unused"))
|
||||||
|
self.connect(role_combo,SIGNAL("activated(int)"),self.slotRoleSelected)
|
||||||
|
grid.addWidget(role_combo,row+1,2)
|
||||||
|
role_combo.setEnabled(self.xsetup.mayModifyXorgConfig())
|
||||||
|
|
||||||
|
monitorbutton = QPushButton(gridwidget)
|
||||||
|
self.monitor_buttons.append(monitorbutton)
|
||||||
|
monitorbutton.setText(i18n("Configure..."))
|
||||||
|
self.connect(monitorbutton,SIGNAL("clicked()"),self.slotMonitorConfigureClicked)
|
||||||
|
grid.addWidget(monitorbutton,row,4)
|
||||||
|
monitorbutton.setEnabled(self.xsetup.mayModifyXorgConfig())
|
||||||
|
row += 2
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
def syncConfig(self):
|
||||||
|
self._syncGUI()
|
||||||
|
|
||||||
|
def _syncGUI(self):
|
||||||
|
if self.gfxcard.getGfxCardModel() is not None:
|
||||||
|
self.setTitle(self.gfxcard.getGfxCardModel().getName())
|
||||||
|
self.gfxcardlabel.setText(self.gfxcard.getGfxCardModel().getName())
|
||||||
|
|
||||||
|
if self.gfxcard.isProprietaryDriver():
|
||||||
|
try:
|
||||||
|
# Displayconfig thinks there is a proprietary driver
|
||||||
|
self.driverlabel.setText(self.gfxcard.getGfxCardModel().getProprietaryDriver())
|
||||||
|
except TypeError, errormsg:
|
||||||
|
# If there isn't it dies, so try again LP: #198269
|
||||||
|
self.driverlabel.setText(self.gfxcard.getGfxCardModel().getDriver())
|
||||||
|
else:
|
||||||
|
self.driverlabel.setText(self.gfxcard.getGfxCardModel().getDriver())
|
||||||
|
else:
|
||||||
|
self.setTitle(i18n("<Unknown>"))
|
||||||
|
self.gfxcardlabel.setText(i18n("<Unknown>"))
|
||||||
|
self.driverlabel.setText(i18n("<none>"))
|
||||||
|
|
||||||
|
# Sync the screens and monitors.
|
||||||
|
for i in range(len(self.gfxcard.getScreens())):
|
||||||
|
screen = self.gfxcard.getScreens()[i]
|
||||||
|
|
||||||
|
if screen.getMonitorModel() is None:
|
||||||
|
monitor_name = i18n("<unknown>")
|
||||||
|
else:
|
||||||
|
monitor_name = QString(screen.getMonitorModel().getName())
|
||||||
|
if screen.getMonitorAspect()==ModeLine.ASPECT_16_9:
|
||||||
|
monitor_name.append(i18n(" (widescreen)"))
|
||||||
|
self.monitorlabels[i].setText(monitor_name)
|
||||||
|
|
||||||
|
if len(self.xsetup.getAllScreens())!=1:
|
||||||
|
self.monitor_roles[i].setCurrentItem(
|
||||||
|
{XSetup.ROLE_PRIMARY: 0,
|
||||||
|
XSetup.ROLE_SECONDARY: 1,
|
||||||
|
XSetup.ROLE_UNUSED: 2}
|
||||||
|
[self.xsetup.getScreenRole(screen)])
|
||||||
|
|
||||||
|
def slotGfxCardConfigureClicked(self):
|
||||||
|
result = self.gfxcarddialog.do(self.gfxcard.getGfxCardModel(), \
|
||||||
|
self.gfxcard.isProprietaryDriver(), self.gfxcard.getDetectedGfxCardModel(),
|
||||||
|
self.gfxcard.getVideoRam())
|
||||||
|
|
||||||
|
(new_card_model, new_proprietary_driver, new_video_ram) = result
|
||||||
|
|
||||||
|
if new_card_model is self.gfxcard.getGfxCardModel() and \
|
||||||
|
new_proprietary_driver==self.gfxcard.isProprietaryDriver() and \
|
||||||
|
new_video_ram==self.gfxcard.getVideoRam():
|
||||||
|
return
|
||||||
|
self.gfxcard.setGfxCardModel(new_card_model)
|
||||||
|
self.gfxcard.setProprietaryDriver(new_proprietary_driver)
|
||||||
|
self.gfxcard.setVideoRam(new_video_ram)
|
||||||
|
self._syncGUI()
|
||||||
|
self.emit(PYSIGNAL("configChanged"), () )
|
||||||
|
|
||||||
|
def slotMonitorConfigureClicked(self):
|
||||||
|
screen_index = self.monitor_buttons.index(self.sender())
|
||||||
|
screen_obj = self.gfxcard.getScreens()[screen_index]
|
||||||
|
|
||||||
|
(new_monitor_model,new_aspect) = self.monitordialog.do(screen_obj.getMonitorModel(),
|
||||||
|
screen_obj.getMonitorAspect(),
|
||||||
|
self.xsetup.getGfxCards()[0].getScreens()[0] is screen_obj)
|
||||||
|
|
||||||
|
screen_obj.setMonitorModel(new_monitor_model)
|
||||||
|
screen_obj.setMonitorAspect(new_aspect)
|
||||||
|
self._syncGUI()
|
||||||
|
self.emit(PYSIGNAL("configChanged"), () )
|
||||||
|
|
||||||
|
def slotRoleSelected(self,index):
|
||||||
|
screen_index = self.monitor_roles.index(self.sender())
|
||||||
|
screen_obj = self.gfxcard.getScreens()[screen_index]
|
||||||
|
self.xsetup.setScreenRole(screen_obj,[XSetup.ROLE_PRIMARY,XSetup.ROLE_SECONDARY,XSetup.ROLE_UNUSED][index])
|
||||||
|
|
||||||
|
self._syncGUI()
|
||||||
|
self.emit(PYSIGNAL("configChanged"), () )
|
@ -0,0 +1,86 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'energy.ui'
|
||||||
|
#
|
||||||
|
# Created: Fri Jun 24 03:45:58 2005
|
||||||
|
# by: The PyQt User Interface Compiler (pyuic) 3.14.1
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
|
||||||
|
from qt import *
|
||||||
|
|
||||||
|
class DPMSTab(QDialog):
|
||||||
|
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
|
||||||
|
QDialog.__init__(self,parent,name,modal,fl)
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
self.setName("DPMSTab")
|
||||||
|
|
||||||
|
|
||||||
|
DPMSTabLayout = QVBoxLayout(self,11,6,"DPMSTabLayout")
|
||||||
|
|
||||||
|
titlelayout = QHBoxLayout(None,0,6,"titlelayout")
|
||||||
|
topspacer = QSpacerItem(221,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
titlelayout.addItem(topspacer)
|
||||||
|
|
||||||
|
self.energystarpix = QLabel(self,"energystarpix")
|
||||||
|
self.energystarpix.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.energystarpix.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.energystarpix.setMinimumSize(QSize(150,77))
|
||||||
|
self.energystarpix.setPixmap(QPixmap("energystar.png"))
|
||||||
|
self.energystarpix.setScaledContents(1)
|
||||||
|
titlelayout.addWidget(self.energystarpix)
|
||||||
|
DPMSTabLayout.addLayout(titlelayout)
|
||||||
|
|
||||||
|
self.screensavergroup = QGroupBox(self,"screensavergroup")
|
||||||
|
self.screensavergroup.setCheckable(1)
|
||||||
|
self.screensavergroup.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.screensavergroup.layout().setSpacing(6)
|
||||||
|
self.screensavergroup.layout().setMargin(11)
|
||||||
|
screensavergroupLayout = QHBoxLayout(self.screensavergroup.layout())
|
||||||
|
screensavergroupLayout.setAlignment(Qt.AlignTop)
|
||||||
|
spacer4 = QSpacerItem(101,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
screensavergroupLayout.addItem(spacer4)
|
||||||
|
|
||||||
|
self.screensavertext = QLabel(self.screensavergroup,"screensavertext")
|
||||||
|
screensavergroupLayout.addWidget(self.screensavertext)
|
||||||
|
|
||||||
|
self.screensavercombo = QComboBox(0,self.screensavergroup,"screensavercombo")
|
||||||
|
screensavergroupLayout.addWidget(self.screensavercombo)
|
||||||
|
DPMSTabLayout.addWidget(self.screensavergroup)
|
||||||
|
|
||||||
|
self.dpmsgroup = QGroupBox(self,"dpmsgroup")
|
||||||
|
self.dpmsgroup.setCheckable(1)
|
||||||
|
self.dpmsgroup.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.dpmsgroup.layout().setSpacing(6)
|
||||||
|
self.dpmsgroup.layout().setMargin(11)
|
||||||
|
dpmsgroupLayout = QHBoxLayout(self.dpmsgroup.layout())
|
||||||
|
dpmsgroupLayout.setAlignment(Qt.AlignTop)
|
||||||
|
spacer4_2 = QSpacerItem(244,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
dpmsgroupLayout.addItem(spacer4_2)
|
||||||
|
|
||||||
|
self.dpmstext = QLabel(self.dpmsgroup,"dpmstext")
|
||||||
|
dpmsgroupLayout.addWidget(self.dpmstext)
|
||||||
|
|
||||||
|
self.dpmscombo = QComboBox(0,self.dpmsgroup,"dpmscombo")
|
||||||
|
dpmsgroupLayout.addWidget(self.dpmscombo)
|
||||||
|
DPMSTabLayout.addWidget(self.dpmsgroup)
|
||||||
|
bottomspacer = QSpacerItem(51,160,QSizePolicy.Minimum,QSizePolicy.Expanding)
|
||||||
|
DPMSTabLayout.addItem(bottomspacer)
|
||||||
|
|
||||||
|
self.languageChange()
|
||||||
|
|
||||||
|
self.resize(QSize(508,372).expandedTo(self.minimumSizeHint()))
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
|
||||||
|
def languageChange(self):
|
||||||
|
self.setCaption(self.__tr("Display power saving"))
|
||||||
|
self.screensavergroup.setTitle(self.__tr("Enable screensaver"))
|
||||||
|
self.screensavertext.setText(self.__tr("Start screensaver after"))
|
||||||
|
self.dpmsgroup.setTitle(self.__tr("Enable display powermanagement"))
|
||||||
|
self.dpmstext.setText(self.__tr("Switch display off after"))
|
||||||
|
|
||||||
|
|
||||||
|
def __tr(self,s,c = None):
|
||||||
|
return qApp.translate("DPMSTab",s,c)
|
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import select
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def ExecWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0,
|
||||||
|
catchfd = 1, closefd = -1):
|
||||||
|
|
||||||
|
if not os.access(root + command, os.X_OK) and not searchPath:
|
||||||
|
raise RuntimeError, command + " can not be run"
|
||||||
|
|
||||||
|
(read, write) = os.pipe()
|
||||||
|
childpid = os.fork()
|
||||||
|
if (not childpid):
|
||||||
|
if (root and root != '/'): os.chroot(root)
|
||||||
|
os.dup2(write, catchfd)
|
||||||
|
os.close(write)
|
||||||
|
os.close(read)
|
||||||
|
|
||||||
|
if closefd != -1:
|
||||||
|
os.close(closefd)
|
||||||
|
if stdin:
|
||||||
|
os.dup2(stdin, 0)
|
||||||
|
os.close(stdin)
|
||||||
|
if searchPath:
|
||||||
|
os.execvp(command, argv)
|
||||||
|
else:
|
||||||
|
os.execv(command, argv)
|
||||||
|
sys.exit(1)
|
||||||
|
os.close(write)
|
||||||
|
|
||||||
|
rc = ""
|
||||||
|
s = "1"
|
||||||
|
while s:
|
||||||
|
select.select([read], [], [])
|
||||||
|
s = os.read(read, 1000)
|
||||||
|
rc = rc + s
|
||||||
|
|
||||||
|
os.close(read)
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.waitpid(childpid, 0)
|
||||||
|
except OSError, (errno, msg):
|
||||||
|
print __name__, "waitpid:", msg
|
||||||
|
|
||||||
|
return rc
|
@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// Extra modes to include as default modes in the X server.
|
||||||
|
//
|
||||||
|
// Based on Xorg's xc/programs/Xserver/hw/xfree86/etc/extramodes file.
|
||||||
|
// The mode names have been changed to include the refresh rate.
|
||||||
|
//
|
||||||
|
|
||||||
|
# 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz
|
||||||
|
ModeLine "832x624@75" 57.284 832 864 928 1152 624 625 628 667 -Hsync -Vsync
|
||||||
|
|
||||||
|
# 1280x960 @ 60.00 Hz (GTF) hsync: 59.64 kHz; pclk: 102.10 MHz
|
||||||
|
Modeline "1280x960@60" 102.10 1280 1360 1496 1712 960 961 964 994 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1280x960 @ 75.00 Hz (GTF) hsync: 75.15 kHz; pclk: 129.86 MHz
|
||||||
|
Modeline "1280x960@75" 129.86 1280 1368 1504 1728 960 961 964 1002 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1152x768 @ 54.8Hz (Titanium PowerBook) hsync: 44.2kHz
|
||||||
|
ModeLine "1152x768@54" 64.995 1152 1178 1314 1472 768 771 777 806 +hsync +vsync
|
||||||
|
|
||||||
|
# 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz
|
||||||
|
ModeLine "1400x1050@60" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +hsync +vsync
|
||||||
|
|
||||||
|
# 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz
|
||||||
|
ModeLine "1400x1050@75" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +hsync +vsync
|
||||||
|
|
||||||
|
# 1600x1024 @ 60Hz (SGI 1600SW) hsync: 64.0kHz
|
||||||
|
Modeline "1600x1024@60" 106.910 1600 1620 1640 1670 1024 1027 1030 1067 -hsync -vsync
|
||||||
|
|
||||||
|
# 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz
|
||||||
|
Modeline "1920x1440@85" 341.35 1920 2072 2288 2656 1440 1441 1444 1512 -hsync +vsync
|
||||||
|
|
||||||
|
# 2048x1536 @ 60Hz (VESA GTF) hsync: 95.3kHz
|
||||||
|
Modeline "2048x1536@60" 266.95 2048 2200 2424 2800 1536 1537 1540 1589 -hsync +vsync
|
||||||
|
|
||||||
|
# 2048x1536 @ 75Hz (VESA GTF) hsync: 120.2kHz
|
||||||
|
Modeline "2048x1536@75" 340.48 2048 2216 2440 2832 1536 1537 1540 1603 -hsync +vsync
|
||||||
|
|
||||||
|
# 2048x1536 @ 85Hz (VESA GTF) hsync: 137.0kHz
|
||||||
|
Modeline "2048x1536@85" 388.04 2048 2216 2440 2832 1536 1537 1540 1612 -hsync +vsync
|
@ -0,0 +1,297 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# Based on inf2mondb.py from RedHat
|
||||||
|
#
|
||||||
|
# originally by Matt Wilson <msw@redhat.com>
|
||||||
|
# option parsing and database comparison by Fred New
|
||||||
|
# ini parsing completely rewritten by Matt Domsch <Matt_Domsch@dell.com> 2006
|
||||||
|
#
|
||||||
|
# Copyright 2002 Red Hat, Inc.
|
||||||
|
# Copyright 2006 Dell, Inc.
|
||||||
|
# Copyright 2007 Sebastian Heinlein
|
||||||
|
#
|
||||||
|
# This software may be freely redistributed under the terms of the GNU
|
||||||
|
# library public license.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Library Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
"""
|
||||||
|
Provides an importer for Microsoft Windows monitor descriptions
|
||||||
|
|
||||||
|
The code can be used as a python module for or as a script to add new monitor
|
||||||
|
definitions to a monitor database.
|
||||||
|
|
||||||
|
In code example: Read the list of monitors from an inf file.
|
||||||
|
|
||||||
|
import infimport
|
||||||
|
monitors = infimport.get_monitors_from_inf(PATH)
|
||||||
|
|
||||||
|
Script example: To check for monitors of an inf file that are not yet in the database.
|
||||||
|
|
||||||
|
./infimport.py MONITORS.inf /usr/share/hwdata/MonitorsDB
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import string
|
||||||
|
import re
|
||||||
|
import ConfigParser
|
||||||
|
import os
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig()
|
||||||
|
log = logging.getLogger("infimport")
|
||||||
|
#log.setLevel(logging.DEBUG)
|
||||||
|
log.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
# this is a class to deal with various file line endings and leading whitespace
|
||||||
|
# converts all \r line endings to \n.
|
||||||
|
# It also strips leading whitespace.
|
||||||
|
# NOTE: be sure to always return _something_, even if it is just "\n", or we
|
||||||
|
# break the file API. (nothing == eof)
|
||||||
|
class myFile(object):
|
||||||
|
def __init__(self, *args):
|
||||||
|
self.fd = open(*args)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
return self.fd.close()
|
||||||
|
|
||||||
|
def readline(self, *args):
|
||||||
|
line = self.fd.readline(*args)
|
||||||
|
line = line.replace('\r', '\n')
|
||||||
|
line = line.replace('\n\n', '\n')
|
||||||
|
line = line.lstrip(" \t")
|
||||||
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
# we will use this to override default option parsing in ConfigParser to handle
|
||||||
|
# Microsoft-style "INI" files. (Which do not necessarily have " = value " after
|
||||||
|
# the option name
|
||||||
|
OPTCRE = re.compile(
|
||||||
|
r'(?P<option>[^:=\s][^:=]*)' # very permissive!
|
||||||
|
r'\s*(?P<vi>[:=]{0,1})\s*' # any number of space/tab,
|
||||||
|
# optionally followed by
|
||||||
|
# separator (either : or =)
|
||||||
|
# optionally followed
|
||||||
|
# by any # space/tab
|
||||||
|
r'(?P<value>.*)$' # everything up to eol
|
||||||
|
)
|
||||||
|
|
||||||
|
percentSplit = re.compile(r'%(?P<field>.*)%')
|
||||||
|
def _percent_to_string(ini, strings, name):
|
||||||
|
mo = percentSplit.match(name)
|
||||||
|
if (mo):
|
||||||
|
field = mo.group('field')
|
||||||
|
try:
|
||||||
|
val = strings[field.lower()]
|
||||||
|
except KeyError:
|
||||||
|
return ""
|
||||||
|
return val.strip(" '\"")
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def get_monitors_from_database(path):
|
||||||
|
"""Returns a dictonary of the found monitor models in the given
|
||||||
|
monitor models database"""
|
||||||
|
monitors = {}
|
||||||
|
try:
|
||||||
|
mdb = open(path, 'r')
|
||||||
|
except IOError, (errno, str):
|
||||||
|
log.error("Unable to open %s: %s" % (path, str))
|
||||||
|
return {}
|
||||||
|
for line in mdb.readlines():
|
||||||
|
if len(line.strip()) == 0 or line.startswith('#'):
|
||||||
|
continue
|
||||||
|
line_split = line.split(";")
|
||||||
|
vendor = line_split[0].strip()
|
||||||
|
name = line_split[1].strip()
|
||||||
|
id = line_split[2].strip()
|
||||||
|
if monitors.has_key((vendor, name, id)):
|
||||||
|
log.warn("Duplicated entry: %s" % line)
|
||||||
|
else:
|
||||||
|
monitors[(vendor, name, id)] = line
|
||||||
|
mdb.close()
|
||||||
|
return monitors
|
||||||
|
|
||||||
|
def get_monitors_from_inf(path):
|
||||||
|
"""Returns a dictonary of the found monitor models in the given .inf file"""
|
||||||
|
monitors = {}
|
||||||
|
ini = ConfigParser.ConfigParser()
|
||||||
|
# FIXME: perhaps could be done in a nicer way, but __builtins__ is a dict
|
||||||
|
# for imported modules
|
||||||
|
#ini.optionxform = __builtins__.str
|
||||||
|
ini.optionxform = type("")
|
||||||
|
ini.OPTCRE = OPTCRE
|
||||||
|
try:
|
||||||
|
f = myFile(path)
|
||||||
|
ini.readfp(f)
|
||||||
|
f.close()
|
||||||
|
except IOError, (errno, str):
|
||||||
|
log.error("Unable to open %s: %s" % (path, str))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# a dictionary of manufacturers we're looking at
|
||||||
|
manufacturers = {}
|
||||||
|
# a big fat dictionary of strings to use later on.
|
||||||
|
strings = {}
|
||||||
|
|
||||||
|
# This RE is for EISA info lines
|
||||||
|
# %D5259A%=D5259A, Monitor\HWP0487
|
||||||
|
monitor1Re = re.compile(r'.*,.*Monitor\\(?P<id>[^\s]*)')
|
||||||
|
# This one is for legacy entries
|
||||||
|
# %3020% =PB3020, MonID_PB3020
|
||||||
|
monitor2Re = re.compile(r'.*,.*MonID_(?P<id>[^\s]*)')
|
||||||
|
|
||||||
|
for section in ini.sections():
|
||||||
|
if section.lower() == "manufacturer":
|
||||||
|
for mfr in ini.options(section):
|
||||||
|
# generate the vendor.arch funny entries
|
||||||
|
manufacturer_values = string.split(ini.get(section, mfr),
|
||||||
|
',')
|
||||||
|
manufacturers[manufacturer_values[0]] = mfr
|
||||||
|
while len(manufacturer_values) > 1:
|
||||||
|
manufacturers["%s.%s" % (manufacturer_values[0],
|
||||||
|
manufacturer_values[-1])] = mfr
|
||||||
|
manufacturer_values = manufacturer_values[0:-1]
|
||||||
|
|
||||||
|
elif section.lower() == "strings":
|
||||||
|
for key in ini.options(section):
|
||||||
|
strings[key.lower()] = string.strip(ini.get(section, key))
|
||||||
|
|
||||||
|
for mfr in manufacturers.keys():
|
||||||
|
if ini.has_section(mfr):
|
||||||
|
monitor_vendor_name = manufacturers[mfr]
|
||||||
|
for monitor_name in ini.options(mfr):
|
||||||
|
v = ini.get(mfr, monitor_name)
|
||||||
|
v = v.split(',')
|
||||||
|
install_key = v[0].strip()
|
||||||
|
|
||||||
|
line = ini.get(mfr, monitor_name)
|
||||||
|
# Find monitor inf IDs and EISA ids
|
||||||
|
|
||||||
|
edid = "0"
|
||||||
|
mo = monitor1Re.match(line)
|
||||||
|
if mo:
|
||||||
|
edid = mo.group('id')
|
||||||
|
else:
|
||||||
|
mo = monitor2Re.match(line)
|
||||||
|
if mo:
|
||||||
|
edid = mo.group('id').strip()
|
||||||
|
|
||||||
|
#if self.monitors.has_key(edid.lower()):
|
||||||
|
# continue
|
||||||
|
|
||||||
|
if ini.has_section(install_key):
|
||||||
|
line = ini.get(install_key, "AddReg")
|
||||||
|
if line:
|
||||||
|
sline = line.split(',')
|
||||||
|
registry = sline[0]
|
||||||
|
try:
|
||||||
|
resolution = sline[1]
|
||||||
|
except IndexError:
|
||||||
|
resolution = ""
|
||||||
|
try:
|
||||||
|
dpms = sline[2]
|
||||||
|
except IndexError:
|
||||||
|
dpms = ""
|
||||||
|
|
||||||
|
if ini.has_section(registry):
|
||||||
|
for line in ini.options(registry):
|
||||||
|
if string.find(line, 'HKR,"MODES') >= 0:
|
||||||
|
sline = line.split('"')
|
||||||
|
try:
|
||||||
|
syncline = sline[3]
|
||||||
|
except IndexError:
|
||||||
|
syncline = ","
|
||||||
|
syncline = syncline.split(',')
|
||||||
|
hsync = syncline[0].strip()
|
||||||
|
vsync = syncline[1].strip()
|
||||||
|
|
||||||
|
vendor_clear = _percent_to_string(ini,
|
||||||
|
strings, monitor_vendor_name)
|
||||||
|
monitor_clear = _percent_to_string(ini,
|
||||||
|
strings, monitor_name)
|
||||||
|
|
||||||
|
output = "%s; %s; %s; %s; %s" % \
|
||||||
|
(vendor_clear, monitor_clear,
|
||||||
|
edid, hsync, vsync)
|
||||||
|
if dpms.lower().strip() == "dpms":
|
||||||
|
output = output + "; 1"
|
||||||
|
|
||||||
|
if not monitors.has_key((vendor_clear,
|
||||||
|
monitor_clear, edid.lower())):
|
||||||
|
log.debug("added %s" % output)
|
||||||
|
monitors[(vendor_clear,
|
||||||
|
monitor_clear,
|
||||||
|
edid.lower())] = output
|
||||||
|
else:
|
||||||
|
log.warn("duplicated entry %s" % output)
|
||||||
|
return monitors
|
||||||
|
|
||||||
|
def write_monitors_to_file(monitors, path):
|
||||||
|
"""Writes monitors as a monitor models database"""
|
||||||
|
try:
|
||||||
|
if os.path.exists(path):
|
||||||
|
os.remove(path)
|
||||||
|
mdb = open(path, 'w')
|
||||||
|
mdb.writelines(map(lambda l: "%s\n" % l, monitors.values()))
|
||||||
|
mdb.close()
|
||||||
|
except IOError, (errno, str):
|
||||||
|
log.error("Unable to write %s: %s" % (path, str))
|
||||||
|
return False
|
||||||
|
|
||||||
|
def append_monitors_to_file(monitors, path):
|
||||||
|
"""Appends monitors to a monitor models database"""
|
||||||
|
try:
|
||||||
|
if os.path.exists(path):
|
||||||
|
os.remove(path)
|
||||||
|
mdb = open(path, 'a')
|
||||||
|
mdb.writelines(map(lambda l: "%s\n" % l, monitors.values()))
|
||||||
|
mdb.close()
|
||||||
|
except IOError, (errno, str):
|
||||||
|
log.error("Unable to write %s: %s" % (path, str))
|
||||||
|
return False
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from optparse import OptionParser
|
||||||
|
import sys
|
||||||
|
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-a", "--append",
|
||||||
|
action="store_true", dest="append",
|
||||||
|
help="Append new models to the database")
|
||||||
|
parser.add_option("-o", "--output",
|
||||||
|
default=None,
|
||||||
|
action="store", type="string", dest="output",
|
||||||
|
help="Write changes to an alternative file")
|
||||||
|
parser.usage = "%prog [options] INF_FILE [MONITOR_DATABASE]"
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) == 2:
|
||||||
|
# continue with normal operation
|
||||||
|
pass
|
||||||
|
elif len(args) == 1:
|
||||||
|
# jsut print the monitors from the given inf file
|
||||||
|
monitors_inf = get_monitors_from_inf(args[0])
|
||||||
|
for mon in monitors_inf.values():
|
||||||
|
print "%s" % mon
|
||||||
|
sys.exit()
|
||||||
|
else:
|
||||||
|
parser.error("You have to specify an .inf file that contains the "
|
||||||
|
"monitor models that you want to add and a "
|
||||||
|
"monitor model database")
|
||||||
|
|
||||||
|
monitors_inf = get_monitors_from_inf(args[0])
|
||||||
|
monitors_db = get_monitors_from_database(args[1])
|
||||||
|
|
||||||
|
monitors_new = {}
|
||||||
|
for mon in monitors_inf.keys():
|
||||||
|
if not monitors_db.has_key(mon):
|
||||||
|
log.info("New monitor: %s" % monitors_inf[mon])
|
||||||
|
monitors_new[mon] = monitors_inf[mon]
|
||||||
|
|
||||||
|
if options.append:
|
||||||
|
if options.output:
|
||||||
|
append_monitors_to_file(monitors_new, options.output)
|
||||||
|
else:
|
||||||
|
append_monitors_to_file(new_monitors, args[1])
|
@ -0,0 +1,155 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# ktimerdialog.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Mon Jul 26 2004 #
|
||||||
|
# copyright : (C) 2004 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# Based on Hamish Rodda's ktimerdialog.cpp.
|
||||||
|
|
||||||
|
from qt import *
|
||||||
|
from kdecore import *
|
||||||
|
from kdeui import *
|
||||||
|
|
||||||
|
class KTimerDialog(KDialogBase):
|
||||||
|
CountDown = 0
|
||||||
|
CountUp = 1
|
||||||
|
Manual = 2
|
||||||
|
|
||||||
|
def __init__(self, msec, style, parent, name, modal, caption="", \
|
||||||
|
buttonmask=KDialogBase.Ok|KDialogBase.Cancel|KDialogBase.Apply, \
|
||||||
|
defaultbutton=KDialogBase.Cancel, separator=False, \
|
||||||
|
user1=KGuiItem(), user2=KGuiItem(), user3=KGuiItem()):
|
||||||
|
"""Parameters:
|
||||||
|
|
||||||
|
msec - integer, timeout in milliseconds
|
||||||
|
style - TimerStyle object.
|
||||||
|
parent - parent QWidget
|
||||||
|
name - String
|
||||||
|
model - boolean.
|
||||||
|
caption - String
|
||||||
|
buttonmask - integer
|
||||||
|
defaultbutton - ButtonCode
|
||||||
|
separator - boolean
|
||||||
|
user1 - KGuiItem
|
||||||
|
user2 - KGuiItem
|
||||||
|
user3 - KGuiItem
|
||||||
|
"""
|
||||||
|
|
||||||
|
KDialogBase.__init__(self,parent, name, modal, caption, buttonmask, defaultbutton, \
|
||||||
|
separator, user1, user2, user3 )
|
||||||
|
|
||||||
|
self.totaltimer = QTimer(self)
|
||||||
|
self.updatetimer = QTimer(self)
|
||||||
|
self.msectotal = self.msecremaining = msec
|
||||||
|
self.updateinterval = 1000
|
||||||
|
self.tstyle = style
|
||||||
|
|
||||||
|
# default to cancelling the dialog on timeout
|
||||||
|
if buttonmask & self.Cancel:
|
||||||
|
self.buttonontimeout = self.Cancel
|
||||||
|
|
||||||
|
self.connect(self.totaltimer, SIGNAL("timeout()"), self.slotInternalTimeout)
|
||||||
|
self.connect(self.updatetimer, SIGNAL("timeout()"), self.slotUpdateTime)
|
||||||
|
|
||||||
|
# create the widgets
|
||||||
|
self.mainwidget = QVBox(self, "mainWidget")
|
||||||
|
self.timerwidget = QHBox(self.mainwidget, "timerWidget")
|
||||||
|
self.timerlabel = QLabel(self.timerwidget)
|
||||||
|
self.timerprogress = QProgressBar(self.timerwidget)
|
||||||
|
self.timerprogress.setTotalSteps(self.msectotal)
|
||||||
|
self.timerprogress.setPercentageVisible(False)
|
||||||
|
self.setMainWidget(self.mainwidget)
|
||||||
|
self.slotUpdateTime(False)
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
self.msecremaining = self.msectotal
|
||||||
|
self.slotUpdateTime(False)
|
||||||
|
KDialogBase.show(self)
|
||||||
|
self.totaltimer.start(self.msectotal, True)
|
||||||
|
self.updatetimer.start(self.updateinterval, False)
|
||||||
|
|
||||||
|
def exec_loop(self):
|
||||||
|
self.totaltimer.start(self.msectotal, True)
|
||||||
|
self.updatetimer.start(self.updateinterval, False)
|
||||||
|
return KDialogBase.exec_loop(self)
|
||||||
|
|
||||||
|
def setMainWidget(self, newmainwidget):
|
||||||
|
# yuck, here goes.
|
||||||
|
newwidget = QVBox(self)
|
||||||
|
|
||||||
|
if newmainwidget.parentWidget()!=self.mainwidget:
|
||||||
|
newmainwidget.reparent(newwidget, 0, QPoint(0,0))
|
||||||
|
else:
|
||||||
|
newwidget.insertChild(newmainwidget)
|
||||||
|
|
||||||
|
self.timerwidget.reparent(newwidget, 0, QPoint(0, 0))
|
||||||
|
|
||||||
|
self.mainwidget = newwidget
|
||||||
|
KDialogBase.setMainWidget(self, self.mainwidget)
|
||||||
|
|
||||||
|
def setRefreshInterval(self, msec):
|
||||||
|
self.updateinterval = msec;
|
||||||
|
if self.updatetimer.isActive():
|
||||||
|
self.updatetimer.changeInterval(self.updateinterval)
|
||||||
|
|
||||||
|
def timeoutButton(self):
|
||||||
|
return self.buttonontimeout
|
||||||
|
|
||||||
|
def setTimeoutButton(self, newbutton):
|
||||||
|
self.buttonontimeout = newbutton
|
||||||
|
|
||||||
|
def timerStyle(self):
|
||||||
|
return self.tstyle
|
||||||
|
|
||||||
|
def setTimerStyle(self, newstyle):
|
||||||
|
self.tstyle = newstyle
|
||||||
|
|
||||||
|
def slotUpdateTime(self, update=True):
|
||||||
|
if update:
|
||||||
|
if self.tstyle==self.CountDown:
|
||||||
|
self.msecremaining -= self.updateinterval
|
||||||
|
elif self.tstyle==self.CountUp:
|
||||||
|
self.msecremaining += self.updateinterval
|
||||||
|
|
||||||
|
self.timerprogress.setProgress(self.msecremaining)
|
||||||
|
self.timerlabel.setText( i18n("%1 seconds remaining:").arg(self.msecremaining/1000.0) )
|
||||||
|
|
||||||
|
def slotInternalTimeout(self):
|
||||||
|
#self.emit(SIGNAL("timerTimeout()"), () )
|
||||||
|
if self.buttonontimeout==self.Help:
|
||||||
|
self.slotHelp()
|
||||||
|
elif self.buttonontimeout==self.Default:
|
||||||
|
self.slotDefault()
|
||||||
|
elif self.buttonontimeout==self.Ok:
|
||||||
|
self.slotOk()
|
||||||
|
elif self.buttonontimeout==self.Apply:
|
||||||
|
self.applyPressed()
|
||||||
|
elif self.buttonontimeout==self.Try:
|
||||||
|
self.slotTry()
|
||||||
|
elif self.buttonontimeout==self.Cancel:
|
||||||
|
self.slotCancel()
|
||||||
|
elif self.buttonontimeout==self.Close:
|
||||||
|
self.slotClose()
|
||||||
|
#case User1:
|
||||||
|
# slotUser1();
|
||||||
|
#case User2:
|
||||||
|
# slotUser2();
|
||||||
|
# break;
|
||||||
|
elif self.buttonontimeout==self.User3:
|
||||||
|
self.slotUser3()
|
||||||
|
elif self.buttonontimeout==self.No:
|
||||||
|
self.slotNo()
|
||||||
|
elif self.buttonontimeout==self.Yes:
|
||||||
|
self.slotCancel()
|
||||||
|
elif self.buttonontimeout==self.Details:
|
||||||
|
self.slotDetails()
|
@ -0,0 +1,113 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# servertestdialog.py - #
|
||||||
|
# ------------------------------ #
|
||||||
|
# copyright : (C) 2004 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
from qt import * # Just use Qt for this.
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ServerTestDialog(QDialog):
|
||||||
|
def __init__(self):
|
||||||
|
QDialog.__init__(self)
|
||||||
|
|
||||||
|
msec = 10000
|
||||||
|
margin = 4
|
||||||
|
spacing = 4
|
||||||
|
|
||||||
|
self.totaltimer = QTimer(self)
|
||||||
|
self.updatetimer = QTimer(self)
|
||||||
|
self.msectotal = self.msecremaining = msec
|
||||||
|
self.updateinterval = 1000
|
||||||
|
|
||||||
|
self.connect(self.totaltimer, SIGNAL("timeout()"), self.slotInternalTimeout)
|
||||||
|
self.connect(self.updatetimer, SIGNAL("timeout()"), self.slotUpdateTime)
|
||||||
|
|
||||||
|
layout = QHBoxLayout(self)
|
||||||
|
# create the widgets
|
||||||
|
self.mainwidget = QVBox(self, "mainWidget")
|
||||||
|
self.mainwidget.setMargin(margin)
|
||||||
|
self.mainwidget.setSpacing(spacing)
|
||||||
|
|
||||||
|
layout.addWidget(self.mainwidget,1)
|
||||||
|
|
||||||
|
label = QLabel(self.mainwidget)
|
||||||
|
label.setText(i18n("Are these settings acceptable?"))
|
||||||
|
QWidget(self.mainwidget)
|
||||||
|
|
||||||
|
self.timerwidget = QHBox(self.mainwidget, "timerWidget")
|
||||||
|
self.timerlabel = QLabel(self.timerwidget)
|
||||||
|
self.timerprogress = QProgressBar(self.timerwidget)
|
||||||
|
self.timerprogress.setTotalSteps(self.msectotal)
|
||||||
|
self.timerprogress.setPercentageVisible(False)
|
||||||
|
|
||||||
|
hbox = QHBox(self.mainwidget)
|
||||||
|
self.okbutton = QPushButton(i18n("Yes"),hbox)
|
||||||
|
QWidget(hbox)
|
||||||
|
self.cancelbutton = QPushButton(i18n("No"),hbox)
|
||||||
|
self.connect(self.okbutton, SIGNAL("clicked()"), self.slotOk)
|
||||||
|
self.connect(self.cancelbutton, SIGNAL("clicked()"), self.slotCancel)
|
||||||
|
|
||||||
|
self.slotUpdateTime(False)
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
QDialog.show(self)
|
||||||
|
self.totaltimer.start(self.msectotal, True)
|
||||||
|
self.updatetimer.start(self.updateinterval, False)
|
||||||
|
|
||||||
|
def exec_loop(self):
|
||||||
|
self.totaltimer.start(self.msectotal, True)
|
||||||
|
self.updatetimer.start(self.updateinterval, False)
|
||||||
|
return QDialog.exec_loop(self)
|
||||||
|
|
||||||
|
def setRefreshInterval(self, msec):
|
||||||
|
self.updateinterval = msec;
|
||||||
|
if self.updatetimer.isActive():
|
||||||
|
self.updatetimer.changeInterval(self.updateinterval)
|
||||||
|
|
||||||
|
def timeoutButton(self):
|
||||||
|
return self.buttonontimeout
|
||||||
|
|
||||||
|
def setTimeoutButton(self, newbutton):
|
||||||
|
self.buttonontimeout = newbutton
|
||||||
|
|
||||||
|
def slotUpdateTime(self, update=True):
|
||||||
|
self.msecremaining -= self.updateinterval
|
||||||
|
|
||||||
|
self.timerprogress.setProgress(self.msecremaining)
|
||||||
|
self.timerlabel.setText( i18n("Automatically cancelling in %1 seconds:").arg(self.msecremaining/1000.0) )
|
||||||
|
|
||||||
|
def slotInternalTimeout(self):
|
||||||
|
self.reject()
|
||||||
|
|
||||||
|
def slotOk(self):
|
||||||
|
self.accept()
|
||||||
|
|
||||||
|
def slotCancel(self):
|
||||||
|
self.reject()
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
os.environ["DISPLAY"] = ":9"
|
||||||
|
os.environ["XAUTHORITY"] = sys.argv[1]
|
||||||
|
|
||||||
|
# FIXME set the application name / string catalog, for i18n().
|
||||||
|
qapp = QApplication(sys.argv)
|
||||||
|
dialog = ServerTestDialog()
|
||||||
|
dialog.show()
|
||||||
|
dialog.exec_loop()
|
||||||
|
|
||||||
|
if dialog.result()==QDialog.Accepted:
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
sys.exit(1)
|
@ -0,0 +1,110 @@
|
|||||||
|
//
|
||||||
|
// Default modes distilled from
|
||||||
|
// "VESA and Industry Standards and Guide for Computer Display Monitor
|
||||||
|
// Timing", version 1.0, revision 0.8, adopted September 17, 1998.
|
||||||
|
//
|
||||||
|
// Based on Xorg's xc/programs/Xserver/hw/xfree86/etc/vesamodes file.
|
||||||
|
// The mode names have been changed to include the refresh rate.
|
||||||
|
|
||||||
|
|
||||||
|
# 640x350 @ 85Hz (VESA) hsync: 37.9kHz
|
||||||
|
ModeLine "640x350@85" 31.5 640 672 736 832 350 382 385 445 +hsync -vsync
|
||||||
|
|
||||||
|
# 640x400 @ 85Hz (VESA) hsync: 37.9kHz
|
||||||
|
ModeLine "640x400@85" 31.5 640 672 736 832 400 401 404 445 -hsync +vsync
|
||||||
|
|
||||||
|
# 720x400 @ 85Hz (VESA) hsync: 37.9kHz
|
||||||
|
ModeLine "720x400@85" 35.5 720 756 828 936 400 401 404 446 -hsync +vsync
|
||||||
|
|
||||||
|
# 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz
|
||||||
|
ModeLine "640x480@60" 25.2 640 656 752 800 480 490 492 525 -hsync -vsync
|
||||||
|
|
||||||
|
# 640x480 @ 72Hz (VESA) hsync: 37.9kHz
|
||||||
|
ModeLine "640x480@72" 31.5 640 664 704 832 480 489 491 520 -hsync -vsync
|
||||||
|
|
||||||
|
# 640x480 @ 75Hz (VESA) hsync: 37.5kHz
|
||||||
|
ModeLine "640x480@75" 31.5 640 656 720 840 480 481 484 500 -hsync -vsync
|
||||||
|
|
||||||
|
# 640x480 @ 85Hz (VESA) hsync: 43.3kHz
|
||||||
|
ModeLine "640x480@85" 36.0 640 696 752 832 480 481 484 509 -hsync -vsync
|
||||||
|
|
||||||
|
# 800x600 @ 56Hz (VESA) hsync: 35.2kHz
|
||||||
|
ModeLine "800x600@56" 36.0 800 824 896 1024 600 601 603 625 +hsync +vsync
|
||||||
|
|
||||||
|
# 800x600 @ 60Hz (VESA) hsync: 37.9kHz
|
||||||
|
ModeLine "800x600@60" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync
|
||||||
|
|
||||||
|
# 800x600 @ 72Hz (VESA) hsync: 48.1kHz
|
||||||
|
ModeLine "800x600@72" 50.0 800 856 976 1040 600 637 643 666 +hsync +vsync
|
||||||
|
|
||||||
|
# 800x600 @ 75Hz (VESA) hsync: 46.9kHz
|
||||||
|
ModeLine "800x600@75" 49.5 800 816 896 1056 600 601 604 625 +hsync +vsync
|
||||||
|
|
||||||
|
# 800x600 @ 85Hz (VESA) hsync: 53.7kHz
|
||||||
|
ModeLine "800x600@85" 56.3 800 832 896 1048 600 601 604 631 +hsync +vsync
|
||||||
|
|
||||||
|
# 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz
|
||||||
|
ModeLine "1024x768@43" 44.9 1024 1032 1208 1264 768 768 776 817 +hsync +vsync Interlace
|
||||||
|
|
||||||
|
# 1024x768 @ 60Hz (VESA) hsync: 48.4kHz
|
||||||
|
ModeLine "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -hsync -vsync
|
||||||
|
|
||||||
|
# 1024x768 @ 70Hz (VESA) hsync: 56.5kHz
|
||||||
|
ModeLine "1024x768@70" 75.0 1024 1048 1184 1328 768 771 777 806 -hsync -vsync
|
||||||
|
|
||||||
|
# 1024x768 @ 75Hz (VESA) hsync: 60.0kHz
|
||||||
|
ModeLine "1024x768@75" 78.8 1024 1040 1136 1312 768 769 772 800 +hsync +vsync
|
||||||
|
|
||||||
|
# 1024x768 @ 85Hz (VESA) hsync: 68.7kHz
|
||||||
|
ModeLine "1024x768@85" 94.5 1024 1072 1168 1376 768 769 772 808 +hsync +vsync
|
||||||
|
|
||||||
|
# 1152x864 @ 75Hz (VESA) hsync: 67.5kHz
|
||||||
|
ModeLine "1152x864@75" 108.0 1152 1216 1344 1600 864 865 868 900 +hsync +vsync
|
||||||
|
|
||||||
|
# 1280x960 @ 60Hz (VESA) hsync: 60.0kHz
|
||||||
|
ModeLine "1280x960@60" 108.0 1280 1376 1488 1800 960 961 964 1000 +hsync +vsync
|
||||||
|
|
||||||
|
# 1280x960 @ 85Hz (VESA) hsync: 85.9kHz
|
||||||
|
ModeLine "1280x960@85" 148.5 1280 1344 1504 1728 960 961 964 1011 +hsync +vsync
|
||||||
|
|
||||||
|
# 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz
|
||||||
|
ModeLine "1280x1024@60" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync
|
||||||
|
|
||||||
|
# 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz
|
||||||
|
ModeLine "1280x1024@75" 135.0 1280 1296 1440 1688 1024 1025 1028 1066 +hsync +vsync
|
||||||
|
|
||||||
|
# 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz
|
||||||
|
ModeLine "1280x1024@85" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +hsync +vsync
|
||||||
|
|
||||||
|
# 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz
|
||||||
|
ModeLine "1600x1200@60" 162.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
|
||||||
|
|
||||||
|
# 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz
|
||||||
|
ModeLine "1600x1200@65" 175.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
|
||||||
|
|
||||||
|
# 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz
|
||||||
|
ModeLine "1600x1200@70" 189.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
|
||||||
|
|
||||||
|
# 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz
|
||||||
|
ModeLine "1600x1200@75" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
|
||||||
|
|
||||||
|
# 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz
|
||||||
|
ModeLine "1600x1200@85" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
|
||||||
|
|
||||||
|
# 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz
|
||||||
|
ModeLine "1792x1344@60" 204.8 1792 1920 2120 2448 1344 1345 1348 1394 -hsync +vsync
|
||||||
|
|
||||||
|
# 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz
|
||||||
|
ModeLine "1792x1344@75" 261.0 1792 1888 2104 2456 1344 1345 1348 1417 -hsync +vsync
|
||||||
|
|
||||||
|
# 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz
|
||||||
|
ModeLine "1856x1392@60" 218.3 1856 1952 2176 2528 1392 1393 1396 1439 -hsync +vsync
|
||||||
|
|
||||||
|
# 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz
|
||||||
|
ModeLine "1856x1392@75" 288.0 1856 1984 2208 2560 1392 1393 1396 1500 -hsync +vsync
|
||||||
|
|
||||||
|
# 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz
|
||||||
|
ModeLine "1920x1440@60" 234.0 1920 2048 2256 2600 1440 1441 1444 1500 -hsync +vsync
|
||||||
|
|
||||||
|
# 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz
|
||||||
|
ModeLine "1920x1440@75" 297.0 1920 2064 2288 2640 1440 1441 1444 1500 -hsync +vsync
|
@ -0,0 +1,66 @@
|
|||||||
|
//
|
||||||
|
// Extra widescreen modes
|
||||||
|
//
|
||||||
|
|
||||||
|
# 1280x720 @ 50.00 Hz (GTF) hsync: 37.05 kHz; pclk: 60.47 MHz
|
||||||
|
Modeline "1280x720@50" 60.47 1280 1328 1456 1632 720 721 724 741 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1280x720 @ 60.00 Hz (GTF) hsync: 44.76 kHz; pclk: 74.48 MHz
|
||||||
|
Modeline "1280x720@60" 74.48 1280 1336 1472 1664 720 721 724 746 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1280x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 80.14 MHz
|
||||||
|
Modeline "1280x768@60" 80.14 1280 1344 1480 1680 768 769 772 795 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1280x768 @ 75.00 Hz (GTF) hsync: 60.15 kHz; pclk: 102.98 MHz
|
||||||
|
Modeline "1280x768@75" 102.98 1280 1360 1496 1712 768 769 772 802 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1280x800 @ 60.00 Hz (GTF) hsync: 49.68 kHz; pclk: 83.46 MHz
|
||||||
|
Modeline "1280x800@60" 83.46 1280 1344 1480 1680 800 801 804 828 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1280x800 @ 75.00 Hz (GTF) hsync: 62.62 kHz; pclk: 107.21 MHz
|
||||||
|
Modeline "1280x800@75" 107.21 1280 1360 1496 1712 800 801 804 835 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1440x900 @ 60.00 Hz (GTF) hsync: 55.92 kHz; pclk: 106.47 MHz
|
||||||
|
Modeline "1440x900@60" 106.47 1440 1520 1672 1904 900 901 904 932 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1440x900 @ 75.00 Hz (GTF) hsync: 70.50 kHz; pclk: 136.49 MHz
|
||||||
|
Modeline "1440x900@75" 136.49 1440 1536 1688 1936 900 901 904 940 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1400x1050 @ 60.00 Hz (GTF) hsync: 65.22 kHz; pclk: 122.61 MHz
|
||||||
|
Modeline "1400x1050@60" 122.61 1400 1488 1640 1880 1050 1051 1054 1087 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1400x1050 @ 75.00 Hz (GTF) hsync: 82.20 kHz; pclk: 155.85 MHz
|
||||||
|
Modeline "1400x1050@75" 155.85 1400 1496 1648 1896 1050 1051 1054 1096 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1600x1024 @ 60.00 Hz (GTF) hsync: 63.60 kHz; pclk: 136.36 MHz
|
||||||
|
Modeline "1600x1024@60" 136.36 1600 1704 1872 2144 1024 1025 1028 1060 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1680x1050 @ 60.00 Hz (GTF) hsync: 65.22 kHz; pclk: 147.14 MHz
|
||||||
|
Modeline "1680x1050@60" 147.14 1680 1784 1968 2256 1050 1051 1054 1087 -HSync +Vsync
|
||||||
|
|
||||||
|
#Modeline "1680x1050@60" 154.20 1680 1712 2296 2328 1050 1071 1081 1103
|
||||||
|
|
||||||
|
# 1680x1050 @ 75.00 Hz (GTF) hsync: 82.20 kHz; pclk: 188.07 MHz
|
||||||
|
Modeline "1680x1050@75" 188.07 1680 1800 1984 2288 1050 1051 1054 1096 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1920x1200 @ 60.00 Hz (GTF) hsync: 74.52 kHz; pclk: 193.16 MHz
|
||||||
|
Modeline "1920x1200@60" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync
|
||||||
|
|
||||||
|
# 1920x1200 @ 75.00 Hz (GTF) hsync: 93.97 kHz; pclk: 246.59 MHz
|
||||||
|
Modeline "1920x1200@75" 246.59 1920 2064 2272 2624 1200 1201 1204 1253 -HSync +Vsync
|
||||||
|
|
||||||
|
# 2560x1600 @ 60.00 Hz (GTF) hsync: 99.36 kHz; pclk: 348.16 MHz
|
||||||
|
Modeline "2560x1600@60" 348.16 2560 2752 3032 3504 1600 1601 1604 1656 -HSync +Vsync
|
||||||
|
|
||||||
|
# 2560x1600 @ 75.00 Hz (GTF) hsync: 125.25 kHz; pclk: 442.88 MHz
|
||||||
|
Modeline "2560x1600@75" 442.88 2560 2768 3048 3536 1600 1601 1604 1670 -HSync +Vsync
|
||||||
|
|
||||||
|
|
||||||
|
# 3200x2048 @ 60.00 Hz (GTF) hsync: 127.14 kHz; pclk: 561.45 MHz
|
||||||
|
Modeline "3200x2048@60" 561.45 3200 3456 3808 4416 2048 2049 2052 2119 -HSync +Vsync
|
||||||
|
|
||||||
|
# 3200x2048 @ 75.00 Hz (GTF) hsync: 160.27 kHz; pclk: 712.90 MHz
|
||||||
|
Modeline "3200x2048@75" 712.90 3200 3472 3824 4448 2048 2049 2052 2137 -HSync +Vsync
|
||||||
|
|
||||||
|
# Powerbook G4 1280x854
|
||||||
|
Modeline "1280x854" 80 1280 1309 1460 1636 854 857 864 896 +HSync +VSync
|
@ -0,0 +1,15 @@
|
|||||||
|
import xorgconfig
|
||||||
|
|
||||||
|
xconfig = xorgconfig.readConfig("/etc/X11/xorg.conf")
|
||||||
|
|
||||||
|
for screensection in xconfig.getSections("screen"):
|
||||||
|
print screensection.identifier
|
||||||
|
print screensection.option
|
||||||
|
|
||||||
|
for screensection in xconfig.getSections("device"):
|
||||||
|
print screensection.option
|
||||||
|
print screensection.option[1]
|
||||||
|
print screensection.option[2]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,903 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# xorgconfig.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Wed Feb 9 2004 #
|
||||||
|
# copyright : (C) 2005 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
import csv
|
||||||
|
import codecs
|
||||||
|
import locale
|
||||||
|
"""
|
||||||
|
General usage:
|
||||||
|
|
||||||
|
import xorgconfig
|
||||||
|
config = readConfig("/etc/X11/xorg.conf")
|
||||||
|
|
||||||
|
input_devices = config.getSections("InputDevice")
|
||||||
|
print input_devices[0].driver
|
||||||
|
options = input_devices[0].options
|
||||||
|
for option in options:
|
||||||
|
# option is of type OptionLine.
|
||||||
|
print option._row[0],
|
||||||
|
if len(option._row)>=2:
|
||||||
|
print "=>",option._row[1]
|
||||||
|
|
||||||
|
# Add line: Option "XkbModel" "pc105"
|
||||||
|
options.append( options.makeLine("Comment text",["XkbModel" "pc105"]) )
|
||||||
|
|
||||||
|
|
||||||
|
Refactor plan
|
||||||
|
=============
|
||||||
|
New usage:
|
||||||
|
|
||||||
|
import xorgconfig
|
||||||
|
config = readConfig("/etc/X11/xorg.conf")
|
||||||
|
|
||||||
|
input_devices = config.section.InputDevice
|
||||||
|
print input_devices[0].driver
|
||||||
|
options = input_devices[0].options
|
||||||
|
for option in options:
|
||||||
|
# option is of type OptionLine.
|
||||||
|
print option[1],
|
||||||
|
if len(option)>=3:
|
||||||
|
print "=>",option[2]
|
||||||
|
|
||||||
|
module_section = config.section.module[0]
|
||||||
|
module_section.append(["load","i2c"])
|
||||||
|
assert module_section.existsLoad("i2c")
|
||||||
|
module_section.removeLoad("i2c")
|
||||||
|
|
||||||
|
device_section = config.section.device[0]
|
||||||
|
if device_section.busid is not None:
|
||||||
|
print "Found busid:",device_section.busid
|
||||||
|
|
||||||
|
* direct references to myline._row should be removed.
|
||||||
|
* A ConfigLine should be a subclass of List. With line[i] accessing the
|
||||||
|
parts of the line.
|
||||||
|
* the order of the makeLine() parameters should be reversed.
|
||||||
|
* it should be possible to directly append a list or tuple that represents
|
||||||
|
a line to a section.
|
||||||
|
"""
|
||||||
|
############################################################################
|
||||||
|
class ConfigLine(object):
|
||||||
|
"""Represents one line from the Xorg.conf file.
|
||||||
|
|
||||||
|
Each part of the line is printed without quotes.
|
||||||
|
"""
|
||||||
|
def __init__(self,comment,row):
|
||||||
|
self._row = [item for item in row if item!='']
|
||||||
|
self._comment = comment
|
||||||
|
|
||||||
|
def toString(self,depth=0):
|
||||||
|
caprow = self._row
|
||||||
|
if len(caprow) > 0:
|
||||||
|
caprow[0] = caprow[0].capitalize()
|
||||||
|
string = ('\t' * (depth/2)) + ' ' * (depth%1) + '\t'.join([unicode(item) for item in caprow])
|
||||||
|
if self._comment is not None:
|
||||||
|
string += '#' + self._comment
|
||||||
|
return string + '\n'
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ConfigLineQuote(ConfigLine):
|
||||||
|
"""Represents one line from the Xorg.conf file.
|
||||||
|
|
||||||
|
The first item in the line is not quoted, but the remaining items are.
|
||||||
|
"""
|
||||||
|
def toString(self,depth=0):
|
||||||
|
string = ('\t' * (depth/2) + ' ' * (depth%1))
|
||||||
|
if len(self._row)!=0:
|
||||||
|
string += self._row[0].capitalize()
|
||||||
|
if len(self._row)>1:
|
||||||
|
if len(self._row[0]) < 8:
|
||||||
|
string += '\t'
|
||||||
|
string += '\t"' + '"\t"'.join([unicode(item) for item in self._row[1:]]) + '"'
|
||||||
|
if self._comment is not None:
|
||||||
|
string += '#' + self._comment
|
||||||
|
return string + '\n'
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class OptionLine(ConfigLineQuote):
|
||||||
|
def __init__(self,comment,row):
|
||||||
|
arg = ['option']
|
||||||
|
arg.extend(row)
|
||||||
|
ConfigLineQuote.__init__(self,comment,arg)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ConfigList(list):
|
||||||
|
def toString(self,depth=0):
|
||||||
|
string = ""
|
||||||
|
for item in self:
|
||||||
|
string += item.toString(depth)
|
||||||
|
return string
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class OptionList(ConfigList):
|
||||||
|
name = "option"
|
||||||
|
def __setitem__(self,key,value):
|
||||||
|
list.__setitem__(self,key,value)
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return OptionLine(comment,row)
|
||||||
|
|
||||||
|
def appendOptionRow(self,row):
|
||||||
|
self.append(self.makeLine(None,row))
|
||||||
|
|
||||||
|
def removeOptionByName(self,name):
|
||||||
|
name = name.lower()
|
||||||
|
i = 0
|
||||||
|
while i < len(self):
|
||||||
|
if self[i]._row[1].lower()==name:
|
||||||
|
del self[i]
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
def getOptionByName(self,name):
|
||||||
|
name = name.lower()
|
||||||
|
for item in self:
|
||||||
|
try:
|
||||||
|
if item._row[1].lower()==name:
|
||||||
|
return item
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ScreenConfigLine(ConfigLine):
|
||||||
|
def __init__(self,comment,row):
|
||||||
|
arg = ["screen"]
|
||||||
|
arg.extend(row)
|
||||||
|
ConfigLine.__init__(self,comment,arg)
|
||||||
|
|
||||||
|
def toString(self,depth=0):
|
||||||
|
string = (' ' * depth)
|
||||||
|
|
||||||
|
try: # Keep on building up the string until the IndexError is thrown.
|
||||||
|
string += self._row[0]
|
||||||
|
i = 1
|
||||||
|
if self._row[i].isdigit():
|
||||||
|
string += ' ' + self._row[i]
|
||||||
|
i += 1
|
||||||
|
string += ' "' + self._row[i] + '"'
|
||||||
|
i += 1
|
||||||
|
while True:
|
||||||
|
item = self._row[i].lower()
|
||||||
|
if item in ['rightof','leftof','above','below']:
|
||||||
|
string += ' %s "%s"' % (item, self._row[i+1])
|
||||||
|
i += 1
|
||||||
|
elif item=='absolute':
|
||||||
|
string += ' %s %d %d' % (item, self._row[i+1], self._row[i+2])
|
||||||
|
i += 2
|
||||||
|
elif item.isdigit():
|
||||||
|
i += 1
|
||||||
|
string += ' %s %s' % (item,self._row[i])
|
||||||
|
i += 1
|
||||||
|
except IndexError: pass
|
||||||
|
|
||||||
|
if self._comment is not None:
|
||||||
|
string += ' #' + self._comment
|
||||||
|
return string + '\n'
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ScreenConfigList(ConfigList):
|
||||||
|
name = "screen"
|
||||||
|
def __setitem__(self,key,value):
|
||||||
|
list.__setitem__(self,key,value)
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return ScreenConfigLine(comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ConfigContainer(object):
|
||||||
|
"""Acts as a container for ConfigLines and other ConfigContainers.
|
||||||
|
Is used for representing things like the whole config file, sections
|
||||||
|
and subsections inside the file.
|
||||||
|
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
self._contents = []
|
||||||
|
|
||||||
|
def append(self,item):
|
||||||
|
assert (item is not None)
|
||||||
|
self._contents.append(item)
|
||||||
|
|
||||||
|
def remove(self,item):
|
||||||
|
self._contents.remove(item)
|
||||||
|
|
||||||
|
def toString(self,depth=0):
|
||||||
|
string = ''
|
||||||
|
for item in self._contents:
|
||||||
|
string += item.toString(depth+1)
|
||||||
|
return string
|
||||||
|
|
||||||
|
def makeSection(self,comment,row):
|
||||||
|
return Section(comment,row)
|
||||||
|
|
||||||
|
def isSection(self,name):
|
||||||
|
lname = name.lower()
|
||||||
|
return lname=='section'
|
||||||
|
|
||||||
|
def isEndSection(self,name):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return ConfigLine(comment,row)
|
||||||
|
|
||||||
|
def isListAttr(self,name):
|
||||||
|
lname = name.lower()
|
||||||
|
return lname in self._listattr
|
||||||
|
|
||||||
|
def makeListAttr(self,comment,row):
|
||||||
|
listobj = self.__getattr__(row[0].lower())
|
||||||
|
listobj.append( listobj.makeLine(comment,row[1:]) )
|
||||||
|
|
||||||
|
def getSections(self,name):
|
||||||
|
"""Get all sections having the given name.
|
||||||
|
|
||||||
|
Returns a list of ConfigContainer objects.
|
||||||
|
"""
|
||||||
|
name = name.lower()
|
||||||
|
sections = []
|
||||||
|
for item in self._contents:
|
||||||
|
try:
|
||||||
|
if isinstance(item,ConfigContainer) and item._name.lower()==name:
|
||||||
|
sections.append(item)
|
||||||
|
except IndexError: pass
|
||||||
|
return sections
|
||||||
|
|
||||||
|
def __getattr__(self,name):
|
||||||
|
if not name.startswith("_"):
|
||||||
|
lname = name.lower()
|
||||||
|
if lname in self._listattr:
|
||||||
|
# Lookup list attributes.
|
||||||
|
for item in self._contents:
|
||||||
|
if isinstance(item,ConfigList) and item.name==lname:
|
||||||
|
return item
|
||||||
|
else:
|
||||||
|
listitem = self._listattr[lname]()
|
||||||
|
self._contents.append(listitem)
|
||||||
|
return listitem
|
||||||
|
else:
|
||||||
|
for item in self._contents:
|
||||||
|
try:
|
||||||
|
if isinstance(item,ConfigLine) and item._row[0].lower()==lname:
|
||||||
|
return item._row[1]
|
||||||
|
except IndexError: pass
|
||||||
|
if lname in self._attr or lname in self._quoteattr:
|
||||||
|
return None
|
||||||
|
raise AttributeError, name
|
||||||
|
|
||||||
|
def __setattr__(self,name,value):
|
||||||
|
if name.startswith('_'):
|
||||||
|
return super(ConfigContainer,self).__setattr__(name,value)
|
||||||
|
|
||||||
|
lname = name.lower()
|
||||||
|
for item in self._contents:
|
||||||
|
try:
|
||||||
|
if isinstance(item,ConfigLine) and item._row[0].lower()==lname:
|
||||||
|
item._row[1] = value
|
||||||
|
break
|
||||||
|
except IndexError: pass
|
||||||
|
else:
|
||||||
|
if lname in self._attr or lname in self._quoteattr:
|
||||||
|
line = self.makeLine(None,[name,value])
|
||||||
|
self.append(line)
|
||||||
|
else:
|
||||||
|
raise AttributeError, name
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._contents = []
|
||||||
|
|
||||||
|
def getRow(self,name):
|
||||||
|
if not name.startswith("_"):
|
||||||
|
lname = name.lower()
|
||||||
|
for item in self._contents:
|
||||||
|
try:
|
||||||
|
if isinstance(item,ConfigLine) and item._row[0].lower()==lname:
|
||||||
|
return item._row[1:]
|
||||||
|
except IndexError: pass
|
||||||
|
|
||||||
|
if name in self._attr or name in self._quoteattr:
|
||||||
|
# is a valid name, just has no real value right now.
|
||||||
|
return None
|
||||||
|
|
||||||
|
raise AttributeError, name
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class Section(ConfigContainer):
|
||||||
|
"""Represents a Section in the config file.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# List of config line types allowed inside this section.
|
||||||
|
# A list of strings naming lines that need to be stored in ConfigLine objects.
|
||||||
|
_attr = []
|
||||||
|
|
||||||
|
# A list of strings naming the lines that need to be stored in ConfigLineQuote objects.
|
||||||
|
# This is often overridden in subclasses.
|
||||||
|
_quoteattr = []
|
||||||
|
|
||||||
|
_listattr = {}
|
||||||
|
|
||||||
|
def __init__(self,comment,row):
|
||||||
|
ConfigContainer.__init__(self)
|
||||||
|
self._name = row[1]
|
||||||
|
self._comment = comment
|
||||||
|
|
||||||
|
def __show__(self):
|
||||||
|
""" For debugging """
|
||||||
|
for a in self._attr:
|
||||||
|
print self._name, "Attribute:", a
|
||||||
|
for a in self._quoteattr:
|
||||||
|
print self._name, "QuoteAttribute:", a
|
||||||
|
for a in self._listattr:
|
||||||
|
print self._name, "ListAttr:", a
|
||||||
|
|
||||||
|
def isSection(self,name):
|
||||||
|
return name.lower()=='subsection'
|
||||||
|
|
||||||
|
def isEndSection(self,name):
|
||||||
|
return name.lower()=='endsection'
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
try:
|
||||||
|
lname = row[0].lower()
|
||||||
|
if lname in self._quoteattr:
|
||||||
|
return ConfigLineQuote(comment,row)
|
||||||
|
if lname in self._attr:
|
||||||
|
return ConfigLine(comment,row)
|
||||||
|
return None
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return ConfigContainer.makeLine(self,comment,row)
|
||||||
|
|
||||||
|
def toString(self,depth=0):
|
||||||
|
if self._comment is None:
|
||||||
|
return '%sSection "%s"\n%s%sEndSection\n' % \
|
||||||
|
(' ' * depth, self._name, ConfigContainer.toString(self,depth+1), ' ' * depth)
|
||||||
|
else:
|
||||||
|
return '%sSection "%s" # %s\n%s%sEndSection\n' % \
|
||||||
|
(' ' * depth, self._name, self._comment, ConfigContainer.toString(self,depth+1), ' ' * depth)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class SubSection(Section):
|
||||||
|
def isSection(self,name):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def isEndSection(self,name):
|
||||||
|
return name.lower()=='endsubsection'
|
||||||
|
|
||||||
|
def toString(self,depth=0):
|
||||||
|
return '%sSubSection "%s"\n%s%sEndSubSection\n' % \
|
||||||
|
('\t' * (depth/2) + ' ' * (depth%1), self._name, ConfigContainer.toString(self,depth+1), '\t' * (depth/2) + ' ' * (depth%1))
|
||||||
|
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class DeviceSection(Section):
|
||||||
|
_attr = ["endsection","dacspeed","clocks","videoram","biosbase","membase", \
|
||||||
|
"iobase","chipid","chiprev","textclockfreq","irq","screen"]
|
||||||
|
|
||||||
|
_quoteattr = ["identifier","vendorname","boardname","chipset","ramdac", \
|
||||||
|
"clockchip","card","driver","busid"]
|
||||||
|
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class DriSection(Section):
|
||||||
|
_attr = ["group","buffers","mode"]
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
try:
|
||||||
|
lname = row[0].lower()
|
||||||
|
if lname=="group" and not row[1].isdigit():
|
||||||
|
return ConfigLineQuote(comment,row)
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return Section.makeLine(self,comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ExtensionsSection(Section):
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class FilesSection(Section):
|
||||||
|
_quoteattr = ["fontpath","rgbpath","modulepath","inputdevices","logfile"]
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return ConfigLineQuote(comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModuleSection(Section):
|
||||||
|
_quoteattr = ["load","loaddriver","disable"]
|
||||||
|
|
||||||
|
def makeSection(self,comment,row):
|
||||||
|
return ModuleSubSection(comment,row)
|
||||||
|
|
||||||
|
def allowModule(self,modname):
|
||||||
|
killlist = []
|
||||||
|
for item in self._contents:
|
||||||
|
try:
|
||||||
|
if isinstance(item,ConfigLineQuote) \
|
||||||
|
and item._row[0].lower()=='disable' \
|
||||||
|
and item._row[1]==modname:
|
||||||
|
killlist.append(item)
|
||||||
|
except IndexError: pass
|
||||||
|
|
||||||
|
for item in killlist:
|
||||||
|
self._contents.remove(item)
|
||||||
|
|
||||||
|
def removeModule(self,modname):
|
||||||
|
killlist = []
|
||||||
|
for item in self._contents:
|
||||||
|
try:
|
||||||
|
if isinstance(item,ConfigLineQuote) \
|
||||||
|
and item._row[0].lower()=='load' \
|
||||||
|
and item._row[1]==modname:
|
||||||
|
killlist.append(item)
|
||||||
|
except IndexError: pass
|
||||||
|
|
||||||
|
for item in killlist:
|
||||||
|
self._contents.remove(item)
|
||||||
|
|
||||||
|
def disableModule(self,modname):
|
||||||
|
self.removeModule(modname)
|
||||||
|
self._contents.append(ConfigLineQuote(None,['disable',modname]))
|
||||||
|
|
||||||
|
def addModule(self,modname):
|
||||||
|
self.removeModule(modname)
|
||||||
|
self._contents.append(ConfigLineQuote(None,['load',modname]))
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModuleSubSection(SubSection):
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModeSection(Section):
|
||||||
|
_attr = ["dotclock","htimings","vtimings","hskew","bcast","vscan"]
|
||||||
|
_quoteattr = ["flags"]
|
||||||
|
|
||||||
|
def __init__(self,comment,row):
|
||||||
|
Section.__init__(self,comment,row)
|
||||||
|
self._name = row[1]
|
||||||
|
|
||||||
|
def isEndSection(self,name):
|
||||||
|
return name.lower()=='endmode'
|
||||||
|
|
||||||
|
def toString(self,depth=0):
|
||||||
|
if self._comment is None:
|
||||||
|
return '%sMode "%s"\n%s%sEndMode\n' % \
|
||||||
|
(' ' * depth, self._name, ConfigContainer.toString(self,depth+1), ' ' * depth)
|
||||||
|
else:
|
||||||
|
return '%sMode "%s" # %s\n%s%sEndMode\n' % \
|
||||||
|
(' ' * depth, self._name, self._comment, ConfigContainer.toString(self,depth+1), ' ' * depth)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModeList(ConfigList):
|
||||||
|
name = "mode"
|
||||||
|
def __setitem__(self,key,value):
|
||||||
|
list.__setitem__(self,key,value)
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return ModeLine(comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModeLineList(ConfigList):
|
||||||
|
name = "modeline"
|
||||||
|
def __setitem__(self,key,value):
|
||||||
|
list.__setitem__(self,key,value)
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return ModeLineConfigLine(comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class MonitorSection(Section):
|
||||||
|
_attr = ["displaysize","horizsync","vertrefresh","gamma"]
|
||||||
|
_quoteattr = ["identifier","vendorname","modelname","usemodes"]
|
||||||
|
_listattr = {"option" : OptionList, "mode" : ModeList, "modeline" : ModeLineList}
|
||||||
|
|
||||||
|
def makeLine(self,comment,row):
|
||||||
|
return Section.makeLine(self,comment,row)
|
||||||
|
|
||||||
|
def isSection(self,name):
|
||||||
|
lname = name.lower()
|
||||||
|
return lname=='mode'
|
||||||
|
|
||||||
|
def isEndSection(self,name):
|
||||||
|
return name.lower()=='endsection'
|
||||||
|
|
||||||
|
def makeSection(self,comment,row):
|
||||||
|
if row[0].lower()=='mode':
|
||||||
|
return ModeSection(comment,row)
|
||||||
|
else:
|
||||||
|
return Section.makeSection(self,comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModeLineConfigLine(ConfigLine):
|
||||||
|
def toString(self,depth=0):
|
||||||
|
string = (' ' * depth)+"modeline "
|
||||||
|
if len(self._row)>0:
|
||||||
|
string += ' "' + self._row[0] + '"'
|
||||||
|
if len(self._row)>1:
|
||||||
|
string += ' ' + ' '.join([unicode(item) for item in self._row[1:]])
|
||||||
|
if self._comment is not None:
|
||||||
|
string += '#' + self._comment
|
||||||
|
return string + '\n'
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ModesSection(MonitorSection):
|
||||||
|
# Like a MonitorSection, only smaller.
|
||||||
|
_attr = ["modeline"]
|
||||||
|
_quoteattr = ["identifier"]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class PointerSection(Section):
|
||||||
|
_attr = ["emulate3timeout","baudrate","samplerate","resolution",\
|
||||||
|
"devicename","buttons"]
|
||||||
|
_quoteattr = ["protocol","device","port","emulate3buttons","chordmiddle",\
|
||||||
|
"cleardtr","clearrts","zaxismapping","alwayscore"]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ScreenSection(Section):
|
||||||
|
_attr = ["screenno","defaultcolordepth","defaultdepth","defaultbpp","defaultfbbpp"]
|
||||||
|
_quoteattr = ["identifier","driver","device","monitor","videoadaptor","option"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
def makeSection(self,comment,row):
|
||||||
|
if row[1].lower()=='display':
|
||||||
|
return DisplaySubSection(comment,row)
|
||||||
|
return SubSection(comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class DisplaySubSection(SubSection):
|
||||||
|
_attr = ["viewport","virtual","black","white","depth","fbbpp","weight"]
|
||||||
|
_quoteattr = ["modes","visual","option"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
############################################################################
|
||||||
|
class ServerFlagsSection(Section):
|
||||||
|
_quoteattr = ["notrapsignals","dontzap","dontzoom","disablevidmodeextension",\
|
||||||
|
"allownonlocalxvidtune","disablemodindev","allownonlocalmodindev","allowmouseopenfail", \
|
||||||
|
"blanktime","standbytime","suspendtime","offtime","defaultserverlayout"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ServerLayoutSection(Section):
|
||||||
|
_attr = []
|
||||||
|
_quoteattr = ["identifier","inactive","inputdevice","option"]
|
||||||
|
_listattr = {"option" : OptionList, "screen" : ScreenConfigList}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class InputDeviceSection(Section):
|
||||||
|
_quoteattr = ["identifier","driver"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
############################################################################
|
||||||
|
class KeyboardSection(Section):
|
||||||
|
_attr = ["autorepeat","xleds"]
|
||||||
|
_quoteattr = ["protocol","panix106","xkbkeymap","xkbcompat","xkbtypes",\
|
||||||
|
"xkbkeycodes","xkbgeometry","xkbsymbols","xkbdisable","xkbrules",\
|
||||||
|
"xkbmodel","xkblayout","xkbvariant","xkboptions","vtinit","vtsysreq",\
|
||||||
|
"servernumlock","leftalt","rightalt","altgr","scrolllock","rightctl"]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class VendorSection(Section):
|
||||||
|
_attr = []
|
||||||
|
_quoteattr = ["identifier"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
def isSection(self,name): return False
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class VideoAdaptorSection(Section):
|
||||||
|
_attr = []
|
||||||
|
_quoteattr = ["identifier","vendorname","boardname","busid","driver"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
def makeSection(self,comment,row):
|
||||||
|
return VideoPortSection(comment,row)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class VideoPortSection(SubSection):
|
||||||
|
_attr = []
|
||||||
|
_quoteattr = ["identifier"]
|
||||||
|
_listattr = {"option" : OptionList}
|
||||||
|
############################################################################
|
||||||
|
class XorgConfig(ConfigContainer):
|
||||||
|
_sectiontypes = { \
|
||||||
|
'device': DeviceSection,
|
||||||
|
'dri': DriSection,
|
||||||
|
'extensions': ExtensionsSection,
|
||||||
|
'files': FilesSection,
|
||||||
|
'inputdevice': InputDeviceSection,
|
||||||
|
'keyboard': KeyboardSection,
|
||||||
|
'modes': ModesSection,
|
||||||
|
'monitor': MonitorSection,
|
||||||
|
'module': ModuleSection,
|
||||||
|
'pointer': PointerSection,
|
||||||
|
'serverflags': ServerFlagsSection,
|
||||||
|
'serverlayout': ServerLayoutSection,
|
||||||
|
'screen': ScreenSection,
|
||||||
|
'videoadaptor': VideoAdaptorSection}
|
||||||
|
|
||||||
|
def makeSection(self,comment,row):
|
||||||
|
lname = row[1].lower()
|
||||||
|
try:
|
||||||
|
return self._sectiontypes[lname](comment,row)
|
||||||
|
except KeyError:
|
||||||
|
return ConfigContainer.makeSection(self,comment,row)
|
||||||
|
|
||||||
|
def toString(self,depth=-1):
|
||||||
|
return ConfigContainer.toString(self,depth)
|
||||||
|
|
||||||
|
def writeConfig(self,filename):
|
||||||
|
try:
|
||||||
|
encoding = locale.getpreferredencoding()
|
||||||
|
except locale.Error:
|
||||||
|
encoding = 'ANSI_X3.4-1968'
|
||||||
|
fhandle = codecs.open(filename,'w',locale.getpreferredencoding())
|
||||||
|
fhandle.write(self.toString())
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
def createUniqueIdentifier(self,stem="id"):
|
||||||
|
"""Create a unique identifier for a section
|
||||||
|
|
||||||
|
"""
|
||||||
|
# Build a list of used identifiers
|
||||||
|
used_identifiers = []
|
||||||
|
for name in ['monitor','videoadaptor','inputdevice','serverlayout','device','screen']:
|
||||||
|
for section in self.getSections(name):
|
||||||
|
if section.identifier is not None:
|
||||||
|
used_identifiers.append(section.identifier)
|
||||||
|
|
||||||
|
# Generate a identifier that is not in use.
|
||||||
|
i = 1
|
||||||
|
while (stem+str(i)) in used_identifiers:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return stem+str(i)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def addxorg(context, stack):
|
||||||
|
# Add minimal xorg.conf if it's missing
|
||||||
|
rows = [[None, [u'Section', u'Device']], [None, [u'Identifier', u'Configured Video Device']], \
|
||||||
|
[None, [u'EndSection']], [None, [u'Section', u'Monitor']], \
|
||||||
|
[None, [u'Identifier', u'Configured Monitor']], \
|
||||||
|
[None, [u'EndSection']], [None, [u'Section', u'Screen']], \
|
||||||
|
[None, [u'Identifier', u'Default Screen']], \
|
||||||
|
[None, [u'Monitor', u'Configured Monitor']], [None, [u'EndSection']], \
|
||||||
|
[None, [u'Section', u'ServerLayout']], \
|
||||||
|
[None, [u'Identifier', u'Default Layout']], \
|
||||||
|
[None, [u'screen', u'Default Screen']], \
|
||||||
|
[None, [u'EndSection']]]
|
||||||
|
|
||||||
|
for data in rows:
|
||||||
|
rowcomment = data[0]
|
||||||
|
row = data[1]
|
||||||
|
try:
|
||||||
|
first = row[0].lower()
|
||||||
|
if context.isSection(first):
|
||||||
|
section = context.makeSection(rowcomment,row)
|
||||||
|
context.append(section)
|
||||||
|
stack.append(context)
|
||||||
|
context = section
|
||||||
|
context_class = context.__class__
|
||||||
|
elif context.isEndSection(first):
|
||||||
|
context = stack.pop()
|
||||||
|
elif context.isListAttr(first):
|
||||||
|
context.makeListAttr(rowcomment,row)
|
||||||
|
else:
|
||||||
|
newline = context.makeLine(rowcomment,row)
|
||||||
|
if newline is None:
|
||||||
|
raise ParseException,"Unknown line type '%s' on line %i" % (first,line)
|
||||||
|
context.append(newline)
|
||||||
|
except IndexError:
|
||||||
|
context.append(ConfigLine(rowcomment,row))
|
||||||
|
|
||||||
|
return context, section, stack, first
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def addServerLayout(context, section, stack, first):
|
||||||
|
# Add empty server layout section to xorg.conf if it's missing
|
||||||
|
rows = [[None, [u'Section', u'ServerLayout']], \
|
||||||
|
[None, [u'Identifier', u'Default Layout']], \
|
||||||
|
[None, [u'screen', u'0', u'Default Screen', u'0', u'0']], \
|
||||||
|
[None, [u'Inputdevice', u'Generic Keyboard']], \
|
||||||
|
[None, [u'Inputdevice', u'Configured Mouse']], \
|
||||||
|
[None, []], ["Uncomment if you have a wacom tablet", []], \
|
||||||
|
["InputDevice \"stylus\" \"SendCoreEvents\"", []], \
|
||||||
|
[" InputDevice \"cursor\" \"SendCoreEvents\"", []], \
|
||||||
|
[" InputDevice \"eraser\" \"SendCoreEvents\"", []], \
|
||||||
|
[None, [u'Inputdevice', u'Synaptics Touchpad']], [None, [u'EndSection']]]
|
||||||
|
for data in rows:
|
||||||
|
rowcomment = data[0]
|
||||||
|
row = data[1]
|
||||||
|
try:
|
||||||
|
first = row[0].lower()
|
||||||
|
if context.isSection(first):
|
||||||
|
section = context.makeSection(rowcomment,row)
|
||||||
|
context.append(section)
|
||||||
|
stack.append(context)
|
||||||
|
context = section
|
||||||
|
context_class = context.__class__
|
||||||
|
elif context.isEndSection(first):
|
||||||
|
context = stack.pop()
|
||||||
|
elif context.isListAttr(first):
|
||||||
|
context.makeListAttr(rowcomment,row)
|
||||||
|
else:
|
||||||
|
newline = context.makeLine(rowcomment,row)
|
||||||
|
if newline is None:
|
||||||
|
raise ParseException,"Unknown line type '%s' on line %i" % (first,line)
|
||||||
|
context.append(newline)
|
||||||
|
except IndexError:
|
||||||
|
context.append(ConfigLine(rowcomment,row))
|
||||||
|
|
||||||
|
return context, section, stack, first
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def readConfig(filename, check_exists=False):
|
||||||
|
|
||||||
|
context = XorgConfig()
|
||||||
|
stack = []
|
||||||
|
line = 1
|
||||||
|
hasserverlayout = False
|
||||||
|
hasxorg = True
|
||||||
|
try:
|
||||||
|
import os
|
||||||
|
try:
|
||||||
|
if os.path.isfile('/etc/X11/xorg.conf'):
|
||||||
|
if os.path.getsize(filename) == 0:
|
||||||
|
raise IOError, "xorg.conf is empty - making up config"
|
||||||
|
else:
|
||||||
|
raise IOError, "xorg.conf is empty - making up config"
|
||||||
|
except OSError, errmsg:
|
||||||
|
raise IOError, errmsg
|
||||||
|
for row in XorgconfCVSReader(filename=filename).readlines():
|
||||||
|
try:
|
||||||
|
first = row[0].lower()
|
||||||
|
if context.isSection(first):
|
||||||
|
section = context.makeSection(row.comment,row)
|
||||||
|
if section._name == 'ServerLayout':
|
||||||
|
hasserverlayout = True
|
||||||
|
context.append(section)
|
||||||
|
stack.append(context)
|
||||||
|
context = section
|
||||||
|
context_class = context.__class__
|
||||||
|
elif context.isEndSection(first):
|
||||||
|
context = stack.pop()
|
||||||
|
elif context.isListAttr(first):
|
||||||
|
context.makeListAttr(row.comment,row)
|
||||||
|
else:
|
||||||
|
newline = context.makeLine(row.comment,row)
|
||||||
|
if newline is None:
|
||||||
|
raise ParseException,"Unknown line type '%s' on line %i" % (first,line)
|
||||||
|
context.append(newline)
|
||||||
|
except IndexError:
|
||||||
|
context.append(ConfigLine(row.comment,row))
|
||||||
|
line += 1
|
||||||
|
except IOError, errmsg:
|
||||||
|
ermsg = str(errmsg)
|
||||||
|
print "IOError", ermsg, " - will create xorg.conf if possible."
|
||||||
|
if ermsg[:9] == "[Errno 2]": # No such file or directory:
|
||||||
|
hasxorg = False
|
||||||
|
addxorg(context, stack)
|
||||||
|
try:
|
||||||
|
xorgfile = open(filename, 'a')
|
||||||
|
xorgfile.close()
|
||||||
|
except IOError, errmsg:
|
||||||
|
ermsg = str(errmsg)
|
||||||
|
if ermsg[:9] == "[Errno 13]": #Permission denied:
|
||||||
|
pass
|
||||||
|
# Since we aren't root, changes can't be made anyway.
|
||||||
|
elif ermsg[:9] == "xorg.conf": # xorg.conf exists, but is empty
|
||||||
|
hasxorg = False
|
||||||
|
addxorg(context, stack)
|
||||||
|
|
||||||
|
if len(stack)!=0:
|
||||||
|
raise ParseException,"Unexpected end of file on line %i" % line
|
||||||
|
if not hasserverlayout and hasxorg:
|
||||||
|
addServerLayout(context, section, stack, first)
|
||||||
|
if check_exists:
|
||||||
|
return context, hasxorg
|
||||||
|
else:
|
||||||
|
return context
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class ParseException(Exception):
|
||||||
|
def __init__(self,*args):
|
||||||
|
Exception.__init__(self,*args)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def toBoolean(value):
|
||||||
|
return unicode(value).lower() in ['on','true','1','yes']
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
# Our own class for reading CSV file. This version supports unicode while
|
||||||
|
# standard Python (2.4) version doesn't. Hence the need for this class.
|
||||||
|
#
|
||||||
|
class XorgconfCVSReader(object):
|
||||||
|
def __init__(self,filename=None, text=None):
|
||||||
|
assert filename is not None or text is not None
|
||||||
|
|
||||||
|
STATE_DELIMITER = 0
|
||||||
|
STATE_ITEM = 1
|
||||||
|
STATE_QUOTE = 2
|
||||||
|
QUOTE = '"'
|
||||||
|
LINE_COMMENT = '#'
|
||||||
|
|
||||||
|
class CommentList(list):
|
||||||
|
def __init__(self):
|
||||||
|
list.__init__(self)
|
||||||
|
self.comment = None
|
||||||
|
|
||||||
|
if filename is not None:
|
||||||
|
try:
|
||||||
|
loc = locale.getpreferredencoding()
|
||||||
|
except locale.Error:
|
||||||
|
loc = 'ANSI_X3.4-1968'
|
||||||
|
fhandle = codecs.open(filename,'r',loc,'replace')
|
||||||
|
source_lines = fhandle.readlines()
|
||||||
|
fhandle.close()
|
||||||
|
else:
|
||||||
|
source_lines = text.split('\n')
|
||||||
|
|
||||||
|
self.lines = []
|
||||||
|
for line in source_lines:
|
||||||
|
if len(line)!=0 and line[-1]=='\n':
|
||||||
|
line = line[:-1]
|
||||||
|
|
||||||
|
state = STATE_DELIMITER
|
||||||
|
row = CommentList()
|
||||||
|
item = None
|
||||||
|
for i in range(len(line)):
|
||||||
|
c = line[i]
|
||||||
|
|
||||||
|
if state==STATE_DELIMITER:
|
||||||
|
if not c.isspace():
|
||||||
|
if c==QUOTE:
|
||||||
|
item = []
|
||||||
|
state = STATE_QUOTE
|
||||||
|
elif c==LINE_COMMENT:
|
||||||
|
row.comment = line[i+1:]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
item = []
|
||||||
|
item.append(c)
|
||||||
|
state = STATE_ITEM
|
||||||
|
|
||||||
|
elif state==STATE_ITEM:
|
||||||
|
if c.isspace():
|
||||||
|
row.append(u''.join(item))
|
||||||
|
state = STATE_DELIMITER
|
||||||
|
item = None
|
||||||
|
else:
|
||||||
|
item.append(c)
|
||||||
|
|
||||||
|
elif state==STATE_QUOTE:
|
||||||
|
if c==QUOTE:
|
||||||
|
row.append(u''.join(item))
|
||||||
|
state = STATE_DELIMITER
|
||||||
|
item = None
|
||||||
|
else:
|
||||||
|
item.append(c)
|
||||||
|
|
||||||
|
if item is not None:
|
||||||
|
row.append(u''.join(item))
|
||||||
|
|
||||||
|
self.lines.append(row)
|
||||||
|
|
||||||
|
def readlines(self):
|
||||||
|
return self.lines
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
if __name__=='__main__':
|
||||||
|
import sys
|
||||||
|
if len(sys.argv)==2:
|
||||||
|
filename = sys.argv[1]
|
||||||
|
else:
|
||||||
|
filename = "/etc/X11/xorg.conf"
|
||||||
|
print "Reading",filename
|
||||||
|
c = readConfig(filename)
|
||||||
|
print c.toString()
|
||||||
|
|
@ -0,0 +1,555 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.1.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
|
||||||
|
<!ENTITY guidance "<application>guidance 0.4</application>">
|
||||||
|
<!ENTITY kappname "&guidance;"><!-- Do *not* replace kappname-->
|
||||||
|
<!ENTITY package "kde-module"><!-- kdebase, kdeadmin, etc -->
|
||||||
|
<!ENTITY % addindex "IGNORE">
|
||||||
|
<!ENTITY % English "INCLUDE"><!-- change language only here -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Do not define any other entities; instead, use the entities
|
||||||
|
from kde-genent.entities and $LANG/user.entities. -->
|
||||||
|
]>
|
||||||
|
<!-- kdoctemplate v0.8 October 1 1999
|
||||||
|
Minor update to "Credits and Licenses" section on August 24, 2000
|
||||||
|
Removed "Revision history" section on 22 January 2001
|
||||||
|
Changed to Installation/Help menu entities 18 October 2001
|
||||||
|
Other minor cleanup and changes 18 October 2001 -->
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This template was designed by: David Rugge davidrugge@mindspring.com
|
||||||
|
with lots of help from: Eric Bischoff ebisch@cybercable.tm.fr
|
||||||
|
and Frederik Fouvry fouvry@sfs.nphil.uni-tuebingen.de
|
||||||
|
of the KDE DocBook team.
|
||||||
|
|
||||||
|
You may freely use this template for writing any sort of KDE documentation.
|
||||||
|
If you have any changes or improvements, please let us know.
|
||||||
|
|
||||||
|
Remember:
|
||||||
|
- in XML, the case of the <tags> and attributes is relevant ;
|
||||||
|
- also, quote all attributes.
|
||||||
|
|
||||||
|
Please don't forget to remove all these comments in your final documentation,
|
||||||
|
thanks ;-).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- ................................................................ -->
|
||||||
|
|
||||||
|
<!-- The language must NOT be changed here. -->
|
||||||
|
|
||||||
|
<book lang="&language;">
|
||||||
|
|
||||||
|
<!-- This header contains all of the meta-information for the document such
|
||||||
|
as Authors, publish date, the abstract, and Keywords -->
|
||||||
|
|
||||||
|
<bookinfo>
|
||||||
|
<title>The &guidance; Handbook</title>
|
||||||
|
|
||||||
|
<authorgroup>
|
||||||
|
<author>
|
||||||
|
<firstname></firstname>
|
||||||
|
<othername></othername>
|
||||||
|
<surname>Simon Edwards</surname>
|
||||||
|
<affiliation>
|
||||||
|
<address><email>simon@simonzone.com</email></address>
|
||||||
|
</affiliation>
|
||||||
|
</author>
|
||||||
|
</authorgroup>
|
||||||
|
|
||||||
|
<!-- TRANS:ROLES_OF_TRANSLATORS -->
|
||||||
|
|
||||||
|
<copyright>
|
||||||
|
<year>1999</year>
|
||||||
|
<year>%{YEAR}</year>
|
||||||
|
<holder>Simon Edwards</holder>
|
||||||
|
</copyright>
|
||||||
|
<!-- Translators: put here the copyright notice of the translation -->
|
||||||
|
<!-- Put here the FDL notice. Read the explanation in fdl-notice.docbook
|
||||||
|
and in the FDL itself on how to use it. -->
|
||||||
|
<legalnotice>&FDLNotice;</legalnotice>
|
||||||
|
|
||||||
|
<!-- Date and version information of the documentation
|
||||||
|
Don't forget to include this last date and this last revision number, we
|
||||||
|
need them for translation coordination !
|
||||||
|
Please respect the format of the date (YYYY-MM-DD) and of the version
|
||||||
|
(V.MM.LL), it could be used by automation scripts.
|
||||||
|
Do NOT change these in the translation. -->
|
||||||
|
|
||||||
|
<date>2001-10-18</date>
|
||||||
|
<releaseinfo>0.1</releaseinfo>
|
||||||
|
|
||||||
|
<!-- Abstract about this handbook -->
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
<para>
|
||||||
|
&guidance; is an application specially designed to do nothing you would
|
||||||
|
ever want.
|
||||||
|
</para>
|
||||||
|
</abstract>
|
||||||
|
|
||||||
|
<!-- This is a set of Keywords for indexing by search engines.
|
||||||
|
Please at least include KDE, the KDE package it is in, the name
|
||||||
|
of your application, and a few relevant keywords. -->
|
||||||
|
|
||||||
|
<keywordset>
|
||||||
|
<keyword>KDE</keyword>
|
||||||
|
<keyword>testapp</keyword>
|
||||||
|
<keyword>nothing</keyword>
|
||||||
|
<keyword>nothing else</keyword>
|
||||||
|
</keywordset>
|
||||||
|
|
||||||
|
</bookinfo>
|
||||||
|
|
||||||
|
<!-- The contents of the documentation begin here. Label
|
||||||
|
each chapter so with the id attribute. This is necessary for two reasons: it
|
||||||
|
allows you to easily reference the chapter from other chapters of your
|
||||||
|
document, and if there is no ID, the name of the generated HTML files will vary
|
||||||
|
from time to time making it hard to manage for maintainers and for the CVS
|
||||||
|
system. Any chapter labelled (OPTIONAL) may be left out at the author's
|
||||||
|
discretion. Other chapters should not be left out in order to maintain a
|
||||||
|
consistent documentation style across all KDE apps. -->
|
||||||
|
|
||||||
|
<chapter id="introduction">
|
||||||
|
<title>Introduction</title>
|
||||||
|
|
||||||
|
<!-- The introduction chapter contains a brief introduction for the
|
||||||
|
application that explains what it does and where to report
|
||||||
|
problems. Basically a long version of the abstract. Don't include a
|
||||||
|
revision history. (see installation appendix comment) -->
|
||||||
|
|
||||||
|
<para>
|
||||||
|
&guidance; is a program that lets you do absolutely nothing. Please report
|
||||||
|
any problems or feature requests to the &kde; mailing lists.
|
||||||
|
</para>
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<chapter id="using-testapp">
|
||||||
|
<title>Using &guidance;</title>
|
||||||
|
|
||||||
|
<!-- This chapter should tell the user how to use your app. You should use as
|
||||||
|
many sections (Chapter, Sect1, Sect3, etc...) as is necessary to fully document
|
||||||
|
your application. -->
|
||||||
|
|
||||||
|
<para>
|
||||||
|
|
||||||
|
<!-- Note that all graphics should be in .png format. Use no gifs because of
|
||||||
|
patent issues. -->
|
||||||
|
|
||||||
|
<screenshot>
|
||||||
|
<screeninfo>Here's a screenshot of &guidance;</screeninfo>
|
||||||
|
<mediaobject>
|
||||||
|
<imageobject>
|
||||||
|
<imagedata fileref="screenshot.png" format="PNG"/>
|
||||||
|
</imageobject>
|
||||||
|
<imageobject>
|
||||||
|
<imagedata fileref="screenshot.eps" format="EPS"/>
|
||||||
|
</imageobject>
|
||||||
|
<textobject>
|
||||||
|
<phrase>Screenshot</phrase>
|
||||||
|
</textobject>
|
||||||
|
</mediaobject>
|
||||||
|
</screenshot>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<sect1 id="testapp-features">
|
||||||
|
<title>More &guidance; features</title>
|
||||||
|
|
||||||
|
<para>It slices! It dices! and it comes with a free toaster!</para>
|
||||||
|
<para>
|
||||||
|
The Squiggle Tool <guiicon><inlinemediaobject>
|
||||||
|
<imageobject>
|
||||||
|
<imagedata fileref="squiggle.png" format="PNG"/>
|
||||||
|
</imageobject>
|
||||||
|
<imageobject>
|
||||||
|
<imagedata fileref="squiggle.eps" format="EPS"/>
|
||||||
|
</imageobject>
|
||||||
|
<textobject>
|
||||||
|
<phrase>Squiggle</phrase>
|
||||||
|
</textobject>
|
||||||
|
</inlinemediaobject></guiicon> is used to draw squiggly lines all over
|
||||||
|
the &guidance; main window. It's not a bug, it's a feature!
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<chapter id="commands">
|
||||||
|
<title>Command Reference</title>
|
||||||
|
|
||||||
|
<!-- (OPTIONAL, BUT RECOMMENDED) This chapter should list all of the
|
||||||
|
application windows and their menubar and toolbar commands for easy reference.
|
||||||
|
Also include any keys that have a special function but have no equivalent in the
|
||||||
|
menus or toolbars. This may not be necessary for small apps or apps with no tool
|
||||||
|
or menu bars. -->
|
||||||
|
|
||||||
|
<sect1 id="testapp-mainwindow">
|
||||||
|
<title>The main &guidance; window</title>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>The File Menu</title>
|
||||||
|
<para>
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><menuchoice>
|
||||||
|
<shortcut>
|
||||||
|
<keycombo action="simul">&Ctrl;<keycap>N</keycap></keycombo>
|
||||||
|
</shortcut>
|
||||||
|
<guimenu>File</guimenu>
|
||||||
|
<guimenuitem>New</guimenuitem>
|
||||||
|
</menuchoice></term>
|
||||||
|
<listitem><para><action>Creates a new document</action></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><menuchoice>
|
||||||
|
<shortcut>
|
||||||
|
<keycombo action="simul">&Ctrl;<keycap>S</keycap></keycombo>
|
||||||
|
</shortcut>
|
||||||
|
<guimenu>File</guimenu>
|
||||||
|
<guimenuitem>Save</guimenuitem>
|
||||||
|
</menuchoice></term>
|
||||||
|
<listitem><para><action>Saves the document</action></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><menuchoice>
|
||||||
|
<shortcut>
|
||||||
|
<keycombo action="simul">&Ctrl;<keycap>Q</keycap></keycombo>
|
||||||
|
</shortcut>
|
||||||
|
<guimenu>File</guimenu>
|
||||||
|
<guimenuitem>Quit</guimenuitem>
|
||||||
|
</menuchoice></term>
|
||||||
|
<listitem><para><action>Quits</action> &guidance;</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>The <guimenu>Help</guimenu> Menu</title>
|
||||||
|
|
||||||
|
<!-- Assuming you have a standard help menu (help, what's this, about -->
|
||||||
|
<!-- &guidance;, about KDE) then the documentation is already written. -->
|
||||||
|
<!-- The following entity is valid anywhere that a variablelist is -->
|
||||||
|
<!-- valid. -->
|
||||||
|
|
||||||
|
&help.menu.documentation;
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<chapter id="developers">
|
||||||
|
<title>Developer's Guide to &guidance;</title>
|
||||||
|
|
||||||
|
<!-- (OPTIONAL) A Programming/Scripting reference chapter should be
|
||||||
|
used for apps that use plugins or that provide their own scripting hooks
|
||||||
|
and/or development libraries. -->
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Programming &guidance; plugins is a joy to behold. Just read through the next
|
||||||
|
66 pages of API's to learn how!
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- Use refentries to describe APIs. Refentries are fairly complicated and you
|
||||||
|
should consult the docbook reference for further details. The example below was
|
||||||
|
taken from that reference and shortened a bit for readability. -->
|
||||||
|
|
||||||
|
<refentry id="re-1007-unmanagechildren-1">
|
||||||
|
<refmeta>
|
||||||
|
<refentrytitle>XtUnmanageChildren</refentrytitle>
|
||||||
|
<refmiscinfo>Xt - Geometry Management</refmiscinfo>
|
||||||
|
</refmeta>
|
||||||
|
<refnamediv>
|
||||||
|
<refname>XtUnmanageChildren
|
||||||
|
</refname>
|
||||||
|
<refpurpose>remove a list of children from a parent widget's managed
|
||||||
|
list.
|
||||||
|
<indexterm id="ix-1007-unmanagechildren-1"><primary>widgets</primary><secondary>removing</secondary></indexterm>
|
||||||
|
<indexterm id="ix-1007-unmanagechildren-2"><primary>XtUnmanageChildren</primary></indexterm>
|
||||||
|
</refpurpose>
|
||||||
|
|
||||||
|
</refnamediv>
|
||||||
|
<refsynopsisdiv>
|
||||||
|
<refsynopsisdivinfo>
|
||||||
|
<date>4 March 1996</date>
|
||||||
|
</refsynopsisdivinfo>
|
||||||
|
<synopsis>
|
||||||
|
void XtUnmanageChildren(<replaceable class="parameter">children</replaceable>, <replaceable class="parameter">num_children</replaceable>)
|
||||||
|
WidgetList <replaceable class="parameter">children</replaceable>;
|
||||||
|
Cardinal <replaceable class="parameter">num_children</replaceable>;
|
||||||
|
</synopsis>
|
||||||
|
|
||||||
|
<refsect2 id="r2-1007-unmanagechildren-1">
|
||||||
|
<title>Inputs</title>
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable class="parameter">children</replaceable>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Specifies an array of child widgets. Each child must be of
|
||||||
|
class RectObj or any subclass thereof.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable class="parameter">num_children</replaceable>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Specifies the number of elements in <replaceable class="parameter">children</replaceable>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect2></refsynopsisdiv>
|
||||||
|
|
||||||
|
<refsect1 id="r1-1007-unmanagechildren-1">
|
||||||
|
<title>Description
|
||||||
|
</title>
|
||||||
|
<para><function>XtUnmanageChildren()</function> unmaps the specified widgets
|
||||||
|
and removes them from their parent's geometry management.
|
||||||
|
The widgets will disappear from the screen, and (depending
|
||||||
|
on its parent) may no longer have screen space allocated for
|
||||||
|
them.
|
||||||
|
</para>
|
||||||
|
<para>Each of the widgets in the <replaceable class="parameter">children</replaceable> array must have
|
||||||
|
the same parent.
|
||||||
|
</para>
|
||||||
|
<para>See the “Algorithm” section below for full details of the
|
||||||
|
widget unmanagement procedure.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id="r1-1007-unmanagechildren-2">
|
||||||
|
<title>Usage</title>
|
||||||
|
<para>Unmanaging widgets is the usual method for temporarily
|
||||||
|
making them invisible. They can be re-managed with
|
||||||
|
<function>XtManageChildren()</function>.
|
||||||
|
</para>
|
||||||
|
<para>You can unmap a widget, but leave it under geometry
|
||||||
|
management by calling <function>XtUnmapWidget()</function>. You can
|
||||||
|
destroy a widget's window without destroying the widget by
|
||||||
|
calling <function>XtUnrealizeWidget()</function>. You can destroy a
|
||||||
|
widget completely with <function>XtDestroyWidget()</function>.
|
||||||
|
</para>
|
||||||
|
<para>If you are only going to unmanage a single widget, it is
|
||||||
|
more convenient to call <function>XtUnmanageChild()</function>. It is
|
||||||
|
often more convenient to call <function>XtUnmanageChild()</function>
|
||||||
|
several times than it is to declare and initialize an array
|
||||||
|
of widgets to pass to <function>XtUnmanageChildren()</function>. Calling
|
||||||
|
<function>XtUnmanageChildren()</function> is more efficient, however,
|
||||||
|
because it only calls the parent's <function>change_managed()</function>
|
||||||
|
method once.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id="r1-1007-unmanagechildren-3">
|
||||||
|
<title>Algorithm
|
||||||
|
</title>
|
||||||
|
<para><function>XtUnmanageChildren()</function> performs the following:
|
||||||
|
</para>
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>-
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Ignores the child if it already is unmanaged or is being
|
||||||
|
destroyed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>-
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Otherwise, if the child is realized, it makes it nonvisible
|
||||||
|
by unmapping it.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
<para>
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id="r1-1007-unmanagechildren-4">
|
||||||
|
<title>Structures</title>
|
||||||
|
<para>The <type>WidgetList</type> type is simply an array of widgets:
|
||||||
|
</para>
|
||||||
|
<screen id="sc-1007-unmanagechildren-1">typedef Widget *WidgetList;
|
||||||
|
</screen>
|
||||||
|
</refsect1>
|
||||||
|
</refentry>
|
||||||
|
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<chapter id="faq">
|
||||||
|
<title>Questions and Answers</title>
|
||||||
|
|
||||||
|
<!-- (OPTIONAL but recommended) This chapter should include all of the silly
|
||||||
|
(and not-so-silly) newbie questions that fill up your mailbox. This chapter
|
||||||
|
should be reserved for BRIEF questions and answers! If one question uses more
|
||||||
|
than a page or so then it should probably be part of the
|
||||||
|
"Using this Application" chapter instead. You should use links to
|
||||||
|
cross-reference questions to the parts of your documentation that answer them.
|
||||||
|
This is also a great place to provide pointers to other FAQ's if your users
|
||||||
|
must do some complicated configuration on other programs in order for your
|
||||||
|
application work. -->
|
||||||
|
|
||||||
|
&reporting.bugs;
|
||||||
|
&updating.documentation;
|
||||||
|
|
||||||
|
<qandaset id="faqlist">
|
||||||
|
<qandaentry>
|
||||||
|
<question>
|
||||||
|
<para>My Mouse doesn't work. How do I quit &guidance;?</para>
|
||||||
|
</question>
|
||||||
|
<answer>
|
||||||
|
<para>You silly goose! Check out the <link linkend="commands">Commands
|
||||||
|
Section</link> for the answer.</para>
|
||||||
|
</answer>
|
||||||
|
</qandaentry>
|
||||||
|
<qandaentry>
|
||||||
|
<question>
|
||||||
|
<para>Why can't I twiddle my documents?</para>
|
||||||
|
</question>
|
||||||
|
<answer>
|
||||||
|
<para>You can only twiddle your documents if you have the foobar.lib
|
||||||
|
installed.</para>
|
||||||
|
</answer>
|
||||||
|
</qandaentry>
|
||||||
|
</qandaset>
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<chapter id="credits">
|
||||||
|
|
||||||
|
<!-- Include credits for the programmers, documentation writers, and
|
||||||
|
contributors here. The license for your software should then be included below
|
||||||
|
the credits with a reference to the appropriate license file included in the KDE
|
||||||
|
distribution. -->
|
||||||
|
|
||||||
|
<title>Credits and License</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
&guidance;
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Program copyright %{YEAR} Simon Edwards <email>simon@simonzone.com</email>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Contributors:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem><para>Konqui the KDE Dragon <email>konqui@kde.org</email></para>
|
||||||
|
</listitem>
|
||||||
|
<listitem><para>Tux the Linux Penguin <email>tux@linux.org</email></para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Documentation copyright %{YEAR} Simon Edwards <email>simon@simonzone.com</email>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- TRANS:CREDIT_FOR_TRANSLATORS -->
|
||||||
|
|
||||||
|
&underFDL; <!-- FDL: do not remove -->
|
||||||
|
|
||||||
|
<!-- Determine which license your application is licensed under,
|
||||||
|
and delete all the remaining licenses below:
|
||||||
|
|
||||||
|
(NOTE: All documentation are licensed under the FDL,
|
||||||
|
regardless of what license the application uses) -->
|
||||||
|
|
||||||
|
&underGPL; <!-- GPL License -->
|
||||||
|
&underBSDLicense; <!-- BSD License -->
|
||||||
|
&underArtisticLicense; <!-- BSD Artistic License -->
|
||||||
|
&underX11License; <!-- X11 License -->
|
||||||
|
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<appendix id="installation">
|
||||||
|
<title>Installation</title>
|
||||||
|
|
||||||
|
<sect1 id="getting-testapp">
|
||||||
|
<title>How to obtain &guidance;</title>
|
||||||
|
|
||||||
|
<!-- This first entity contains boiler plate for applications that are
|
||||||
|
part of KDE CVS. You should remove it if you are releasing your
|
||||||
|
application -->
|
||||||
|
|
||||||
|
&install.intro.documentation;
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
<sect1 id="requirements">
|
||||||
|
<title>Requirements</title>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
List any special requirements for your application here. This should include:
|
||||||
|
.Libraries or other software that is not included in kdesupport,
|
||||||
|
kdelibs, or kdebase.
|
||||||
|
.Hardware requirements like amount of RAM, disk space, graphics card
|
||||||
|
capabilities, screen resolution, special expansion cards, etc.
|
||||||
|
.Operating systems the app will run on. If your app is designed only for a
|
||||||
|
specific OS, (you wrote a graphical LILO configurator for example) put this
|
||||||
|
information here.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In order to successfully use &guidance;, you need &kde; 1.1. Foobar.lib is
|
||||||
|
required in order to support the advanced &guidance; features. &guidance; uses
|
||||||
|
about 5 megs of memory to run, but this may vary depending on your
|
||||||
|
platform and configuration.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
All required libraries as well as &guidance; itself can be found
|
||||||
|
on <ulink url="ftp://ftp.testapp.org">The &guidance; home page</ulink>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- For a list of updates, you may refer to the application web site
|
||||||
|
or the ChangeLog file, or ... -->
|
||||||
|
<para>
|
||||||
|
You can find a list of changes at <ulink
|
||||||
|
url="http://apps.kde.org/testapp">http://apps.kde.org/testapp</ulink>.
|
||||||
|
</para>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
<sect1 id="compilation">
|
||||||
|
<title>Compilation and Installation</title>
|
||||||
|
|
||||||
|
<!-- This entity contains the boilerplate text for standard -->
|
||||||
|
<!-- compilation instructions. If your application requires any -->
|
||||||
|
<!-- special handling, remove it, and replace with your own text. -->
|
||||||
|
|
||||||
|
&install.compile.documentation;
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
<sect1 id="configuration">
|
||||||
|
<title>Configuration</title>
|
||||||
|
|
||||||
|
<para>Don't forget to tell your system to start the <filename>dtd</filename>
|
||||||
|
dicer-toaster daemon first, or &guidance; won't work !</para>
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
</appendix>
|
||||||
|
|
||||||
|
&documentation.index;
|
||||||
|
</book>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Local Variables:
|
||||||
|
mode: sgml
|
||||||
|
sgml-minimize-attributes:nil
|
||||||
|
sgml-general-insert-case:lower
|
||||||
|
sgml-indent-step:0
|
||||||
|
sgml-indent-data:nil
|
||||||
|
End:
|
||||||
|
|
||||||
|
vim:tabstop=2:shiftwidth=2:expandtab
|
||||||
|
-->
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Boot Loader Configuration
|
||||||
|
Name[el]=Ρύθμιση φορτωτή εκκίνησης συστήματος
|
||||||
|
Name[es]=Configuración del cargador de arranque
|
||||||
|
Name[et]=Alglaaduri seadistamine
|
||||||
|
Name[it]=Configurazione dell'avviamento del sistema
|
||||||
|
Name[ja]=ブートローダの設定
|
||||||
|
Name[nl]=Bootloaderconfiguratie
|
||||||
|
Name[pt]=Configuração do Gestor de Arranque
|
||||||
|
Name[pt_BR]=Configuração do Gerenciador de Inicialização
|
||||||
|
Name[sr]=Подешавање подизања система
|
||||||
|
Name[sr@Latn]=Podešavanje podizanja sistema
|
||||||
|
Name[sv]=Startprograminställning
|
||||||
|
Name[xx]=xxBoot Loader Configurationxx
|
||||||
|
Comment=Boot Options Management
|
||||||
|
Comment[el]=Διαχείριση επιλογών εκκίνησης συστήματος
|
||||||
|
Comment[es]=Administración de las opciones de arranque
|
||||||
|
Comment[et]=Alglaadimise võtmete haldamine
|
||||||
|
Comment[it]=Gestione delle opzioni di avviamento del sistema
|
||||||
|
Comment[ja]=起動オプションの管理
|
||||||
|
Comment[nl]=Opstartopties beheren
|
||||||
|
Comment[pt]=Gestão das Opções de Arranque
|
||||||
|
Comment[pt_BR]=Gerenciamento das Opções de Inicialização
|
||||||
|
Comment[sr]=Управљање опцијама бутовања
|
||||||
|
Comment[sr@Latn]=Upravljanje opcijama butovanja
|
||||||
|
Comment[sv]=Hantering av startalternativ
|
||||||
|
Comment[xx]=xxBoot Options Managementxx
|
||||||
|
Icon=grubconfig.png
|
||||||
|
Encoding=UTF-8
|
||||||
|
X-KDE-ModuleType=Library
|
||||||
|
X-KDE-Library=grubconfig
|
||||||
|
X-KDE-FactoryName=grubconfig
|
||||||
|
X-KDE-RootOnly=true
|
||||||
|
Type=Application
|
||||||
|
Exec=kcmshell System/grubconfig
|
||||||
|
Categories=Qt;KDE;X-KDE-settings-system;
|
||||||
|
GenericName=Boot Loader Configuration
|
||||||
|
GenericName[el]=Ρυθμίσεις φορτωτή εκκίνησης συστήματος
|
||||||
|
GenericName[es]=Configuración del cargador de arranque
|
||||||
|
GenericName[et]=Alglaaduri seadistamine
|
||||||
|
GenericName[it]=Configurazione dell'avviamento del sistema
|
||||||
|
GenericName[ja]=ブートローダの設定
|
||||||
|
GenericName[nl]=Bootloaderconfiguratie
|
||||||
|
GenericName[pt]=Configuração do Gestor de Arranque
|
||||||
|
GenericName[pt_BR]=Configuração do Gerenciador de Inicialização
|
||||||
|
GenericName[sr]=Подешавање подизања система
|
||||||
|
GenericName[sr@Latn]=Podešavanje podizanja sistema
|
||||||
|
GenericName[sv]=Inställning av startprogram
|
||||||
|
GenericName[xx]=xxBoot Loader Configurationxx
|
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 5.0 KiB |
@ -0,0 +1,516 @@
|
|||||||
|
/*#########################################################################
|
||||||
|
# ixf86misc.c - #
|
||||||
|
# ------------------------------ #
|
||||||
|
# copyright : (C) 2004-2007 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# A small binding for playing with the gamma and RandR settings under #
|
||||||
|
# XFree86. #
|
||||||
|
# #
|
||||||
|
# Simon Edwards <simon@simonzone.com> #
|
||||||
|
#########################################################################*/
|
||||||
|
|
||||||
|
#include "Python.h"
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/xf86vmode.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <X11/extensions/scrnsaver.h>
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
XOpenDisplay(displayname)
|
||||||
|
|
||||||
|
Args:
|
||||||
|
displayname - String
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
opaque display reference.
|
||||||
|
*/
|
||||||
|
static void ixf86misc_destroydisplay(void *ptr) {
|
||||||
|
if(ptr!=NULL) {
|
||||||
|
XCloseDisplay((Display *)ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *ixf86misc_xopendisplay(PyObject *self, PyObject *args) {
|
||||||
|
Display *dpy;
|
||||||
|
char *displayname = NULL;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "z", &displayname)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpy = XOpenDisplay(displayname);
|
||||||
|
if(dpy==NULL) {
|
||||||
|
return Py_BuildValue("");
|
||||||
|
} else {
|
||||||
|
return PyCObject_FromVoidPtr((void *)dpy,ixf86misc_destroydisplay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
DefaultScreen(display)
|
||||||
|
|
||||||
|
Args:
|
||||||
|
display - display object.
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
screen number - integer
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_defaultscreen(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
int screen;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
screen = DefaultScreen((Display *)PyCObject_AsVoidPtr(pydisplay));
|
||||||
|
return Py_BuildValue("i", screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
ScreenCount(display)
|
||||||
|
|
||||||
|
Args:
|
||||||
|
display - display object.
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
number of screens - integer
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_screencount(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
count = ScreenCount((Display *)PyCObject_AsVoidPtr(pydisplay));
|
||||||
|
return Py_BuildValue("i", count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
RootWindow(display,screennumber)
|
||||||
|
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_rootwindow(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
int screen = 0;
|
||||||
|
Drawable pydrawable;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pydrawable = RootWindow((Display *)PyCObject_AsVoidPtr(pydisplay),screen);
|
||||||
|
return Py_BuildValue("l",pydrawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_getgamma(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
int screen = 0;
|
||||||
|
XF86VidModeGamma gamma;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!XF86VidModeGetGamma((Display *)PyCObject_AsVoidPtr(pydisplay), screen, &gamma)) {
|
||||||
|
/* FIXME set an exception? */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Py_BuildValue("(fff)", gamma.red, gamma.green, gamma.blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_setgamma(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display;
|
||||||
|
int screen = 0;
|
||||||
|
XF86VidModeGamma gamma;
|
||||||
|
float red,green,blue;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oifff", &pydisplay, &screen, &red, &green, &blue)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
|
||||||
|
if(!XF86VidModeGetGamma(display, screen, &gamma)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gamma.red = red;
|
||||||
|
gamma.green = green;
|
||||||
|
gamma.blue = blue;
|
||||||
|
if(!XF86VidModeSetGamma(display, screen, &gamma)) {
|
||||||
|
/* FIXME set an exception? */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
XFlush(display);
|
||||||
|
return Py_BuildValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
XRRQueryExtension (Display *dpy,
|
||||||
|
int *event_basep, int *error_basep);
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrqueryextension(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display;
|
||||||
|
int event_basep, error_basep;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
|
||||||
|
Bool rc = XRRQueryExtension(display, &event_basep, &error_basep);
|
||||||
|
return Py_BuildValue("(iii)",(int)rc, event_basep, error_basep);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
XRRScreenConfiguration *XRRGetScreenInfo(Display *dpy,Drawable d)
|
||||||
|
*/
|
||||||
|
static void ixf86misc_destroyxrrscreenconfig(void *ptr) {
|
||||||
|
if(ptr!=NULL) {
|
||||||
|
XRRFreeScreenConfigInfo((XRRScreenConfiguration *)ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static PyObject *ixf86misc_xrrgetscreeninfo(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Drawable pydrawable;
|
||||||
|
XRRScreenConfiguration *xrrconfig;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Ol", &pydisplay, &pydrawable)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
xrrconfig = XRRGetScreenInfo((Display *)PyCObject_AsVoidPtr(pydisplay), pydrawable);
|
||||||
|
|
||||||
|
if(xrrconfig==NULL) {
|
||||||
|
return Py_BuildValue("");
|
||||||
|
} else {
|
||||||
|
return PyCObject_FromVoidPtr((void *)xrrconfig,ixf86misc_destroyxrrscreenconfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
SizeID XRRConfigCurrentConfiguration(XRRScreenConfiguration *config)
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrconfigcurrentconfiguration(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pyconfig = NULL;
|
||||||
|
Rotation currentrotation;
|
||||||
|
SizeID currentsize;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pyconfig)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
currentsize = XRRConfigCurrentConfiguration((XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig), ¤trotation);
|
||||||
|
return Py_BuildValue("(ll)", (long)currentsize, (long)currentrotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
XRRRotations(display,screen)
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrrotations(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display;
|
||||||
|
int screen = 0;
|
||||||
|
Rotation currentrotation,availablerotations;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
availablerotations = XRRRotations(display, screen, ¤trotation);
|
||||||
|
return Py_BuildValue("l", (long)availablerotations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
XRRSizes(display,screen)
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrsizes(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
PyObject *sizelist,*item;
|
||||||
|
Display *display;
|
||||||
|
XRRScreenSize *sizes;
|
||||||
|
int screen = 0;
|
||||||
|
int numSizes;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oi", &pydisplay, &screen)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
|
||||||
|
sizelist = PyList_New(0);
|
||||||
|
sizes = XRRSizes(display, screen, &numSizes);
|
||||||
|
for(i = 0; i < numSizes; i++) {
|
||||||
|
item = Py_BuildValue("(iiii)",sizes[i].width, sizes[i].height,sizes[i].mwidth, sizes[i].mheight);
|
||||||
|
PyList_Append(sizelist, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sizelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
short XRRConfigCurrentRate(config)
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrconfigcurrentrate(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pyconfig = NULL;
|
||||||
|
int rate;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pyconfig)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
rate = XRRConfigCurrentRate((XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig));
|
||||||
|
return Py_BuildValue("i", (int)rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrrates(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
PyObject *ratelist,*item;
|
||||||
|
Display *display;
|
||||||
|
int numrates;
|
||||||
|
int size;
|
||||||
|
int screen = 0;
|
||||||
|
int i;
|
||||||
|
short *rates;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oii", &pydisplay, &screen,&size)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
rates = XRRRates(display, screen, (SizeID)size, &numrates);
|
||||||
|
|
||||||
|
ratelist = PyList_New(0);
|
||||||
|
for(i = 0; i < numrates; i++) {
|
||||||
|
item = Py_BuildValue("i",(int)rates[i]);
|
||||||
|
PyList_Append(ratelist, item);
|
||||||
|
}
|
||||||
|
return ratelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
Time XRRConfigTimes( XRRScreenConfiguration *config, Time *config_timestamp )
|
||||||
|
*/
|
||||||
|
|
||||||
|
static PyObject *ixf86misc_xrrconfigtimes(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pyconfig = NULL;
|
||||||
|
int rate;
|
||||||
|
Time ts,ts2;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pyconfig)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ts2 = XRRConfigTimes((XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig),&ts);
|
||||||
|
return Py_BuildValue("l", (long)ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
status = XRRSetScreenConfigAndRate(display, config, window, newsize, newrotation, newrefresh, currenttime)
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xrrsetscreenconfigandrate(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display = NULL;
|
||||||
|
PyObject *pyconfig = NULL;
|
||||||
|
Drawable pydrawable;
|
||||||
|
Rotation newrotation;
|
||||||
|
long newrefresh;
|
||||||
|
// Time currenttime;
|
||||||
|
Status status;
|
||||||
|
long newsize;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "OOllll", &pydisplay, &pyconfig, &pydrawable, &newsize, &newrotation, &newrefresh /*, ¤ttime*/ )) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
|
||||||
|
status = XRRSetScreenConfigAndRate(display, (XRRScreenConfiguration *)PyCObject_AsVoidPtr(pyconfig), pydrawable,
|
||||||
|
(SizeID)newsize, newrotation, newrefresh, CurrentTime);
|
||||||
|
|
||||||
|
return Py_BuildValue("i", (int)status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
(dotclock,hdisplay,hsyncstart,hsyncend,htotal,vdisplay,vsyncstart,vsyncend,vtotal,flags) = \
|
||||||
|
ixf86misc_vidmodegetmodeline(display,screen)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static PyObject *ixf86misc_vidmodegetmodeline(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display = NULL;
|
||||||
|
long screen;
|
||||||
|
int dotclock_return;
|
||||||
|
XF86VidModeModeLine modeline;
|
||||||
|
PyObject *returnvalue;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Ol", &pydisplay, &screen)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
|
||||||
|
if(XF86VidModeGetModeLine(display,screen,&dotclock_return,&modeline)) {
|
||||||
|
returnvalue = Py_BuildValue("(iiiiiiiiii)",
|
||||||
|
dotclock_return,
|
||||||
|
modeline.hdisplay, /* Number of display pixels horizontally */
|
||||||
|
modeline.hsyncstart, /* Horizontal sync start */
|
||||||
|
modeline.hsyncend, /* Horizontal sync end */
|
||||||
|
modeline.htotal, /* Total horizontal pixels */
|
||||||
|
modeline.vdisplay, /* Number of display pixels vertically */
|
||||||
|
modeline.vsyncstart, /* Vertical sync start */
|
||||||
|
modeline.vsyncend, /* Vertical sync start */
|
||||||
|
modeline.vtotal, /* Total vertical pixels */
|
||||||
|
modeline.flags /* Mode flags */);
|
||||||
|
if(modeline.private!=NULL) {
|
||||||
|
XFree(modeline.private);
|
||||||
|
}
|
||||||
|
return returnvalue;
|
||||||
|
} else {
|
||||||
|
return Py_BuildValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
DisplaySize(display,screen_num)
|
||||||
|
|
||||||
|
Args:
|
||||||
|
display - display object.
|
||||||
|
screen_num - screen number
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
dimensions - a tuple consisting of 4 integers (width_pixels, height_pixels,
|
||||||
|
width_mm, height_mm)
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_displaysize(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display = NULL;
|
||||||
|
int screennum = 0;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "Oi", &pydisplay,&screennum)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
|
||||||
|
return Py_BuildValue("(iiii)",
|
||||||
|
DisplayWidth(display,screennum),
|
||||||
|
DisplayHeight(display,screennum),
|
||||||
|
DisplayWidthMM(display,screennum),
|
||||||
|
DisplayHeightMM(display,screennum));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
static PyObject *ixf86misc_xscreensaverqueryextension(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay = NULL;
|
||||||
|
Display *display;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "O", &pydisplay)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
int event_base, error_base;
|
||||||
|
|
||||||
|
int rc = XScreenSaverQueryExtension(display, &event_base, &error_base);
|
||||||
|
return Py_BuildValue("i", rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
static void ixf86misc_destroyscreensaver(void *ptr) {
|
||||||
|
if(ptr!=NULL) {
|
||||||
|
XFree(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *ixf86misc_xscreensaverallocinfo(PyObject *self, PyObject *args) {
|
||||||
|
XScreenSaverInfo *ss_info;
|
||||||
|
ss_info = XScreenSaverAllocInfo();
|
||||||
|
return PyCObject_FromVoidPtr((void *)ss_info,ixf86misc_destroyscreensaver);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static PyObject *ixf86misc_xscreensaverqueryinfo(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pydisplay;
|
||||||
|
Display *display;
|
||||||
|
Drawable window;
|
||||||
|
PyObject *pyscreensaverinfo;
|
||||||
|
XScreenSaverInfo *screensaverinfo;
|
||||||
|
|
||||||
|
if(!PyArg_ParseTuple(args, "OlO", &pydisplay, &window, &pyscreensaverinfo)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
display = (Display *)PyCObject_AsVoidPtr(pydisplay);
|
||||||
|
screensaverinfo = (XScreenSaverInfo *)PyCObject_AsVoidPtr(pyscreensaverinfo);
|
||||||
|
|
||||||
|
int state = 0;
|
||||||
|
int kind = 0;
|
||||||
|
unsigned long idle = 0;
|
||||||
|
unsigned long til_or_since = 0;
|
||||||
|
if(XScreenSaverQueryInfo(display, window, screensaverinfo)) {
|
||||||
|
state = screensaverinfo->state;
|
||||||
|
kind = screensaverinfo->kind;
|
||||||
|
til_or_since = screensaverinfo->til_or_since;
|
||||||
|
idle = screensaverinfo->idle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Py_BuildValue("(iikk)", state, kind ,til_or_since, idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static struct PyMethodDef ixf86misc_methods[] = {
|
||||||
|
{ "XOpenDisplay", ixf86misc_xopendisplay, METH_VARARGS },
|
||||||
|
{ "DefaultScreen", ixf86misc_defaultscreen, METH_VARARGS },
|
||||||
|
{ "ScreenCount", ixf86misc_screencount, METH_VARARGS },
|
||||||
|
{ "GetGamma", ixf86misc_getgamma, METH_VARARGS },
|
||||||
|
{ "SetGamma", ixf86misc_setgamma, METH_VARARGS },
|
||||||
|
{ "RootWindow", ixf86misc_rootwindow, METH_VARARGS },
|
||||||
|
{ "XRRGetScreenInfo", ixf86misc_xrrgetscreeninfo, METH_VARARGS },
|
||||||
|
{ "XRRConfigCurrentConfiguration", ixf86misc_xrrconfigcurrentconfiguration, METH_VARARGS },
|
||||||
|
{ "XRRRotations", ixf86misc_xrrrotations, METH_VARARGS },
|
||||||
|
{ "XRRSizes", ixf86misc_xrrsizes, METH_VARARGS },
|
||||||
|
{ "XRRConfigCurrentRate", ixf86misc_xrrconfigcurrentrate, METH_VARARGS },
|
||||||
|
{ "XRRRates", ixf86misc_xrrrates, METH_VARARGS },
|
||||||
|
{ "XRRConfigTimes", ixf86misc_xrrconfigtimes, METH_VARARGS },
|
||||||
|
{ "XRRSetScreenConfigAndRate", ixf86misc_xrrsetscreenconfigandrate, METH_VARARGS },
|
||||||
|
{ "XF86VidModeGetModeLine", ixf86misc_vidmodegetmodeline, METH_VARARGS },
|
||||||
|
{ "DisplaySize", ixf86misc_displaysize, METH_VARARGS },
|
||||||
|
{ "XScreenSaverQueryExtension", ixf86misc_xscreensaverqueryextension, METH_VARARGS },
|
||||||
|
{ "XScreenSaverAllocInfo", ixf86misc_xscreensaverallocinfo, METH_VARARGS },
|
||||||
|
{ "XScreenSaverQueryInfo", ixf86misc_xscreensaverqueryinfo, METH_VARARGS },
|
||||||
|
{ "XRRQueryExtension", ixf86misc_xrrqueryextension, METH_VARARGS },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
void initixf86misc(void) {
|
||||||
|
PyObject *ixf86misc = Py_InitModule3("ixf86misc",ixf86misc_methods,"Bindings for some XFree86 config functions.");
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,197 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
###########################################################################
|
||||||
|
# xf86misc.py - #
|
||||||
|
# ------------------------------ #
|
||||||
|
# copyright : (C) 2004 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
"""A simple interface for changing the current gamma setting under XFree86.
|
||||||
|
"""
|
||||||
|
import ixf86misc
|
||||||
|
import os, time
|
||||||
|
|
||||||
|
class XF86Screen(object):
|
||||||
|
|
||||||
|
RR_Rotate_0 = 1
|
||||||
|
RR_Rotate_90 = 2
|
||||||
|
RR_Rotate_180 = 4
|
||||||
|
RR_Rotate_270 = 8
|
||||||
|
RR_Reflect_X = 16
|
||||||
|
RR_Reflect_Y = 32
|
||||||
|
|
||||||
|
def __init__(self,display,screenid):
|
||||||
|
self.screenid = screenid
|
||||||
|
self.display = display
|
||||||
|
self.ssinfo = None
|
||||||
|
self.starttime = time.time()
|
||||||
|
self.resettime = 0
|
||||||
|
self.lastidle = 0
|
||||||
|
|
||||||
|
self.screenconfig = None
|
||||||
|
self._load()
|
||||||
|
|
||||||
|
def _load(self):
|
||||||
|
# Check for the presence of the xrandr extension.
|
||||||
|
try:
|
||||||
|
(rc,x,y) = ixf86misc.XRRQueryExtension(self.display)
|
||||||
|
if rc==0:
|
||||||
|
return
|
||||||
|
except AttributeError, errmsg:
|
||||||
|
print "Trapped AttributeError:", errmsg, " - attempting to continue."
|
||||||
|
return
|
||||||
|
|
||||||
|
self.screenconfig = ixf86misc.XRRGetScreenInfo(self.display, ixf86misc.RootWindow(self.display, self.screenid))
|
||||||
|
if self.screenconfig is not None:
|
||||||
|
(self.currentsizeid,self.currentrotation) = ixf86misc.XRRConfigCurrentConfiguration(self.screenconfig)
|
||||||
|
self.availablerotations = ixf86misc.XRRRotations(self.display, self.screenid)
|
||||||
|
self.sizes = ixf86misc.XRRSizes(self.display, self.screenid)
|
||||||
|
self.currentrefreshrate = ixf86misc.XRRConfigCurrentRate(self.screenconfig)
|
||||||
|
|
||||||
|
def resolutionSupportAvailable(self):
|
||||||
|
return self.screenconfig is not None
|
||||||
|
|
||||||
|
def getScreenId(self):
|
||||||
|
return self.screenid
|
||||||
|
|
||||||
|
def getGamma(self):
|
||||||
|
return ixf86misc.GetGamma(self.display,self.screenid)
|
||||||
|
|
||||||
|
def setGamma(self,gammatuple):
|
||||||
|
ixf86misc.SetGamma(self.display,self.screenid,gammatuple[0],gammatuple[1],gammatuple[2])
|
||||||
|
|
||||||
|
def getRotation(self):
|
||||||
|
return self.currentrotation
|
||||||
|
|
||||||
|
def getAvailableRotations(self):
|
||||||
|
return self.availablerotations
|
||||||
|
|
||||||
|
def getSize(self):
|
||||||
|
return self.sizes[self.currentsizeid]
|
||||||
|
|
||||||
|
def getSizeID(self):
|
||||||
|
return self.currentsizeid
|
||||||
|
|
||||||
|
def getAvailableSizes(self):
|
||||||
|
return self.sizes[:]
|
||||||
|
|
||||||
|
def getRefreshRate(self):
|
||||||
|
return self.currentrefreshrate
|
||||||
|
|
||||||
|
def getAvailableRefreshRates(self,sizeid):
|
||||||
|
return ixf86misc.XRRRates(self.display,self.screenid,sizeid)
|
||||||
|
|
||||||
|
def setScreenConfigAndRate(self, sizeid, rotation, refresh):
|
||||||
|
rc = ixf86misc.XRRSetScreenConfigAndRate(self.display, self.screenconfig, \
|
||||||
|
ixf86misc.RootWindow(self.display, self.screenid), sizeid, rotation, refresh)
|
||||||
|
#ixf86misc.XRRConfigTimes(self.screenconfig) \
|
||||||
|
|
||||||
|
self._load()
|
||||||
|
return rc # FIXME handle failures due to the timestamp.
|
||||||
|
|
||||||
|
def getDimensions(self):
|
||||||
|
return ixf86misc.DisplaySize(self.display,self.screenid)
|
||||||
|
|
||||||
|
def getIdleSeconds(self):
|
||||||
|
data = self.__getScreenSaverInfo()
|
||||||
|
if data is None:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
(state, kind, til_or_since, idle) = data
|
||||||
|
idletime = idle/1000.0
|
||||||
|
|
||||||
|
if (self.lastidle > idletime) or (self.resettime > idletime): # Something has moved in the meantime
|
||||||
|
self.starttime = 0
|
||||||
|
self.resettime = 0
|
||||||
|
else:
|
||||||
|
idletime = idletime - self.resettime
|
||||||
|
self.lastidle = idletime
|
||||||
|
return idletime
|
||||||
|
|
||||||
|
def resetIdleSeconds(self):
|
||||||
|
self.resettime = time.time() - self.starttime
|
||||||
|
|
||||||
|
# See man XScreenSaver(3)
|
||||||
|
def __getScreenSaverInfo(self):
|
||||||
|
if self.ssinfo is None:
|
||||||
|
if ixf86misc.XScreenSaverQueryExtension(self.display):
|
||||||
|
self.ssinfo = ixf86misc.XScreenSaverAllocInfo()
|
||||||
|
else:
|
||||||
|
return 0 # Error actually.
|
||||||
|
|
||||||
|
return ixf86misc.XScreenSaverQueryInfo(self.display,
|
||||||
|
ixf86misc.RootWindow(self.display, self.screenid), self.ssinfo)
|
||||||
|
|
||||||
|
|
||||||
|
class XF86Server(object):
|
||||||
|
def __init__(self,displayname=None):
|
||||||
|
if displayname==None:
|
||||||
|
if 'DISPLAY' in os.environ:
|
||||||
|
displayname = os.environ['DISPLAY']
|
||||||
|
else:
|
||||||
|
displayname = ":0.0"
|
||||||
|
self.displayname = displayname
|
||||||
|
self.display = ixf86misc.XOpenDisplay(displayname)
|
||||||
|
if self.display is None:
|
||||||
|
raise XF86Error, "Couldn't connect to X server."
|
||||||
|
|
||||||
|
self._defaultscreen = ixf86misc.DefaultScreen(self.display)
|
||||||
|
|
||||||
|
self.screens = []
|
||||||
|
for i in range(ixf86misc.ScreenCount(self.display)):
|
||||||
|
self.screens.append(XF86Screen(self.display,i))
|
||||||
|
|
||||||
|
def getDefaultScreen(self):
|
||||||
|
return self.screens[self._defaultscreen]
|
||||||
|
|
||||||
|
def getDisplay(self):
|
||||||
|
return self.display
|
||||||
|
|
||||||
|
def getDisplayName(self):
|
||||||
|
return self.displayname
|
||||||
|
|
||||||
|
def getScreens(self):
|
||||||
|
return self.screens[:]
|
||||||
|
|
||||||
|
def resolutionSupportAvailable(self):
|
||||||
|
return self.screens[0].resolutionSupportAvailable()
|
||||||
|
|
||||||
|
class XF86Error(Exception):
|
||||||
|
"""Just an exception when some goes wrong with X."""
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
xg = XF86Server()
|
||||||
|
xs = xg.getDefaultScreen()
|
||||||
|
print "Number of screens:",str(len(xg.screens))
|
||||||
|
print "Idle seconds:",xs.getIdleSeconds()
|
||||||
|
print
|
||||||
|
print "Gamma:"+str(xs.getGamma())
|
||||||
|
print
|
||||||
|
if xg.resolutionSupportAvailable():
|
||||||
|
print "SizeID:"+str(xs.getSizeID())
|
||||||
|
print "Size:"+str(xs.getSize())
|
||||||
|
sizes = xs.getAvailableSizes()
|
||||||
|
print "Available Sizes:" + str(sizes)
|
||||||
|
print
|
||||||
|
print "Rotation:" + str(xs.getRotation())
|
||||||
|
print "Available Rotations:" + str(xs.getAvailableRotations())
|
||||||
|
print
|
||||||
|
print "Refresh rate:" + str(xs.getRefreshRate())
|
||||||
|
print "Refresh rates for the current screen:"+str(xs.getAvailableRefreshRates(xs.getSizeID()))
|
||||||
|
|
||||||
|
for i in range(len(sizes)):
|
||||||
|
print "All Refresh Rates:"+str(xs.getAvailableRefreshRates(i))
|
||||||
|
xs.setScreenConfigAndRate(0,1,75)
|
||||||
|
print "SizeID:"+str(xs.getSizeID())
|
||||||
|
print "Size:"+str(xs.getSize())
|
||||||
|
sizes = xs.getAvailableSizes()
|
||||||
|
print "Available Sizes:" + str(sizes)
|
||||||
|
else:
|
||||||
|
print "(no resolution / randr support available)"
|
@ -0,0 +1,884 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# MicroHAL.py - #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Tue Oct 30 2004 #
|
||||||
|
# copyright : (C) 2004 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
from SimpleCommandRunner import *
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class MicroHAL__(object):
|
||||||
|
|
||||||
|
# Major device numbers for Linux block devices that support partitions.
|
||||||
|
partitionblockdevs = [
|
||||||
|
3, # IDE harddisks
|
||||||
|
8, # SCSI disks
|
||||||
|
13, # 8-bit MFM/RLL/IDE controller
|
||||||
|
14, # BIOS harddrive callback support {2.6}
|
||||||
|
21, # Acorn MFM hard drive interface
|
||||||
|
22, # Second IDE hard disk/CD-ROM interface
|
||||||
|
28, # ACSI disk (68k/Atari)
|
||||||
|
33, # Third IDE hard disk/CD-ROM interface
|
||||||
|
34, # Fourth IDE hard disk/CD-ROM interface
|
||||||
|
36, # MCA ESDI hard disk
|
||||||
|
44, # Flash Translation Layer (FTL) filesystems
|
||||||
|
45, # Parallel port IDE disk devices
|
||||||
|
48, # Mylex DAC960 PCI RAID controller; first controller
|
||||||
|
49, # Mylex DAC960 PCI RAID controller; second controller
|
||||||
|
50, # Mylex DAC960 PCI RAID controller; third controller
|
||||||
|
51, # Mylex DAC960 PCI RAID controller; fourth controller
|
||||||
|
52, # Mylex DAC960 PCI RAID controller; fifth controller
|
||||||
|
53, # Mylex DAC960 PCI RAID controller; sixth controller
|
||||||
|
54, # Mylex DAC960 PCI RAID controller; seventh controller
|
||||||
|
55, # Mylex DAC960 PCI RAID controller; eigth controller
|
||||||
|
56, # Fifth IDE hard disk/CD-ROM interface
|
||||||
|
57, # Sixth IDE hard disk/CD-ROM interface
|
||||||
|
65, # SCSI disk devices (16-31)
|
||||||
|
66, # SCSI disk devices (32-47)
|
||||||
|
67, # SCSI disk devices (48-63)
|
||||||
|
68, # SCSI disk devices (64-79)
|
||||||
|
69, # SCSI disk devices (80-95)
|
||||||
|
70, # SCSI disk devices (96-111)
|
||||||
|
71, # SCSI disk devices (112-127)
|
||||||
|
72, # Compaq Intelligent Drive Array, first controller
|
||||||
|
73, # Compaq Intelligent Drive Array, second controller
|
||||||
|
74, # Compaq Intelligent Drive Array, third controller
|
||||||
|
75, # Compaq Intelligent Drive Array, fourth controller
|
||||||
|
76, # Compaq Intelligent Drive Array, fifth controller
|
||||||
|
77, # Compaq Intelligent Drive Array, sixth controller
|
||||||
|
78, # Compaq Intelligent Drive Array, seventh controller
|
||||||
|
79, # Compaq Intelligent Drive Array, eigth controller
|
||||||
|
80, # I2O hard disk
|
||||||
|
81, # I2O hard disk
|
||||||
|
82, # I2O hard disk
|
||||||
|
83, # I2O hard disk
|
||||||
|
84, # I2O hard disk
|
||||||
|
85, # I2O hard disk
|
||||||
|
86, # I2O hard disk
|
||||||
|
87, # I2O hard disk
|
||||||
|
88, # Seventh IDE hard disk/CD-ROM interface
|
||||||
|
89, # Eighth IDE hard disk/CD-ROM interface
|
||||||
|
90, # Ninth IDE hard disk/CD-ROM interface
|
||||||
|
91, # Tenth IDE hard disk/CD-ROM interface
|
||||||
|
92, # PPDD encrypted disk driver
|
||||||
|
95, # IBM S/390 DASD block storage
|
||||||
|
101, # AMI HyperDisk RAID controller
|
||||||
|
102, # Compressed block device
|
||||||
|
104, # Compaq Next Generation Drive Array, first controller
|
||||||
|
105, # Compaq Next Generation Drive Array, second controller
|
||||||
|
106, # Compaq Next Generation Drive Array, third controller
|
||||||
|
107, # Compaq Next Generation Drive Array, fourth controller
|
||||||
|
108, # Compaq Next Generation Drive Array, fifth controller
|
||||||
|
109, # Compaq Next Generation Drive Array, sixth controller
|
||||||
|
110, # Compaq Next Generation Drive Array, seventh controller
|
||||||
|
111, # Compaq Next Generation Drive Array, eigth controller
|
||||||
|
112, # IBM iSeries virtual disk
|
||||||
|
114, # IDE BIOS powered software RAID interfaces such as the Promise Fastrak
|
||||||
|
128, # SCSI disk devices (128-143)
|
||||||
|
129, # SCSI disk devices (144-159)
|
||||||
|
130, # SCSI disk devices (160-175)
|
||||||
|
131, # SCSI disk devices (176-191)
|
||||||
|
132, # SCSI disk devices (192-207)
|
||||||
|
133, # SCSI disk devices (208-223)
|
||||||
|
134, # SCSI disk devices (224-239)
|
||||||
|
135, # SCSI disk devices (240-255)
|
||||||
|
136, # Mylex DAC960 PCI RAID controller; ninth controller
|
||||||
|
137, # Mylex DAC960 PCI RAID controller; tenth controller
|
||||||
|
138, # Mylex DAC960 PCI RAID controller; eleventh controller
|
||||||
|
139, # Mylex DAC960 PCI RAID controller; twelfth controller
|
||||||
|
140, # Mylex DAC960 PCI RAID controller; thirteenth controller
|
||||||
|
141, # Mylex DAC960 PCI RAID controller; fourteenth controller
|
||||||
|
142, # Mylex DAC960 PCI RAID controller; fifteenth controller
|
||||||
|
143, # Mylex DAC960 PCI RAID controller; sixteenth controller
|
||||||
|
160, # Promise SX8 8-port SATA Disks on First Controller
|
||||||
|
161 # Promise SX8 8-port SATA Disks on Second Controller
|
||||||
|
]
|
||||||
|
|
||||||
|
floppydevs = [
|
||||||
|
2, # Floppy disks
|
||||||
|
40 # Syquest EZ135 parallel port removable drive
|
||||||
|
]
|
||||||
|
|
||||||
|
cdromsdevs = [
|
||||||
|
11, # SCSI CD-ROM devices
|
||||||
|
12, # MSCDEX CD-ROM callback support {2.6}
|
||||||
|
15, # Sony CDU-31A/CDU-33A CD-ROM
|
||||||
|
16, # GoldStar CD-ROM
|
||||||
|
17, # Optics Storage CD-ROM
|
||||||
|
18, # Sanyo CD-ROM
|
||||||
|
20, # Hitachi CD-ROM (under development)
|
||||||
|
23, # Mitsumi proprietary CD-ROM
|
||||||
|
24, # Sony CDU-535 CD-ROM
|
||||||
|
25, # First Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
26, # Second Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
27, # Third Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
28, # Fourth Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
29, # Aztech/Orchid/Okano/Wearnes CD-ROM
|
||||||
|
30, # Philips LMS CM-205 CD-ROM
|
||||||
|
32, # Philips LMS CM-206 CD-ROM
|
||||||
|
41, # MicroSolutions BackPack parallel port CD-ROM
|
||||||
|
46, # Parallel port ATAPI CD-ROM devices
|
||||||
|
47, # Parallel port ATAPI disk devices
|
||||||
|
48, # Mylex DAC960 PCI RAID controller; first controller
|
||||||
|
113 # IBM iSeries virtual CD-ROM
|
||||||
|
]
|
||||||
|
|
||||||
|
burnerpacketdevs = [
|
||||||
|
97 # Packet writing for CD/DVD devices
|
||||||
|
]
|
||||||
|
|
||||||
|
# We provide a mapping between filesystems and kernelmodules, so filesystems
|
||||||
|
# that are built as modules can be loaded on demand. (In fact, mountconfig will
|
||||||
|
# load all filesystem modules needed to be able to mount all fstab entries.)
|
||||||
|
FilesystemProcDriver = [
|
||||||
|
# fstab name, /proc name, kernel module name
|
||||||
|
('auto','autofs','autofs4'),
|
||||||
|
('iso9660','iso9660','isofs'),
|
||||||
|
('nfs','nfsd','nfs')
|
||||||
|
]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def __init__(self):
|
||||||
|
self.devices = None
|
||||||
|
self.supportedfs = None
|
||||||
|
self.partitionsizelines = None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getDevices(self):
|
||||||
|
if self.devices is None:
|
||||||
|
self.devices = []
|
||||||
|
# Scan through /sys/block for devices. Find out which disks are
|
||||||
|
# installed and should be shown in the listview. For real
|
||||||
|
# disks we put a 'group' in the listview and under the group
|
||||||
|
# we list the partitions, whether they are mounted or not.
|
||||||
|
# FIXME: Check if sysfs is mounted.
|
||||||
|
blockdevices = os.listdir("/sys/block")
|
||||||
|
blockdevices.sort()
|
||||||
|
|
||||||
|
for blockdevice in blockdevices:
|
||||||
|
# We are looking for block devices that represent hard disks or
|
||||||
|
# things that have partitions.
|
||||||
|
# Grab the major device number
|
||||||
|
fhandle = open(os.path.join("/sys/block",blockdevice,"dev"))
|
||||||
|
devnumbers = fhandle.read()
|
||||||
|
fhandle.close()
|
||||||
|
devnum = int(devnumbers.split(":")[0])
|
||||||
|
# Is it on our list of partition devices?
|
||||||
|
if devnum in MicroHAL.partitionblockdevs:
|
||||||
|
fulldevice = os.path.join("/dev",blockdevice)
|
||||||
|
|
||||||
|
# Check for removable devices.
|
||||||
|
fhandle = open(os.path.join("/sys/block",blockdevice,"removable"))
|
||||||
|
removable = fhandle.read().strip()=="1"
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
if not removable:
|
||||||
|
newdisk = Disk()
|
||||||
|
else:
|
||||||
|
if os.readlink(os.path.join("/sys/block",blockdevice,"device")).split(os.path.sep)[5].startswith("usb"):
|
||||||
|
newdisk = USBDisk()
|
||||||
|
else:
|
||||||
|
newdisk = RemovableDisk()
|
||||||
|
newdisk.dev = fulldevice
|
||||||
|
newdisk.major = devnum
|
||||||
|
newdisk.removable = removable
|
||||||
|
newdisk.modelname = self.getModelName(fulldevice)
|
||||||
|
|
||||||
|
if not removable or isinstance(newdisk, USBDisk):
|
||||||
|
# We have a not removable block device or a USB Disk here.
|
||||||
|
partitions = os.listdir(os.path.join("/sys/block",blockdevice))
|
||||||
|
partitions.sort()
|
||||||
|
i = 1
|
||||||
|
for partition in partitions:
|
||||||
|
# Look for a partitions device names and not the other
|
||||||
|
# stuff that lives in the directory.
|
||||||
|
if partition.startswith(blockdevice):
|
||||||
|
fullpartition = os.path.join("/dev",partition)
|
||||||
|
newpartition = Partition()
|
||||||
|
newpartition.dev = fullpartition
|
||||||
|
newpartition.size = self.getPartitionSize(fullpartition)
|
||||||
|
newpartition.num = i
|
||||||
|
newdisk.partitions.append(newpartition)
|
||||||
|
i += 1
|
||||||
|
self.devices.append(newdisk)
|
||||||
|
|
||||||
|
elif devnum in MicroHAL.cdromsdevs:
|
||||||
|
fulldevice = os.path.join("/dev",blockdevice)
|
||||||
|
newdisk = RemovableDisk()
|
||||||
|
newdisk.dev = fulldevice
|
||||||
|
newdisk.major = devnum
|
||||||
|
newdisk.modelname = self.getModelName(fulldevice)
|
||||||
|
self.devices.append(newdisk)
|
||||||
|
|
||||||
|
elif devnum in MicroHAL.burnerpacketdevs:
|
||||||
|
fulldevice = os.path.join("/dev",blockdevice)
|
||||||
|
newdisk = BurnerDisk(self)
|
||||||
|
newdisk.dev = fulldevice
|
||||||
|
newdisk.major = devnum
|
||||||
|
newdisk.modelname = self.getModelName(fulldevice)
|
||||||
|
|
||||||
|
self.devices.append(newdisk)
|
||||||
|
|
||||||
|
return self.devices[:]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getPartitionSize(self,devicename):
|
||||||
|
partitionname = os.path.basename(devicename)
|
||||||
|
|
||||||
|
if self.partitionsizelines is None:
|
||||||
|
fhandle = open('/proc/partitions')
|
||||||
|
self.partitionsizelines = fhandle.readlines()
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
for line in self.partitionsizelines:
|
||||||
|
if i>=2:
|
||||||
|
(major, minor, blocks, name) = line.split()
|
||||||
|
if name==partitionname:
|
||||||
|
blocks = int(blocks) # 1K blocks now.
|
||||||
|
if blocks<1024:
|
||||||
|
return str(blocks)+" Kb"
|
||||||
|
if blocks<1024*1024:
|
||||||
|
return str(round(float(blocks)/1024.0,1))+" Mb"
|
||||||
|
blocks /= 1024
|
||||||
|
if blocks<1024*1024:
|
||||||
|
return str(round(float(blocks)/1024.0,1))+" Gb"
|
||||||
|
blocks /= 1024
|
||||||
|
return str(round(float(blocks)/1024.0,1))+" Tb"
|
||||||
|
i += 1
|
||||||
|
return None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getIDEModel(self,devname):
|
||||||
|
try:
|
||||||
|
fhandle = open(os.path.join("/proc/ide",os.path.basename(devname),"model"))
|
||||||
|
model = fhandle.read()
|
||||||
|
fhandle.close()
|
||||||
|
return model.strip()
|
||||||
|
except (OSError, IOError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getSCSIModel(self,devname):
|
||||||
|
try:
|
||||||
|
fhandle_model = open(os.path.join("/sys/block",os.path.basename(devname),"device/model"))
|
||||||
|
fhandle_vendor = open(os.path.join("/sys/block",os.path.basename(devname),"device/vendor"))
|
||||||
|
model = fhandle_model.read()[:-1]
|
||||||
|
vendor = fhandle_vendor.read()[:-1]
|
||||||
|
fhandle_model.close()
|
||||||
|
fhandle_vendor.close()
|
||||||
|
except (OSError, IOError):
|
||||||
|
pass
|
||||||
|
if len(model) + len(vendor) == 0:
|
||||||
|
return None
|
||||||
|
return vendor + " " + model
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getModelName(self,devname):
|
||||||
|
modelname = self.getIDEModel(devname)
|
||||||
|
if modelname is None:
|
||||||
|
modelname = self.getSCSIModel(devname)
|
||||||
|
if modelname is None:
|
||||||
|
modelname = devname
|
||||||
|
return " '"+modelname+"'"
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getSupportedFileSystems(self):
|
||||||
|
if self.supportedfs is None:
|
||||||
|
if os.path.isfile("/proc/filesystems"):
|
||||||
|
fhandle = open("/proc/filesystems")
|
||||||
|
self.supportedfs = []
|
||||||
|
for fs in fhandle.readlines():
|
||||||
|
try:
|
||||||
|
self.supportedfs.append(fs.strip().split()[1])
|
||||||
|
except IndexError:
|
||||||
|
self.supportedfs.append(fs.strip().split()[0])
|
||||||
|
# The following filesystems aren't found there, but usually they are
|
||||||
|
# supported.
|
||||||
|
self.supportedfs.extend(('swap','shm'))
|
||||||
|
return self.supportedfs[:]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def isSupportedFileSystem(self,fs):
|
||||||
|
# Look up the /proc and kernel driver name for the given filesystem type.
|
||||||
|
module = fs
|
||||||
|
proc = fs
|
||||||
|
for entry in self.FilesystemProcDriver:
|
||||||
|
if entry[0]==fs:
|
||||||
|
proc = entry[1]
|
||||||
|
module = entry[2]
|
||||||
|
|
||||||
|
if proc not in self.getSupportedFileSystems():
|
||||||
|
# The filesystem is not supported by the running kernel,
|
||||||
|
# but it might be built as module, so we try to load that.
|
||||||
|
retval, msg = SimpleCommandRunner().run(["/sbin/modprobe",module])
|
||||||
|
if retval > 0:
|
||||||
|
print msg
|
||||||
|
print "Couldn't load driver " + module + " for filesystem " + fs
|
||||||
|
# Force refresh of list of supported filesystems
|
||||||
|
self.supportedfs = None
|
||||||
|
return proc in self.getSupportedFileSystems()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class Device(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.dev = None
|
||||||
|
self.major = None
|
||||||
|
self.removable = None
|
||||||
|
self.uuid = None
|
||||||
|
self.label = None
|
||||||
|
|
||||||
|
def getDev(self):
|
||||||
|
return self.dev
|
||||||
|
|
||||||
|
def getMajor(self):
|
||||||
|
return self.major
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return self.dev
|
||||||
|
|
||||||
|
def getUUID(self):
|
||||||
|
if not self.uuid:
|
||||||
|
return ""
|
||||||
|
return self.uuid
|
||||||
|
|
||||||
|
def getLabel(self):
|
||||||
|
if not self.label:
|
||||||
|
return ""
|
||||||
|
return self.label
|
||||||
|
|
||||||
|
def isRemovable(self):
|
||||||
|
return self.removable
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Name: %s, Device: %s, Major: %i, " % (self.getName(),
|
||||||
|
self.getDev(),
|
||||||
|
self.getMajor())
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class Disk(Device):
|
||||||
|
def __init__(self):
|
||||||
|
super(Disk,self).__init__()
|
||||||
|
self.removable = False
|
||||||
|
self.partitions = []
|
||||||
|
self.modelname = None
|
||||||
|
self.iconname = "hi16-hdd"
|
||||||
|
|
||||||
|
def getModelName(self):
|
||||||
|
return self.modelname
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
if self.getModelName():
|
||||||
|
return i18n("Disk ")+self.getModelName()
|
||||||
|
else:
|
||||||
|
return i18n("Unknown Disk")
|
||||||
|
|
||||||
|
def getPartitions(self):
|
||||||
|
return self.partitions[:]
|
||||||
|
|
||||||
|
def appendPartition(self,partition):
|
||||||
|
self.partitions.append(partition)
|
||||||
|
def cmpNum(a,b): return cmp(a.num,b.num)
|
||||||
|
self.partitions.sort(cmpNum)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
x = Device.__str__(self) + "Partitions: ["
|
||||||
|
for part in self.partitions:
|
||||||
|
x += "["
|
||||||
|
x += str(part)
|
||||||
|
x += "], "
|
||||||
|
x += "],"
|
||||||
|
return x
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class RemovableDisk(Disk):
|
||||||
|
def __init__(self):
|
||||||
|
super(RemovableDisk,self).__init__()
|
||||||
|
self.iconname = "hi16-cdrom"
|
||||||
|
self.removable = True
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return "Optical Disk "+self.getModelName()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class USBDisk(Disk):
|
||||||
|
def __init__(self):
|
||||||
|
super(USBDisk,self).__init__()
|
||||||
|
self.iconname = "hi16-usbpen"
|
||||||
|
self.removable = True
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return "Removable USB Disk "+self.getModelName()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class BurnerDisk(RemovableDisk):
|
||||||
|
def __init__(self):
|
||||||
|
super(BurnerDisk,self).__init__()
|
||||||
|
self.iconname = "hi16-burner"
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return "Burner "+self.modelname
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class Floppy(Device):
|
||||||
|
def isRemovable(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return "Floppy"
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class Partition(Device):
|
||||||
|
def __init__(self):
|
||||||
|
super(Partition,self).__init__()
|
||||||
|
self.num = None
|
||||||
|
self.size = None
|
||||||
|
self.iconname = "hi16-hdd"
|
||||||
|
|
||||||
|
def getName(self):
|
||||||
|
return str(self.num)+" Partition "+ self.getSize()
|
||||||
|
# A group item for all of the other kernel/system mount entries.
|
||||||
|
|
||||||
|
def getSize(self):
|
||||||
|
return self.size
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Device: %s, Num: %i, Size: %s, Label: %s, UUID: %s" % (self.dev, self.num, self.getSize(),
|
||||||
|
self.getLabel(), self.getUUID())
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class FakeSystemDevice(object):
|
||||||
|
def getName(self): return "System"
|
||||||
|
def getIconName(self): return "hi16-blockdevice"
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class MicroHAL(object):
|
||||||
|
|
||||||
|
# Major device numbers for Linux block devices that support partitions.
|
||||||
|
partitionblockdevs = [
|
||||||
|
3, # IDE harddisks
|
||||||
|
8, # SCSI disks
|
||||||
|
13, # 8-bit MFM/RLL/IDE controller
|
||||||
|
14, # BIOS harddrive callback support {2.6}
|
||||||
|
21, # Acorn MFM hard drive interface
|
||||||
|
22, # Second IDE hard disk/CD-ROM interface
|
||||||
|
28, # ACSI disk (68k/Atari)
|
||||||
|
33, # Third IDE hard disk/CD-ROM interface
|
||||||
|
34, # Fourth IDE hard disk/CD-ROM interface
|
||||||
|
36, # MCA ESDI hard disk
|
||||||
|
44, # Flash Translation Layer (FTL) filesystems
|
||||||
|
45, # Parallel port IDE disk devices
|
||||||
|
48, # Mylex DAC960 PCI RAID controller; first controller
|
||||||
|
49, # Mylex DAC960 PCI RAID controller; second controller
|
||||||
|
50, # Mylex DAC960 PCI RAID controller; third controller
|
||||||
|
51, # Mylex DAC960 PCI RAID controller; fourth controller
|
||||||
|
52, # Mylex DAC960 PCI RAID controller; fifth controller
|
||||||
|
53, # Mylex DAC960 PCI RAID controller; sixth controller
|
||||||
|
54, # Mylex DAC960 PCI RAID controller; seventh controller
|
||||||
|
55, # Mylex DAC960 PCI RAID controller; eigth controller
|
||||||
|
56, # Fifth IDE hard disk/CD-ROM interface
|
||||||
|
57, # Sixth IDE hard disk/CD-ROM interface
|
||||||
|
65, # SCSI disk devices (16-31)
|
||||||
|
66, # SCSI disk devices (32-47)
|
||||||
|
67, # SCSI disk devices (48-63)
|
||||||
|
68, # SCSI disk devices (64-79)
|
||||||
|
69, # SCSI disk devices (80-95)
|
||||||
|
70, # SCSI disk devices (96-111)
|
||||||
|
71, # SCSI disk devices (112-127)
|
||||||
|
72, # Compaq Intelligent Drive Array, first controller
|
||||||
|
73, # Compaq Intelligent Drive Array, second controller
|
||||||
|
74, # Compaq Intelligent Drive Array, third controller
|
||||||
|
75, # Compaq Intelligent Drive Array, fourth controller
|
||||||
|
76, # Compaq Intelligent Drive Array, fifth controller
|
||||||
|
77, # Compaq Intelligent Drive Array, sixth controller
|
||||||
|
78, # Compaq Intelligent Drive Array, seventh controller
|
||||||
|
79, # Compaq Intelligent Drive Array, eigth controller
|
||||||
|
80, # I2O hard disk
|
||||||
|
81, # I2O hard disk
|
||||||
|
82, # I2O hard disk
|
||||||
|
83, # I2O hard disk
|
||||||
|
84, # I2O hard disk
|
||||||
|
85, # I2O hard disk
|
||||||
|
86, # I2O hard disk
|
||||||
|
87, # I2O hard disk
|
||||||
|
88, # Seventh IDE hard disk/CD-ROM interface
|
||||||
|
89, # Eighth IDE hard disk/CD-ROM interface
|
||||||
|
90, # Ninth IDE hard disk/CD-ROM interface
|
||||||
|
91, # Tenth IDE hard disk/CD-ROM interface
|
||||||
|
92, # PPDD encrypted disk driver
|
||||||
|
95, # IBM S/390 DASD block storage
|
||||||
|
101, # AMI HyperDisk RAID controller
|
||||||
|
102, # Compressed block device
|
||||||
|
104, # Compaq Next Generation Drive Array, first controller
|
||||||
|
105, # Compaq Next Generation Drive Array, second controller
|
||||||
|
106, # Compaq Next Generation Drive Array, third controller
|
||||||
|
107, # Compaq Next Generation Drive Array, fourth controller
|
||||||
|
108, # Compaq Next Generation Drive Array, fifth controller
|
||||||
|
109, # Compaq Next Generation Drive Array, sixth controller
|
||||||
|
110, # Compaq Next Generation Drive Array, seventh controller
|
||||||
|
111, # Compaq Next Generation Drive Array, eigth controller
|
||||||
|
112, # IBM iSeries virtual disk
|
||||||
|
114, # IDE BIOS powered software RAID interfaces such as the Promise Fastrak
|
||||||
|
128, # SCSI disk devices (128-143)
|
||||||
|
129, # SCSI disk devices (144-159)
|
||||||
|
130, # SCSI disk devices (160-175)
|
||||||
|
131, # SCSI disk devices (176-191)
|
||||||
|
132, # SCSI disk devices (192-207)
|
||||||
|
133, # SCSI disk devices (208-223)
|
||||||
|
134, # SCSI disk devices (224-239)
|
||||||
|
135, # SCSI disk devices (240-255)
|
||||||
|
136, # Mylex DAC960 PCI RAID controller; ninth controller
|
||||||
|
137, # Mylex DAC960 PCI RAID controller; tenth controller
|
||||||
|
138, # Mylex DAC960 PCI RAID controller; eleventh controller
|
||||||
|
139, # Mylex DAC960 PCI RAID controller; twelfth controller
|
||||||
|
140, # Mylex DAC960 PCI RAID controller; thirteenth controller
|
||||||
|
141, # Mylex DAC960 PCI RAID controller; fourteenth controller
|
||||||
|
142, # Mylex DAC960 PCI RAID controller; fifteenth controller
|
||||||
|
143, # Mylex DAC960 PCI RAID controller; sixteenth controller
|
||||||
|
160, # Promise SX8 8-port SATA Disks on First Controller
|
||||||
|
161 # Promise SX8 8-port SATA Disks on Second Controller
|
||||||
|
]
|
||||||
|
|
||||||
|
floppydevs = [
|
||||||
|
2, # Floppy disks
|
||||||
|
40 # Syquest EZ135 parallel port removable drive
|
||||||
|
]
|
||||||
|
|
||||||
|
cdromsdevs = [
|
||||||
|
11, # SCSI CD-ROM devices
|
||||||
|
12, # MSCDEX CD-ROM callback support {2.6}
|
||||||
|
15, # Sony CDU-31A/CDU-33A CD-ROM
|
||||||
|
16, # GoldStar CD-ROM
|
||||||
|
17, # Optics Storage CD-ROM
|
||||||
|
18, # Sanyo CD-ROM
|
||||||
|
20, # Hitachi CD-ROM (under development)
|
||||||
|
23, # Mitsumi proprietary CD-ROM
|
||||||
|
24, # Sony CDU-535 CD-ROM
|
||||||
|
25, # First Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
26, # Second Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
27, # Third Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
28, # Fourth Matsushita (Panasonic/SoundBlaster) CD-ROM
|
||||||
|
29, # Aztech/Orchid/Okano/Wearnes CD-ROM
|
||||||
|
30, # Philips LMS CM-205 CD-ROM
|
||||||
|
32, # Philips LMS CM-206 CD-ROM
|
||||||
|
41, # MicroSolutions BackPack parallel port CD-ROM
|
||||||
|
46, # Parallel port ATAPI CD-ROM devices
|
||||||
|
47, # Parallel port ATAPI disk devices
|
||||||
|
48, # Mylex DAC960 PCI RAID controller; first controller
|
||||||
|
113 # IBM iSeries virtual CD-ROM
|
||||||
|
]
|
||||||
|
|
||||||
|
burnerpacketdevs = [
|
||||||
|
97 # Packet writing for CD/DVD devices
|
||||||
|
]
|
||||||
|
|
||||||
|
# We provide a mapping between filesystems and kernelmodules, so filesystems
|
||||||
|
# that are built as modules can be loaded on demand. (In fact, mountconfig will
|
||||||
|
# load all filesystem modules needed to be able to mount all fstab entries.)
|
||||||
|
FilesystemProcDriver = [
|
||||||
|
# fstab name, /proc name, kernel module name
|
||||||
|
('auto','autofs','autofs4'),
|
||||||
|
('iso9660','iso9660','isofs'),
|
||||||
|
('nfs','nfsd','nfs')
|
||||||
|
]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def __init__(self):
|
||||||
|
self.devices = None
|
||||||
|
self.supportedfs = None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getDevices(self):
|
||||||
|
if self.devices is None:
|
||||||
|
self.devices = []
|
||||||
|
|
||||||
|
retval, msg = SimpleCommandRunner().run(["/usr/bin/lshal"])
|
||||||
|
if retval > 0:
|
||||||
|
return []
|
||||||
|
|
||||||
|
partition_to_uid = {}
|
||||||
|
uid_to_disk = {}
|
||||||
|
|
||||||
|
READING_TOP = 0
|
||||||
|
READING_DEVICE = 1
|
||||||
|
state = READING_TOP
|
||||||
|
|
||||||
|
parsed_hash = None
|
||||||
|
current_uid = None
|
||||||
|
|
||||||
|
for line in msg.split('\n'):
|
||||||
|
|
||||||
|
if state==READING_TOP:
|
||||||
|
if line.startswith("udi ="):
|
||||||
|
parsed_hash = {}
|
||||||
|
current_uid = self._parseString(line[6:])
|
||||||
|
state = READING_DEVICE
|
||||||
|
|
||||||
|
elif state==READING_DEVICE:
|
||||||
|
if line=="" or not line.startswith(" "):
|
||||||
|
# Detect the end of this block of device data.
|
||||||
|
state = READING_TOP
|
||||||
|
|
||||||
|
if u"info.category" in parsed_hash:
|
||||||
|
|
||||||
|
new_device = None
|
||||||
|
|
||||||
|
capabilities_string = u" ".join(parsed_hash[u"info.capabilities"])
|
||||||
|
capabilities = self._parseStringList(capabilities_string)
|
||||||
|
|
||||||
|
category = self._parseString(' '.join(parsed_hash[u"info.category"]))
|
||||||
|
if category==u"volume":
|
||||||
|
# Is it a volume?
|
||||||
|
|
||||||
|
is_disc = parsed_hash.get(u"volume.is_disc")
|
||||||
|
if is_disc is not None and is_disc[0]=='true':
|
||||||
|
continue
|
||||||
|
|
||||||
|
is_partition = parsed_hash.get(u"volume.is_partition")
|
||||||
|
if is_partition is not None:
|
||||||
|
is_partition = is_partition[0]
|
||||||
|
|
||||||
|
if is_partition=='true':
|
||||||
|
new_device = Partition()
|
||||||
|
new_device.num = int(parsed_hash[u"volume.partition.number"][0])
|
||||||
|
partition_to_uid[new_device] = current_uid
|
||||||
|
|
||||||
|
if u"info.parent" in parsed_hash:
|
||||||
|
parent_uid = self._parseString(' '.join(parsed_hash[u"info.parent"]))
|
||||||
|
partition_to_uid[new_device] = parent_uid
|
||||||
|
|
||||||
|
else:
|
||||||
|
new_device = Disk()
|
||||||
|
uid_to_disk[current_uid] = new_device
|
||||||
|
|
||||||
|
if u"volume.uuid" in parsed_hash:
|
||||||
|
new_device.uuid = self._parseString(' '.join(parsed_hash[u"volume.uuid"]))
|
||||||
|
|
||||||
|
if u"volume.label" in parsed_hash:
|
||||||
|
new_device.label = self._parseString(parsed_hash[u"volume.label"][0])
|
||||||
|
|
||||||
|
if u"volume.size" in parsed_hash:
|
||||||
|
size = parsed_hash[u"volume.size"][0]
|
||||||
|
new_device.size = self.formatSizeBytes(int(size))
|
||||||
|
else:
|
||||||
|
new_device.size = "?"
|
||||||
|
|
||||||
|
|
||||||
|
# is it a storage device?
|
||||||
|
elif category==u"storage":
|
||||||
|
storage_model = self._parseString(' '.join(parsed_hash[u"storage.model"]))
|
||||||
|
storage_removable = parsed_hash[u"storage.removable"][0]==u"true"
|
||||||
|
|
||||||
|
if u"storage.cdrom" in capabilities:
|
||||||
|
|
||||||
|
if u"storage.cdrom.cdrw" in parsed_hash \
|
||||||
|
and parsed_hash[u"storage.cdrom.cdrw"][0]==u"true":
|
||||||
|
new_device = BurnerDisk()
|
||||||
|
else:
|
||||||
|
new_device= RemovableDisk()
|
||||||
|
|
||||||
|
elif u"storage.floppy" in capabilities:
|
||||||
|
new_device = FloppyDevice()
|
||||||
|
else:
|
||||||
|
if u"storage.bus" in parsed_hash \
|
||||||
|
and self._parseString(' '.join(parsed_hash[u"storage.bus"]))==u"usb":
|
||||||
|
|
||||||
|
new_device = USBDisk()
|
||||||
|
else:
|
||||||
|
new_device = Disk()
|
||||||
|
|
||||||
|
new_device.modelname = storage_model
|
||||||
|
uid_to_disk[current_uid] = new_device
|
||||||
|
else:
|
||||||
|
# Not interesting, skip it.
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Handle the generic properties.
|
||||||
|
new_device.dev = self._parseString(' '.join(parsed_hash[u"block.device"]))
|
||||||
|
new_device.major = int(parsed_hash[u"block.major"][0])
|
||||||
|
|
||||||
|
self.devices.append(new_device)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Keep on accumulating info about this device.
|
||||||
|
parts = line.split()
|
||||||
|
parsed_hash[ parts[0] ] = parts[2:]
|
||||||
|
|
||||||
|
# Attach the partitions to thier devices.
|
||||||
|
for partition in partition_to_uid.keys():
|
||||||
|
parent = partition_to_uid[partition]
|
||||||
|
if parent in uid_to_disk.keys():
|
||||||
|
parent_device = uid_to_disk[parent]
|
||||||
|
parent_device.appendPartition(partition)
|
||||||
|
self.devices.remove(partition)
|
||||||
|
|
||||||
|
return self.devices[:]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def _parseStringList(self,source_string):
|
||||||
|
STATE_TOP = 0
|
||||||
|
STATE_STRING = 1
|
||||||
|
|
||||||
|
state = STATE_TOP
|
||||||
|
current_string = ""
|
||||||
|
string_list = []
|
||||||
|
for c in source_string:
|
||||||
|
if state==STATE_TOP:
|
||||||
|
if c=='}':
|
||||||
|
break
|
||||||
|
if c=="'":
|
||||||
|
state = STATE_STRING
|
||||||
|
else:
|
||||||
|
if c=="'":
|
||||||
|
state = STATE_TOP
|
||||||
|
string_list.append(current_string)
|
||||||
|
current_string = ""
|
||||||
|
else:
|
||||||
|
current_string += c
|
||||||
|
|
||||||
|
return string_list
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def _parseString(self,source_string):
|
||||||
|
STATE_TOP = 0
|
||||||
|
STATE_STRING = 1
|
||||||
|
|
||||||
|
state = STATE_TOP
|
||||||
|
current_string = ""
|
||||||
|
for c in source_string:
|
||||||
|
if state==STATE_TOP:
|
||||||
|
if c=="'":
|
||||||
|
state = STATE_STRING
|
||||||
|
else:
|
||||||
|
if c=="'":
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
current_string += c
|
||||||
|
return current_string
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def formatSizeBytes(self,size):
|
||||||
|
if size<1024:
|
||||||
|
return str(size+" B")
|
||||||
|
if size<1024*1042:
|
||||||
|
return str(round(float(size)/1024.0,1))+" Kb"
|
||||||
|
size /= 1024
|
||||||
|
if size<1024*1024:
|
||||||
|
return str(round(float(size)/1024.0,1))+" Mb"
|
||||||
|
size /= 1024
|
||||||
|
if size<1024*1024:
|
||||||
|
return str(round(float(size)/1024.0,1))+" Gb"
|
||||||
|
size /= 1024
|
||||||
|
return str(round(float(size)/1024.0,1))+" Tb"
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getSupportedFileSystems(self):
|
||||||
|
if self.supportedfs is None:
|
||||||
|
if os.path.isfile("/proc/filesystems"):
|
||||||
|
fhandle = open("/proc/filesystems")
|
||||||
|
self.supportedfs = []
|
||||||
|
for fs in fhandle.readlines():
|
||||||
|
try:
|
||||||
|
self.supportedfs.append(fs.strip().split()[1])
|
||||||
|
except IndexError:
|
||||||
|
self.supportedfs.append(fs.strip().split()[0])
|
||||||
|
# The following filesystems aren't found there, but usually they are
|
||||||
|
# supported.
|
||||||
|
self.supportedfs.extend(('swap','shm'))
|
||||||
|
return self.supportedfs[:]
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def isSupportedFileSystem(self,fs):
|
||||||
|
# Look up the /proc and kernel driver name for the given filesystem type.
|
||||||
|
module = fs
|
||||||
|
proc = fs
|
||||||
|
for entry in self.FilesystemProcDriver:
|
||||||
|
if entry[0]==fs:
|
||||||
|
proc = entry[1]
|
||||||
|
module = entry[2]
|
||||||
|
|
||||||
|
if proc not in self.getSupportedFileSystems():
|
||||||
|
# The filesystem is not supported by the running kernel,
|
||||||
|
# but it might be built as module, so we try to load that.
|
||||||
|
retval, msg = SimpleCommandRunner().run(["/sbin/modprobe",module])
|
||||||
|
if retval > 0:
|
||||||
|
print msg
|
||||||
|
print "Couldn't load driver " + module + " for filesystem " + fs
|
||||||
|
# Force refresh of list of supported filesystems
|
||||||
|
self.supportedfs = None
|
||||||
|
return proc in self.getSupportedFileSystems()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
def getDeviceByLabel(self, label):
|
||||||
|
for device in self.getDevices():
|
||||||
|
if device.getLabel()==label:
|
||||||
|
return device
|
||||||
|
|
||||||
|
if isinstance(device,Disk):
|
||||||
|
for partition in device.getPartitions():
|
||||||
|
if partition.getLabel()==label:
|
||||||
|
return partition
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getLabelByDevice(self, device):
|
||||||
|
for item in self.getDevices():
|
||||||
|
for partition in item.partitions:
|
||||||
|
if partition.dev==device:
|
||||||
|
return partition.label
|
||||||
|
print "No Label found for ",device
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def getUUIDByDevice(self, device):
|
||||||
|
for item in self.getDevices():
|
||||||
|
for partition in item.partitions:
|
||||||
|
#print partition, partition.getUUID()
|
||||||
|
if partition.dev==device:
|
||||||
|
return partition.uuid
|
||||||
|
print "No UUID found for ",device
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def getDeviceByUUID(self, uuid):
|
||||||
|
for device in self.getDevices():
|
||||||
|
if device.getUUID()==uuid:
|
||||||
|
return device
|
||||||
|
|
||||||
|
if isinstance(device,Disk):
|
||||||
|
for partition in device.getPartitions():
|
||||||
|
if partition.getUUID()==uuid:
|
||||||
|
return partition
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
if __name__=='__main__':
|
||||||
|
hal = MicroHAL()
|
||||||
|
for item in hal.getDevices():
|
||||||
|
print(str(item))
|
||||||
|
|
||||||
|
print
|
||||||
|
|
||||||
|
#"""
|
||||||
|
for item in hal.getDevices():
|
||||||
|
for partition in item.partitions:
|
||||||
|
print partition, partition.getLabel()
|
||||||
|
#"""
|
||||||
|
#realhal = RealHAL()
|
||||||
|
#for item in realhal.getDevices():
|
||||||
|
# print(str(item))
|
||||||
|
|
||||||
|
print
|
||||||
|
|
||||||
|
|
@ -0,0 +1,573 @@
|
|||||||
|
###########################################################################
|
||||||
|
# SMBShareSelectDialog.py - Dialog for selecting an SMB share on a network#
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Tue Oct 30 2004 #
|
||||||
|
# copyright : (C) 2004 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
from qt import *
|
||||||
|
from kdeui import *
|
||||||
|
from kdecore import *
|
||||||
|
from kio import *
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class SMBShareSelectDialog(KDialogBase):
|
||||||
|
|
||||||
|
STATUS_IDLE = 0
|
||||||
|
STATUS_SEARCH_TOP_LEVEL = 1
|
||||||
|
STATUS_SEARCH = 2
|
||||||
|
STATUS_RESOLVE = 3
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def __init__(self,parent,name=None):
|
||||||
|
super(SMBShareSelectDialog,self).__init__(parent,name,1,"",KDialogBase.Ok|KDialogBase.Cancel)
|
||||||
|
self.updatinggui = False
|
||||||
|
|
||||||
|
self.resize(600,400)
|
||||||
|
|
||||||
|
vbox = self.makeVBoxMainWidget()
|
||||||
|
|
||||||
|
hbox = QHBox(vbox)
|
||||||
|
hbox.setSpacing(self.spacingHint())
|
||||||
|
tmplabel = QLabel(hbox)
|
||||||
|
tmplabel.setPixmap(UserIcon("hi32-samba"))
|
||||||
|
|
||||||
|
hbox.setStretchFactor(tmplabel,0)
|
||||||
|
|
||||||
|
self.headinglabel = QLabel(hbox)
|
||||||
|
self.headinglabel.setText(i18n("Select a network share"))
|
||||||
|
hbox.setStretchFactor(self.headinglabel,1)
|
||||||
|
|
||||||
|
hbox2 = QHBox(vbox)
|
||||||
|
|
||||||
|
# The main treeview where the action happens.
|
||||||
|
self.treeview = KListView(hbox2)
|
||||||
|
self.treeview.addColumn("(hidden)")
|
||||||
|
self.treeview.header().hide()
|
||||||
|
self.treeview.setRootIsDecorated(True)
|
||||||
|
|
||||||
|
self.connect(self.treeview,SIGNAL("expanded(QListViewItem *)"),self.slotNodeExpanded)
|
||||||
|
self.connect(self.treeview,SIGNAL("selectionChanged(QListViewItem *)"),self.slotNodeSelected)
|
||||||
|
self.connect(self.treeview,SIGNAL("clicked(QListViewItem *)"),self.slotClicked)
|
||||||
|
self.dirlister = KDirLister()
|
||||||
|
self.dirlister.setDirOnlyMode(True)
|
||||||
|
self.dirlister.setAutoUpdate(False)
|
||||||
|
self.dirlister.setAutoErrorHandlingEnabled(True,self)
|
||||||
|
self.connect(self.dirlister,SIGNAL("newItems(const KFileItemList &)"),self.slotNewItems)
|
||||||
|
self.connect(self.dirlister,SIGNAL("completed()"),self.slotDirListCompleted)
|
||||||
|
self.connect(self.dirlister,SIGNAL("canceled()"),self.slotDirListCanceled)
|
||||||
|
self.connect(self.dirlister,SIGNAL("redirection(const KURL &,const KURL &)"),self.slotDirListRedirection)
|
||||||
|
self.enableButtonOK(False)
|
||||||
|
|
||||||
|
# The "Connect as" part
|
||||||
|
widget = QWidget(hbox2)
|
||||||
|
grid = QGridLayout(widget,6,4,KDialog.spacingHint())
|
||||||
|
grid.setRowStretch(5,1)
|
||||||
|
|
||||||
|
tmplabel = QLabel(widget)
|
||||||
|
tmplabel.setPixmap(UserIcon("hi16-password"))
|
||||||
|
grid.addWidget(tmplabel,0,0)
|
||||||
|
|
||||||
|
self.connectaslabel = QLabel(widget)
|
||||||
|
self.connectaslabel.setText("Connect to 'XXX' as:")
|
||||||
|
grid.addMultiCellWidget(self.connectaslabel,0,0,1,3)
|
||||||
|
|
||||||
|
self.guestradio = QRadioButton(widget)
|
||||||
|
self.guestradio.setChecked(True)
|
||||||
|
grid.addWidget(self.guestradio,1,1)
|
||||||
|
tmplabel = QLabel(widget)
|
||||||
|
tmplabel.setText(i18n("Guest"))
|
||||||
|
grid.addWidget(tmplabel,1,2)
|
||||||
|
self.connect(self.guestradio,SIGNAL("stateChanged(int)"),self.slotGuestRadioClicked)
|
||||||
|
|
||||||
|
self.userradio = QRadioButton(widget)
|
||||||
|
grid.addWidget(self.userradio,2,1)
|
||||||
|
tmplabel = QLabel(widget)
|
||||||
|
tmplabel.setText(i18n("Username:"))
|
||||||
|
grid.addWidget(tmplabel,2,2)
|
||||||
|
self.connect(self.userradio,SIGNAL("stateChanged(int)"),self.slotUserRadioClicked)
|
||||||
|
|
||||||
|
self.usernameedit = KLineEdit(widget)
|
||||||
|
grid.addWidget(self.usernameedit,2,3)
|
||||||
|
self.connect(self.usernameedit,SIGNAL("textChanged(const QString &)"),self.slotUsernameChanged)
|
||||||
|
|
||||||
|
tmplabel = QLabel(widget)
|
||||||
|
tmplabel.setText(i18n("Password:"))
|
||||||
|
grid.addWidget(tmplabel,3,2)
|
||||||
|
|
||||||
|
self.passwordedit = KLineEdit(widget)
|
||||||
|
grid.addWidget(self.passwordedit,3,3)
|
||||||
|
|
||||||
|
self.reconnectbutton = KPushButton(i18n("Reconnect now"),widget)
|
||||||
|
grid.addMultiCellWidget(self.reconnectbutton,4,4,1,3)
|
||||||
|
self.connect(self.reconnectbutton,SIGNAL("clicked()"),self.slotReconnectClicked)
|
||||||
|
|
||||||
|
self.dirlistertimer = None
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def choose(self,currenturl):
|
||||||
|
self.lookupqueue = []
|
||||||
|
self.selecteditem = None
|
||||||
|
|
||||||
|
self.treeview.clear()
|
||||||
|
self.url_to_list_item_map = {}
|
||||||
|
|
||||||
|
# Fill the first level
|
||||||
|
root_url = KURL("smb:/")
|
||||||
|
self.rootitem = SMBShareListViewItem(self.treeview, i18n("Network Neighbourhood"), root_url, self)
|
||||||
|
|
||||||
|
self.searchurl = currenturl
|
||||||
|
self._updateConnectGUI()
|
||||||
|
self.enableButtonOK(False)
|
||||||
|
self._openDefaultURL()
|
||||||
|
|
||||||
|
self.spintimerid = self.startTimer(250)
|
||||||
|
self.exec_loop()
|
||||||
|
self.stopResolve()
|
||||||
|
|
||||||
|
self.killTimer(self.spintimerid)
|
||||||
|
|
||||||
|
if self.result()==self.Accepted:
|
||||||
|
currenturl = self.selecteditem.getURL()
|
||||||
|
|
||||||
|
self.url_to_list_item_map = None
|
||||||
|
|
||||||
|
return currenturl
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def _openDefaultURL(self):
|
||||||
|
if self.searchurl is not None:
|
||||||
|
rc = self.rootitem.selectURL(self.searchurl)
|
||||||
|
if rc==self.rootitem.OPEN_SUCCESS:
|
||||||
|
self.currenturl = self.searchurl
|
||||||
|
self.searchurl = None
|
||||||
|
self.enableButtonOK(True)
|
||||||
|
elif rc==self.rootitem.OPEN_FAIL or rc==self.rootitem.OPEN_SUCCESS_INVALID:
|
||||||
|
self.searchurl = None
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def stopResolve(self):
|
||||||
|
if self.dirlistertimer is not None:
|
||||||
|
self.killTimer(self.dirlistertimer)
|
||||||
|
self.dirlister.stop()
|
||||||
|
for item in self.lookupqueue:
|
||||||
|
item.cancelResolve()
|
||||||
|
self.lookupqueue = []
|
||||||
|
|
||||||
|
self.searchurl = None # Stop trying to open this URL too.
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def setOpen(self,item,open):
|
||||||
|
if item.isResolved():
|
||||||
|
KListView.setOpen(self.treeview,item,open)
|
||||||
|
else:
|
||||||
|
item.startResolve(True)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def appendToResolveQueue(self,item):
|
||||||
|
if item not in self.lookupqueue:
|
||||||
|
self.lookupqueue.append(item)
|
||||||
|
self._startDirLister()
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotNodeExpanded(self,item):
|
||||||
|
self.setOpen(item,True)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotClicked(self):
|
||||||
|
if self.treeview.selectedItem() is None:
|
||||||
|
self.selecteditem = None
|
||||||
|
self._updateConnectGUI()
|
||||||
|
self.enableButtonOK(False)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotNodeSelected(self,item):
|
||||||
|
self.selecteditem = item
|
||||||
|
self._updateConnectGUI()
|
||||||
|
self.enableButtonOK(item.getLevel()==item.LEVEL_DIR)
|
||||||
|
|
||||||
|
if not self.selecteditem.isResolved():
|
||||||
|
self.selecteditem.startResolve(False)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotNewItems(self,items):
|
||||||
|
for entry in items:
|
||||||
|
newitem = SMBShareListViewItem(self.lookupqueue[0], unicode(entry.name()), KURL(entry.url()), self)
|
||||||
|
self.url_to_list_item_map[unicode(entry.url().prettyURL())] = newitem
|
||||||
|
# Notice how I copied the KURL object and QString (to a python string)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotDirListCompleted(self):
|
||||||
|
item = self.lookupqueue[0]
|
||||||
|
item.setBusyIcon(False)
|
||||||
|
del self.lookupqueue[0]
|
||||||
|
|
||||||
|
item.resolveComplete()
|
||||||
|
self._startDirLister()
|
||||||
|
|
||||||
|
self._openDefaultURL()
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotDirListCanceled(self):
|
||||||
|
self.stopResolve()
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotDirListRedirection(self,oldUrl,newUrl):
|
||||||
|
list_item = self.url_to_list_item_map[unicode(oldUrl.prettyURL())]
|
||||||
|
list_item.setURL(KURL(newUrl)) # The copy is important.
|
||||||
|
|
||||||
|
# Reselect the selected node. (This will force a refresh).
|
||||||
|
if self.selecteditem is not None:
|
||||||
|
self.updatinggui = True
|
||||||
|
self.slotNodeSelected(self.selecteditem)
|
||||||
|
self.updatinggui = False
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotUsernameChanged(self,newtext):
|
||||||
|
self.reconnectbutton.setEnabled(self.usernameedit.text()!="")
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotReconnectClicked(self):
|
||||||
|
if self.updatinggui:
|
||||||
|
return
|
||||||
|
self.updatinggui = True
|
||||||
|
|
||||||
|
if self.selecteditem is None: # Sanity check.
|
||||||
|
return
|
||||||
|
|
||||||
|
# The user wants to change how we connect to this remote machine.
|
||||||
|
|
||||||
|
machineitem = self.selecteditem.getMachineItem()
|
||||||
|
if machineitem is None:
|
||||||
|
return # Shouldn't happen.
|
||||||
|
|
||||||
|
self.stopResolve()
|
||||||
|
|
||||||
|
# Grab the URL object before we delete the listviewitem that holds it.
|
||||||
|
selectedurl = self.selecteditem.getURL()
|
||||||
|
|
||||||
|
# Close up the machine item and remove the items under the machine item.
|
||||||
|
machineitem.unresolve()
|
||||||
|
|
||||||
|
# Set the username/password for the machine item.
|
||||||
|
if self.guestradio.isChecked():
|
||||||
|
machineitem.getURL().setUser(QString.null)
|
||||||
|
machineitem.getURL().setPass(QString.null)
|
||||||
|
selectedurl.setUser(QString.null)
|
||||||
|
selectedurl.setPass(QString.null)
|
||||||
|
else:
|
||||||
|
machineitem.getURL().setUser(self.usernameedit.text())
|
||||||
|
machineitem.getURL().setPass(self.passwordedit.text())
|
||||||
|
selectedurl.setUser(self.usernameedit.text())
|
||||||
|
selectedurl.setPass(self.passwordedit.text())
|
||||||
|
self.selecteditem = None
|
||||||
|
self._updateConnectGUI()
|
||||||
|
|
||||||
|
self.searchurl = selectedurl
|
||||||
|
self._openDefaultURL()
|
||||||
|
self.updatinggui = False
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def _startDirLister(self):
|
||||||
|
if self.dirlistertimer is None:
|
||||||
|
# Check the URL lister queue the next the event loop runs.
|
||||||
|
# Don't get all "recursed up"!
|
||||||
|
self.dirlistertimer = self.startTimer(0)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def timerEvent(self,event):
|
||||||
|
KDialogBase.timerEvent(self,event)
|
||||||
|
if self.spintimerid==event.timerId():
|
||||||
|
# Spin the current folder icon
|
||||||
|
if len(self.lookupqueue)!=0:
|
||||||
|
self.lookupqueue[0].setBusyIcon(True)
|
||||||
|
elif event.timerId()==self.dirlistertimer:
|
||||||
|
self.killTimer(self.dirlistertimer)
|
||||||
|
self.dirlistertimer = None
|
||||||
|
if self.dirlister.isFinished():
|
||||||
|
if len(self.lookupqueue)!=0:
|
||||||
|
self.dirlister.openURL(self.lookupqueue[0].getURL())
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotGuestRadioClicked(self,state):
|
||||||
|
if self.updatinggui:
|
||||||
|
return
|
||||||
|
self.updatinggui = True
|
||||||
|
|
||||||
|
if self.selecteditem is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if state==QButton.Off:
|
||||||
|
self.guestradio.setChecked(True)
|
||||||
|
self.userradio.setChecked(False)
|
||||||
|
|
||||||
|
self.passwordedit.setEnabled(False)
|
||||||
|
self.usernameedit.setEnabled(False)
|
||||||
|
|
||||||
|
selectedurl = self.selecteditem.getURL()
|
||||||
|
self.reconnectbutton.setEnabled(unicode(selectedurl.user())!="")
|
||||||
|
|
||||||
|
self.updatinggui = False
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotUserRadioClicked(self,state):
|
||||||
|
if self.updatinggui:
|
||||||
|
return
|
||||||
|
self.updatinggui = True
|
||||||
|
if state==QButton.Off:
|
||||||
|
self.userradio.setChecked(True)
|
||||||
|
self.guestradio.setChecked(False)
|
||||||
|
|
||||||
|
self.passwordedit.setEnabled(True)
|
||||||
|
self.usernameedit.setEnabled(True)
|
||||||
|
|
||||||
|
username = unicode(self.usernameedit.text())
|
||||||
|
password = unicode(self.passwordedit.text())
|
||||||
|
selectedurl = self.selecteditem.getURL()
|
||||||
|
if username!="" and password!="" and \
|
||||||
|
((unicode(selectedurl.user())!=username) or (unicode(selectedurl.pass_())!=password)):
|
||||||
|
self.reconnectbutton.setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.reconnectbutton.setEnabled(False)
|
||||||
|
|
||||||
|
self.updatinggui = False
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def _updateConnectGUI(self):
|
||||||
|
if self.selecteditem is not None:
|
||||||
|
selectedurl = self.selecteditem.getURL()
|
||||||
|
self.guestradio.setEnabled(True)
|
||||||
|
self.userradio.setEnabled(True)
|
||||||
|
self.usernameedit.setEnabled(selectedurl.hasUser())
|
||||||
|
self.passwordedit.setEnabled(selectedurl.hasUser())
|
||||||
|
self.connectaslabel.setText(i18n("Connect to '%1' as:").arg(selectedurl.host()))
|
||||||
|
if selectedurl.hasUser():
|
||||||
|
self.guestradio.setChecked(False)
|
||||||
|
self.userradio.setChecked(True)
|
||||||
|
self.usernameedit.setText(selectedurl.user())
|
||||||
|
self.passwordedit.setText(selectedurl.pass_())
|
||||||
|
else:
|
||||||
|
self.guestradio.setChecked(True)
|
||||||
|
self.userradio.setChecked(False)
|
||||||
|
self.passwordedit.setText("")
|
||||||
|
self.usernameedit.setText("")
|
||||||
|
self.reconnectbutton.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.guestradio.setChecked(True)
|
||||||
|
self.userradio.setChecked(False)
|
||||||
|
self.guestradio.setEnabled(False)
|
||||||
|
self.userradio.setEnabled(False)
|
||||||
|
self.passwordedit.setEnabled(False)
|
||||||
|
self.usernameedit.setEnabled(False)
|
||||||
|
self.connectaslabel.setText(i18n("Connect to 'machine' as:"))
|
||||||
|
self.guestradio.setChecked(True)
|
||||||
|
self.userradio.setChecked(False)
|
||||||
|
self.passwordedit.setText("")
|
||||||
|
self.usernameedit.setText("")
|
||||||
|
self.reconnectbutton.setEnabled(False)
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
class SMBShareListViewItem(KListViewItem):
|
||||||
|
# Return codes for selectURL()
|
||||||
|
OPEN_SUCCESS = 1
|
||||||
|
OPEN_SUCCESS_INVALID = 2
|
||||||
|
OPEN_FAIL = 0
|
||||||
|
OPEN_BUSY = 3
|
||||||
|
|
||||||
|
# Node types.
|
||||||
|
LEVEL_ROOT = 0
|
||||||
|
LEVEL_WORKGROUP = 1
|
||||||
|
LEVEL_MACHINE = 2
|
||||||
|
LEVEL_DIR = 3 # and deeper.
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def __init__(self,parentitem,name,url,smbdialog):
|
||||||
|
KListViewItem.__init__(self,parentitem,name)
|
||||||
|
if not isinstance(parentitem,SMBShareListViewItem):
|
||||||
|
self._setIcon(0)
|
||||||
|
self.setSelectable(False)
|
||||||
|
else:
|
||||||
|
self._setIcon(parentitem.depth()+1)
|
||||||
|
self.setSelectable(parentitem.getLevel()>=self.LEVEL_WORKGROUP)
|
||||||
|
self.setExpandable(True)
|
||||||
|
|
||||||
|
if url.hasPath() and url.path(-1)!="/":
|
||||||
|
parts = [x for x in unicode(url.path(-1)).split("/") if x!=""]
|
||||||
|
self.component = parts[-1].lower()
|
||||||
|
elif url.hasHost():
|
||||||
|
self.component = unicode(url.host()).lower()
|
||||||
|
else:
|
||||||
|
self.component = None
|
||||||
|
|
||||||
|
self.smbdialog = smbdialog
|
||||||
|
self.resolved = False
|
||||||
|
self.url = url
|
||||||
|
self.autoopen = False
|
||||||
|
self.animationcounter = 0
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def getURL(self):
|
||||||
|
return self.url
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def setURL(self,url):
|
||||||
|
self.url = url
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def getComponent(self):
|
||||||
|
return self.component
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def isResolved(self):
|
||||||
|
return self.resolved
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def startResolve(self,autoopen):
|
||||||
|
if self.smbdialog.appendToResolveQueue(self):
|
||||||
|
self.setBusyIcon(True)
|
||||||
|
self.autoopen = self.autoopen or autoopen
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def cancelResolve(self):
|
||||||
|
self.setBusyIcon(False)
|
||||||
|
self.autoopen = False
|
||||||
|
self.resolved = False
|
||||||
|
while self.childCount()!=0:
|
||||||
|
self.takeItem(self.firstChild())
|
||||||
|
self.setOpen(False)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def unresolve(self):
|
||||||
|
self.cancelResolve()
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def getMachineItem(self):
|
||||||
|
if self.getLevel()<=self.LEVEL_WORKGROUP:
|
||||||
|
return None
|
||||||
|
elif self.getLevel()==self.LEVEL_DIR:
|
||||||
|
return self.parent().getMachineItem()
|
||||||
|
else:
|
||||||
|
return self
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def _setIcon(self,depth):
|
||||||
|
if depth==self.LEVEL_ROOT or depth==self.LEVEL_WORKGROUP:
|
||||||
|
self.setPixmap(0,SmallIcon("network"))
|
||||||
|
elif depth==self.LEVEL_MACHINE:
|
||||||
|
self.setPixmap(0,SmallIcon("network_local"))
|
||||||
|
else:
|
||||||
|
self.setPixmap(0,SmallIcon("folder"))
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def setBusyIcon(self,on):
|
||||||
|
if on:
|
||||||
|
self.setPixmap(0,UserIcon("kde1"))
|
||||||
|
self.setPixmap(0,UserIcon("kde"+str(self.animationcounter+1)))
|
||||||
|
self.animationcounter += 1
|
||||||
|
self.animationcounter %= 6
|
||||||
|
else:
|
||||||
|
self._setIcon(self.depth())
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def resolveComplete(self):
|
||||||
|
self.resolved = True
|
||||||
|
if self.childCount()==0:
|
||||||
|
self.setExpandable(False)
|
||||||
|
else:
|
||||||
|
if self.autoopen:
|
||||||
|
self.setOpen(True)
|
||||||
|
########################################################################
|
||||||
|
def getLevel(self):
|
||||||
|
if self.depth()>self.LEVEL_DIR:
|
||||||
|
return self.LEVEL_DIR
|
||||||
|
else:
|
||||||
|
return self.depth()
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# This is one of the more nasty pieces of code. It tries to select a given
|
||||||
|
# URL in the treeview. Opening and resolving the contents of URLs as neccessary
|
||||||
|
# while at the same time trying not have list everything on the network.
|
||||||
|
# Another wrinkle is that the treeview contains a level of workgroups while
|
||||||
|
# a given URL omits the workgroup a jumps directly to the machine name.
|
||||||
|
def selectURL(self,targeturl):
|
||||||
|
path = unicode(targeturl.path(-1))
|
||||||
|
parts = [x for x in path.split("/") if x!=""]
|
||||||
|
if targeturl.hasHost():
|
||||||
|
tmp = [targeturl.host()]
|
||||||
|
tmp.extend(parts)
|
||||||
|
parts = tmp
|
||||||
|
|
||||||
|
if self.getLevel()==self.LEVEL_ROOT:
|
||||||
|
# Root item.
|
||||||
|
# We should first resolve our contents. the Workgroups.
|
||||||
|
if not self.resolved:
|
||||||
|
self.startResolve(True)
|
||||||
|
return self.OPEN_BUSY
|
||||||
|
else:
|
||||||
|
if len(parts)==0:
|
||||||
|
# The URL is really short, and is not selectable.
|
||||||
|
# So we just say that we couldn't resolve/select it.
|
||||||
|
return self.OPEN_SUCCESS_INVALID
|
||||||
|
else:
|
||||||
|
# OK, the url has some more components. Ask each of the Workgroup items
|
||||||
|
# to help resolve it.
|
||||||
|
kid = self.firstChild()
|
||||||
|
while kid is not None:
|
||||||
|
rc = kid.selectURL(targeturl)
|
||||||
|
if rc==self.OPEN_SUCCESS or rc==self.OPEN_SUCCESS_INVALID:
|
||||||
|
kid.setOpen(True)
|
||||||
|
return rc
|
||||||
|
elif rc==self.OPEN_BUSY:
|
||||||
|
return rc
|
||||||
|
kid = kid.nextSibling()
|
||||||
|
return self.OPEN_FAIL
|
||||||
|
elif self.getLevel()==self.LEVEL_WORKGROUP:
|
||||||
|
# Workgroup level
|
||||||
|
if not self.resolved:
|
||||||
|
self.startResolve(False)
|
||||||
|
return self.OPEN_BUSY
|
||||||
|
else:
|
||||||
|
# Find a child named after the next part of the URL path.
|
||||||
|
kid = self.firstChild()
|
||||||
|
partname = parts[0].lower()
|
||||||
|
while kid is not None:
|
||||||
|
if kid.getComponent()==partname:
|
||||||
|
self.setOpen(True)
|
||||||
|
return kid.selectURL(targeturl)
|
||||||
|
kid = kid.nextSibling()
|
||||||
|
return self.OPEN_FAIL
|
||||||
|
elif self.getLevel()==self.LEVEL_MACHINE:
|
||||||
|
# Machine level
|
||||||
|
if len(parts)==1:
|
||||||
|
# The URL is successfully resolved but is not selectable!
|
||||||
|
return self.OPEN_SUCCESS_INVALID
|
||||||
|
else:
|
||||||
|
# Share level
|
||||||
|
if len(parts)==self.depth()-1:
|
||||||
|
self.smbdialog.treeview.setSelected(self,True)
|
||||||
|
return self.OPEN_SUCCESS
|
||||||
|
|
||||||
|
if not self.resolved:
|
||||||
|
self.startResolve(True)
|
||||||
|
return self.OPEN_BUSY
|
||||||
|
else:
|
||||||
|
# Find a child item that matches the next part of the URL path.
|
||||||
|
kid = self.firstChild()
|
||||||
|
partname = parts[self.depth()-1].lower()
|
||||||
|
while kid is not None:
|
||||||
|
if kid.getComponent()==partname:
|
||||||
|
return kid.selectURL(targeturl)
|
||||||
|
kid = kid.nextSibling()
|
||||||
|
return self.OPEN_FAIL
|
@ -0,0 +1,69 @@
|
|||||||
|
###########################################################################
|
||||||
|
# SimpleCommandRunner.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Tue May 17 2005 #
|
||||||
|
# copyright : (C) 2005 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
from qt import *
|
||||||
|
from kdecore import *
|
||||||
|
import locale
|
||||||
|
|
||||||
|
debug = False
|
||||||
|
#debug = True
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleCommandRunner(QObject):
|
||||||
|
########################################################################
|
||||||
|
def __init__(self):
|
||||||
|
QObject.__init__(self)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def run(self,cmdlist,STDOUT_only=False):
|
||||||
|
"""Run the given command and return the result.
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
cmdlist - Command and arguments. Given as a list of strings. The first item is
|
||||||
|
the executable.
|
||||||
|
STDOUT_only - Do not return STDERR in the output stream.
|
||||||
|
|
||||||
|
Returns a tuple (rc,output). rc is the numeric return code from
|
||||||
|
the command, or None if the command couldn't be started. output
|
||||||
|
is the output from stdout and stderr.
|
||||||
|
"""
|
||||||
|
global debug
|
||||||
|
if debug: print cmdlist
|
||||||
|
self.STDOUT_only = STDOUT_only
|
||||||
|
self.output = u""
|
||||||
|
proc = KProcess()
|
||||||
|
proc.setEnvironment("LANG","US")
|
||||||
|
proc.setEnvironment("LC_ALL","US")
|
||||||
|
self.connect(proc,SIGNAL("receivedStdout(KProcess *,char *,int)"),self.slotStdout)
|
||||||
|
self.connect(proc,SIGNAL("receivedStderr(KProcess *,char *,int)"),self.slotStderr)
|
||||||
|
proc.setArguments(cmdlist)
|
||||||
|
rc = None
|
||||||
|
if proc.start(proc.Block,proc.AllOutput)==True:
|
||||||
|
if proc.normalExit():
|
||||||
|
rc = proc.exitStatus()
|
||||||
|
return (rc,self.output)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotStdout(self,proc,buffer,buflen):
|
||||||
|
global debug
|
||||||
|
if debug: print "slotStdout() |"+buffer+"|"
|
||||||
|
self.output += buffer.decode(locale.getpreferredencoding())
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
def slotStderr(self,proc,buffer,buflen):
|
||||||
|
global debug
|
||||||
|
if debug: print "slotStderr() |"+buffer+"|"
|
||||||
|
if not self.STDOUT_only:
|
||||||
|
self.output += buffer.decode(locale.getpreferredencoding())
|
@ -0,0 +1,299 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# fuser.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Wed Jun 15 2005 #
|
||||||
|
# copyright : (C) 2005-2006 by Sebastian Kuegler #
|
||||||
|
# email : sebas@vizZzion.org #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
"""
|
||||||
|
TODO:
|
||||||
|
- Fix running standalone:
|
||||||
|
* KCmdLineArgs stuff.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from qt import *
|
||||||
|
from kdeui import *
|
||||||
|
#import kdedesigner
|
||||||
|
from fuser_ui import *
|
||||||
|
from SimpleCommandRunner import *
|
||||||
|
|
||||||
|
standalone = __name__ == "__main__"
|
||||||
|
|
||||||
|
class FileProcess(QListViewItem):
|
||||||
|
""" A FileProcess is simply one line from lsof, one filedescriptor that's in use
|
||||||
|
by a process represented as a listviewitem in the lsof processtable. """
|
||||||
|
|
||||||
|
# Available signals.
|
||||||
|
signals = {
|
||||||
|
"TERM":15,
|
||||||
|
"KILL":9 }
|
||||||
|
|
||||||
|
# Column names mapping.
|
||||||
|
cols = {
|
||||||
|
"pname":0,
|
||||||
|
"pid":1,
|
||||||
|
"powner":2,
|
||||||
|
"pfile":3 }
|
||||||
|
|
||||||
|
def __init__(self,parent,pid,isparent=False):
|
||||||
|
QListViewItem.__init__(self,parent)
|
||||||
|
self.setPid(pid)
|
||||||
|
self.isparent = isparent
|
||||||
|
self.pfile = ""
|
||||||
|
self.pix = None
|
||||||
|
|
||||||
|
def setPid(self,pid):
|
||||||
|
self.pid = pid
|
||||||
|
|
||||||
|
def setName(self,pname):
|
||||||
|
self.pname = pname
|
||||||
|
|
||||||
|
def setOwner(self,powner):
|
||||||
|
self.powner = powner
|
||||||
|
|
||||||
|
def setFile(self,pfile):
|
||||||
|
self.pfile = pfile
|
||||||
|
|
||||||
|
def setPixmaps(self,pix):
|
||||||
|
""" Eats a dict with pixmaps. """
|
||||||
|
self.pix = pix
|
||||||
|
|
||||||
|
def sendSignal(self,signal):
|
||||||
|
""" Parses a signal string representation or a signal number and sends it to
|
||||||
|
the process."""
|
||||||
|
if not self.isparent:
|
||||||
|
print "Item is not a process, only a filedescriptor."
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
signal_int = int(signal)
|
||||||
|
except ValueError:
|
||||||
|
try:
|
||||||
|
signal_int = self.signals[signal]
|
||||||
|
except IndexError:
|
||||||
|
print "No known signal received ", signal
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
rc = os.kill(int(self.pid),signal_int) # TODO: Catch OSError
|
||||||
|
except OSError, message:
|
||||||
|
print "OSError: Couldn't %s %s %s" % (signal,self.pname,self.pid)
|
||||||
|
print message
|
||||||
|
if not rc:
|
||||||
|
print "Successfully sent signal ", signal_int, " to process ", self.pid
|
||||||
|
return True
|
||||||
|
print "Signal %i didn't succeed" % signal_int
|
||||||
|
return False
|
||||||
|
|
||||||
|
def fillColumns(self):
|
||||||
|
""" Writes strings into columns once an entry is completed. """
|
||||||
|
if self.isparent:
|
||||||
|
self.setText(self.cols["pid"],self.pid)
|
||||||
|
self.setText(self.cols["pname"],self.pname)
|
||||||
|
self.setText(self.cols["powner"],self.powner)
|
||||||
|
self.setPixmap(0,self.pix["exec"])
|
||||||
|
self.setPixmap(1,self.pix["pid"])
|
||||||
|
self.setPixmap(2,self.pix["owner"])
|
||||||
|
else:
|
||||||
|
self.setText(self.cols["pfile"],self.pfile)
|
||||||
|
self.setPixmap(3,self.pix["file"])
|
||||||
|
|
||||||
|
########################################################################################################
|
||||||
|
class FUser(FUserUI):
|
||||||
|
""" done() / result() return 0 on successful umount and 1 if cancelled. """
|
||||||
|
|
||||||
|
def __init__(self,device,parentdialog=None,lsof_bin='/usr/sbin/lsof',kapp=None):
|
||||||
|
FUserUI.__init__(self,parentdialog,name = None,modal = 0,fl = 0)
|
||||||
|
self.device = device
|
||||||
|
self.fileprocesses = []
|
||||||
|
self.lsof_bin = '/usr/sbin/lsof'
|
||||||
|
self.setLsof(lsof_bin)
|
||||||
|
self.setApp(kapp)
|
||||||
|
|
||||||
|
self.processlist.clear()
|
||||||
|
self.processhidden = False
|
||||||
|
# We're having processes blocking umounting, show that.
|
||||||
|
self.umountbutton.setEnabled(False)
|
||||||
|
|
||||||
|
self.explanationlabel.setText(
|
||||||
|
unicode(i18n("""The volume %s is in use and can not be disabled.<br>
|
||||||
|
<br>
|
||||||
|
The processes that are blocking %s are listed below. These processes must be closed
|
||||||
|
before %s can be disabled.
|
||||||
|
Killing a process may cause data loss! Make sure all work is saved before killing an
|
||||||
|
application.
|
||||||
|
""")) % (self.device,self.device,self.device))
|
||||||
|
|
||||||
|
self.connect(self.cancelbutton,SIGNAL("clicked()"),self.slotCancelButtonClicked)
|
||||||
|
self.connect(self.killbutton,SIGNAL("clicked()"),self.slotKillButtonClicked)
|
||||||
|
self.connect(self.killallbutton,SIGNAL("clicked()"),self.slotKillallButtonClicked)
|
||||||
|
self.connect(self.refreshbutton,SIGNAL("clicked()"),self.refreshProcesslist)
|
||||||
|
self.connect(self.processlist,SIGNAL("selectionChanged()"),self.slotSelectionChanged)
|
||||||
|
self.connect(self.umountbutton,SIGNAL("clicked()"),self.slotUmountButtonClicked)
|
||||||
|
|
||||||
|
# TODO: Make optionsbutton resize dialog if processframe is hidden, hide Optionsbutton until then.
|
||||||
|
self.optionsbutton.hide()
|
||||||
|
self.readPixmaps()
|
||||||
|
self.warningimage.setPixmap(MainBarIcon("messagebox_warning"))
|
||||||
|
|
||||||
|
# Delayed initialisation.
|
||||||
|
QTimer.singleShot(0,self.isMounted)
|
||||||
|
QTimer.singleShot(0,self.refreshProcesslist)
|
||||||
|
|
||||||
|
def setApp(self,app):
|
||||||
|
""" We need a reference to the (K|Q)Application for certain things, e.g. setting
|
||||||
|
the MouseCursor. """
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
def setLsof(self,path):
|
||||||
|
""" Where's the lsof binary? """
|
||||||
|
if os.path.isfile(path):
|
||||||
|
self.lsof_bin = path
|
||||||
|
else:
|
||||||
|
print path, " is not a valid binary, keeping %s", self.lsof_bin
|
||||||
|
|
||||||
|
def readPixmaps(self):
|
||||||
|
self.pix = {
|
||||||
|
"exec": UserIcon("exec"),
|
||||||
|
"owner": UserIcon("user"),
|
||||||
|
"pid": UserIcon("tux"),
|
||||||
|
"file": UserIcon("file")}
|
||||||
|
|
||||||
|
def refreshProcesslist(self):
|
||||||
|
""" Read lsof output and add the processdescriptors to the listview. """
|
||||||
|
kapp = self.app
|
||||||
|
|
||||||
|
kapp.setOverrideCursor(QCursor(Qt.BusyCursor))
|
||||||
|
|
||||||
|
self.processlist.clear()
|
||||||
|
rc, output = SimpleCommandRunner().run([self.lsof_bin,'-FpcLn',self.device],True)
|
||||||
|
procs = output.split()
|
||||||
|
|
||||||
|
self.processes = []
|
||||||
|
self.realprocesses = []
|
||||||
|
for line in procs:
|
||||||
|
line = str(line)
|
||||||
|
type = line[0]
|
||||||
|
info = line[1:]
|
||||||
|
|
||||||
|
if type is "p":
|
||||||
|
pid = info
|
||||||
|
parentproc = FileProcess(self.processlist,pid,True)
|
||||||
|
self.processes.append(parentproc)
|
||||||
|
self.realprocesses.append(parentproc)
|
||||||
|
parentproc.setPixmaps(self.pix)
|
||||||
|
files = 0
|
||||||
|
|
||||||
|
if type == "c":
|
||||||
|
pname = info
|
||||||
|
parentproc.setName(pname)
|
||||||
|
|
||||||
|
if type == "L":
|
||||||
|
powner = info
|
||||||
|
parentproc.setOwner(powner)
|
||||||
|
|
||||||
|
if type == "n":
|
||||||
|
pfile = info
|
||||||
|
childproc = FileProcess(parentproc,pid)
|
||||||
|
self.processes.append(childproc)
|
||||||
|
childproc.setPixmaps(self.pix)
|
||||||
|
childproc.setFile(pfile)
|
||||||
|
childproc.setOwner(powner)
|
||||||
|
childproc.setName(pname)
|
||||||
|
if files == 0:
|
||||||
|
parentproc.fillColumns()
|
||||||
|
files += 1
|
||||||
|
childproc.fillColumns()
|
||||||
|
|
||||||
|
kapp.restoreOverrideCursor()
|
||||||
|
|
||||||
|
# Enable / disable buttons which are (in)appropriate.
|
||||||
|
self.killallbutton.setEnabled(len(self.realprocesses)!=0)
|
||||||
|
self.killbutton.setEnabled(len(self.realprocesses)!=0)
|
||||||
|
self.umountbutton.setEnabled(len(self.realprocesses)==0)
|
||||||
|
if self.processlist.selectedItem() == None:
|
||||||
|
self.killbutton.setEnabled(False)
|
||||||
|
|
||||||
|
def isMounted(self):
|
||||||
|
rc,output = SimpleCommandRunner().run(["/bin/mount"],False)
|
||||||
|
mounts = []
|
||||||
|
for line in output.split('\n'):
|
||||||
|
try:
|
||||||
|
mounts.append(line.split()[0])
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
ismounted = self.device in mounts
|
||||||
|
self.umountbutton.setEnabled(ismounted)
|
||||||
|
return ismounted
|
||||||
|
|
||||||
|
def slotCancelButtonClicked(self):
|
||||||
|
self.done(1)
|
||||||
|
|
||||||
|
def slotKillButtonClicked(self):
|
||||||
|
try:
|
||||||
|
self.processlist.selectedItem().sendSignal("KILL")
|
||||||
|
self.refreshProcesslist()
|
||||||
|
except AttributeError:
|
||||||
|
print "No killable item selected."
|
||||||
|
|
||||||
|
def slotKillallButtonClicked(self):
|
||||||
|
for process in self.realprocesses:
|
||||||
|
process.sendSignal("KILL")
|
||||||
|
self.refreshProcesslist()
|
||||||
|
|
||||||
|
def slotOptionsButtonCLicked(self):
|
||||||
|
self.processhidden = not self.processhidden
|
||||||
|
self.processframe.setHidden(self.processhidden)
|
||||||
|
|
||||||
|
def slotSelectionChanged(self):
|
||||||
|
""" Check if item is a process or a file, disable killbutton for children. """
|
||||||
|
selected = self.processlist.selectedItem()
|
||||||
|
if not selected.isparent:
|
||||||
|
self.killbutton.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.killbutton.setEnabled(True)
|
||||||
|
|
||||||
|
def slotUmountButtonClicked(self):
|
||||||
|
SimpleCommandRunner
|
||||||
|
rc, output = SimpleCommandRunner().run(['/bin/umount',self.device])
|
||||||
|
if rc == 0:
|
||||||
|
print "%s successfully unmounted." % self.device
|
||||||
|
# Close dialog and return 0 - sucessfully umounted.
|
||||||
|
self.done(0)
|
||||||
|
else:
|
||||||
|
print "Unmounting %s failed: %s" % (self.device,output[:-1])
|
||||||
|
self.isMounted()
|
||||||
|
|
||||||
|
################################################################################################
|
||||||
|
if standalone:
|
||||||
|
device = "/dev/hda1"
|
||||||
|
print 'Device is ', device
|
||||||
|
|
||||||
|
cmd_args = KCmdLineArgs.init(sys.argv, "FUser",
|
||||||
|
"A graphical frontend to fuser, but without using it :-)", "0.2")
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# FIXME: All the arg-parsing stuff does not work yet since I don't understand KCmdLineArgs.
|
||||||
|
options = [("device <device>", "Device to umount")]
|
||||||
|
KCmdLineArgs.addCmdLineOptions(options)
|
||||||
|
args = KCmdLineArgs.parsedArgs()
|
||||||
|
# print args.count()
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
kapp = KApplication()
|
||||||
|
KGlobal.iconLoader().addAppDir("guidance")
|
||||||
|
fuserapp = FUser(device)
|
||||||
|
|
||||||
|
fuserapp.setApp(kapp)
|
||||||
|
kapp.setMainWidget(fuserapp)
|
||||||
|
fuserapp.show()
|
||||||
|
kapp.exec_loop()
|
@ -0,0 +1,352 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>FUserUI</class>
|
||||||
|
<comment>Python:from kdeui import *
|
||||||
|
Python:from kdecore import *</comment>
|
||||||
|
<author>Sebastian Kuegler</author>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Process</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>546</width>
|
||||||
|
<height>536</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>250</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>250</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Error: Volume in use</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout10</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>warningimage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap></pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>explanationlabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>The volume $VOLUME is in use and can not be disabled.
|
||||||
|
|
||||||
|
The processes that are blocking $VOLUME are listed below. These processes must be closed before $VOLUME can be disabled.
|
||||||
|
Killing a process may cause data loss. Make sure all work is saved before killing an application.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>WordBreak|AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>processframe</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Raised</enum>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout7</cstring>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QListView">
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Process</string>
|
||||||
|
</property>
|
||||||
|
<property name="clickable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="resizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Process ID</string>
|
||||||
|
</property>
|
||||||
|
<property name="clickable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="resizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Owner</string>
|
||||||
|
</property>
|
||||||
|
<property name="clickable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="resizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>File</string>
|
||||||
|
</property>
|
||||||
|
<property name="clickable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="resizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>processlist</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>7</vsizetype>
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="resizePolicy">
|
||||||
|
<enum>Manual</enum>
|
||||||
|
</property>
|
||||||
|
<property name="allColumnsShowFocus">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="showSortIndicator">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="rootIsDecorated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="resizeMode">
|
||||||
|
<enum>LastColumn</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout11</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="KPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>killallbutton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Kill all listed processes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>listbuttonspacer</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>184</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="KPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>killbutton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Kill process</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>refreshbutton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Refresh list</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout12</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="KPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>optionsbutton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>1</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>>>> Options</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>bottombuttonspacer</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>280</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="KPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>umountbutton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>1</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Disable volume</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>cancelbutton</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>1</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<pixmapfunction>QPixmap</pixmapfunction>
|
||||||
|
<layoutdefaults spacing="6" margin="6"/>
|
||||||
|
<includehints>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
</includehints>
|
||||||
|
</UI>
|
@ -0,0 +1,51 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=Disk & Filesystems
|
||||||
|
Name[da]=Disk & Filesystemer
|
||||||
|
Name[el]=Δίσκοι & συστήματα αρχείων
|
||||||
|
Name[es]=Disco y sistemas de archivos
|
||||||
|
Name[et]=Ketas ja failisüsteemid
|
||||||
|
Name[it]=Dischi e filesystem
|
||||||
|
Name[ja]=ディスクとファイルシステム
|
||||||
|
Name[nl]=Schijven en bestandssystemen
|
||||||
|
Name[pt]=Disco & Sistemas de Ficheiros
|
||||||
|
Name[pt_BR]=Disco & Sistemas de Arquivos
|
||||||
|
Name[sr]=Диск и фајл-системи
|
||||||
|
Name[sr@Latn]=Disk i fajl-sistemi
|
||||||
|
Name[sv]=Disk- och filsystem
|
||||||
|
Name[xx]=xxDisk & Filesystemsxx
|
||||||
|
name[en_GB]=Disk & Filesystems
|
||||||
|
Comment=Disk & Filesystem Configuration
|
||||||
|
Comment[el]=Ρυθμίσεις δίσκων & συστημάτων αρχείων
|
||||||
|
Comment[es]=Configuración del disco y sistema de archivos
|
||||||
|
Comment[et]=Ketta ja failisüsteemi seadistamine
|
||||||
|
Comment[it]=Configurazione di dischi e filesystem
|
||||||
|
Comment[ja]=ディスクとファイルシステムの設定
|
||||||
|
Comment[nl]=Schijven en bestandssystemen instellen
|
||||||
|
Comment[pt]=Configuração do Disco & Sistema de Ficheiros
|
||||||
|
Comment[pt_BR]=Configuração de Disco e Sistemas de Arquivos
|
||||||
|
Comment[sr]=Подешавање диска и фајл-система
|
||||||
|
Comment[sr@Latn]=Podešavanje diska i fajl-sistema
|
||||||
|
Comment[sv]=Disk och filsysteminitierníng
|
||||||
|
Comment[xx]=xxDisk & Filesystem Configurationxx
|
||||||
|
Icon=disksfilesystems.png
|
||||||
|
Encoding=UTF-8
|
||||||
|
X-KDE-ModuleType=Library
|
||||||
|
X-KDE-Library=mountconfig
|
||||||
|
X-KDE-FactoryName=mountconfig
|
||||||
|
X-KDE-RootOnly=true
|
||||||
|
Type=Application
|
||||||
|
Exec=kcmshell System/mountconfig
|
||||||
|
Categories=Qt;KDE;X-KDE-settings-system;
|
||||||
|
GenericName=Mount Point Editor
|
||||||
|
GenericName[el]=Επεξεργαστής σημείων προσάρτησης
|
||||||
|
GenericName[es]=Editor del punto de montaje
|
||||||
|
GenericName[et]=Ühenduspunktide redaktor
|
||||||
|
GenericName[it]=Editor dei punti di montaggio
|
||||||
|
GenericName[ja]=マウントポイントエディタ
|
||||||
|
GenericName[nl]=Aankoppelpunten bewerken
|
||||||
|
GenericName[pt]=Editor de Pontos de Montagem
|
||||||
|
GenericName[pt_BR]=Editor de Pontos de Montagem
|
||||||
|
GenericName[sr]=Уређивач тачки монтирања
|
||||||
|
GenericName[sr@Latn]=Uređivač tački montiranja
|
||||||
|
GenericName[sv]=Editor för monteringspunkter
|
||||||
|
GenericName[xx]=xxMount Point Editorxx
|
@ -0,0 +1,504 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from qt import *
|
||||||
|
from kdecore import *
|
||||||
|
import sys, os
|
||||||
|
|
||||||
|
def getLabel(blocks):
|
||||||
|
""" Translates blocksize into human readable labels, such as 17.3 Gb, 2.1 Mb. """
|
||||||
|
|
||||||
|
try:
|
||||||
|
blocks = int(blocks) # 1K blocks now.
|
||||||
|
except ValueError:
|
||||||
|
return i18n("n/a")
|
||||||
|
if blocks<1024:
|
||||||
|
return i18n("%1 Kb").arg(blocks)
|
||||||
|
if blocks<1024*1024:
|
||||||
|
return i18n("%1 Mb").arg(round(float(blocks)/1024.0,1))
|
||||||
|
blocks /= 1024
|
||||||
|
if blocks<1024*1024:
|
||||||
|
return i18n("%1 Gb").arg(round(float(blocks)/1024.0,1))
|
||||||
|
blocks /= 1024
|
||||||
|
return i18n("%1 Tb").arg(round(float(blocks)/1024.0,1))
|
||||||
|
|
||||||
|
|
||||||
|
class SizeViewApplication(QApplication):
|
||||||
|
""" Boilerplate """
|
||||||
|
def __init__(self,devicename,devicepath,args=[]):
|
||||||
|
QApplication.__init__(self,args)
|
||||||
|
|
||||||
|
self.maindialog = SizeView(None,devicename,devicepath)
|
||||||
|
self.setMainWidget(self.maindialog)
|
||||||
|
self.maindialog.show()
|
||||||
|
self.exec_loop()
|
||||||
|
|
||||||
|
class SizeView(QDialog):
|
||||||
|
""" A SizeView represents a horizontal list of PartitionGroupWidgets.
|
||||||
|
It supplies the code to read the sizes and the values that have
|
||||||
|
to be filled in, using the /proc filesystem and the program "df".
|
||||||
|
"""
|
||||||
|
|
||||||
|
dev_path = "/dev/" # Where to look for the partitions
|
||||||
|
devicename = "" # Such as hda1
|
||||||
|
partitions = {} # List of partitions
|
||||||
|
sizes = {} # Maps devicenames to blocksizes
|
||||||
|
mountpoints = {} # Maps devicenames to mountpoints
|
||||||
|
used = {} # Blocks used on a partition
|
||||||
|
available = {} # Blocks available
|
||||||
|
part_types = {} # Maps devicenames to partitiontypes
|
||||||
|
partitionwidgets = [] # Holds a list of the PartitionGroup widgets
|
||||||
|
|
||||||
|
def __init__(self,parent,devicename,devicepath=None):
|
||||||
|
self.partitionwidgets = []
|
||||||
|
QDialog.__init__(self,None,None,0,0)
|
||||||
|
self.dialogtitle = i18n("Diskspace & Partitions")
|
||||||
|
self.setCaption(self.dialogtitle)
|
||||||
|
self.devicename = devicename
|
||||||
|
if devicepath:
|
||||||
|
self.dev_path = devicepath
|
||||||
|
|
||||||
|
# Retrieve all information from the system.
|
||||||
|
self.readMounts()
|
||||||
|
self.readSize()
|
||||||
|
self.readSwaps()
|
||||||
|
|
||||||
|
partitions = self.partitions.keys()
|
||||||
|
partitions.sort()
|
||||||
|
|
||||||
|
number=1
|
||||||
|
for part in partitions:
|
||||||
|
try:
|
||||||
|
fill = self.sizes[part]
|
||||||
|
mountpoint = self.mountpoints[part]
|
||||||
|
used = self.used[part]
|
||||||
|
available = self.available[part]
|
||||||
|
except KeyError:
|
||||||
|
# Handles empty or not-mounted partitions
|
||||||
|
fill = None
|
||||||
|
mountpoint = i18n("n/a")
|
||||||
|
used = str(i18n("n/a"))
|
||||||
|
available = str(i18n("n/a"))
|
||||||
|
|
||||||
|
pwidg = PartitionGroup(part,self,fill,number,self.part_types,self.dev_path)
|
||||||
|
pwidg.setSize(self.partitions[part])
|
||||||
|
pwidg.setMountPoint(mountpoint)
|
||||||
|
pwidg.setUsed(used)
|
||||||
|
pwidg.setAvailable(available)
|
||||||
|
pwidg.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding,0,0,
|
||||||
|
pwidg.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.partitionwidgets.append(pwidg)
|
||||||
|
number += 1
|
||||||
|
|
||||||
|
n = len(partitions)
|
||||||
|
r = 2
|
||||||
|
c = 0
|
||||||
|
cols = 1
|
||||||
|
|
||||||
|
# Compute number of rows needed for partitions.
|
||||||
|
if n%cols > 0:
|
||||||
|
rows = int(n/cols)+1
|
||||||
|
else:
|
||||||
|
rows = int(n/cols)
|
||||||
|
if n is 1: rows = 2
|
||||||
|
|
||||||
|
# Build main Gridlayout.
|
||||||
|
total_rows = rows+2
|
||||||
|
self.grid = QGridLayout(self,total_rows,2,5)
|
||||||
|
#self.setSizeGripEnabled(1)
|
||||||
|
|
||||||
|
self.buttonCancel = QPushButton(i18n("Close"),self,"buttonCancel")
|
||||||
|
self.buttonCancel.setAutoDefault(1)
|
||||||
|
self.buttonCancel.setFixedWidth(80)
|
||||||
|
self.grid.addWidget(self.buttonCancel,total_rows-1,1,Qt.AlignRight)
|
||||||
|
|
||||||
|
self.grid.setRowStretch(0,0)
|
||||||
|
self.grid.setRowStretch(total_rows-1,0)
|
||||||
|
|
||||||
|
# Stretch all but first and last rows.
|
||||||
|
for row in range(1,total_rows-1):
|
||||||
|
self.grid.setRowStretch(row,5)
|
||||||
|
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
self.connect(self.buttonCancel,SIGNAL("clicked()"),self.hide)
|
||||||
|
|
||||||
|
#self.mainlabel = QLabel("<font size=+2><b>"+self.dialogtitle+"</b></font>",self)
|
||||||
|
#self.grid.addWidget(self.mainlabel,0,0)
|
||||||
|
|
||||||
|
self.diskgroup = DiskGroup(self,self.devicename,self.dev_path,self.partitions,self.totalsize,self.mountpoints)
|
||||||
|
self.grid.addMultiCellWidget(self.diskgroup,1,1,0,1)
|
||||||
|
|
||||||
|
for pw in self.partitionwidgets:
|
||||||
|
self.grid.addWidget(pw,r,c)
|
||||||
|
if c is cols:
|
||||||
|
r += 1
|
||||||
|
c = 0
|
||||||
|
else:
|
||||||
|
c += 1
|
||||||
|
|
||||||
|
def readSize(self):
|
||||||
|
fhandle = open("/proc/partitions","r")
|
||||||
|
self.partitions = {}
|
||||||
|
self.totalsize = 0
|
||||||
|
for line in fhandle.readlines():
|
||||||
|
try:
|
||||||
|
major,minor,blocks,name = line.split()
|
||||||
|
if name == self.devicename:
|
||||||
|
self.totalsize = blocks
|
||||||
|
if name[:len(self.devicename)] == self.devicename and len(name) > len(self.devicename):
|
||||||
|
self.partitions[name] = blocks
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
def readMounts(self):
|
||||||
|
fhandle = os.popen("/bin/df")
|
||||||
|
for l in fhandle.readlines():
|
||||||
|
v = l.split()
|
||||||
|
try:
|
||||||
|
p,s = v[0].split("/")[2],v[4][:-1]
|
||||||
|
self.sizes[p] = s
|
||||||
|
self.mountpoints[p] = v[5]
|
||||||
|
self.used[p] = v[2]
|
||||||
|
self.available[p] = v[3]
|
||||||
|
self.part_types[p] = "filesystem"
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
def readSwaps(self):
|
||||||
|
fhandle = open("/proc/swaps")
|
||||||
|
for line in fhandle.readlines():
|
||||||
|
try:
|
||||||
|
device,type,size,used,priority = line.split()
|
||||||
|
device = device[len(self.dev_path):]
|
||||||
|
self.used[device] = used
|
||||||
|
self.sizes[device] = round(float(used)/float(size)*100 ,1)
|
||||||
|
self.available[device] = str(int(size)-int(used))
|
||||||
|
self.mountpoints[device] = "swap"
|
||||||
|
self.part_types[device] = "swap"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
"""
|
||||||
|
def __show__(self):
|
||||||
|
print self.partitions
|
||||||
|
print "Device", self.devicename, self.totalsize
|
||||||
|
for p in self.partitions:
|
||||||
|
print p, self.partitions[p], self.partitions[p]
|
||||||
|
"""
|
||||||
|
class DiskGroup(QGroupBox):
|
||||||
|
""" Shows an overview of the physical layout of the disks, with the different partitions on it. """
|
||||||
|
|
||||||
|
def __init__(self,parent,device,dev_path,partitions,totalsize,mountpoints):
|
||||||
|
|
||||||
|
QGroupBox.__init__(self,parent,"DiskViewGroup")
|
||||||
|
self.setTitle(i18n("Disk %1%2").arg(dev_path).arg(device))
|
||||||
|
self.mountpoints = mountpoints
|
||||||
|
self.partitions = partitions
|
||||||
|
self.totalsize = totalsize
|
||||||
|
|
||||||
|
self.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.layout().setSpacing(6)
|
||||||
|
self.layout().setMargin(11)
|
||||||
|
DiskViewGroupLayout = QVBoxLayout(self.layout())
|
||||||
|
DiskViewGroupLayout.setAlignment(Qt.AlignTop)
|
||||||
|
colors = ["dark orange","dodger blue","gold","green","firebrick","navy","darkorange","darkblue"]
|
||||||
|
|
||||||
|
self.diskview = DiskView(self,self.percentages(),colors)
|
||||||
|
self.diskview.setScaledContents(1)
|
||||||
|
DiskViewGroupLayout.addWidget(self.diskview)
|
||||||
|
|
||||||
|
parts = self.partitions.keys()
|
||||||
|
parts.sort()
|
||||||
|
self.percentages()
|
||||||
|
|
||||||
|
cols = 3 # Number of columns to use for colorlabels.
|
||||||
|
rows = len(parts)/cols
|
||||||
|
mod = len(parts)%cols
|
||||||
|
if mod > 0:
|
||||||
|
rows += cols-mod
|
||||||
|
|
||||||
|
# We multiply the number of cols by 3, first for the colorlabel, second for the name, third for spacing.
|
||||||
|
cols = cols*3
|
||||||
|
DiskViewPartitionListLayout = QGridLayout(DiskViewGroupLayout,rows,cols)
|
||||||
|
|
||||||
|
i = cl = r = c = 0
|
||||||
|
ps = ls = {}
|
||||||
|
for dev in parts:
|
||||||
|
ps[i] = LegendLabel(self,colors[cl])
|
||||||
|
DiskViewPartitionListLayout.addWidget(ps[i],r,c)
|
||||||
|
try:
|
||||||
|
lbl = self.mountpoints[dev]
|
||||||
|
except KeyError:
|
||||||
|
lbl = "not mounted"
|
||||||
|
ls[i] = QLabel(self,lbl+'<br /> ('+dev_path+dev+')',self)
|
||||||
|
DiskViewPartitionListLayout.addWidget(ls[i],r,c+1)
|
||||||
|
cl += 1
|
||||||
|
if cl == len(colors):
|
||||||
|
cl = 0
|
||||||
|
i += 1
|
||||||
|
if c is cols:
|
||||||
|
c = 0
|
||||||
|
r += 1
|
||||||
|
else:
|
||||||
|
c += 3
|
||||||
|
|
||||||
|
def percentages(self):
|
||||||
|
|
||||||
|
p_t = 0
|
||||||
|
for p in self.partitions.values():
|
||||||
|
p_t += int(p)
|
||||||
|
|
||||||
|
self.perc = {}
|
||||||
|
for p in self.partitions.keys():
|
||||||
|
self.perc[p] = float(float(self.partitions[p])/float(p_t))
|
||||||
|
return self.perc
|
||||||
|
|
||||||
|
|
||||||
|
class PartitionGroup(QGroupBox):
|
||||||
|
""" Represents a groupbox with the filled bar and a couple of labels with
|
||||||
|
information about the partition in it."""
|
||||||
|
|
||||||
|
blocksize = 0
|
||||||
|
title = str(i18n("Partition"))
|
||||||
|
|
||||||
|
def __init__(self,device,parent,fill_percent,number,part_types,dev_path):
|
||||||
|
QGroupBox.__init__(self,parent)
|
||||||
|
self.part_types = part_types
|
||||||
|
self.dev_path = dev_path
|
||||||
|
self.setGeometry(QRect(110,100,370,203))
|
||||||
|
self.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.layout().setSpacing(3)
|
||||||
|
self.layout().setMargin(5)
|
||||||
|
self.setMinimumSize(280,120)
|
||||||
|
|
||||||
|
partitiongroup_layout = QGridLayout(self.layout())
|
||||||
|
partitiongroup_layout.setAlignment(Qt.AlignTop)
|
||||||
|
self.available = QLabel(i18n("available"),self)
|
||||||
|
partitiongroup_layout.addWidget(self.available,3,4)
|
||||||
|
|
||||||
|
self.device = QLabel(i18n("device"),self)
|
||||||
|
partitiongroup_layout.addMultiCellWidget(self.device,1,1,3,4)
|
||||||
|
|
||||||
|
self.partpixmap = PartitionView(self,fill_percent,self.part_types,device)
|
||||||
|
self.partpixmap.setScaledContents(1)
|
||||||
|
|
||||||
|
partitiongroup_layout.addMultiCellWidget(self.partpixmap,0,0,0,4)
|
||||||
|
self.textLabel1_3 = QLabel("textLabel1_3",self)
|
||||||
|
partitiongroup_layout.addWidget(self.textLabel1_3,3,0)
|
||||||
|
self.totalsize = QLabel("totalsize",self)
|
||||||
|
partitiongroup_layout.addWidget(self.totalsize,2,1)
|
||||||
|
self.textLabel1_2 = QLabel(self,"textLabel1_2")
|
||||||
|
partitiongroup_layout.addWidget(self.textLabel1_2,2,0)
|
||||||
|
self.textLabel1 = QLabel(self,"textLabel1")
|
||||||
|
partitiongroup_layout.addWidget(self.textLabel1,1,0)
|
||||||
|
self.textLabel3_2 = QLabel(self,"textLabel3_2")
|
||||||
|
partitiongroup_layout.addMultiCellWidget(self.textLabel3_2,2,2,2,3)
|
||||||
|
self.percentfilled = QLabel(self,"percentfree")
|
||||||
|
partitiongroup_layout.addWidget(self.percentfilled,2,4)
|
||||||
|
self.textLabel3_3 = QLabel(self,"textLabel3_3")
|
||||||
|
partitiongroup_layout.addWidget(self.textLabel3_3,3,2)
|
||||||
|
self.textLabel3 = QLabel(self,"textLabel3")
|
||||||
|
partitiongroup_layout.addWidget(self.textLabel3,1,2)
|
||||||
|
self.used = QLabel(self,"used")
|
||||||
|
partitiongroup_layout.addWidget(self.used,3,1)
|
||||||
|
self.mountpoint = QLabel(self,"mountpoint")
|
||||||
|
self.mountpoint.setMinimumSize(QSize(60,0))
|
||||||
|
partitiongroup_layout.addWidget(self.mountpoint,1,1)
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
self.setTitle(i18n("%1. Partition").arg(number))
|
||||||
|
self.textLabel1_3.setText(i18n("Used:"))
|
||||||
|
self.textLabel1_2.setText(i18n("Total Size:"))
|
||||||
|
self.textLabel1.setText(i18n("Mountpoint:"))
|
||||||
|
self.textLabel3_2.setText(i18n("% Used:"))
|
||||||
|
self.textLabel3_3.setText(i18n("Available:"))
|
||||||
|
self.textLabel3.setText(i18n("Device:"))
|
||||||
|
|
||||||
|
self.setDevice(self.dev_path+device)
|
||||||
|
self.setFillPercentage(fill_percent)
|
||||||
|
|
||||||
|
def setSize(self,label):
|
||||||
|
self.totalsize.setText(getLabel(label))
|
||||||
|
|
||||||
|
def setDevice(self,device):
|
||||||
|
self.device.setText(device)
|
||||||
|
|
||||||
|
def setMountPoint(self,mountpoint):
|
||||||
|
self.mountpoint.setText(mountpoint)
|
||||||
|
self.setTitle(i18n("Partition %1").arg(mountpoint))
|
||||||
|
|
||||||
|
def setTotalSize(self,totalsize):
|
||||||
|
self.totalsize.setText(getLabel(totalsize))
|
||||||
|
|
||||||
|
def setFillPercentage(self,fill_percent):
|
||||||
|
self.fill_percent = self.partpixmap.fill_percent = fill_percent
|
||||||
|
if fill_percent is not None:
|
||||||
|
self.percentfilled.setText("%s%%" % fill_percent)
|
||||||
|
else:
|
||||||
|
self.percentfilled.setText(i18n("Unknown"))
|
||||||
|
|
||||||
|
def setUsed(self,used):
|
||||||
|
self.used.setText(getLabel(used))
|
||||||
|
|
||||||
|
def setAvailable(self,available):
|
||||||
|
self.available.setText(getLabel(available))
|
||||||
|
|
||||||
|
class LegendLabel(QLabel):
|
||||||
|
""" Show some color in the DiskView legend """
|
||||||
|
|
||||||
|
def __init__(self,parent,color="green",style=QBrush.SolidPattern):
|
||||||
|
QLabel.__init__(self,parent,"bla")
|
||||||
|
self.w = 40
|
||||||
|
self.h = 20
|
||||||
|
self.pmsize = QSize(self.w,self.h)
|
||||||
|
self.pm = QPixmap(self.pmsize)
|
||||||
|
self.linewidth = 2
|
||||||
|
self.color = QColor(color)
|
||||||
|
self.style = style
|
||||||
|
self.framecolor = QColor("black")
|
||||||
|
self.paintMe()
|
||||||
|
self.setPixmap(self.pm)
|
||||||
|
self.setScaledContents(1)
|
||||||
|
self.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,
|
||||||
|
self.sizePolicy().hasHeightForWidth()))
|
||||||
|
|
||||||
|
def paintMe(self):
|
||||||
|
p = QPainter(self.pm)
|
||||||
|
p.fillRect(0,0,self.w,self.h,QBrush(self.color,self.style))
|
||||||
|
p.setPen(QPen(QColor("black"),self.linewidth))
|
||||||
|
p.drawRect(self.linewidth/2,self.linewidth/2,self.w-self.linewidth/2,self.h-self.linewidth/2)
|
||||||
|
p.end()
|
||||||
|
|
||||||
|
class PartitionView(QLabel):
|
||||||
|
""" PartitionView is a label carryig a pixmap. This class's main purpose is handlig layout
|
||||||
|
of the underlying pixmap."""
|
||||||
|
w = 250
|
||||||
|
h = 35
|
||||||
|
def __init__(self,parent,fill_percent,part_types,device):
|
||||||
|
self.part_types = part_types
|
||||||
|
self.fill_percent = fill_percent
|
||||||
|
QLabel.__init__(self,parent,"pview")
|
||||||
|
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding,0,0,
|
||||||
|
self.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.setMinimumSize(QSize(self.w,self.h))
|
||||||
|
self.setPixmap(PartitionPixmap(QSize(self.w,self.h),self.fill_percent,self.part_types,device))
|
||||||
|
self.setScaledContents(1)
|
||||||
|
self.setAlignment(QLabel.AlignCenter)
|
||||||
|
|
||||||
|
class DiskView(PartitionView):
|
||||||
|
""" PartitionView is a label carryig a pixmap. This class's main purpose is handlig layout
|
||||||
|
of the underlying pixmap."""
|
||||||
|
|
||||||
|
w = 540
|
||||||
|
h = 50
|
||||||
|
linewidth = 2
|
||||||
|
|
||||||
|
def __init__(self,parent,percents,colors):
|
||||||
|
QLabel.__init__(self,parent)
|
||||||
|
|
||||||
|
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding,0,0,
|
||||||
|
self.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.setPixmap(DiskPixmap(percents,colors,(self.w,self.h)))
|
||||||
|
self.setScaledContents(1)
|
||||||
|
self.setAlignment(QLabel.AlignCenter)
|
||||||
|
|
||||||
|
class DiskPixmap(QPixmap):
|
||||||
|
|
||||||
|
linewidth = 2 # Width of surrounding frame
|
||||||
|
|
||||||
|
def __init__(self,percents,colors,(w,h)):
|
||||||
|
self.percents = percents
|
||||||
|
self.w,self.h = w,h
|
||||||
|
self.colors = colors
|
||||||
|
QPixmap.__init__(self,w,h)
|
||||||
|
self.paintMe()
|
||||||
|
|
||||||
|
def paintMe(self):
|
||||||
|
p = QPainter(self)
|
||||||
|
w,h = self.w,self.h
|
||||||
|
i = 0
|
||||||
|
x0 = 0
|
||||||
|
y = 0
|
||||||
|
|
||||||
|
# Paint background, this is interesting for empty partitions.
|
||||||
|
p.fillRect(0,0,w,h,QBrush(QColor("white")))
|
||||||
|
|
||||||
|
parts = self.percents.keys()
|
||||||
|
parts.sort()
|
||||||
|
xa = wa = 0
|
||||||
|
for part in parts:
|
||||||
|
W = (w * self.percents[part])
|
||||||
|
# We need to adjust a little to avoid to get wholes.
|
||||||
|
if x0>0: xa = 2
|
||||||
|
if W < self.w: wa = 2
|
||||||
|
p.fillRect(x0-xa,0,W+wa,h,QBrush(QColor(self.colors[i])))
|
||||||
|
i += 1
|
||||||
|
x0 += W
|
||||||
|
|
||||||
|
# Paint Frame around it.
|
||||||
|
p.setPen(QPen(QColor("black"),self.linewidth))
|
||||||
|
p.drawRect(self.linewidth/2,self.linewidth/2,self.width()-self.linewidth/2,self.height()-self.linewidth/2)
|
||||||
|
p.end()
|
||||||
|
|
||||||
|
|
||||||
|
class PartitionPixmap(QPixmap):
|
||||||
|
""" A PartitionPixmap is a two colored bar with a black frame. The first color represents the
|
||||||
|
percentage that's used, the second one the free percentage."""
|
||||||
|
linewidth = 2 # Width of surrounding frame
|
||||||
|
|
||||||
|
def __init__(self,pmsize,fill_percent,part_types,device):
|
||||||
|
QPixmap.__init__(self,pmsize)
|
||||||
|
|
||||||
|
self.pmsize = pmsize # Size of the pixmap
|
||||||
|
self.part_types = part_types # Array to look up the type of the partition
|
||||||
|
self.fill_percent = fill_percent
|
||||||
|
self.device = device # Device name of the partition
|
||||||
|
|
||||||
|
self.w = self.pmsize.width()
|
||||||
|
self.h = self.pmsize.height()
|
||||||
|
self.paintMe()
|
||||||
|
|
||||||
|
def paintMe(self):
|
||||||
|
p = QPainter(self)
|
||||||
|
try:
|
||||||
|
fill_percent = int(self.fill_percent)
|
||||||
|
if self.part_types[self.device] == "swap":
|
||||||
|
# Swap partitions get blueish colors.
|
||||||
|
color_used = QColor("blue")
|
||||||
|
color_free = QColor("lightblue")
|
||||||
|
else:
|
||||||
|
# Regular partitions get a red / green color combo.
|
||||||
|
color_used = QColor("red")
|
||||||
|
color_free = QColor("forest green")
|
||||||
|
except (KeyError,TypeError):
|
||||||
|
# Partition has no fillsize, might be empty or not mounted partition
|
||||||
|
p.fillRect(0,0,self.w,self.h,QBrush(QColor("darkgrey")))
|
||||||
|
p.setPen(QPen(QColor("black"),self.linewidth))
|
||||||
|
p.drawRect(self.linewidth/2,self.linewidth/2,self.w-self.linewidth/2,self.h-self.linewidth/2)
|
||||||
|
p.end()
|
||||||
|
return
|
||||||
|
# Total width of the pixmap
|
||||||
|
W,H = float(self.w),float(self.h)
|
||||||
|
|
||||||
|
# Paint filled == red part of the bar.
|
||||||
|
x = y = 0
|
||||||
|
w = W - (W*(1-(fill_percent/100.00)))
|
||||||
|
h = H
|
||||||
|
p.fillRect(x,y,w,h,QBrush(color_used))
|
||||||
|
|
||||||
|
# Paint green part == space left
|
||||||
|
x = w
|
||||||
|
w = W - w
|
||||||
|
p.fillRect(x,y,w,h,QBrush(color_free))
|
||||||
|
|
||||||
|
# Paint Frame around it.
|
||||||
|
p.setPen(QPen(QColor("black"),self.linewidth))
|
||||||
|
p.drawRect(self.linewidth/2,self.linewidth/2,W-self.linewidth/2,H-self.linewidth/2)
|
||||||
|
|
||||||
|
p.end()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
device = "sdc"
|
||||||
|
app = SizeViewApplication(device,None,sys.argv)
|
@ -0,0 +1 @@
|
|||||||
|
?package(guidance): needs="kde" kde_filename="displayconfig" section="System/Configuration/KDE/Peripherals" title="Display & Monitor" icon="displayconfig.png" command="/usr/bin/displayconfig" kde_command="kcmshell displayconfig" longtitle="Display and monitor settings" kde_opt="\\nEncoding=UTF-8\\nX-KDE-ModuleType=Library\\nX-KDE-Library=displayconfig\\nX-KDE-FactoryName=displayconfig\\nX-KDE-ParentApp=kcontrol\\nX-KDE-RootOnly=true\\nX-KDE-SubstituteUID=true\\nKeywords=resolution;display;monitor;video;X11;xorg;gfx\\n"
|
@ -0,0 +1 @@
|
|||||||
|
?package(guidance): needs="kde" kde_filename="mountconfig" section="System/Configuration/KDE/System" title="Disk & Filesystems" icon="disksfilesystems.png" command="/usr/bin/mountconfig" kde_command="kcmshell mountconfig" longtitle="Manage disks and filesystems" kde_opt="\\nEncoding=UTF-8\\nX-KDE-ModuleType=Library\\nX-KDE-Library=mountconfig\\nX-KDE-FactoryName=mountconfig\\nX-KDE-ParentApp=kcontrol\\nX-KDE-RootOnly=true\\nX-KDE-SubstituteUID=true\\nKeywords=disk;filesystem;mount\\n"
|
@ -0,0 +1 @@
|
|||||||
|
?package(guidance): needs="kde" kde_filename="serviceconfig" section="System/Configuration/KDE/System" title="Services" icon="daemons.png" command="/usr/bin/serviceconfig" kde_command="kcmshell serviceconfig" longtitle="Manage running services" kde_opt="\\nEncoding=UTF-8\\nX-KDE-ModuleType=Library\\nX-KDE-Library=serviceconfig\\nX-KDE-FactoryName=serviceconfig\\nX-KDE-ParentApp=kcontrol\\nX-KDE-RootOnly=true\\nX-KDE-SubstituteUID=true\\nKeywords=init.d;service;boot;daemon;demon\\n"
|
@ -0,0 +1 @@
|
|||||||
|
?package(guidance): needs="kde" kde_filename="userconfig" section="System/Configuration/KDE/System" title="Users and Groups" icon="userconfig.png" command="/usr/bin/userconfig" kde_command="kcmshell userconfig" longtitle="Manage user accounts and groups" kde_opt="\\nEncoding=UTF-8\\nX-KDE-ModuleType=Library\\nX-KDE-Library=userconfig\\nX-KDE-FactoryName=userconfig\\nX-KDE-ParentApp=kcontrol\\nX-KDE-RootOnly=true\\nX-KDE-SubstituteUID=true\\nKeywords=user;account;group;password\\n"
|
@ -0,0 +1,79 @@
|
|||||||
|
%define name guidance
|
||||||
|
%define version 0.3.0
|
||||||
|
%define release 1mdk
|
||||||
|
|
||||||
|
Summary: Configuration Utilities
|
||||||
|
Name: %{name}
|
||||||
|
Version: %{version}
|
||||||
|
Release: %{release}
|
||||||
|
Packager: Simon Edwards <simon@simonzone.com>
|
||||||
|
Source: %{name}-%{version}.tar.bz2
|
||||||
|
License: GPL
|
||||||
|
Group: System/Configuration
|
||||||
|
URL: http://www.simonzone.com/software/guidance/
|
||||||
|
Requires: python
|
||||||
|
Requires: libpythonize0
|
||||||
|
BuildRequires: python-devel
|
||||||
|
BuildRequires: libpythonize0-devel
|
||||||
|
Requires: PyKDE
|
||||||
|
Buildroot: %_tmppath/%name-buildroot
|
||||||
|
|
||||||
|
%description
|
||||||
|
Guidance.
|
||||||
|
|
||||||
|
Development version.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
%build
|
||||||
|
%install
|
||||||
|
./setup.py install --root=$RPM_BUILD_ROOT build_kcm
|
||||||
|
install -D --mode=a=r,u+w package/mandrake/guidance-kcmuserconfig $RPM_BUILD_ROOT/%{_menudir}/guidance-kcmuserconfig
|
||||||
|
install -D --mode=a=r,u+w package/mandrake/guidance-kcmmountconfig $RPM_BUILD_ROOT/%{_menudir}/guidance-kcmmountconfig
|
||||||
|
install -D --mode=a=r,u+w package/mandrake/guidance-kcmserviceconfig $RPM_BUILD_ROOT/%{_menudir}/guidance-kcmserviceconfig
|
||||||
|
install -D --mode=a=r,u+w package/mandrake/guidance-kcmdisplayconfig $RPM_BUILD_ROOT/%{_menudir}/guidance-kcmdisplayconfig
|
||||||
|
|
||||||
|
install -D kde/serviceconfig/pics/16x16/daemons.png $RPM_BUILD_ROOT/%{_iconsdir}/daemons.png
|
||||||
|
install -D kde/mountconfig/pics/16x16/disksfilesystems.png $RPM_BUILD_ROOT/%{_iconsdir}/disksfilesystems.png
|
||||||
|
install -D kde/userconfig/pics/16x16/userconfig.png $RPM_BUILD_ROOT/%{_iconsdir}/userconfig.png
|
||||||
|
install -D kde/displayconfig/pics/16x16/displayconfig.png $RPM_BUILD_ROOT/%{_iconsdir}/displayconfig.png
|
||||||
|
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/applnk/Settings/Peripherals/displayconfig.desktop
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/applnk/Settings/System/mountconfig.desktop
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/applnk/Settings/System/serviceconfig.desktop
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/applnk/Settings/System/userconfig.desktop
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/icons/crystalsvg/16x16/apps/daemons.png
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/icons/crystalsvg/16x16/apps/disksfilesystems.png
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/icons/crystalsvg/16x16/apps/displayconfig.png
|
||||||
|
rm $RPM_BUILD_ROOT/usr/share/icons/crystalsvg/16x16/apps/userconfig.png
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root)
|
||||||
|
%doc README TODO COPYING ChangeLog
|
||||||
|
%_bindir/*
|
||||||
|
%_datadir/apps/guidance/*
|
||||||
|
%_libdir/kde3/*
|
||||||
|
%_libdir/python2.3/*
|
||||||
|
%{_menudir}/*
|
||||||
|
%{_iconsdir}/daemons.png
|
||||||
|
%{_iconsdir}/disksfilesystems.png
|
||||||
|
%{_iconsdir}/userconfig.png
|
||||||
|
%{_iconsdir}/displayconfig.png
|
||||||
|
|
||||||
|
%post
|
||||||
|
%{update_menus}
|
||||||
|
%postun
|
||||||
|
%{clean_menus}
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Sun Mar 20 2005 Simon Edwards <simon@simonzone.com> 0.3.0-1mdk
|
||||||
|
- 0.3.0.
|
||||||
|
|
||||||
|
* Thu Dec 9 2004 Simon Edwards <simon@simonzone.com> 0.2.0-1mdk
|
||||||
|
- Initial rpm.
|
@ -0,0 +1,49 @@
|
|||||||
|
guidance-power-manager TODO:
|
||||||
|
------------------------------
|
||||||
|
- [brightness preview], see below
|
||||||
|
- make power-manager non-blocking
|
||||||
|
- Wait with hibernate / suspending if the plug has just been pulled
|
||||||
|
Some batteries only report remaining_time correctly after 30 or so
|
||||||
|
seconds
|
||||||
|
|
||||||
|
|
||||||
|
DUNNO's:
|
||||||
|
---------
|
||||||
|
- How to detect how long the machine is idle?
|
||||||
|
- How to perform actions that need root privileges (and are not available via HAL)?
|
||||||
|
- Should we notify when battery is fully charged?
|
||||||
|
|
||||||
|
FIXED:
|
||||||
|
-------
|
||||||
|
- What is "blank"? "Screen Saver", "Blank Screen" or "Monitor off"?
|
||||||
|
- Handle CPU hotplugging gracefully (try switching off one CPU when g-p-m is running...)
|
||||||
|
- Make use of kstandardirs
|
||||||
|
- Add icons to contextmenu
|
||||||
|
- Remove brightness controls when not hasBrighness
|
||||||
|
- Remove battery-specifif items from tooltip when there's no battery
|
||||||
|
- Make settings dialogue not apply instantly (Save config only on OK and Apply)
|
||||||
|
- Add cpu frequency to tooltip
|
||||||
|
- Add icons to tooltip
|
||||||
|
- Make tooltip size properly
|
||||||
|
- battery hotplugging
|
||||||
|
- Implement switchToBattery(), collecting all stuff for onBattery
|
||||||
|
- notify
|
||||||
|
- blankscreensaveronly
|
||||||
|
- lowerbrightness
|
||||||
|
|
||||||
|
- Implement switchToAC(), collecting stuff to run when plugged in:
|
||||||
|
- notify
|
||||||
|
- undo blankscreensaveronly
|
||||||
|
- up brightness
|
||||||
|
- Clicking onto the slider should move the handle to the closest tick, but how?
|
||||||
|
- support for second battery
|
||||||
|
|
||||||
|
[brightness preview]
|
||||||
|
Currently there is only a brightness preview for the currently active scheme (_either_ mains or battery powered).
|
||||||
|
That means if you want to set the battery brightness when you are currently mains powered, you'll probably
|
||||||
|
move the battery slider, realise that there is no preview, go to the mains slider, move it till you found a nice
|
||||||
|
brightness level, then go back to the battery slider and set it there. Would be nicer to have a preview for both sliders:
|
||||||
|
Whenever you move to a new location, the brightness is adjusted. Has to be tested if it should be set back to
|
||||||
|
previous value after 5 seconds, or if it should remain till you either move the other slider or click save (assuming
|
||||||
|
explicit apply).
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "stopping guidance-power-manager ..."
|
||||||
|
dcop `dcopfind -a "power-manager*"` MainApplication-Interface quit
|
||||||
|
|
||||||
|
echo "starting guidance-power-manager ..."
|
||||||
|
guidance-power-manager.py &
|
@ -0,0 +1,147 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
"""
|
||||||
|
Copyright 2008 Sebastian Kügler, Canonical Ltd, Luka Renko
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
Andreas Wenning <awen@awen.dk>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
A frontend to HAL's power features for KDE - Helper application
|
||||||
|
This application listens for HAL signals and issues dcop-calls to the
|
||||||
|
kde-power-manager that originally started it. To avoid the need for
|
||||||
|
kde-power-manager to shut it's helper down, this application
|
||||||
|
will automatically shut down if it's kde-power-manager isn't running.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import dbus, sys, time
|
||||||
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
import gobject
|
||||||
|
from dcopext import DCOPClient, DCOPObj, DCOPApp
|
||||||
|
|
||||||
|
class GPMHelper():
|
||||||
|
def mother_alive(self):
|
||||||
|
"""Check that our mother is still alive"""
|
||||||
|
found = False
|
||||||
|
for name in self.dcop.registeredApplications():
|
||||||
|
name = str(name)
|
||||||
|
if name == self.motherName:
|
||||||
|
found = True
|
||||||
|
if not found:
|
||||||
|
"""No mother; commit suicide"""
|
||||||
|
print "guidance-power-manager not alive; exiting"
|
||||||
|
loop.quit()
|
||||||
|
|
||||||
|
"""Called when signal is received"""
|
||||||
|
def signal_recv(self, *args):
|
||||||
|
if args[0] == "ButtonPressed":
|
||||||
|
if args[1] == "brightness-up":
|
||||||
|
if time.time()-0.02 <= self.last_brightness_up <= time.time():
|
||||||
|
"""Most likely an extra brightness-up call, discarding"""
|
||||||
|
print "Extra brightness-up call discarded"
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
ok, foo = self.mother.brightnessUp()
|
||||||
|
if not ok:
|
||||||
|
print "brightnessUp-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
self.last_brightness_up = time.time()
|
||||||
|
except:
|
||||||
|
print "brightnessUp-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
elif args[1] == "brightness-down":
|
||||||
|
if time.time()-0.02 <= self.last_brightness_down <= time.time():
|
||||||
|
"""Most likely an extra brightness-down call, discarding"""
|
||||||
|
print "Extra brightness-down call discarded"
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
ok, foo = self.mother.brightnessDown()
|
||||||
|
if not ok:
|
||||||
|
print "brightnessDown-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
self.last_brightness_down = time.time()
|
||||||
|
except:
|
||||||
|
print "brightnessDown-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
elif args[1] == "sleep":
|
||||||
|
if time.time()-1 <= self.last_sleep <= time.time():
|
||||||
|
"""Most likely an extra sleep-call, discarding"""
|
||||||
|
print "Extra sleep-call discarded"
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
ok, foo = self.mother.suspend()
|
||||||
|
if not ok:
|
||||||
|
print "suspend-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
self.last_sleep = time.time()
|
||||||
|
except:
|
||||||
|
print "suspend-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
elif args[1] == "hibernate":
|
||||||
|
if time.time()-1 <= self.last_hibernate <= time.time():
|
||||||
|
"""Most likely an extra hibernate-call, discarding"""
|
||||||
|
print "Extra hibernate-call discarded"
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
ok, foo = self.mother.hibernate()
|
||||||
|
if not ok:
|
||||||
|
print "hibernate-call failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
self.last_hibernate = time.time()
|
||||||
|
except:
|
||||||
|
print "hibernate failed"
|
||||||
|
return self.mother_alive()
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Connect to HAL"""
|
||||||
|
self.dbus_loop = DBusGMainLoop(set_as_default=True)
|
||||||
|
self.bus = dbus.SystemBus(mainloop=self.dbus_loop)
|
||||||
|
hal_manager_obj = self.bus.get_object("org.freedesktop.Hal",u'/org/freedesktop/Hal/Manager')
|
||||||
|
self.hal_manager = dbus.Interface(hal_manager_obj, "org.freedesktop.Hal.Manager")
|
||||||
|
|
||||||
|
"""Find button-devices and to connect to"""
|
||||||
|
button_devices = self.hal_manager.FindDeviceByCapability("button")
|
||||||
|
for device in button_devices:
|
||||||
|
self.bus.add_signal_receiver(self.signal_recv,
|
||||||
|
"Condition",
|
||||||
|
"org.freedesktop.Hal.Device",
|
||||||
|
"org.freedesktop.Hal",
|
||||||
|
device)
|
||||||
|
"""Let's find our mother"""
|
||||||
|
self.dcop = DCOPClient()
|
||||||
|
self.dcop.attach()
|
||||||
|
found = False
|
||||||
|
for name in self.dcop.registeredApplications():
|
||||||
|
name = str(name)
|
||||||
|
if name.startswith('guidance-'):
|
||||||
|
self.motherName = name
|
||||||
|
try:
|
||||||
|
self.mother = DCOPObj(name, self.dcop, 'power-manager')
|
||||||
|
found = True
|
||||||
|
except:
|
||||||
|
"""Do nothing, catched by found=False"""
|
||||||
|
break
|
||||||
|
if not found:
|
||||||
|
"""No mother; commit suicide"""
|
||||||
|
print "No guidance-power-manager is running"
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
"""Some laptops issue double sleep/hibernate-calls, we need to discard one in that case"""
|
||||||
|
self.last_sleep = 0
|
||||||
|
self.last_hibernate = 0
|
||||||
|
|
||||||
|
"""And multiple brightness calls is also possible"""
|
||||||
|
self.last_brightness_up = 0
|
||||||
|
self.last_brightness_down = 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
gpmh = GPMHelper()
|
||||||
|
loop = gobject.MainLoop()
|
||||||
|
loop.run()
|
@ -0,0 +1,35 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Name=Power Manager
|
||||||
|
Name[el]=Διαχειριστής ενέργειας
|
||||||
|
Name[es]=Administrador de energía
|
||||||
|
Name[et]=Toitehaldur
|
||||||
|
Name[it]=Gestore dell'energia
|
||||||
|
Name[ja]=電源管理
|
||||||
|
Name[nl]=Energiebeheer
|
||||||
|
Name[pt]=Gestor de Energia
|
||||||
|
Name[pt_BR]=Gerenciador de Energia
|
||||||
|
Name[sr]=Управљач енергијом
|
||||||
|
Name[sr@Latn]=Upravljač energijom
|
||||||
|
Name[sv]=Energisparfunktion
|
||||||
|
Name[xx]=xxPower Managerxx
|
||||||
|
Comment=Power management applet
|
||||||
|
Comment[el]=Μικροεφαρμογή διαχείρισης ενέργειας
|
||||||
|
Comment[es]=Applet de administrador de potencia
|
||||||
|
Comment[et]=Toitehalduse aplett
|
||||||
|
Comment[it]=Applicazione per la gestione dell'energia
|
||||||
|
Comment[ja]=電源管理アプレット
|
||||||
|
Comment[nl]=Energiebeheer-applet
|
||||||
|
Comment[pt]='Applet' de gestão de energia
|
||||||
|
Comment[pt_BR]=Mini-aplicativo de gerenciamento de energia
|
||||||
|
Comment[sr]=Аплет за управљање енергијом
|
||||||
|
Comment[sr@Latn]=Aplet za upravljanje energijom
|
||||||
|
Comment[sv]=Miniprogram för energisparfunktion
|
||||||
|
Comment[xx]=xxPower management appletxx
|
||||||
|
Icon=guidance-power-manager
|
||||||
|
Exec=guidance-power-manager
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=Qt;KDE;
|
||||||
|
OnlyShowIn=KDE;
|
||||||
|
X-DCOP-ServiceType=Unique
|
@ -0,0 +1,241 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'guidance_power_manager_ui.ui'
|
||||||
|
#
|
||||||
|
# Created: Thu Apr 10 00:50:39 2008
|
||||||
|
# by: The PyQt User Interface Compiler (pyuic) 3.17.4
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from qt import *
|
||||||
|
from kdecore import KCmdLineArgs, KApplication
|
||||||
|
from kdecore import i18n
|
||||||
|
from kdeui import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PowerManagerUI(QWidget):
|
||||||
|
def __init__(self,parent = None,name = None,fl = 0):
|
||||||
|
QWidget.__init__(self,parent,name,fl)
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
self.setName("PowerManagerUI")
|
||||||
|
|
||||||
|
self.setMouseTracking(1)
|
||||||
|
|
||||||
|
PowerManagerUILayout = QVBoxLayout(self,11,6,"PowerManagerUILayout")
|
||||||
|
|
||||||
|
self.GeneralSettingsBox = QGroupBox(self,"GeneralSettingsBox")
|
||||||
|
self.GeneralSettingsBox.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.GeneralSettingsBox.layout().setSpacing(6)
|
||||||
|
self.GeneralSettingsBox.layout().setMargin(11)
|
||||||
|
GeneralSettingsBoxLayout = QVBoxLayout(self.GeneralSettingsBox.layout())
|
||||||
|
GeneralSettingsBoxLayout.setAlignment(Qt.AlignTop)
|
||||||
|
|
||||||
|
self.lockScreenOnResume = QCheckBox(self.GeneralSettingsBox,"lockScreenOnResume")
|
||||||
|
GeneralSettingsBoxLayout.addWidget(self.lockScreenOnResume)
|
||||||
|
PowerManagerUILayout.addWidget(self.GeneralSettingsBox)
|
||||||
|
|
||||||
|
self.MainsPoweredBox = QGroupBox(self,"MainsPoweredBox")
|
||||||
|
self.MainsPoweredBox.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Fixed,0,0,self.MainsPoweredBox.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.MainsPoweredBox.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.MainsPoweredBox.layout().setSpacing(6)
|
||||||
|
self.MainsPoweredBox.layout().setMargin(11)
|
||||||
|
MainsPoweredBoxLayout = QVBoxLayout(self.MainsPoweredBox.layout())
|
||||||
|
MainsPoweredBoxLayout.setAlignment(Qt.AlignTop)
|
||||||
|
|
||||||
|
layout17 = QHBoxLayout(None,0,6,"layout17")
|
||||||
|
|
||||||
|
self.PoweredBrightnessLabel = QLabel(self.MainsPoweredBox,"PoweredBrightnessLabel")
|
||||||
|
layout17.addWidget(self.PoweredBrightnessLabel)
|
||||||
|
|
||||||
|
self.PoweredBrightnessSlider = QSlider(self.MainsPoweredBox,"PoweredBrightnessSlider")
|
||||||
|
self.PoweredBrightnessSlider.setMouseTracking(1)
|
||||||
|
self.PoweredBrightnessSlider.setAcceptDrops(1)
|
||||||
|
self.PoweredBrightnessSlider.setMaxValue(7)
|
||||||
|
self.PoweredBrightnessSlider.setLineStep(1)
|
||||||
|
self.PoweredBrightnessSlider.setPageStep(1)
|
||||||
|
self.PoweredBrightnessSlider.setOrientation(QSlider.Horizontal)
|
||||||
|
self.PoweredBrightnessSlider.setTickmarks(QSlider.Both)
|
||||||
|
self.PoweredBrightnessSlider.setTickInterval(0)
|
||||||
|
layout17.addWidget(self.PoweredBrightnessSlider)
|
||||||
|
MainsPoweredBoxLayout.addLayout(layout17)
|
||||||
|
|
||||||
|
layout13 = QHBoxLayout(None,0,6,"layout13")
|
||||||
|
spacer12_3_2_2 = QSpacerItem(200,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
layout13.addItem(spacer12_3_2_2)
|
||||||
|
|
||||||
|
self.PoweredIdleLabel = QLabel(self.MainsPoweredBox,"PoweredIdleLabel")
|
||||||
|
layout13.addWidget(self.PoweredIdleLabel)
|
||||||
|
|
||||||
|
self.PoweredIdleTime = QSpinBox(self.MainsPoweredBox,"PoweredIdleTime")
|
||||||
|
layout13.addWidget(self.PoweredIdleTime)
|
||||||
|
|
||||||
|
self.PoweredIdleCombo = QComboBox(0,self.MainsPoweredBox,"PoweredIdleCombo")
|
||||||
|
layout13.addWidget(self.PoweredIdleCombo)
|
||||||
|
MainsPoweredBoxLayout.addLayout(layout13)
|
||||||
|
|
||||||
|
layout13_2_2 = QHBoxLayout(None,0,6,"layout13_2_2")
|
||||||
|
spacer12_3_2_2_3_2 = QSpacerItem(200,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
layout13_2_2.addItem(spacer12_3_2_2_3_2)
|
||||||
|
|
||||||
|
self.PoweredFreqLabel = QLabel(self.MainsPoweredBox,"PoweredFreqLabel")
|
||||||
|
layout13_2_2.addWidget(self.PoweredFreqLabel)
|
||||||
|
|
||||||
|
self.PoweredFreqCombo = QComboBox(0,self.MainsPoweredBox,"PoweredFreqCombo")
|
||||||
|
layout13_2_2.addWidget(self.PoweredFreqCombo)
|
||||||
|
MainsPoweredBoxLayout.addLayout(layout13_2_2)
|
||||||
|
PowerManagerUILayout.addWidget(self.MainsPoweredBox)
|
||||||
|
|
||||||
|
self.BatteryBox = QGroupBox(self,"BatteryBox")
|
||||||
|
self.BatteryBox.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Fixed,0,0,self.BatteryBox.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.BatteryBox.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.BatteryBox.layout().setSpacing(6)
|
||||||
|
self.BatteryBox.layout().setMargin(11)
|
||||||
|
BatteryBoxLayout = QVBoxLayout(self.BatteryBox.layout())
|
||||||
|
BatteryBoxLayout.setAlignment(Qt.AlignTop)
|
||||||
|
|
||||||
|
layout16 = QHBoxLayout(None,0,6,"layout16")
|
||||||
|
|
||||||
|
self.BatteryBrightnessLabel = QLabel(self.BatteryBox,"BatteryBrightnessLabel")
|
||||||
|
layout16.addWidget(self.BatteryBrightnessLabel)
|
||||||
|
|
||||||
|
self.BatteryBrightnessSlider = QSlider(self.BatteryBox,"BatteryBrightnessSlider")
|
||||||
|
self.BatteryBrightnessSlider.setMouseTracking(1)
|
||||||
|
self.BatteryBrightnessSlider.setMaxValue(7)
|
||||||
|
self.BatteryBrightnessSlider.setPageStep(1)
|
||||||
|
self.BatteryBrightnessSlider.setOrientation(QSlider.Horizontal)
|
||||||
|
self.BatteryBrightnessSlider.setTickmarks(QSlider.Both)
|
||||||
|
layout16.addWidget(self.BatteryBrightnessSlider)
|
||||||
|
BatteryBoxLayout.addLayout(layout16)
|
||||||
|
|
||||||
|
layout14 = QGridLayout(None,1,1,0,6,"layout14")
|
||||||
|
|
||||||
|
self.BatteryIdleCombo = QComboBox(0,self.BatteryBox,"BatteryIdleCombo")
|
||||||
|
|
||||||
|
layout14.addWidget(self.BatteryIdleCombo,1,4)
|
||||||
|
|
||||||
|
self.BatteryIdleLabel = QLabel(self.BatteryBox,"BatteryIdleLabel")
|
||||||
|
|
||||||
|
layout14.addWidget(self.BatteryIdleLabel,1,2)
|
||||||
|
|
||||||
|
self.BatteryCriticalCombo = QComboBox(0,self.BatteryBox,"BatteryCriticalCombo")
|
||||||
|
|
||||||
|
layout14.addWidget(self.BatteryCriticalCombo,0,4)
|
||||||
|
|
||||||
|
self.BatteryCriticalLabel = QLabel(self.BatteryBox,"BatteryCriticalLabel")
|
||||||
|
|
||||||
|
layout14.addMultiCellWidget(self.BatteryCriticalLabel,0,0,1,2)
|
||||||
|
|
||||||
|
self.BatteryIdleTime = QSpinBox(self.BatteryBox,"BatteryIdleTime")
|
||||||
|
|
||||||
|
layout14.addWidget(self.BatteryIdleTime,1,3)
|
||||||
|
|
||||||
|
self.CriticalRemainTime = QSpinBox(self.BatteryBox,"CriticalRemainTime")
|
||||||
|
|
||||||
|
layout14.addWidget(self.CriticalRemainTime,0,3)
|
||||||
|
spacer12_3 = QSpacerItem(28,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
layout14.addItem(spacer12_3,0,0)
|
||||||
|
spacer12_3_2 = QSpacerItem(50,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
layout14.addMultiCell(spacer12_3_2,1,1,0,1)
|
||||||
|
BatteryBoxLayout.addLayout(layout14)
|
||||||
|
|
||||||
|
layout13_2 = QHBoxLayout(None,0,6,"layout13_2")
|
||||||
|
spacer12_3_2_2_3 = QSpacerItem(200,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
layout13_2.addItem(spacer12_3_2_2_3)
|
||||||
|
|
||||||
|
self.BatteryFreqLabel = QLabel(self.BatteryBox,"BatteryFreqLabel")
|
||||||
|
layout13_2.addWidget(self.BatteryFreqLabel)
|
||||||
|
|
||||||
|
self.BatteryFreqCombo = QComboBox(0,self.BatteryBox,"BatteryFreqCombo")
|
||||||
|
layout13_2.addWidget(self.BatteryFreqCombo)
|
||||||
|
BatteryBoxLayout.addLayout(layout13_2)
|
||||||
|
PowerManagerUILayout.addWidget(self.BatteryBox)
|
||||||
|
|
||||||
|
self.LaptopLidRadios = QButtonGroup(self,"LaptopLidRadios")
|
||||||
|
self.LaptopLidRadios.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Fixed,0,0,self.LaptopLidRadios.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.LaptopLidRadios.setFrameShape(QButtonGroup.GroupBoxPanel)
|
||||||
|
self.LaptopLidRadios.setColumnLayout(0,Qt.Vertical)
|
||||||
|
self.LaptopLidRadios.layout().setSpacing(5)
|
||||||
|
self.LaptopLidRadios.layout().setMargin(11)
|
||||||
|
LaptopLidRadiosLayout = QHBoxLayout(self.LaptopLidRadios.layout())
|
||||||
|
LaptopLidRadiosLayout.setAlignment(Qt.AlignTop)
|
||||||
|
|
||||||
|
self.laptopClosedNone = QRadioButton(self.LaptopLidRadios,"laptopClosedNone")
|
||||||
|
LaptopLidRadiosLayout.addWidget(self.laptopClosedNone)
|
||||||
|
|
||||||
|
self.laptopClosedBlank = QRadioButton(self.LaptopLidRadios,"laptopClosedBlank")
|
||||||
|
LaptopLidRadiosLayout.addWidget(self.laptopClosedBlank)
|
||||||
|
|
||||||
|
self.laptopClosedSuspend = QRadioButton(self.LaptopLidRadios,"laptopClosedSuspend")
|
||||||
|
LaptopLidRadiosLayout.addWidget(self.laptopClosedSuspend)
|
||||||
|
|
||||||
|
self.laptopClosedHibernate = QRadioButton(self.LaptopLidRadios,"laptopClosedHibernate")
|
||||||
|
LaptopLidRadiosLayout.addWidget(self.laptopClosedHibernate)
|
||||||
|
|
||||||
|
self.laptopClosedShutdown = QRadioButton(self.LaptopLidRadios,"laptopClosedShutdown")
|
||||||
|
LaptopLidRadiosLayout.addWidget(self.laptopClosedShutdown)
|
||||||
|
spacer12_2 = QSpacerItem(213,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
|
||||||
|
LaptopLidRadiosLayout.addItem(spacer12_2)
|
||||||
|
PowerManagerUILayout.addWidget(self.LaptopLidRadios)
|
||||||
|
spacer11 = QSpacerItem(31,80,QSizePolicy.Minimum,QSizePolicy.Expanding)
|
||||||
|
PowerManagerUILayout.addItem(spacer11)
|
||||||
|
|
||||||
|
self.languageChange()
|
||||||
|
|
||||||
|
self.resize(QSize(505,374).expandedTo(self.minimumSizeHint()))
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
|
||||||
|
def languageChange(self):
|
||||||
|
self.setCaption(i18n("PowerManagerUI"))
|
||||||
|
self.GeneralSettingsBox.setTitle(i18n("General Settings"))
|
||||||
|
self.lockScreenOnResume.setText(i18n("Lock screen on resume"))
|
||||||
|
self.MainsPoweredBox.setTitle(i18n("Mains Powered"))
|
||||||
|
self.PoweredBrightnessLabel.setText(i18n("Brightness"))
|
||||||
|
QWhatsThis.add(self.PoweredBrightnessSlider,i18n("With this slider you can set the brightness when the system is plugged into the socket outlet"))
|
||||||
|
self.PoweredIdleLabel.setText(i18n("When the system is idle for more than"))
|
||||||
|
self.PoweredIdleTime.setPrefix(QString.null)
|
||||||
|
self.PoweredIdleTime.setSuffix(i18n(" min"))
|
||||||
|
QWhatsThis.add(self.PoweredIdleTime,i18n("To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action."))
|
||||||
|
self.PoweredFreqLabel.setText(i18n("CPU frequency scaling policy"))
|
||||||
|
self.BatteryBox.setTitle(i18n("Battery Powered"))
|
||||||
|
self.BatteryBrightnessLabel.setText(i18n("Brightness"))
|
||||||
|
QWhatsThis.add(self.BatteryBrightnessSlider,i18n("This slider controls the brightness when the system runs on batteries"))
|
||||||
|
self.BatteryIdleLabel.setText(i18n("When the system is idle for more than"))
|
||||||
|
self.BatteryCriticalLabel.setText(i18n("When battery remaining time drops below"))
|
||||||
|
self.BatteryIdleTime.setPrefix(QString.null)
|
||||||
|
self.BatteryIdleTime.setSuffix(i18n(" min"))
|
||||||
|
QWhatsThis.add(self.BatteryIdleTime,i18n("To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action."))
|
||||||
|
self.CriticalRemainTime.setPrefix(QString.null)
|
||||||
|
self.CriticalRemainTime.setSuffix(i18n(" min"))
|
||||||
|
QWhatsThis.add(self.CriticalRemainTime,i18n("To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action."))
|
||||||
|
self.BatteryFreqLabel.setText(i18n("CPU frequency scaling policy"))
|
||||||
|
self.LaptopLidRadios.setTitle(i18n("When Laptop Lid Closed"))
|
||||||
|
self.laptopClosedNone.setText(i18n("Do nothing"))
|
||||||
|
self.laptopClosedBlank.setText(i18n("Lock screen"))
|
||||||
|
self.laptopClosedSuspend.setText(i18n("Suspend"))
|
||||||
|
QToolTip.add(self.laptopClosedSuspend,i18n("Suspend to Memory"))
|
||||||
|
QWhatsThis.add(self.laptopClosedSuspend,i18n("Suspend is a sleep state, the system will consume only very little energy when suspended"))
|
||||||
|
self.laptopClosedHibernate.setText(i18n("Hibernate"))
|
||||||
|
QToolTip.add(self.laptopClosedHibernate,i18n("Suspend to Disk"))
|
||||||
|
QWhatsThis.add(self.laptopClosedHibernate,i18n("Hibernate or \"Suspend to Disk\" is a deep sleepstate, allowing the system to power off completely"))
|
||||||
|
self.laptopClosedShutdown.setText(i18n("Shutdown"))
|
||||||
|
QToolTip.add(self.laptopClosedShutdown,i18n("Halt the machine"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
appname = ""
|
||||||
|
description = ""
|
||||||
|
version = ""
|
||||||
|
|
||||||
|
KCmdLineArgs.init (sys.argv, appname, description, version)
|
||||||
|
a = KApplication ()
|
||||||
|
|
||||||
|
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
|
||||||
|
w = PowerManagerUI()
|
||||||
|
a.setMainWidget(w)
|
||||||
|
w.show()
|
||||||
|
a.exec_loop()
|
@ -0,0 +1,530 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>PowerManagerUI</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowerManagerUI</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>505</width>
|
||||||
|
<height>374</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>PowerManagerUI</string>
|
||||||
|
</property>
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>GeneralSettingsBox</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>General Settings</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>lockScreenOnResume</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Lock screen on resume</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>MainsPoweredBox</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Mains Powered</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout17</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredBrightnessLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Brightness</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSlider">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredBrightnessSlider</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maxValue">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<property name="lineStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickmarks">
|
||||||
|
<enum>Both</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickInterval">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>With this slider you can set the brightness when the system is plugged into the socket outlet</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout13</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer12_3_2_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredIdleLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When the system is idle for more than</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredIdleTime</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> min</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredIdleCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout13_2_2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer12_3_2_2_3_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredFreqLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>CPU frequency scaling policy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PoweredFreqCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryBox</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Battery Powered</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout16</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryBrightnessLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Brightness</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSlider">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryBrightnessSlider</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maxValue">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickmarks">
|
||||||
|
<enum>Both</enum>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>This slider controls the brightness when the system runs on batteries</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout14</cstring>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QComboBox" row="1" column="4">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryIdleCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="1" column="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryIdleLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When the system is idle for more than</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" row="0" column="4">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryCriticalCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="0" column="1" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryCriticalLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When battery remaining time drops below</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" row="1" column="3">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryIdleTime</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> min</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" row="0" column="3">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>CriticalRemainTime</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> min</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer12_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<spacer row="1" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer12_3_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout13_2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer12_3_2_2_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryFreqLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>CPU frequency scaling policy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryFreqCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QButtonGroup">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>LaptopLidRadios</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>GroupBoxPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>When Laptop Lid Closed</string>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>laptopClosedNone</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>laptopClosedBlank</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Lock screen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>laptopClosedSuspend</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Suspend</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" stdset="0">
|
||||||
|
<string>Suspend to Memory</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>Suspend is a sleep state, the system will consume only very little energy when suspended</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>laptopClosedHibernate</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" stdset="0">
|
||||||
|
<string>Suspend to Disk</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>Hibernate or "Suspend to Disk" is a deep sleepstate, allowing the system to power off completely</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>laptopClosedShutdown</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Shutdown</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" stdset="0">
|
||||||
|
<string>Halt the machine</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer12_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>213</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer11</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>31</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,35 @@
|
|||||||
|
import dbus
|
||||||
|
|
||||||
|
bus = dbus.SystemBus()
|
||||||
|
hal_manager_obj = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
|
||||||
|
hal_manager = dbus.Interface(hal_manager_obj, "org.freedesktop.Hal.Manager")
|
||||||
|
#device_names = hal_manager.GetAllDevices()
|
||||||
|
|
||||||
|
ac = hal_manager.FindDeviceByCapability("ac_adapter")
|
||||||
|
|
||||||
|
#all_devices = hal_manager.GetAllDevices()
|
||||||
|
|
||||||
|
#for n in device_names: print n
|
||||||
|
#obj = bus.get_object("org.freedesktop.Hal", u'/org/freedesktop/Hal/devices/acpi_AC')
|
||||||
|
#obj.GetAllProperties()
|
||||||
|
|
||||||
|
name = ac[0]
|
||||||
|
device_dbus_obj = bus.get_object("org.freedesktop.Hal" ,ac[0])
|
||||||
|
properties = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
|
||||||
|
try:
|
||||||
|
parent_name = properties["info.parent"]
|
||||||
|
except KeyError:
|
||||||
|
# no parent, must be parent of virtual_root
|
||||||
|
parent_name = "/"
|
||||||
|
except TypeError:
|
||||||
|
print "Error: no properties for device %s"%name
|
||||||
|
#continue
|
||||||
|
print properties['ac_adapter.present']
|
||||||
|
#for p in properties:
|
||||||
|
# print p, " :: ", properties[p]
|
||||||
|
if properties['ac_adapter.present']:
|
||||||
|
print "plugged in"
|
||||||
|
else:
|
||||||
|
print "unplugged"
|
||||||
|
|
@ -0,0 +1,68 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'notify.ui'
|
||||||
|
#
|
||||||
|
# Created: Thu Apr 10 00:50:39 2008
|
||||||
|
# by: The PyQt User Interface Compiler (pyuic) 3.17.4
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from qt import *
|
||||||
|
from kdecore import KCmdLineArgs, KApplication
|
||||||
|
from kdecore import i18n
|
||||||
|
from kdeui import *
|
||||||
|
|
||||||
|
|
||||||
|
class NotifyWidget(QWidget):
|
||||||
|
def __init__(self,parent = None,name = None,fl = 0):
|
||||||
|
QWidget.__init__(self,parent,name,fl)
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
self.setName("NotifyWidgetUI")
|
||||||
|
|
||||||
|
self.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding,0,0,self.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.setBaseSize(QSize(0,0))
|
||||||
|
|
||||||
|
NotifyWidgetUILayout = QGridLayout(self,1,1,11,6,"NotifyWidgetUILayout")
|
||||||
|
|
||||||
|
self.Icon = QLabel(self,"Icon")
|
||||||
|
self.Icon.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.Icon.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.Icon.setScaledContents(1)
|
||||||
|
|
||||||
|
NotifyWidgetUILayout.addMultiCellWidget(self.Icon,0,1,0,0)
|
||||||
|
|
||||||
|
self.Text = QLabel(self,"Text")
|
||||||
|
|
||||||
|
NotifyWidgetUILayout.addWidget(self.Text,1,1)
|
||||||
|
|
||||||
|
self.Caption = QLabel(self,"Caption")
|
||||||
|
|
||||||
|
NotifyWidgetUILayout.addWidget(self.Caption,0,1)
|
||||||
|
|
||||||
|
self.languageChange()
|
||||||
|
|
||||||
|
self.resize(QSize(151,60).expandedTo(self.minimumSizeHint()))
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
|
||||||
|
def languageChange(self):
|
||||||
|
self.setCaption(i18n("Form3"))
|
||||||
|
self.Text.setText(QString.null)
|
||||||
|
self.Caption.setText(i18n("<b>Powermanager:</b>"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
appname = ""
|
||||||
|
description = ""
|
||||||
|
version = ""
|
||||||
|
|
||||||
|
KCmdLineArgs.init (sys.argv, appname, description, version)
|
||||||
|
a = KApplication ()
|
||||||
|
|
||||||
|
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
|
||||||
|
w = NotifyWidget()
|
||||||
|
a.setMainWidget(w)
|
||||||
|
w.show()
|
||||||
|
a.exec_loop()
|
@ -0,0 +1,75 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>NotifyWidget</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>NotifyWidgetUI</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>151</width>
|
||||||
|
<height>60</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>3</hsizetype>
|
||||||
|
<vsizetype>3</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Form3</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" row="0" column="0" rowspan="2" colspan="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Icon</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>0</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap></pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="1" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Text</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="0" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Caption</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><b>Powermanager:</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<pixmapfunction>QPixmap</pixmapfunction>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,606 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
###########################################################################
|
||||||
|
# Copyright (C) 2006 by Sebastian Kügler
|
||||||
|
# <sebas@kde.org>
|
||||||
|
#
|
||||||
|
# Copyright: See COPYING file that comes with this distribution
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
# An API for changing the powerstate of a notebook
|
||||||
|
|
||||||
|
import dbus
|
||||||
|
import dbus.glib
|
||||||
|
import os, time
|
||||||
|
from dcopext import DCOPClient, DCOPApp # Used for kscreensaver
|
||||||
|
import xf86misc
|
||||||
|
|
||||||
|
DEBUG = False
|
||||||
|
|
||||||
|
def debug(msg):
|
||||||
|
""" Print debug message to terminal. """
|
||||||
|
if DEBUG:
|
||||||
|
print msg
|
||||||
|
|
||||||
|
# Default values for actions when battery runs out.
|
||||||
|
BATTERY_CRITICAL_MINUTES=5
|
||||||
|
|
||||||
|
# Only do an emergency suspend if charge level percentage is below ...
|
||||||
|
CHARGE_LEVEL_THRESHOLD = 10
|
||||||
|
|
||||||
|
isroot = os.environ["USER"] == "root"
|
||||||
|
|
||||||
|
# Send suspend / hibernate commands to HAL or use Sx_COMMANDS
|
||||||
|
SUSPEND_USE_HAL = True
|
||||||
|
|
||||||
|
# Show the cpu frequency widgets in the tooltip?
|
||||||
|
SHOW_CPUFREQ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Command to initiate suspend-to-disk when not using HAL
|
||||||
|
S4_COMMAND = "/usr/local/bin/hibernate"
|
||||||
|
# Command to initiate suspend-to-ram when not using HAL
|
||||||
|
S3_COMMAND = "/usr/local/bin/s2ram"
|
||||||
|
|
||||||
|
# Override isLaptop method
|
||||||
|
#IS_LAPTOP = True
|
||||||
|
|
||||||
|
def _readValue(filename, line=0):
|
||||||
|
""" Reads a single value from the first line of a file. """
|
||||||
|
fhandle = open(filename)
|
||||||
|
value = fhandle.readlines()[line][:-1]
|
||||||
|
fhandle.close()
|
||||||
|
return value
|
||||||
|
|
||||||
|
class PowerManage:
|
||||||
|
""" Class providing low-level power managerment functionality. """
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# (En|Dis)able using hdparm to set disk timeout
|
||||||
|
self.USE_HDPARM = True
|
||||||
|
# (En|Dis)able using laptop_mode to make the disk spin up less often
|
||||||
|
self.USE_LAPTOP_MODE = True
|
||||||
|
# (En|Dis)able using cpufreq to control cpu frequency scaling
|
||||||
|
self.USE_CPUFREQ = True
|
||||||
|
# (En|Dis)able using wireless adapter powermanagement (causes lag in network connection)
|
||||||
|
self.USE_WI_PM = True
|
||||||
|
# (En|Dis)able using display powermanagement
|
||||||
|
self.USE_DPMS = True
|
||||||
|
# (En|Dis)able using display brightness switching
|
||||||
|
self.USE_DISPLAY = True
|
||||||
|
# (En|Dis)able screensaver blankonly
|
||||||
|
self.SCREENSAVER_BLANKONLY = True
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
xg = xf86misc.XF86Server()
|
||||||
|
self.xscreen = xg.getDefaultScreen()
|
||||||
|
except xf86misc.XF86Error:
|
||||||
|
print "Problem connecting to X server for idletime detection."
|
||||||
|
# Currently only used in the test method
|
||||||
|
self.display_dark = 0.5
|
||||||
|
self.display_light = 1
|
||||||
|
|
||||||
|
# Some status initialisations
|
||||||
|
self.lowBatteryState = False
|
||||||
|
self.warningBatteryState = False
|
||||||
|
self.criticalBatteryState = False
|
||||||
|
|
||||||
|
self.criticalBatteryState = False
|
||||||
|
self.lidClosedState = False
|
||||||
|
|
||||||
|
# What does HAL support on this machine
|
||||||
|
self.hasBrightness = False
|
||||||
|
self.hasAC = False
|
||||||
|
self.hasLid = False
|
||||||
|
self.hasBattery = False
|
||||||
|
self.hasCpuFreqGovernors = False
|
||||||
|
|
||||||
|
# Used to track if the previous check reported a battery to determine
|
||||||
|
# if we want to fire a notice "battery removed|plugged in"
|
||||||
|
self.wasOnBattery = False
|
||||||
|
self._initHAL()
|
||||||
|
self._initBrightness()
|
||||||
|
self._initBattery()
|
||||||
|
self._initAc()
|
||||||
|
self._initLid()
|
||||||
|
self._checkSuspend()
|
||||||
|
self._checkCpuCapabilities()
|
||||||
|
self._findDisks()
|
||||||
|
|
||||||
|
def checkHAL(self):
|
||||||
|
""" Handle HAL and DBus restarts """
|
||||||
|
try:
|
||||||
|
self.hal_manager.FindDeviceByCapability("")
|
||||||
|
except dbus.DBusException, e:
|
||||||
|
if str(e) == 'org.freedesktop.DBus.Error.Disconnected: Connection is closed' \
|
||||||
|
or str(e) == 'org.freedesktop.DBus.Error.Disconnected: Connection was disconnected before a reply was received':
|
||||||
|
# DBus doesn't support on-the-fly restart
|
||||||
|
print "connection with DBus lost, please restart the display manager"
|
||||||
|
return
|
||||||
|
|
||||||
|
if os.system("ps aux|grep [h]ald-runner") == 0:
|
||||||
|
print "connection with HAL lost, trying to reconnect"
|
||||||
|
self._initHAL()
|
||||||
|
self._initBrightness()
|
||||||
|
self._initBattery()
|
||||||
|
self._initAc()
|
||||||
|
self._initLid()
|
||||||
|
self._checkSuspend()
|
||||||
|
self._checkCpuCapabilities()
|
||||||
|
else:
|
||||||
|
print "HAL is not running"
|
||||||
|
|
||||||
|
def isLaptop(self):
|
||||||
|
""" Detect if system is laptop. """
|
||||||
|
try:
|
||||||
|
return IS_LAPTOP
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
self.computerObject = self.bus.get_object("org.freedesktop.Hal",
|
||||||
|
u'/org/freedesktop/Hal/devices/computer')
|
||||||
|
properties = self.computerObject.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
# formfactor sometimes (ppc) also reports "unknown" for laptops
|
||||||
|
# workaround: consider laptop anything with primary battery (see LP #64053)
|
||||||
|
return properties["system.formfactor"] == "laptop" or self.hasBattery
|
||||||
|
|
||||||
|
def _findDisks(self):
|
||||||
|
""" Scan /sys/block for non-removable and non-ramdisks, used for hdparm actions,
|
||||||
|
currently not implemented in the powermanager frontend. """
|
||||||
|
self.disks = []
|
||||||
|
blk_path = "/sys/block/"
|
||||||
|
for d in os.listdir(blk_path):
|
||||||
|
# No RAM disks, no DM-RAID
|
||||||
|
if d.startswith("ram") or d.startswith("dm"):
|
||||||
|
continue
|
||||||
|
fhandle = open(blk_path+d+"/removable")
|
||||||
|
if fhandle.readlines()[0][:-1] == "0":
|
||||||
|
self.disks.append(d)
|
||||||
|
debug("Detected disks: "+" ".join(self.disks))
|
||||||
|
|
||||||
|
def onBattery(self):
|
||||||
|
""" Find out if we're on AC or on battery using HAL. """
|
||||||
|
if not self.hasAC:
|
||||||
|
print "No AC adapter found - assume that we are on batteries."
|
||||||
|
return False
|
||||||
|
properties = self.acObject.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
if properties.has_key("ac_adapter.present"):
|
||||||
|
return not properties['ac_adapter.present']
|
||||||
|
else:
|
||||||
|
print "Error: ac_adapter has no property \"present\""
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _initBattery(self):
|
||||||
|
""" Looks for a battery in HAL. """
|
||||||
|
batteryDevices = self.hal_manager.FindDeviceByCapability("battery")
|
||||||
|
self.batteries = {}
|
||||||
|
self.batteryIsPresent = {}
|
||||||
|
|
||||||
|
numBatt = 0
|
||||||
|
for batt in batteryDevices:
|
||||||
|
battObj = self.bus.get_object("org.freedesktop.Hal", batt)
|
||||||
|
properties = battObj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
if properties['battery.type'] != "primary":
|
||||||
|
continue
|
||||||
|
self.batteries[numBatt] = battObj
|
||||||
|
self.batteryIsPresent[numBatt] = properties['battery.present']
|
||||||
|
numBatt += 1
|
||||||
|
|
||||||
|
if numBatt > 0:
|
||||||
|
self.hasBattery = True
|
||||||
|
else:
|
||||||
|
self.hasBattery = False
|
||||||
|
print "No battery found."
|
||||||
|
|
||||||
|
def getBatteryState(self,batt):
|
||||||
|
""" Read battery status from HAL and return
|
||||||
|
(battery state, charge percentage, remaining seconds).
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
properties = self.batteries[batt].GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
except dbus.DBusException:
|
||||||
|
print "problem getting battery state from dbus."
|
||||||
|
return "not present", 0, 0, 0, 0, 0
|
||||||
|
|
||||||
|
if not properties['battery.present']:
|
||||||
|
return "not present", 0, 0, 0, 0, 0
|
||||||
|
else:
|
||||||
|
current = full = level = remain = rate = 0
|
||||||
|
if properties.has_key("battery.charge_level.current"):
|
||||||
|
current = properties["battery.charge_level.current"]
|
||||||
|
if properties.has_key("battery.charge_level.last_full"):
|
||||||
|
full = properties["battery.charge_level.last_full"]
|
||||||
|
|
||||||
|
if properties["battery.rechargeable.is_charging"]:
|
||||||
|
state = "charging"
|
||||||
|
elif properties["battery.rechargeable.is_discharging"]:
|
||||||
|
if self.onBattery():
|
||||||
|
state = "discharging"
|
||||||
|
else:
|
||||||
|
state = "charged"
|
||||||
|
elif not properties["battery.rechargeable.is_discharging"] \
|
||||||
|
and not properties["battery.rechargeable.is_charging"]:
|
||||||
|
if current == 0:
|
||||||
|
state = "empty"
|
||||||
|
else:
|
||||||
|
state = "charged"
|
||||||
|
else:
|
||||||
|
print "Unknown battery state ..."
|
||||||
|
|
||||||
|
# Sometimes, HAL doesn't report the percentage, but we can compute that ourselves anyway
|
||||||
|
if properties.has_key("battery.charge_level.percentage"):
|
||||||
|
level = properties["battery.charge_level.percentage"]
|
||||||
|
elif current > 0 and full > 0:
|
||||||
|
level = current / full
|
||||||
|
|
||||||
|
if state in ("charging","discharging"):
|
||||||
|
if properties.has_key("battery.remaining_time"):
|
||||||
|
remain = properties["battery.remaining_time"]
|
||||||
|
if properties.has_key("battery.charge_level.rate"):
|
||||||
|
rate = properties["battery.charge_level.rate"]
|
||||||
|
|
||||||
|
return state, level, remain, rate, current, full
|
||||||
|
|
||||||
|
def showInfo(self):
|
||||||
|
""" Outputs some random information to show that it does not work yet. """
|
||||||
|
print "OnBattery:", self.onBattery()
|
||||||
|
print "CPUs:", len(self.cpus)
|
||||||
|
|
||||||
|
def _initHAL(self):
|
||||||
|
""" Initialise HAL client to be used later. """
|
||||||
|
self.bus = dbus.SystemBus()
|
||||||
|
hal_manager_obj = self.bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")
|
||||||
|
self.hal_manager = dbus.Interface(hal_manager_obj, "org.freedesktop.Hal.Manager")
|
||||||
|
|
||||||
|
def _initLid(self):
|
||||||
|
""" Find out if there's a Lid device. """
|
||||||
|
lidDevice = self.hal_manager.FindDeviceStringMatch("button.type", "lid")
|
||||||
|
if len(lidDevice) >= 1:
|
||||||
|
self.hasLid = True
|
||||||
|
self.lidObject = self.bus.get_object("org.freedesktop.Hal" ,lidDevice[0])
|
||||||
|
|
||||||
|
def _initAc(self):
|
||||||
|
""" Search HAL for detecting if power is plugged in. """
|
||||||
|
acDevice = self.hal_manager.FindDeviceByCapability("ac_adapter")
|
||||||
|
if len(acDevice) >= 1:
|
||||||
|
self.hasAC = True
|
||||||
|
self.acObject = self.bus.get_object("org.freedesktop.Hal" ,acDevice[0])
|
||||||
|
|
||||||
|
def _checkSuspend(self):
|
||||||
|
""" Ask HAL whether we can suspend / hibernate. """
|
||||||
|
if SUSPEND_USE_HAL:
|
||||||
|
self.computerObject = self.bus.get_object("org.freedesktop.Hal",
|
||||||
|
u'/org/freedesktop/Hal/devices/computer')
|
||||||
|
properties = self.computerObject.GetAllProperties(
|
||||||
|
dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
self.canSuspend = properties["power_management.can_suspend"]
|
||||||
|
self.canHibernate = properties["power_management.can_hibernate"]
|
||||||
|
else:
|
||||||
|
self.canSuspend = self.canHibernate = True
|
||||||
|
|
||||||
|
def _initBrightness(self):
|
||||||
|
""" Search HAL for a screen with brightness controls."""
|
||||||
|
|
||||||
|
brightnessDevice = self.hal_manager.FindDeviceByCapability("laptop_panel")
|
||||||
|
|
||||||
|
if len(brightnessDevice) >= 1:
|
||||||
|
self.hasBrightness = True
|
||||||
|
self.brightnessObject = self.bus.get_object("org.freedesktop.Hal", brightnessDevice[0])
|
||||||
|
self.brightness_properties = self.brightnessObject.GetAllProperties(
|
||||||
|
dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
try:
|
||||||
|
self.brightness_levels = self.brightness_properties[u'laptop_panel.num_levels']
|
||||||
|
except KeyError,e:
|
||||||
|
self.hasBrightness = False
|
||||||
|
return 0 # Really don't know what to do here, but don't crash in any case.
|
||||||
|
try:
|
||||||
|
self.old_b = self.brightness_levels[-1] # Setting cached brightness value to brightest
|
||||||
|
except TypeError,e:
|
||||||
|
return 0 # Really don't know what to do here, but don't crash in any case.
|
||||||
|
|
||||||
|
def getBrightness(self):
|
||||||
|
""" Read brightness from HAL. """
|
||||||
|
if not self.hasBrightness:
|
||||||
|
debug("Brightness setting not supported.")
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
b = self.brightnessObject.GetBrightness(
|
||||||
|
dbus_interface="org.freedesktop.Hal.Device.LaptopPanel")
|
||||||
|
except dbus.DBusException, e:
|
||||||
|
# Sometimes, right after resume, the HAL call
|
||||||
|
# fails, in that case, we return the last value
|
||||||
|
# and hope that it goes well next time.
|
||||||
|
print "Warning: in getBrightness(): ", e
|
||||||
|
# try and return the old brightness setting, but don't die in any case:
|
||||||
|
try:
|
||||||
|
return self.old_b
|
||||||
|
except AttributeError, errmsg:
|
||||||
|
return
|
||||||
|
self.old_b = b
|
||||||
|
return b
|
||||||
|
|
||||||
|
def adjustBrightness(self, level):
|
||||||
|
""" Adjust the brightness via HAL. """
|
||||||
|
if not self.hasBrightness:
|
||||||
|
debug("Brightness setting not supported.")
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
self.brightnessObject.SetBrightness(level,
|
||||||
|
dbus_interface="org.freedesktop.Hal.Device.LaptopPanel")
|
||||||
|
except dbus.DBusException, e:
|
||||||
|
print e
|
||||||
|
|
||||||
|
def _checkCpuCapabilities(self):
|
||||||
|
""" Find out the number of CPUs / cores, check which governors are avaible."""
|
||||||
|
cpufreq_dir = "/sys/devices/system/cpu"
|
||||||
|
self.cpus = []
|
||||||
|
for cpu in os.listdir(cpufreq_dir):
|
||||||
|
if cpu.startswith('cpu') and cpu != 'cpuidle':
|
||||||
|
self.cpus.append(cpu)
|
||||||
|
self.cpus.sort()
|
||||||
|
|
||||||
|
# Map our policies to cpufreq governors.
|
||||||
|
self.cpu_policy = {}
|
||||||
|
self.cpu_policy['dynamic/ac'] = []
|
||||||
|
self.cpu_policy['dynamic/battery'] = []
|
||||||
|
self.cpu_policy['powersave'] = []
|
||||||
|
self.cpu_policy['performance'] = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
comp_obj = self.bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/devices/computer')
|
||||||
|
self.cpufreq = dbus.Interface(comp_obj, 'org.freedesktop.Hal.Device.CPUFreq')
|
||||||
|
self.governor_available = self.cpufreq.GetCPUFreqAvailableGovernors()
|
||||||
|
except dbus.DBusException:
|
||||||
|
return
|
||||||
|
self.hasCpuFreqGovernors = True
|
||||||
|
|
||||||
|
if 'ondemand' in self.governor_available:
|
||||||
|
self.cpu_policy['dynamic/ac'].append('ondemand')
|
||||||
|
self.cpu_policy['dynamic/battery'].append('ondemand')
|
||||||
|
if 'conservative' in self.governor_available:
|
||||||
|
self.cpu_policy['dynamic/ac'].append('conservative')
|
||||||
|
self.cpu_policy['dynamic/battery'].insert(0,'conservative')
|
||||||
|
if 'userspace' in self.governor_available:
|
||||||
|
self.cpu_policy['dynamic/ac'].append('userspace')
|
||||||
|
self.cpu_policy['dynamic/battery'].append('userspace')
|
||||||
|
if 'powersave' in self.governor_available:
|
||||||
|
self.cpu_policy['powersave'].append('powersave')
|
||||||
|
if 'performance' in self.governor_available:
|
||||||
|
self.cpu_policy['performance'].append('performance')
|
||||||
|
|
||||||
|
def getSupportedCpuPolicies(self):
|
||||||
|
""" Report a list of supported CPU policies """
|
||||||
|
policies = []
|
||||||
|
if len(self.cpu_policy['dynamic/ac']) > 0:
|
||||||
|
policies.append('dynamic')
|
||||||
|
if len(self.cpu_policy['powersave']) > 0:
|
||||||
|
policies.append('powersave')
|
||||||
|
if len(self.cpu_policy['performance']) > 0:
|
||||||
|
policies.append('performance')
|
||||||
|
return policies
|
||||||
|
|
||||||
|
def getCpuPolicy(self):
|
||||||
|
""" Translate current CPU frequency governor into policy """
|
||||||
|
if not self.USE_CPUFREQ or not self.hasCpuFreqGovernors:
|
||||||
|
return ""
|
||||||
|
gov = self.cpufreq.GetCPUFreqGovernor()
|
||||||
|
for policy in self.cpu_policy.keys():
|
||||||
|
if gov in self.cpu_policy[policy]:
|
||||||
|
return policy.split('/')[0] # strip ac or battery off
|
||||||
|
return gov ## return as-is - no conversion
|
||||||
|
|
||||||
|
def setCpuPolicy(self,policy):
|
||||||
|
""" Using cpufreq governors. Mode is powersave, dynamic or performance. We're assuming that
|
||||||
|
the available governors are the same for all CPUs. This method changes the cpufreq
|
||||||
|
governor on all CPUs to a certain policy."""
|
||||||
|
if not self.USE_CPUFREQ or not self.hasCpuFreqGovernors:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if policy == "dynamic":
|
||||||
|
if self.onBattery():
|
||||||
|
policy = "dynamic/battery"
|
||||||
|
else:
|
||||||
|
policy = "dynamic/ac"
|
||||||
|
|
||||||
|
for gov in self.cpu_policy[policy]:
|
||||||
|
try:
|
||||||
|
self.cpufreq.SetCPUFreqGovernor(gov)
|
||||||
|
return True
|
||||||
|
except dbus.DBusException:
|
||||||
|
pass
|
||||||
|
return False # no of governor worked
|
||||||
|
|
||||||
|
def cpuIsOnline(self,cpu):
|
||||||
|
""" Check if cpu is online. CPU0 is always online, CPU1 might be unplugged. Since
|
||||||
|
/sys/devices/system/cpu/$cpu/cpufreq is not readable for normal users, we just
|
||||||
|
check for the cpufreq subdir (which is where it's really needed anyway).
|
||||||
|
"""
|
||||||
|
if cpu == "cpu0": return True
|
||||||
|
else: return os.path.isdir("/sys/devices/system/cpu/"+cpu+"/cpufreq")
|
||||||
|
|
||||||
|
def getCpuState(self,cpu):
|
||||||
|
""" Reads the status of a CPU from /sys. """
|
||||||
|
state = {}
|
||||||
|
state['online'] = self.cpuIsOnline(cpu)
|
||||||
|
if not state['online']:
|
||||||
|
debug("getCpuState: "+cpu+" is offline")
|
||||||
|
return state
|
||||||
|
try:
|
||||||
|
state['cpu'] = cpu
|
||||||
|
state['cur'] = int(_readValue("/sys/devices/system/cpu/"+cpu+"/cpufreq/scaling_cur_freq"))/1000
|
||||||
|
state['governor'] = _readValue("/sys/devices/system/cpu/"+cpu+"/cpufreq/scaling_governor")
|
||||||
|
state['driver'] = _readValue("/sys/devices/system/cpu/"+cpu+"/cpufreq/scaling_driver")
|
||||||
|
state['steps'] = []
|
||||||
|
freqs = _readValue("/sys/devices/system/cpu/"+cpu+"/cpufreq/scaling_available_frequencies")
|
||||||
|
except IOError:
|
||||||
|
# CPUFREQ has gone away, let's disable it.
|
||||||
|
state['online'] = False
|
||||||
|
return state
|
||||||
|
for v in freqs.split():
|
||||||
|
state['steps'].append(int(v)/1000)
|
||||||
|
state['max'] = max(state['steps'])
|
||||||
|
state['min'] = min(state['steps'])
|
||||||
|
debug(state)
|
||||||
|
return state
|
||||||
|
|
||||||
|
def getLidClosedState(self):
|
||||||
|
""" Returns True if the lid is currently closed, or False if it isn't. """
|
||||||
|
try:
|
||||||
|
properties = self.lidObject.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
|
||||||
|
return properties["button.state.value"]
|
||||||
|
except (KeyError, dbus.DBusException):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def setPowerSave(self, state):
|
||||||
|
# No SetPowerSave in Ubuntu's HAL
|
||||||
|
try:
|
||||||
|
self.computerObject.SetPowerSave(state,
|
||||||
|
dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement")
|
||||||
|
except dbus.DBusException, e:
|
||||||
|
print "Warning: While setting SystemPowerManagement to ", state, ": ",
|
||||||
|
print e
|
||||||
|
|
||||||
|
def blankScreen(self):
|
||||||
|
""" Call dpms to switch off the screen immediately. """
|
||||||
|
os.system('xset dpms force standby')
|
||||||
|
|
||||||
|
def setScreensaverBlankOnly(self,blankonly):
|
||||||
|
""" Switches a screensaver to blankonly, so cpu hungry screensavers will not drain the poor
|
||||||
|
battery."""
|
||||||
|
# create a new DCOP-Client:
|
||||||
|
client = DCOPClient()
|
||||||
|
# connect the client to the local DCOP-server:
|
||||||
|
client.attach()
|
||||||
|
# create a DCOP-Application-Object to talk to amarok:
|
||||||
|
kdesktop = DCOPApp('kdesktop', client)
|
||||||
|
# call a DCOP-function:
|
||||||
|
ok, foo = kdesktop.KScreensaverIface.setBlankOnly(blankonly)
|
||||||
|
if not ok:
|
||||||
|
debug("Failed to set kdesktop screensaver to blankonly.")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def getIdleSeconds(self):
|
||||||
|
""" Get idle seconds from X server. """
|
||||||
|
return self.xscreen.getIdleSeconds()
|
||||||
|
|
||||||
|
def resetIdleSeconds(self):
|
||||||
|
""" Reset idle seconds. """
|
||||||
|
return self.xscreen.resetIdleSeconds()
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
""" Try all kinds of stuff and see what breaks."""
|
||||||
|
print "Trying to adjust brightness ..."
|
||||||
|
bright = self.getBrightness()
|
||||||
|
self.adjustBrightness(2)
|
||||||
|
time.sleep(1)
|
||||||
|
self.adjustBrightness(bright)
|
||||||
|
print " ... OK."
|
||||||
|
|
||||||
|
if self.USE_CPUFREQ:
|
||||||
|
print "Reading speeds from cpufreq..."
|
||||||
|
for cpu in self.cpus:
|
||||||
|
print self.getCpuState(cpu)
|
||||||
|
print "Report supported cpufreq policies..."
|
||||||
|
for policy in self.cpu_policy.keys():
|
||||||
|
print "Policy:", policy, "=", self.cpu_policy[policy]
|
||||||
|
|
||||||
|
print "Trying all cpufreq policies ..."
|
||||||
|
orig_pol = self.getCpuPolicy()
|
||||||
|
for pol in self.cpu_policy.keys():
|
||||||
|
print ". ", pol
|
||||||
|
self.setCpuPolicy(pol)
|
||||||
|
self.setCpuPolicy(orig_pol)
|
||||||
|
print "... OK."
|
||||||
|
else:
|
||||||
|
print "Skipping CPUFREQ: USE_CPUFREQ = False"
|
||||||
|
|
||||||
|
if self.SCREENSAVER_BLANKONLY:
|
||||||
|
if self.setScreensaverBlankOnly(True):
|
||||||
|
debug("Manipulating screensaver seems to work well.")
|
||||||
|
else:
|
||||||
|
debug("Manipulating screensaver seems broken.")
|
||||||
|
|
||||||
|
if isroot:
|
||||||
|
print "Trying to use Disk powermanagement and laptop_mode"
|
||||||
|
self.setDiskPM(True)
|
||||||
|
time.sleep(1)
|
||||||
|
self.setDiskPM(False)
|
||||||
|
print "...OK"
|
||||||
|
else:
|
||||||
|
print "Skipping DiskPM, not root."
|
||||||
|
|
||||||
|
if self.hasLid:
|
||||||
|
if self.getLidClosedState():
|
||||||
|
print "Lid is closed."
|
||||||
|
else:
|
||||||
|
print "Lid is currently open."
|
||||||
|
|
||||||
|
def setDiskPM(self,on=True):
|
||||||
|
""" Switches on laptop_mode and sets disks to advanced powermanagement."""
|
||||||
|
if self.USE_LAPTOP_MODE:
|
||||||
|
# Check if laptop_mode exists:
|
||||||
|
laptop_mode = "/proc/sys/vm/laptop_mode"
|
||||||
|
if not os.path.isfile(laptop_mode):
|
||||||
|
self.USE_LAPTOP_MODE = False
|
||||||
|
debug("Laptop mode not supported, no "+laptop_mode)
|
||||||
|
else:
|
||||||
|
fhandle = open(laptop_mode,"w")
|
||||||
|
if on: val = 1
|
||||||
|
else: val = 0
|
||||||
|
fhandle.write(str(val))
|
||||||
|
fhandle.close()
|
||||||
|
|
||||||
|
if self.USE_HDPARM:
|
||||||
|
# Set disks to advanced PM
|
||||||
|
for disk in self.disks:
|
||||||
|
if on:
|
||||||
|
# Switch on advanced powermanagement
|
||||||
|
cmd = "hdparm -B1 /dev/"+disk+" > /dev/null"
|
||||||
|
else:
|
||||||
|
# Switch off advanced powermanagement
|
||||||
|
cmd = "hdparm -B255 /dev/"+disk+" > /dev/null"
|
||||||
|
if os.system(cmd) != 0:
|
||||||
|
self.USE_HDPARM = False
|
||||||
|
print "Switching advanced powermanagement failed, not using hdparm anymore"
|
||||||
|
|
||||||
|
def suspend(self):
|
||||||
|
""" Run a suspend command, either via HAL or script. """
|
||||||
|
if SUSPEND_USE_HAL:
|
||||||
|
try:
|
||||||
|
self.computerObject.Suspend(0, dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement")
|
||||||
|
except dbus.DBusException:
|
||||||
|
pass #we get a DBusException: No reply within specified time
|
||||||
|
else:
|
||||||
|
self._sleepMode(S3_COMMAND)
|
||||||
|
|
||||||
|
def hibernate(self):
|
||||||
|
""" Implements suspend to disk (S4). """
|
||||||
|
if SUSPEND_USE_HAL:
|
||||||
|
try:
|
||||||
|
self.computerObject.Hibernate(dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement")
|
||||||
|
except dbus.DBusException:
|
||||||
|
pass #we get a DBusException: No reply within specified time
|
||||||
|
else:
|
||||||
|
self._sleepMode(S4_COMMAND)
|
||||||
|
|
||||||
|
def _sleepMode(self, command):
|
||||||
|
""" Send the system into S3 or S4 not using HAL. """
|
||||||
|
debug("Initiating a sleep cycle")
|
||||||
|
if os.system(command) != 0:
|
||||||
|
print "sleepmode failed. ("+command+")"
|
||||||
|
return False
|
||||||
|
debug("Everything is dandy")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def shutdown(self):
|
||||||
|
""" Shutdown the system via HAL. """
|
||||||
|
self.computerObject.Shutdown(dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
""" Run some tests, used for debugging."""
|
||||||
|
pman = PowerManage()
|
||||||
|
pman.showInfo()
|
||||||
|
pman.test()
|
||||||
|
|
@ -0,0 +1,924 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>Powermanager</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Powermanager</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>568</width>
|
||||||
|
<height>600</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Powermanager</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QTabWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>tabWidget</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Widget8</cstring>
|
||||||
|
</property>
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Power Schemes</string>
|
||||||
|
</attribute>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerformanceGroup</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Performance</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Brightness</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>551</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSlider">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerrformanceBrightnessSlider</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="maxValue">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickmarks">
|
||||||
|
<enum>Both</enum>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>Control the brightness setting in the active scheme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Line">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>line1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>HLine</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout6</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When system is inactive for</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerformanceMinutesSpin</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>minutes ...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer4</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>311</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerformanceNothing</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerformanceFade</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fade display</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerformanceSleepmode</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Initiate sleepmode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Standby (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PerformanceSleepmodeCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticGroup</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Automatic</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4_3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel1_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Brightness</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer3_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>551</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSlider">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticBrightnessSlider</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="maxValue">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickmarks">
|
||||||
|
<enum>Both</enum>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>Control the brightness setting in the active scheme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Line">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>line1_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>HLine</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout6_3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel2_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When system is inactive for</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticMinutesSpin</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel3_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>minutes ...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer4_3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>311</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout3_3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticNothing</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticFade</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fade display</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticSleepmode</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Initiate sleepmode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Standby (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>AutomaticSleepmodeCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveGroup</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Powersave</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4_2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel1_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Brightness</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer3_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>551</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSlider">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveBrightnessSlider</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="maxValue">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickmarks">
|
||||||
|
<enum>Both</enum>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>Control the brightness setting in the active scheme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Line">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>line1_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>HLine</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout6_2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel2_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When system is inactive for</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveMinutesSpin</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel3_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>minutes ...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer4_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>311</width>
|
||||||
|
<height>21</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout3_2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveNothing</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveFade</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fade display</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveSleepmode</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Initiate sleepmode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Standby (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>PowersaveSleepmodeCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Widget9</cstring>
|
||||||
|
</property>
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Events</string>
|
||||||
|
</attribute>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer row="1" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer9</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>520</width>
|
||||||
|
<height>260</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<spacer row="0" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer10</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>110</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLayoutWidget" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout17</cstring>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QComboBox" row="1" column="1">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Performance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Automatic</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Powersave</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Suspend (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>ACPluggedinCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout16</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel7</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When battery power is below</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryLowPercentage</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel8</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>%</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel4</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When AC adapter is removed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" row="2" column="1">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Performance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Automatic</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Powersave</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Suspend (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>BatteryLowCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel6</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When AC adapter is plugged in</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" row="3" column="1">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Performance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Automatic</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Powersave</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Suspend (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>LidCloseCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>textLabel5</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>When the lid is closed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" row="0" column="1">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do nothing</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Performance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Automatic</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to Powersave</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Suspend (S3)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hibernate (S4)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>ACRemovedCombo</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>buttonHelp</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Help</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>F1</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>buttonOk</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>buttonCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonOk</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>Powermanager</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>Powermanager</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
pyuic -tr i18n tooltip.ui -o tooltip.py
|
||||||
|
pyuic -tr i18n guidance_power_manager_ui.ui -o guidance_power_manager_ui.py
|
||||||
|
pyuic -tr i18n notify.ui -o notify.py
|
||||||
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'tooltip.ui'
|
||||||
|
#
|
||||||
|
# Created: Thu Apr 10 00:50:39 2008
|
||||||
|
# by: The PyQt User Interface Compiler (pyuic) 3.17.4
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from qt import *
|
||||||
|
from kdecore import KCmdLineArgs, KApplication
|
||||||
|
from kdecore import i18n
|
||||||
|
from kdeui import *
|
||||||
|
|
||||||
|
from kdeui import *
|
||||||
|
|
||||||
|
class ToolTip(QWidget):
|
||||||
|
def __init__(self,parent = None,name = None,fl = 0):
|
||||||
|
QWidget.__init__(self,parent,name,fl)
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
self.setName("ToolTip")
|
||||||
|
|
||||||
|
self.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding,0,0,self.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.setMinimumSize(QSize(240,0))
|
||||||
|
self.setBaseSize(QSize(200,0))
|
||||||
|
|
||||||
|
ToolTipLayout = QVBoxLayout(self,0,6,"ToolTipLayout")
|
||||||
|
|
||||||
|
self.languageChange()
|
||||||
|
|
||||||
|
self.resize(QSize(300,80).expandedTo(self.minimumSizeHint()))
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
|
||||||
|
def languageChange(self):
|
||||||
|
self.setCaption(i18n("Form1"))
|
||||||
|
|
||||||
|
|
||||||
|
def ToolTip_destroyed(self,a0):
|
||||||
|
print "ToolTip.ToolTip_destroyed(QObject*): Not implemented yet"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
appname = ""
|
||||||
|
description = ""
|
||||||
|
version = ""
|
||||||
|
|
||||||
|
KCmdLineArgs.init (sys.argv, appname, description, version)
|
||||||
|
a = KApplication ()
|
||||||
|
|
||||||
|
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
|
||||||
|
w = ToolTip()
|
||||||
|
a.setMainWidget(w)
|
||||||
|
w.show()
|
||||||
|
a.exec_loop()
|
@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>ToolTip</class>
|
||||||
|
<comment>Python:from kdeui import *</comment>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>ToolTip</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>300</width>
|
||||||
|
<height>80</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>3</hsizetype>
|
||||||
|
<vsizetype>3</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>240</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Form1</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<slots>
|
||||||
|
<slot>ToolTip_destroyed( QObject * )</slot>
|
||||||
|
</slots>
|
||||||
|
<pixmapfunction>QPixmap</pixmapfunction>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,50 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=System Services
|
||||||
|
Name[el]=Υπηρεσίες συστήματος
|
||||||
|
Name[es]=Servicios del sistema
|
||||||
|
Name[et]=Süsteemsed teenused
|
||||||
|
Name[it]=Servizi di sistema
|
||||||
|
Name[ja]=システムサービス
|
||||||
|
Name[nl]=Systeemdiensten
|
||||||
|
Name[pt]=Serviços do Sistema
|
||||||
|
Name[pt_BR]=Serviços do Sistema
|
||||||
|
Name[sr]=Системски сервиси
|
||||||
|
Name[sr@Latn]=Sistemski servisi
|
||||||
|
Name[sv]=Systemtjänster
|
||||||
|
Name[xx]=xxSystem Servicesxx
|
||||||
|
name[en_GB]=System Services
|
||||||
|
Comment=System Service Configuration
|
||||||
|
Comment[el]=Ρυθμίσεις υπηρεσιών συστήματος
|
||||||
|
Comment[es]=Configuración del servicio del sistema
|
||||||
|
Comment[et]=Süsteemi teenuste seadistamine
|
||||||
|
Comment[it]=Configurazione dei servizi di sistema
|
||||||
|
Comment[ja]=システムサービスの設定
|
||||||
|
Comment[nl]=Systeemdiensten instellen
|
||||||
|
Comment[pt]=Configuração dos Serviços do Sistema
|
||||||
|
Comment[pt_BR]=Configuração dos Serviços do Sistema
|
||||||
|
Comment[sr]=Подешавање системских сервиса
|
||||||
|
Comment[sr@Latn]=Podešavanje sistemskih servisa
|
||||||
|
Comment[sv]=Inställning av systemtjänster
|
||||||
|
Comment[xx]=xxSystem Service Configurationxx
|
||||||
|
Icon=daemons.png
|
||||||
|
Encoding=UTF-8
|
||||||
|
X-KDE-ModuleType=Library
|
||||||
|
X-KDE-Library=serviceconfig
|
||||||
|
X-KDE-FactoryName=serviceconfig
|
||||||
|
X-KDE-RootOnly=true
|
||||||
|
Type=Application
|
||||||
|
Exec=kcmshell System/serviceconfig
|
||||||
|
Categories=Qt;KDE;X-KDE-settings-system;
|
||||||
|
GenericName=Runlevel Editor
|
||||||
|
GenericName[el]=Επεξεργαστής επιπέδων εκτέλεσης
|
||||||
|
GenericName[es]=Editor del nivel de ejecución
|
||||||
|
GenericName[et]=Käitustasemete redaktor
|
||||||
|
GenericName[it]=Editor dei runlevel
|
||||||
|
GenericName[ja]=ランレベルエディタ
|
||||||
|
GenericName[nl]=Runlevel-bewerker
|
||||||
|
GenericName[pt]=Editor de Níveis de Execução
|
||||||
|
GenericName[pt_BR]=Editor de Níveis de Execução
|
||||||
|
GenericName[sr]=Уређивач радних нивоа
|
||||||
|
GenericName[sr@Latn]=Uređivač radnih nivoa
|
||||||
|
GenericName[sv]=Editor för körnivå
|
||||||
|
GenericName[xx]=xxRunlevel Editorxx
|
@ -0,0 +1,208 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
###########################################################################
|
||||||
|
# setup - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Fri Jun 27 2003 #
|
||||||
|
# copyright : (C) 2003-2006 by Simon Edwards #
|
||||||
|
# email : simon@simonzone.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
from distutils.core import Extension
|
||||||
|
import kdedistutils
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
def doit():
|
||||||
|
kdedistutils.setup(name="guidance",
|
||||||
|
version="0.8.0",
|
||||||
|
author="Simon Edwards",
|
||||||
|
author_email="simon@simonzone.com",
|
||||||
|
url="http://www.simonzone.com/software/guidance/",
|
||||||
|
min_kde_version = "3.0.0",
|
||||||
|
min_qt_version = "3.0.0",
|
||||||
|
license = "GPL",
|
||||||
|
executable_links = [('serviceconfig','serviceconfig.py'),
|
||||||
|
('userconfig','userconfig.py'),
|
||||||
|
('mountconfig','mountconfig.py'),
|
||||||
|
('displayconfig','displayconfig.py'),
|
||||||
|
('displayconfig-restore','displayconfig-restore.py'),
|
||||||
|
('wineconfig','wineconfig.py'),
|
||||||
|
('grubconfig','grubconfig.py')],
|
||||||
|
|
||||||
|
data_files = [# Icons for in KControl
|
||||||
|
('share/icons/crystalsvg/16x16/apps',['kde/serviceconfig/pics/16x16/daemons.png',
|
||||||
|
'kde/mountconfig/pics/16x16/disksfilesystems.png',
|
||||||
|
'kde/userconfig/pics/16x16/userconfig.png',
|
||||||
|
'kde/displayconfig/pics/16x16/displayconfig.png',
|
||||||
|
'kde/wineconfig/pics/16x16/wineconfig.svg']),
|
||||||
|
('/etc/X11/Xsession.d',['displayconfig/40guidance-displayconfig_restore'])],
|
||||||
|
|
||||||
|
i18n = ('po',['mountconfig','userconfig','serviceconfig','displayconfig','wineconfig','powermanager']),
|
||||||
|
|
||||||
|
application_data = [('pics',
|
||||||
|
['kde/serviceconfig/pics/laserwarn.png',
|
||||||
|
'kde/serviceconfig/pics/hi32-app-daemons.png',
|
||||||
|
'kde/userconfig/pics/hi16-encrypted.png',
|
||||||
|
'kde/userconfig/pics/hi32-user.png',
|
||||||
|
'kde/userconfig/pics/hi32-group.png',
|
||||||
|
'kde/userconfig/pics/hi32-identity.png',
|
||||||
|
'kde/userconfig/pics/hi32-password.png',
|
||||||
|
'kde/mountconfig/pics/kcmpartitions.png',
|
||||||
|
'kde/mountconfig/pics/kde1.png',
|
||||||
|
'kde/mountconfig/pics/kde2.png',
|
||||||
|
'kde/mountconfig/pics/kde3.png',
|
||||||
|
'kde/mountconfig/pics/kde4.png',
|
||||||
|
'kde/mountconfig/pics/kde5.png',
|
||||||
|
'kde/mountconfig/pics/kde6.png',
|
||||||
|
'kde/mountconfig/pics/hi32-samba.png',
|
||||||
|
'kde/mountconfig/pics/hi16-hdd.png',
|
||||||
|
'kde/mountconfig/pics/hi16-cdrom.png',
|
||||||
|
'kde/mountconfig/pics/hi16-burner.png',
|
||||||
|
'kde/mountconfig/pics/hi16-floppy.png',
|
||||||
|
'kde/mountconfig/pics/hi16-blockdevice.png',
|
||||||
|
'kde/mountconfig/pics/hi16-password.png',
|
||||||
|
'kde/mountconfig/pics/hi16-memory.png',
|
||||||
|
'kde/mountconfig/pics/hi16-network.png',
|
||||||
|
'kde/mountconfig/pics/hi16-lock.png',
|
||||||
|
'kde/mountconfig/pics/hi16-usbpen.png',
|
||||||
|
'kde/mountconfig/pics/greenled.png',
|
||||||
|
'kde/mountconfig/pics/greyled.png',
|
||||||
|
'kde/mountconfig/pics/exec.png',
|
||||||
|
'kde/mountconfig/pics/file.png',
|
||||||
|
'kde/mountconfig/pics/important.png',
|
||||||
|
'kde/mountconfig/pics/tux.png',
|
||||||
|
'kde/mountconfig/pics/user.png',
|
||||||
|
'kde/displayconfig/pics/energystar.png',
|
||||||
|
'kde/displayconfig/pics/hi32-gfxcard.png',
|
||||||
|
'kde/displayconfig/pics/hi32-display.png',
|
||||||
|
'kde/wineconfig/pics/32-wine.png',
|
||||||
|
'kde/wineconfig/pics/kdewinewizard.png',
|
||||||
|
'kde/powermanager/pics/ac-adapter.png',
|
||||||
|
'kde/powermanager/pics/ac-adapter.svg',
|
||||||
|
'kde/powermanager/pics/battery-charging-000.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-010.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-020.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-030.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-040.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-050.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-060.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-070.png',
|
||||||
|
'kde/powermanager/pics/battery-charging-090.png',
|
||||||
|
'kde/powermanager/pics/battery_charging_0.svg',
|
||||||
|
'kde/powermanager/pics/battery-charging-100.png',
|
||||||
|
'kde/powermanager/pics/battery_charging_1.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_2.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_3.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_4.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_5.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_6.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_7.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_8.svg',
|
||||||
|
'kde/powermanager/pics/battery_charging_9.svg',
|
||||||
|
'kde/powermanager/pics/battery-discharging-000.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-010.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-020.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-020.svg',
|
||||||
|
'kde/powermanager/pics/battery-discharging-030.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-040.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-050.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-060.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-070.png',
|
||||||
|
'kde/powermanager/pics/battery-discharging-090.png',
|
||||||
|
'kde/powermanager/pics/battery_discharging_0.svg',
|
||||||
|
'kde/powermanager/pics/battery-discharging-100.png',
|
||||||
|
'kde/powermanager/pics/battery_discharging_1.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_2.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_3.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_4.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_5.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_6.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_7.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_8.svg',
|
||||||
|
'kde/powermanager/pics/battery_discharging_9.svg',
|
||||||
|
'kde/powermanager/pics/processor.png',
|
||||||
|
'kde/powermanager/pics/processor.svg']),
|
||||||
|
('pics/displayconfig/dualhead',
|
||||||
|
['kde/displayconfig/pics/dualhead/monitor_1.png',
|
||||||
|
'kde/displayconfig/pics/dualhead/monitor_2.png']),
|
||||||
|
('pics/displayconfig/monitor_resizable',
|
||||||
|
['kde/displayconfig/pics/monitor_resizable/background.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/background_r90.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/background_wide.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/background_wide_r90.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/monitor.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/monitor_r90.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/monitor_wide.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/monitor_wide_r90.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/window_4th.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/window_bottom_left_4th.png',
|
||||||
|
'kde/displayconfig/pics/monitor_resizable/window_bottom_right_4th.png']),
|
||||||
|
('pics/displayconfig/gammapics',
|
||||||
|
['kde/displayconfig/pics/gammapics/MGam14.png',
|
||||||
|
'kde/displayconfig/pics/gammapics/MGam16.png',
|
||||||
|
'kde/displayconfig/pics/gammapics/MGam18.png',
|
||||||
|
'kde/displayconfig/pics/gammapics/MGam20.png',
|
||||||
|
'kde/displayconfig/pics/gammapics/MGam22.png',
|
||||||
|
'kde/displayconfig/pics/gammapics/MGam24.png']),
|
||||||
|
'serviceconfig/serviceconfig.py',
|
||||||
|
'userconfig/userconfig.py',
|
||||||
|
'userconfig/unixauthdb.py',
|
||||||
|
'mountconfig/mountconfig.py',
|
||||||
|
'mountconfig/MicroHAL.py',
|
||||||
|
'mountconfig/SMBShareSelectDialog.py',
|
||||||
|
'mountconfig/SimpleCommandRunner.py',
|
||||||
|
'mountconfig/fuser.py',
|
||||||
|
'mountconfig/fuser_ui.ui',
|
||||||
|
'mountconfig/sizeview.py',
|
||||||
|
'displayconfig/displayconfig.py',
|
||||||
|
'displayconfig/displayconfigabstraction.py',
|
||||||
|
'displayconfig/displayconfigwidgets.py',
|
||||||
|
'displayconfig/displayconfig-restore.py',
|
||||||
|
'displayconfig/execwithcapture.py',
|
||||||
|
'displayconfig/infimport.py',
|
||||||
|
'displayconfig/ScanPCI.py',
|
||||||
|
'displayconfig/ktimerdialog.py',
|
||||||
|
'displayconfig/servertestdialog.py',
|
||||||
|
'displayconfig/xorgconfig.py',
|
||||||
|
'displayconfig/vesamodes',
|
||||||
|
'displayconfig/extramodes',
|
||||||
|
'displayconfig/widescreenmodes',
|
||||||
|
'displayconfig/ldetect-lst/Cards+',
|
||||||
|
'displayconfig/ldetect-lst/MonitorsDB',
|
||||||
|
'displayconfig/ldetect-lst/pcitable',
|
||||||
|
'wineconfig/wineconfig.py',
|
||||||
|
'wineconfig/wineread.py',
|
||||||
|
'wineconfig/winewrite.py',
|
||||||
|
'wineconfig/drivedetect.py',
|
||||||
|
'powermanager/guidance-power-manager.py',
|
||||||
|
'powermanager/powermanage.py',
|
||||||
|
'powermanager/gpmhelper.py',
|
||||||
|
'powermanager/guidance_power_manager_ui.ui',
|
||||||
|
'powermanager/powermanager_ui.ui',
|
||||||
|
'grubconfig/grubconfig.py'],
|
||||||
|
|
||||||
|
kcontrol_modules = [ \
|
||||||
|
('serviceconfig/serviceconfig.desktop','serviceconfig.py'),
|
||||||
|
('userconfig/userconfig.desktop','userconfig.py'),
|
||||||
|
('mountconfig/mountconfig.desktop','mountconfig.py'),
|
||||||
|
('displayconfig/displayconfig.desktop','displayconfig.py'),
|
||||||
|
('wineconfig/wineconfig.desktop','wineconfig.py')],
|
||||||
|
|
||||||
|
docbooks = [ ('doc/en','en') ],
|
||||||
|
|
||||||
|
package_dir={'':'modules'},
|
||||||
|
py_modules=['xf86misc'],
|
||||||
|
ext_modules=[\
|
||||||
|
Extension('ixf86misc',\
|
||||||
|
sources=['modules/ixf86misc.c'],\
|
||||||
|
library_dirs=['/usr/X11R6/lib'],\
|
||||||
|
libraries=['X11','Xxf86vm','Xext','Xrandr','Xrender','Xss'])]
|
||||||
|
)
|
||||||
|
doit()
|
@ -0,0 +1,5 @@
|
|||||||
|
import os
|
||||||
|
fhandle = open("install_log.txt","r")
|
||||||
|
for line in fhandle.readlines():
|
||||||
|
print "deleting ", line[:-1]
|
||||||
|
os.system("rm -f "+line[:-1])
|
@ -0,0 +1,49 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=User Management
|
||||||
|
Name[el]=Διαχείριση χρηστών
|
||||||
|
Name[es]=Administrador de usuarios
|
||||||
|
Name[et]=Kasutajate haldamine
|
||||||
|
Name[it]=Gestione degli utenti
|
||||||
|
Name[ja]=ユーザの管理
|
||||||
|
Name[nl]=Gebruikersbeheer
|
||||||
|
Name[pt]=Gestão de Utilizadores
|
||||||
|
Name[pt_BR]=Gerenciamento de Usuários
|
||||||
|
Name[sr]=Управљање корисницима
|
||||||
|
Name[sr@Latn]=Upravljanje korisnicima
|
||||||
|
Name[sv]=Användarhantering
|
||||||
|
Name[xx]=xxUser Managementxx
|
||||||
|
Comment=Users & Groups Administration
|
||||||
|
Comment[el]=Διαχείριση χρηστών & ομάδων
|
||||||
|
Comment[es]=Administrador de usuarios y grupos
|
||||||
|
Comment[et]=Kasutajate ja gruppide haldamine
|
||||||
|
Comment[it]=Amministrazione di utenti e gruppi
|
||||||
|
Comment[ja]=ユーザとグループの管理
|
||||||
|
Comment[nl]=Gebruikers en groepen beheren
|
||||||
|
Comment[pt]=Administração dos Utilizadores & Grupos
|
||||||
|
Comment[pt_BR]=Administração de Usuários & Grupos
|
||||||
|
Comment[sr]=Администрирање корисника и група
|
||||||
|
Comment[sr@Latn]=Administriranje korisnika i grupa
|
||||||
|
Comment[sv]=Administration av användare och grupper
|
||||||
|
Comment[xx]=xxUsers & Groups Administrationxx
|
||||||
|
Icon=userconfig.png
|
||||||
|
Encoding=UTF-8
|
||||||
|
X-KDE-ModuleType=Library
|
||||||
|
X-KDE-Library=userconfig
|
||||||
|
X-KDE-FactoryName=userconfig
|
||||||
|
X-KDE-RootOnly=true
|
||||||
|
Type=Application
|
||||||
|
Exec=kcmshell System/userconfig
|
||||||
|
Categories=Qt;KDE;X-KDE-settings-system;
|
||||||
|
GenericName=User Account Editor
|
||||||
|
GenericName[el]=Επεξεργαστής λογαριασμών χρηστών
|
||||||
|
GenericName[es]=Editor de cuenta de usuario
|
||||||
|
GenericName[et]=Kasutajakonto redaktor
|
||||||
|
GenericName[it]=Editor degli account degli utenti
|
||||||
|
GenericName[ja]=ユーザアカウントエディタ
|
||||||
|
GenericName[nl]=Gebruikeraccounts bewerken
|
||||||
|
GenericName[pt]=Editor de Contas dos Utilizadores
|
||||||
|
GenericName[pt_BR]=Editor de Contas de Usuários
|
||||||
|
GenericName[sr]=Уређивач корисничких налога
|
||||||
|
GenericName[sr@Latn]=Uređivač korisničkih naloga
|
||||||
|
GenericName[sv]=Editor för användarkonton
|
||||||
|
GenericName[xx]=xxUser Account Editorxx
|
@ -0,0 +1,122 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
###########################################################################
|
||||||
|
# wineread.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Fri Mar 26 2004 #
|
||||||
|
# copyright : (C) 2006 by Yuriy Kozlov #
|
||||||
|
# email : yuriy.kozlov@gmail.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import wineread
|
||||||
|
|
||||||
|
""" Reads a default set of drives from /etc/fstab """
|
||||||
|
|
||||||
|
fstabpath = "/etc/fstab"
|
||||||
|
|
||||||
|
# Listed in winecfg
|
||||||
|
ignored_fs_types = set(["devpts",
|
||||||
|
"tmpfs",
|
||||||
|
"proc",
|
||||||
|
"sysfs",
|
||||||
|
"swap",
|
||||||
|
"usbdevfs",
|
||||||
|
"rpc_pipefs",
|
||||||
|
"binfmt_misc"])
|
||||||
|
|
||||||
|
# Listed in winecfg
|
||||||
|
ignored_mnt_pts = set(["/boot"])
|
||||||
|
|
||||||
|
cd_fs_types = set(["cdfs","udf","iso9660"])
|
||||||
|
|
||||||
|
# An incomplete listing, I don't know how winecfg does this.
|
||||||
|
# RAMFS is included here because I don't know what the correct type for it is in wine.
|
||||||
|
hd_fs_types = set(["ext4","ext3","ext2","ext","fat","fat32","fat16","ntfs","reiserfs","reiser4",
|
||||||
|
"jfs","xfs","ramfs","vfat","ufs","hfs","hfsplus"])
|
||||||
|
|
||||||
|
# Listed in winecfg
|
||||||
|
net_fs_types = set(["nfs","nfs4","smbfs","cifs","coda"])
|
||||||
|
|
||||||
|
def autodetect(drives=None):
|
||||||
|
""" Returns a set of drives found by scanning /etc/fstab, and an error code """
|
||||||
|
if not drives:
|
||||||
|
drives = wineread.GetEmptyDrives()
|
||||||
|
mappings = set()
|
||||||
|
if not drives[2][2]:
|
||||||
|
drives[2][2] = "../drive_c"
|
||||||
|
drives[2][3] = "hd"
|
||||||
|
|
||||||
|
for drive in drives:
|
||||||
|
mapping = drive[2]
|
||||||
|
if mapping:
|
||||||
|
mappings.add(mapping)
|
||||||
|
|
||||||
|
driveid = 3
|
||||||
|
fstab=open(fstabpath,'r')
|
||||||
|
|
||||||
|
for driveline in fstab:
|
||||||
|
if driveline[0] == '#' or len(driveline.strip()) == 0: # Comment or empty line
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
driveprops = driveline.split()
|
||||||
|
fs = driveprops[0]
|
||||||
|
mnt = driveprops[1]
|
||||||
|
fstypes = set(driveprops[2].split(','))
|
||||||
|
|
||||||
|
ignore = False
|
||||||
|
for fstype in fstypes:
|
||||||
|
if fstype in ignored_fs_types:
|
||||||
|
ignore = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if mnt in ignored_mnt_pts or mnt in mappings:
|
||||||
|
ignore = True
|
||||||
|
|
||||||
|
if not ignore:
|
||||||
|
while drives[driveid][2]: # Drive is in use, don't overwrite.
|
||||||
|
driveid += 1
|
||||||
|
if driveid > 25:
|
||||||
|
return (1,drives)
|
||||||
|
drives[driveid][2] = mnt
|
||||||
|
if "/dev/fd" in fs or "floppy" in mnt:
|
||||||
|
drives[driveid][3] = "floppy"
|
||||||
|
elif fstype in cd_fs_types or "/dev/cdrom" in fs or "cdrom" in mnt:
|
||||||
|
drives[driveid][3] = "cdrom"
|
||||||
|
elif fstype in hd_fs_types:
|
||||||
|
drives[driveid][3] = "hd"
|
||||||
|
elif fstype in net_fs_types:
|
||||||
|
drives[driveid][3] = "network"
|
||||||
|
else:
|
||||||
|
drives[driveid][3] = "auto"
|
||||||
|
driveid += 1
|
||||||
|
|
||||||
|
fstab.close()
|
||||||
|
return (0,drives)
|
||||||
|
|
||||||
|
def autodetectshelllinks(shelllinks = None):
|
||||||
|
""" Returns a default set of windows shell folder mappings """
|
||||||
|
if not shelllinks:
|
||||||
|
shelllinks = wineread.GetEmptyShellLinks()
|
||||||
|
|
||||||
|
for link in shelllinks:
|
||||||
|
if link[2]:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
link[3] = "shellfolder"
|
||||||
|
#link[4] = wineread.winepath + "/dosdevices/c:/windows/profiles/" + os.environ['USER'] + "/" + link[1]
|
||||||
|
link[4] = wineread.defaultwinfolderspath + "\\" + link[1]
|
||||||
|
link[5] = wineread.defaultwinfolderspath + "\\" + link[1]
|
||||||
|
link[2] = os.environ['HOME']
|
||||||
|
if link[1] == "Desktop":
|
||||||
|
link[2] = os.environ['HOME'] + "/Desktop"
|
||||||
|
|
||||||
|
return shelllinks
|
@ -0,0 +1,326 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
###########################################################################
|
||||||
|
# wineconfig.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Fri Mar 26 2004 #
|
||||||
|
# copyright : (C) 2006 by Yuriy Kozlov #
|
||||||
|
# email : yuriy.kozlov@gmail.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
from qt import *
|
||||||
|
from kdecore import *
|
||||||
|
from kdeui import *
|
||||||
|
from kfile import *
|
||||||
|
from kio import *
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import signal
|
||||||
|
import wineread
|
||||||
|
import winewrite
|
||||||
|
import drivedetect
|
||||||
|
|
||||||
|
class FirstRunWizard(KWizard):
|
||||||
|
default_winepath = os.environ['HOME'] + "/.wine"
|
||||||
|
|
||||||
|
def __init__(self, parent = None, name=None, modal=0, fl=0):
|
||||||
|
KWizard.__init__(self,parent,name,modal,fl)
|
||||||
|
|
||||||
|
if not name:
|
||||||
|
self.setName("firstrunwizard")
|
||||||
|
|
||||||
|
self.imagedir = unicode(KGlobal.dirs().findDirs("data","guidance/pics")[0])
|
||||||
|
|
||||||
|
self.setupPage1()
|
||||||
|
self.setupPageVersion()
|
||||||
|
self.setupPageExistingWine()
|
||||||
|
self.setupPageCreateWine()
|
||||||
|
self.slotCreateExistingToggled(0)
|
||||||
|
#self.connect(self,SIGNAL("selected(const QString &)"),self.slotPageChanged)
|
||||||
|
|
||||||
|
#self.resize(QSize(600,480).expandedTo(self.minimumSizeHint()))
|
||||||
|
self.clearWState(Qt.WState_Polished)
|
||||||
|
|
||||||
|
def setupPage1(self):
|
||||||
|
page1 = QHBox(self,"page1")
|
||||||
|
|
||||||
|
self.kdewinepicture = QLabel(page1,"kdewinepicture")
|
||||||
|
self.kdewinepicture.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.kdewinepicture.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.kdewinepicture.setMinimumSize(QSize(140,320))
|
||||||
|
self.kdewinepicture.setPixmap(QPixmap(self.imagedir+"kdewinewizard.png"))
|
||||||
|
#self.kdewinepicture.setScaledContents(1)
|
||||||
|
|
||||||
|
spacer = QWidget(page1)
|
||||||
|
spacer.setMinimumSize(QSize(6,300))
|
||||||
|
|
||||||
|
pagebody = QVBox(page1,"pagebody")
|
||||||
|
page1.setStretchFactor(pagebody,1)
|
||||||
|
|
||||||
|
introtext = QLabel(pagebody,"introtext")
|
||||||
|
introtext.setText(i18n("It appears that you do not yet have a Windows drive set up.\n" +\
|
||||||
|
"This wizard will help set it up so that you can run windows applications.\n"))
|
||||||
|
|
||||||
|
spacer = QWidget(pagebody)
|
||||||
|
spacer.setMinimumSize(QSize(6,20))
|
||||||
|
|
||||||
|
self.createinstall = True
|
||||||
|
|
||||||
|
createwinepathchoice = QRadioButton(i18n("Set up the fake windows installation " +\
|
||||||
|
"in the following directory:"),pagebody)
|
||||||
|
|
||||||
|
self.winepath = self.default_winepath
|
||||||
|
hbox = QHBox(pagebody)
|
||||||
|
hbox.setSpacing(KDialog.spacingHint())
|
||||||
|
|
||||||
|
self.winefolderedit = KLineEdit(self.winepath,hbox)
|
||||||
|
self.urlcompletion = KURLCompletion(KURLCompletion.DirCompletion)
|
||||||
|
self.winefolderedit.setCompletionObject(self.urlcompletion)
|
||||||
|
self.winefolderedit.setCompletionMode(KGlobalSettings.CompletionPopup)
|
||||||
|
self.connect(self.winefolderedit,SIGNAL("textChanged(const QString &)"),self.slotWineFolderEdited)
|
||||||
|
|
||||||
|
self.browsecreatebutton = KPushButton(i18n("Browse"),hbox)
|
||||||
|
self.connect(self.browsecreatebutton,SIGNAL("clicked()"),self.slotBrowseClicked)
|
||||||
|
|
||||||
|
spacer = QWidget(pagebody)
|
||||||
|
spacer.setMinimumSize(QSize(6,10))
|
||||||
|
|
||||||
|
existingwinepathchoice = QRadioButton(i18n("There is already a fake windows installation " +\
|
||||||
|
"in the following directory:"),pagebody)
|
||||||
|
|
||||||
|
hbox = QHBox(pagebody)
|
||||||
|
hbox.setSpacing(KDialog.spacingHint())
|
||||||
|
|
||||||
|
self.existingwinefolderedit = KLineEdit("",hbox)
|
||||||
|
self.urlcompletion = KURLCompletion(KURLCompletion.DirCompletion)
|
||||||
|
self.existingwinefolderedit.setCompletionObject(self.urlcompletion)
|
||||||
|
self.existingwinefolderedit.setCompletionMode(KGlobalSettings.CompletionPopup)
|
||||||
|
self.connect(self.existingwinefolderedit,SIGNAL("textChanged(const QString &)"),self.slotWineFolderEdited)
|
||||||
|
|
||||||
|
self.browseexistingbutton = KPushButton(i18n("Browse"),hbox)
|
||||||
|
self.connect(self.browseexistingbutton,SIGNAL("clicked()"),self.slotBrowseClicked)
|
||||||
|
|
||||||
|
self.createexistingchoicesgroup = QButtonGroup(pagebody,"createexistingchoicesgroup")
|
||||||
|
self.createexistingchoicesgroup.insert(createwinepathchoice,0)
|
||||||
|
self.createexistingchoicesgroup.insert(existingwinepathchoice,1)
|
||||||
|
self.createexistingchoicesgroup.setExclusive(True)
|
||||||
|
self.createexistingchoicesgroup.hide()
|
||||||
|
self.createexistingchoicesgroup.setButton(0)
|
||||||
|
self.connect(self.createexistingchoicesgroup,SIGNAL("clicked(int)"),self.slotCreateExistingToggled)
|
||||||
|
|
||||||
|
bottomspacer = QWidget(pagebody)
|
||||||
|
pagebody.setStretchFactor(bottomspacer,1)
|
||||||
|
|
||||||
|
self.addPage( page1, i18n("Setting up your windows drive") )
|
||||||
|
|
||||||
|
self.setBackEnabled( page1, False )
|
||||||
|
self.setNextEnabled( page1, True )
|
||||||
|
self.setHelpEnabled( page1, False )
|
||||||
|
self.setFinishEnabled( page1, False )
|
||||||
|
|
||||||
|
def setupPageExistingWine(self):
|
||||||
|
self.pageexisting = QHBox(self,"pageexisting")
|
||||||
|
|
||||||
|
self.kdewinepicture = QLabel(self.pageexisting,"kdewinepicture")
|
||||||
|
self.kdewinepicture.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.kdewinepicture.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.kdewinepicture.setMinimumSize(QSize(140,320))
|
||||||
|
self.kdewinepicture.setPixmap(QPixmap(self.imagedir+"kdewinewizard.png"))
|
||||||
|
#self.kdewinepicture.setScaledContents(1)
|
||||||
|
|
||||||
|
spacer = QWidget(self.pageexisting)
|
||||||
|
spacer.setMinimumSize(QSize(6,300))
|
||||||
|
|
||||||
|
valid = wineread.VerifyWineDrive(self.winepath)
|
||||||
|
|
||||||
|
pagebody = QVBox(self.pageexisting,"pagebody")
|
||||||
|
self.pageexisting.setStretchFactor(pagebody,1)
|
||||||
|
|
||||||
|
existstext = QLabel(pagebody,"existstext")
|
||||||
|
if valid:
|
||||||
|
existstext.setText(i18n("A fake windows installation was found."))
|
||||||
|
else:
|
||||||
|
existstext.setText(i18n("No fake windows installation was found in\n" +\
|
||||||
|
self.winepath + "\nPlease go back and create one."))
|
||||||
|
|
||||||
|
bottomspacer = QWidget(pagebody)
|
||||||
|
pagebody.setStretchFactor(bottomspacer,1)
|
||||||
|
|
||||||
|
self.addPage( self.pageexisting, i18n("Setting up your windows drive") )
|
||||||
|
|
||||||
|
self.setBackEnabled( self.pageexisting, True )
|
||||||
|
self.setNextEnabled( self.pageexisting, True )
|
||||||
|
self.setHelpEnabled( self.pageexisting, False )
|
||||||
|
self.setFinishEnabled( self.pageexisting, True )
|
||||||
|
|
||||||
|
def setupPageCreateWine(self):
|
||||||
|
self.pagecreate = QHBox(self,"pagecreate")
|
||||||
|
|
||||||
|
self.kdewinepicture = QLabel(self.pagecreate,"kdewinepicture")
|
||||||
|
self.kdewinepicture.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.kdewinepicture.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.kdewinepicture.setMinimumSize(QSize(140,320))
|
||||||
|
self.kdewinepicture.setPixmap(QPixmap(self.imagedir+"kdewinewizard.png"))
|
||||||
|
#self.kdewinepicture.setScaledContents(1)
|
||||||
|
|
||||||
|
spacer = QWidget(self.pagecreate)
|
||||||
|
spacer.setMinimumSize(QSize(6,300))
|
||||||
|
|
||||||
|
pagebody = QVBox(self.pagecreate,"pagebody")
|
||||||
|
self.pagecreate.setStretchFactor(pagebody,1)
|
||||||
|
|
||||||
|
self.createdtext = QLabel(pagebody,"existstext")
|
||||||
|
self.createdtext.setText(i18n("A fake windows installation was created for you in\n" +\
|
||||||
|
self.winepath))
|
||||||
|
|
||||||
|
bottomspacer = QWidget(pagebody)
|
||||||
|
pagebody.setStretchFactor(bottomspacer,1)
|
||||||
|
|
||||||
|
self.addPage( self.pagecreate, i18n("Setting up your windows drive") )
|
||||||
|
|
||||||
|
self.setBackEnabled( self.pagecreate, False )
|
||||||
|
self.setNextEnabled( self.pagecreate, True )
|
||||||
|
self.setHelpEnabled( self.pagecreate, False )
|
||||||
|
self.setFinishEnabled( self.pagecreate, True )
|
||||||
|
|
||||||
|
def setupPageVersion(self):
|
||||||
|
self.pageversion = QHBox(self,"pageversion")
|
||||||
|
|
||||||
|
self.kdewinepicture = QLabel(self.pageversion,"kdewinepicture")
|
||||||
|
self.kdewinepicture.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.kdewinepicture.sizePolicy().hasHeightForWidth()))
|
||||||
|
self.kdewinepicture.setMinimumSize(QSize(140,320))
|
||||||
|
self.kdewinepicture.setPixmap(QPixmap(self.imagedir+"kdewinewizard.png"))
|
||||||
|
#self.kdewinepicture.setScaledContents(1)
|
||||||
|
|
||||||
|
spacer = QWidget(self.pageversion)
|
||||||
|
spacer.setMinimumSize(QSize(6,300))
|
||||||
|
|
||||||
|
pagebody = QVBox(self.pageversion,"pagebody")
|
||||||
|
self.pageversion.setStretchFactor(pagebody,1)
|
||||||
|
|
||||||
|
versiontext = QLabel(pagebody,"versiontext")
|
||||||
|
versiontext.setText(i18n("What windows version would you like to emulate?\n"))
|
||||||
|
|
||||||
|
self.winversions = wineread.winversions
|
||||||
|
|
||||||
|
self.verid=1
|
||||||
|
self.versioncombo = KComboBox(0,pagebody,"versioncombo")
|
||||||
|
self.fillVersionCombo(self.versioncombo)
|
||||||
|
self.connect(self.versioncombo,SIGNAL("activated(int)"),self.slotVersionActivated)
|
||||||
|
self.__selectWinVer(self.verid)
|
||||||
|
|
||||||
|
bottomspacer = QWidget(pagebody)
|
||||||
|
pagebody.setStretchFactor(bottomspacer,1)
|
||||||
|
|
||||||
|
self.addPage( self.pageversion, i18n("Setting up your windows drive") )
|
||||||
|
|
||||||
|
self.setBackEnabled( self.pageversion, True )
|
||||||
|
self.setNextEnabled( self.pageversion, True )
|
||||||
|
self.setHelpEnabled( self.pageversion, False )
|
||||||
|
self.setFinishEnabled( self.pageversion, False )
|
||||||
|
|
||||||
|
def fillVersionCombo(self,combo):
|
||||||
|
""" Fill the combobox with the values from our list """
|
||||||
|
for version in self.winversions:
|
||||||
|
combo.insertItem(version[1])
|
||||||
|
|
||||||
|
def __selectWinVer(self,verid):
|
||||||
|
"""
|
||||||
|
Sets the current windows version and selects it in the combo box
|
||||||
|
"""
|
||||||
|
self.versioncombo.setCurrentItem(verid)
|
||||||
|
|
||||||
|
def slotVersionActivated(self,verid):
|
||||||
|
self.verid = verid
|
||||||
|
|
||||||
|
def slotFolderChanged(self,folder):
|
||||||
|
""" Change the directory when a new one is entered in the URL box """
|
||||||
|
self.winepath = str(folder)
|
||||||
|
|
||||||
|
def slotWineFolderEdited(self,folder):
|
||||||
|
""" Change the directory when a new one is entered manually in the URL box """
|
||||||
|
self.urlcompletion.makeCompletion("") # Doesn't seem like this should be required.
|
||||||
|
self.slotFolderChanged(folder)
|
||||||
|
|
||||||
|
def slotBrowseClicked(self):
|
||||||
|
""" Bring up a browse window to choose a directory """
|
||||||
|
path = KFileDialog.getExistingDirectory(wineread.winepath,self,i18n("Windows Directory"))
|
||||||
|
if path:
|
||||||
|
self.winepath = str(path)
|
||||||
|
|
||||||
|
#def slotPageChanged(self,pagename):
|
||||||
|
# if pagename == "pagecreate":
|
||||||
|
# self.CreateWindowsInstall()
|
||||||
|
|
||||||
|
def slotCreateExistingToggled(self, buttonid):
|
||||||
|
""" Called when the choice to create a new windows drive or use an existing one is changed """
|
||||||
|
if buttonid == 0:
|
||||||
|
self.createinstall = True
|
||||||
|
self.winefolderedit.setEnabled(True)
|
||||||
|
self.browsecreatebutton.setEnabled(True)
|
||||||
|
self.existingwinefolderedit.setEnabled(False)
|
||||||
|
self.browseexistingbutton.setEnabled(False)
|
||||||
|
self.setAppropriate(self.pageversion,True)
|
||||||
|
self.setAppropriate(self.pageexisting,False)
|
||||||
|
self.setAppropriate(self.pagecreate,True)
|
||||||
|
elif buttonid == 1:
|
||||||
|
self.createinstall = False
|
||||||
|
self.winefolderedit.setEnabled(False)
|
||||||
|
self.browsecreatebutton.setEnabled(False)
|
||||||
|
self.existingwinefolderedit.setEnabled(True)
|
||||||
|
self.browseexistingbutton.setEnabled(True)
|
||||||
|
self.setAppropriate(self.pageversion,False)
|
||||||
|
self.setAppropriate(self.pageexisting,True)
|
||||||
|
self.setAppropriate(self.pagecreate,False)
|
||||||
|
|
||||||
|
def showPage(self,page):
|
||||||
|
if page == self.pagecreate:
|
||||||
|
self.CreateWindowsInstall()
|
||||||
|
|
||||||
|
KWizard.showPage(self,page)
|
||||||
|
|
||||||
|
def CreateWindowsInstall(self):
|
||||||
|
winewrite.CreateWineDrive(self.winepath)
|
||||||
|
wineread.SetWinePath(self.winepath)
|
||||||
|
|
||||||
|
autodrives = drivedetect.autodetect()
|
||||||
|
autoshelllinks = drivedetect.autodetectshelllinks()
|
||||||
|
|
||||||
|
if autodrives[0] == 1:
|
||||||
|
KMessageBox.sorry(self, \
|
||||||
|
i18n("There were not enough letters to add all the autodetected drives."))
|
||||||
|
drives = autodrives[1]
|
||||||
|
drives[26:] = autoshelllinks
|
||||||
|
|
||||||
|
winewrite.SetDriveMappings(drives)
|
||||||
|
|
||||||
|
winewrite.SetAudioDriver('alsa')
|
||||||
|
|
||||||
|
dsoundsettings = {"HardwareAcceleration":"Full",
|
||||||
|
"DefaultSampleRate":"44100",
|
||||||
|
"DefaultBitsPerSample":"8",
|
||||||
|
"EmulDriver":"N"}
|
||||||
|
|
||||||
|
winewrite.SetDSoundSettings(dsoundsettings)
|
||||||
|
|
||||||
|
windowsettings = {"DXGrab":"N",
|
||||||
|
"DesktopDoubleBuffered":"Y",
|
||||||
|
"Managed":"Y",
|
||||||
|
"Desktop":""}
|
||||||
|
|
||||||
|
winewrite.SetWindowSettings(windowsettings)
|
||||||
|
|
||||||
|
d3dsettings = {"VertexShaderMode":"hardware",
|
||||||
|
"PixelShaderMode":"Y"}
|
||||||
|
|
||||||
|
winewrite.SetD3DSettings(d3dsettings)
|
||||||
|
|
||||||
|
winewrite.SetWinVersion(self.winversions[self.verid])
|
||||||
|
|
||||||
|
self.createdtext.setText(i18n("A fake windows installation was created for you in\n" +\
|
||||||
|
self.winepath))
|
@ -0,0 +1,156 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* pykcm_launcher.cpp
|
||||||
|
*
|
||||||
|
* Launch Control Centre modules written in Python using an embedded Python
|
||||||
|
* interpreter.
|
||||||
|
* Based on David Boddie's PyKDE-components.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// pythonize.h must be included first.
|
||||||
|
#include <pythonize.h>
|
||||||
|
#include <kcmodule.h>
|
||||||
|
#include <kglobal.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <klibloader.h>
|
||||||
|
#include <kstandarddirs.h>
|
||||||
|
#include <ksimpleconfig.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <sip.h>
|
||||||
|
|
||||||
|
#define MODULE_DIR "/opt/kde3/share/apps/guidance"
|
||||||
|
#define EXTRA_MODULE_DIR "/opt/kde3/share/python-support/kde-guidance-kde3"
|
||||||
|
#define EXTRA_MODULE_DIR_TWO "/opt/kde3/share/python-support/guidance-backends-kde3"
|
||||||
|
#define EXTRA_MODULE_DIR_THREE "/opt/kde3/share/python-support/kde-guidance-powermanager-kde3"
|
||||||
|
#define MODULE_NAME "wineconfig"
|
||||||
|
#define FACTORY "create_wineconfig"
|
||||||
|
#define CPP_FACTORY create_wineconfig
|
||||||
|
#define LIB_PYTHON "libpython2.5.so"
|
||||||
|
#define debug 1
|
||||||
|
|
||||||
|
static KCModule *report_error(char *msg) {
|
||||||
|
if (debug) printf ("error: %s\n", msg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static KCModule* return_instance( QWidget *parent, const char *name ) {
|
||||||
|
KCModule* kcmodule;
|
||||||
|
PyObject *pyKCModuleTuple;
|
||||||
|
PyObject *pyKCModule;
|
||||||
|
Pythonize *pyize; // Pythonize object to manage the Python interpreter.
|
||||||
|
int isErr;
|
||||||
|
|
||||||
|
// Try to determine what py script we're loading. Note that "name"
|
||||||
|
// typically appears to be NULL.
|
||||||
|
QString script(MODULE_NAME);
|
||||||
|
|
||||||
|
// Reload libpython, but this time tell the runtime linker to make the
|
||||||
|
// symbols global and available for later loaded libraries/module.
|
||||||
|
KLibLoader::self()->globalLibrary(LIB_PYTHON);
|
||||||
|
|
||||||
|
// Start the interpreter.
|
||||||
|
pyize = initialize();
|
||||||
|
if (!pyize) {
|
||||||
|
return report_error ("***Failed to start interpreter\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the path to the python script to the interpreter search path.
|
||||||
|
QString path = QString(MODULE_DIR);
|
||||||
|
if(path == QString::null) {
|
||||||
|
return report_error ("***Failed to locate script path");
|
||||||
|
}
|
||||||
|
if(!pyize->appendToSysPath (path.latin1 ())) {
|
||||||
|
return report_error ("***Failed to set sys.path\n");
|
||||||
|
}
|
||||||
|
QString extrapath = QString(EXTRA_MODULE_DIR);
|
||||||
|
if(!pyize->appendToSysPath (extrapath.latin1 ())) {
|
||||||
|
return report_error ("***Failed to set extra sys.path\n");
|
||||||
|
}
|
||||||
|
QString extrapath_two = QString(EXTRA_MODULE_DIR_TWO);
|
||||||
|
if(!pyize->appendToSysPath (extrapath_two.latin1 ())) {
|
||||||
|
return report_error ("***Failed to set extra 2 sys.path\n");
|
||||||
|
}
|
||||||
|
QString extrapath_three = QString(EXTRA_MODULE_DIR_THREE);
|
||||||
|
if(!pyize->appendToSysPath (extrapath_three.latin1 ())) {
|
||||||
|
return report_error ("***Failed to set extra 3 sys.path\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the Python script.
|
||||||
|
PyObject *pyModule = pyize->importModule ((char *)script.latin1 ());
|
||||||
|
if(!pyModule) {
|
||||||
|
PyErr_Print();
|
||||||
|
return report_error ("***failed to import module\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inject a helper function
|
||||||
|
QString bridge = QString("import sip\n"
|
||||||
|
"import qt\n"
|
||||||
|
"def kcontrol_bridge_" FACTORY "(parent,name):\n"
|
||||||
|
" if parent!=0:\n"
|
||||||
|
#if SIP_VERSION >= 0x040200
|
||||||
|
" wparent = sip.wrapinstance(parent,qt.QWidget)\n"
|
||||||
|
#else
|
||||||
|
" wparent = sip.wrapinstance(parent,'QWidget')\n"
|
||||||
|
#endif
|
||||||
|
" else:\n"
|
||||||
|
" wparent = None\n"
|
||||||
|
" inst = " FACTORY "(wparent, name)\n"
|
||||||
|
" return (inst,sip.unwrapinstance(inst))\n");
|
||||||
|
PyRun_String(bridge.latin1(),Py_file_input,PyModule_GetDict(pyModule),PyModule_GetDict(pyModule));
|
||||||
|
|
||||||
|
// Get the Python module's factory function.
|
||||||
|
PyObject *kcmFactory = pyize->getNewObjectRef(pyModule, "kcontrol_bridge_" FACTORY);
|
||||||
|
if(!kcmFactory) {
|
||||||
|
return report_error ("***failed to find module factory\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the factory function. Set up the args.
|
||||||
|
PyObject *pyParent = PyLong_FromVoidPtr(parent);
|
||||||
|
PyObject *pyName = PyString_FromString(MODULE_NAME);
|
||||||
|
// Using NN here is effect gives our references to the arguement away.
|
||||||
|
PyObject *args = Py_BuildValue ("NN", pyParent, pyName);
|
||||||
|
if(pyName && pyParent && args) {
|
||||||
|
// run the factory function
|
||||||
|
pyKCModuleTuple = pyize->runFunction(kcmFactory, args);
|
||||||
|
if(!pyKCModuleTuple) {
|
||||||
|
PyErr_Print();
|
||||||
|
return report_error ("*** runFunction failure\n;");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return report_error ("***failed to create args\n");
|
||||||
|
}
|
||||||
|
// cleanup a bit
|
||||||
|
pyize->decref(args);
|
||||||
|
pyize->decref(kcmFactory);
|
||||||
|
|
||||||
|
// Stop this from getting garbage collected.
|
||||||
|
Py_INCREF(PyTuple_GET_ITEM(pyKCModuleTuple,0));
|
||||||
|
|
||||||
|
// convert the KCModule PyObject to a real C++ KCModule *.
|
||||||
|
isErr = 0;
|
||||||
|
pyKCModule = PyTuple_GET_ITEM(pyKCModuleTuple,1);
|
||||||
|
kcmodule = (KCModule *)PyLong_AsVoidPtr(pyKCModule);
|
||||||
|
if(!kcmodule) {
|
||||||
|
return report_error ("***failed sip conversion to C++ pointer\n");
|
||||||
|
}
|
||||||
|
pyize->decref(pyKCModuleTuple);
|
||||||
|
|
||||||
|
// PyKDE can't run the module without this - Pythonize
|
||||||
|
// grabs the lock at initialization and we have to give
|
||||||
|
// it back before exiting. At this point, we no longer need
|
||||||
|
// it.
|
||||||
|
//pyize->releaseLock ();
|
||||||
|
|
||||||
|
// take care of any translation info
|
||||||
|
KGlobal::locale()->insertCatalogue(script);
|
||||||
|
|
||||||
|
// Return the pointer to our new KCModule
|
||||||
|
return kcmodule;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
// Factory function that kcontrol will call.
|
||||||
|
KCModule* CPP_FACTORY(QWidget *parent, const char *name) {
|
||||||
|
return return_instance(parent, name);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Categories=Qt;KDE;X-KDE-settings-system;X-KDE-systemsettings-advancedadministration;
|
||||||
|
Comment=Wine Configuration
|
||||||
|
Comment[el]=Ρυθμίσεις του Wine
|
||||||
|
Comment[es]=Configuración de wine
|
||||||
|
Comment[et]=Wine seadistamine
|
||||||
|
Comment[it]=Configurazione di Wine
|
||||||
|
Comment[ja]=Wine の設定
|
||||||
|
Comment[nl]=Wine instellen
|
||||||
|
Comment[pt]=Configuração do Wine
|
||||||
|
Comment[pt_BR]=Configuração do Wine
|
||||||
|
Comment[sr]=Wine подешавања
|
||||||
|
Comment[sr@Latn]=Wine podešavanja
|
||||||
|
Comment[sv]=Inställning av Wine
|
||||||
|
Comment[xx]=xxWine Configurationxx
|
||||||
|
Encoding=UTF-8
|
||||||
|
Exec=kcmshell System/wineconfig
|
||||||
|
GenericName=Wine Configuration Editor
|
||||||
|
GenericName[el]=Επεξεργαστής ρυθμίσεων του Wine
|
||||||
|
GenericName[es]=Editor de la configuración de wine
|
||||||
|
GenericName[et]=Wine seadistuste redaktor
|
||||||
|
GenericName[it]=Editor della configurazione di Wine
|
||||||
|
GenericName[ja]=Wine 設定エディタ
|
||||||
|
GenericName[nl]=Wine-configuratiemodule
|
||||||
|
GenericName[pt]=Editor de Configuração do Wine
|
||||||
|
GenericName[pt_BR]=Editor de Configurações do Wine
|
||||||
|
GenericName[sr]=Уређивач Wine подешавања
|
||||||
|
GenericName[sr@Latn]=Uređivač Wine podešavanja
|
||||||
|
GenericName[sv]=Editor för inställning av Wine
|
||||||
|
GenericName[xx]=xxWine Configuration Editorxx
|
||||||
|
Icon=wineconfig
|
||||||
|
MimeType=
|
||||||
|
Name=Windows Applications
|
||||||
|
Name[el]=Εφαρμογές Windows
|
||||||
|
Name[es]=Aplicaciones de Windows
|
||||||
|
Name[et]=Windowsi rakendused
|
||||||
|
Name[it]=Applicazioni Windows
|
||||||
|
Name[ja]=Windows アプリケーション
|
||||||
|
Name[nl]=Windows-programma's
|
||||||
|
Name[pt]=Aplicações do Windows
|
||||||
|
Name[pt_BR]=Aplicativos Windows
|
||||||
|
Name[sr]=Windows програми
|
||||||
|
Name[sr@Latn]=Windows programi
|
||||||
|
Name[sv]=Windows-program
|
||||||
|
Name[xx]=xxWindows Applicationsxx
|
||||||
|
Path=
|
||||||
|
StartupNotify=true
|
||||||
|
Terminal=false
|
||||||
|
TerminalOptions=
|
||||||
|
Type=Application
|
||||||
|
X-DCOP-ServiceType=
|
||||||
|
X-KDE-FactoryName=wineconfig
|
||||||
|
X-KDE-Library=wineconfig
|
||||||
|
X-KDE-ModuleType=Library
|
||||||
|
X-KDE-RootOnly=false
|
||||||
|
X-KDE-SubstituteUID=false
|
||||||
|
X-KDE-Username=
|
@ -0,0 +1,543 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
###########################################################################
|
||||||
|
# wineread.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Fri Mar 26 2004 #
|
||||||
|
# copyright : (C) 2006 by Yuriy Kozlov #
|
||||||
|
# email : yuriy.kozlov@gmail.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
""" Provides a set of functions for accessing wine's settings """
|
||||||
|
|
||||||
|
# Assumes the fake windows is installed in ~/.wine
|
||||||
|
default_winepath = os.environ['HOME'] + "/.wine"
|
||||||
|
winepath = default_winepath
|
||||||
|
defaultwinfolderspath = "c:\\windows\\profiles\\" + os.environ['USER']
|
||||||
|
|
||||||
|
# Where the dll's are
|
||||||
|
default_winebuildpath = "/usr/lib/wine"
|
||||||
|
default_winebuildpath2 = "/usr/lib32/wine"
|
||||||
|
default_winebuildpath3 = "/usr/local/lib/wine"
|
||||||
|
|
||||||
|
winebuildpath = None
|
||||||
|
|
||||||
|
def GetWineBuildPath():
|
||||||
|
""" Returns the wine build path, None if not present """
|
||||||
|
path = None
|
||||||
|
if winebuildpath:
|
||||||
|
path = winebuildpath
|
||||||
|
elif os.path.exists(default_winebuildpath):
|
||||||
|
path = default_winebuildpath
|
||||||
|
elif os.path.exists(default_winebuildpath2):
|
||||||
|
path = default_winebuildpath2
|
||||||
|
elif os.path.exists(default_winebuildpath3):
|
||||||
|
path = default_winebuildpath3
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
|
def SetWineBuildPath(path):
|
||||||
|
""" Sets the winebuildpath to path """
|
||||||
|
global winebuildpath
|
||||||
|
winebuildpath = path
|
||||||
|
|
||||||
|
# drive = [index, letter, unixpath/mapping, type, label, serial]
|
||||||
|
empty_drives = (
|
||||||
|
[0,"A:","","","",""],
|
||||||
|
[1,"B:","","","",""],
|
||||||
|
[2,"C:","","","",""],
|
||||||
|
[3,"D:","","","",""],
|
||||||
|
[4,"E:","","","",""],
|
||||||
|
[5,"F:","","","",""],
|
||||||
|
[6,"G:","","","",""],
|
||||||
|
[7,"H:","","","",""],
|
||||||
|
[8,"I:","","","",""],
|
||||||
|
[9,"J:","","","",""],
|
||||||
|
[10,"K:","","","",""],
|
||||||
|
[11,"L:","","","",""],
|
||||||
|
[12,"M:","","","",""],
|
||||||
|
[13,"N:","","","",""],
|
||||||
|
[14,"O:","","","",""],
|
||||||
|
[15,"P:","","","",""],
|
||||||
|
[16,"Q:","","","",""],
|
||||||
|
[17,"R:","","","",""],
|
||||||
|
[18,"S:","","","",""],
|
||||||
|
[19,"T:","","","",""],
|
||||||
|
[20,"U:","","","",""],
|
||||||
|
[21,"V:","","","",""],
|
||||||
|
[22,"W:","","","",""],
|
||||||
|
[23,"X:","","","",""],
|
||||||
|
[24,"Y:","","","",""],
|
||||||
|
[25,"Z:","","","",""])
|
||||||
|
|
||||||
|
def GetEmptyDrives():
|
||||||
|
""" Returns a list of 26 empty drives """
|
||||||
|
drives = []
|
||||||
|
for drive in empty_drives:
|
||||||
|
drives.append(drive[:])
|
||||||
|
return drives
|
||||||
|
|
||||||
|
def LoadDrives():
|
||||||
|
drives = GetEmptyDrives()
|
||||||
|
|
||||||
|
driveletters = os.listdir(winepath + "/dosdevices")
|
||||||
|
for folder in driveletters:
|
||||||
|
if len(folder) > 2 or folder[1] != ':':
|
||||||
|
del folder
|
||||||
|
set(driveletters)
|
||||||
|
|
||||||
|
drivetypes = GetDriveTypes()
|
||||||
|
|
||||||
|
for drive in drives:
|
||||||
|
letter = drive[1].lower()
|
||||||
|
if letter in driveletters:
|
||||||
|
drive[2] = os.readlink(winepath + "/dosdevices/" + letter)
|
||||||
|
if drivetypes.has_key(drive[1]):
|
||||||
|
drive[3] = drivetypes[drive[1]]
|
||||||
|
return drives
|
||||||
|
|
||||||
|
empty_shelllinks = ([26,"Desktop","","","",""],
|
||||||
|
[27,"My Documents","","","",""],
|
||||||
|
[28,"My Pictures","","","",""],
|
||||||
|
[29,"My Music","","","",""],
|
||||||
|
[30,"My Video","","","",""])
|
||||||
|
|
||||||
|
folder_nonexistent = "This folder does not exist, please map it."
|
||||||
|
profilesdirectory = winepath + "/dosdevices/c:/windows/profiles/" + os.environ['USER']
|
||||||
|
|
||||||
|
def GetEmptyShellLinks():
|
||||||
|
""" Returns a list of important windows folders """
|
||||||
|
shelllinks = []
|
||||||
|
for link in empty_shelllinks:
|
||||||
|
shelllinks.append(link[:])
|
||||||
|
return shelllinks
|
||||||
|
|
||||||
|
def GetShellLinks():
|
||||||
|
shelllinks = GetEmptyShellLinks()
|
||||||
|
|
||||||
|
existingshelllinks = os.listdir(profilesdirectory)
|
||||||
|
set(existingshelllinks)
|
||||||
|
shellregistry = GetShellRegistry()
|
||||||
|
usershellregistry = GetUserShellRegistry()
|
||||||
|
|
||||||
|
for link in shelllinks:
|
||||||
|
if link[1] in existingshelllinks:
|
||||||
|
linkpath = profilesdirectory + "/" + link[1]
|
||||||
|
if os.path.islink(linkpath):
|
||||||
|
link[2] = os.readlink(linkpath)
|
||||||
|
else:
|
||||||
|
link[2] = linkpath
|
||||||
|
link[3] = "shellfolder"
|
||||||
|
winpath = defaultwinfolderspath + "\\" + link[1]
|
||||||
|
link[4] = winpath
|
||||||
|
link[5] = shellregistry.get(link[1], defaultwinfolderspath + "\\" + link[1])
|
||||||
|
link[5] = link[5].replace("\\\\","\\")
|
||||||
|
else:
|
||||||
|
link[3] = "shellfolder"
|
||||||
|
link[4] = folder_nonexistent
|
||||||
|
link[5] = shellregistry.get(link[1], folder_nonexistent)
|
||||||
|
link[5] = link[5].replace("\\\\","\\")
|
||||||
|
|
||||||
|
return shelllinks
|
||||||
|
|
||||||
|
def GetValue(key, value):
|
||||||
|
""" Returns a specific value, returns a blank string if the value is not there. """
|
||||||
|
# Need 4 \'s to generate one because both python and the shell use it as an escape character
|
||||||
|
key = key.replace("\\","\\\\")
|
||||||
|
key = key.replace(" ","\\ ")
|
||||||
|
error = os.system("wine regedit /E .registryvalue.reg " + key)
|
||||||
|
if error != 0:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
file=open('.registryvalue.reg')
|
||||||
|
|
||||||
|
for line in file:
|
||||||
|
if line and line[0] == '"' or line[0] == '@':
|
||||||
|
line = line.strip('\r\n')
|
||||||
|
line = line.split('=')
|
||||||
|
line = (line[0].strip('"'),line[1].strip('"@'))
|
||||||
|
if line[0] == value:
|
||||||
|
file.close()
|
||||||
|
os.remove(".registryvalue.reg")
|
||||||
|
return line[1]
|
||||||
|
else:
|
||||||
|
file.close()
|
||||||
|
os.remove(".registryvalue.reg")
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def GetKeyValues(key):
|
||||||
|
""" Returns a dictionary of all the values in the key
|
||||||
|
Returns an empty dictionary if the key does not exist
|
||||||
|
Does not read subkeys within the key """
|
||||||
|
# Need 4 \'s to generate one because both python and the shell use it as an escape character
|
||||||
|
key = key.replace("\\","\\\\")
|
||||||
|
key = key.replace(" ","\\ ")
|
||||||
|
error = os.system("wine regedit /E .registrykey.reg " + key)
|
||||||
|
if error != 0:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
settings = {}
|
||||||
|
|
||||||
|
file=open('.registrykey.reg')
|
||||||
|
|
||||||
|
keycount = 0
|
||||||
|
for line in file:
|
||||||
|
if keycount > 1:
|
||||||
|
break
|
||||||
|
elif line and line[0] == '[':
|
||||||
|
keycount += 1
|
||||||
|
elif line and line[0] == '"':
|
||||||
|
line = line.split('=')
|
||||||
|
settings[line[0].strip('"')] = line[1].strip('"\r\n@')
|
||||||
|
|
||||||
|
file.close()
|
||||||
|
os.remove(".registrykey.reg")
|
||||||
|
|
||||||
|
return settings
|
||||||
|
|
||||||
|
def GetUserShellRegistry():
|
||||||
|
error = os.system("wine regedit /E .registryshelluser.reg HKEY_USERS\\\\.Default\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Explorer\\\\User\\ Shell\\ Folders")
|
||||||
|
if error != 0:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
usershellfile=open('.registryshelluser.reg')
|
||||||
|
usershellfilelines = usershellfile.readlines()
|
||||||
|
usershellfile.close()
|
||||||
|
os.remove(".registryshelluser.reg")
|
||||||
|
|
||||||
|
settings = {}
|
||||||
|
|
||||||
|
del(usershellfilelines[:3])
|
||||||
|
|
||||||
|
for usershellline in usershellfilelines:
|
||||||
|
usershellline = usershellline.split('=')
|
||||||
|
settings[usershellline[0].strip('"')] = usershellline[1].strip('"\r\n')
|
||||||
|
|
||||||
|
return settings
|
||||||
|
|
||||||
|
def GetShellRegistry():
|
||||||
|
error = os.system("wine regedit /E .registryshell.reg HKEY_USERS\\\\.Default\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Explorer\\\\Shell\\ Folders")
|
||||||
|
if error != 0:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
shellfile=open('.registryshell.reg')
|
||||||
|
shellfilelines = shellfile.readlines()
|
||||||
|
shellfile.close()
|
||||||
|
os.remove(".registryshell.reg")
|
||||||
|
|
||||||
|
settings = {}
|
||||||
|
|
||||||
|
del(shellfilelines[:3])
|
||||||
|
|
||||||
|
for shellline in shellfilelines:
|
||||||
|
shellline = shellline.split('=')
|
||||||
|
settings[shellline[0].strip('"')] = shellline[1].strip('"\r\n')
|
||||||
|
|
||||||
|
return settings
|
||||||
|
|
||||||
|
def GetDriveTypes():
|
||||||
|
""" Returns a dictionary of the drive types """
|
||||||
|
# Drive C: doesn't get stored in the registry
|
||||||
|
defaulttypes = {"C:":"hd"}
|
||||||
|
|
||||||
|
types = GetKeyValues("HKEY_LOCAL_MACHINE\\Software\\Wine\\Drives")
|
||||||
|
types.update(defaulttypes)
|
||||||
|
|
||||||
|
return types
|
||||||
|
|
||||||
|
def GetAudioDriver():
|
||||||
|
""" Returns the audio driver currently set in the registry """
|
||||||
|
return GetValue("HKEY_CURRENT_USER\\Software\\Wine\\Drivers","Audio")
|
||||||
|
|
||||||
|
def GetDSoundSettings(app = None):
|
||||||
|
""" Returns a dictionary of the settings for the DirectSound section """
|
||||||
|
if not app:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\DirectSound")
|
||||||
|
else:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\DirectSound")
|
||||||
|
|
||||||
|
def GetWindowSettings(app = None):
|
||||||
|
""" Returns a dictionary of the Window Settings """
|
||||||
|
if not app:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\X11 Driver")
|
||||||
|
else:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\X11 Driver")
|
||||||
|
|
||||||
|
def GetD3DSettings(app = None):
|
||||||
|
""" Returns a dictionary of the Direct3D Settings """
|
||||||
|
if not app:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D")
|
||||||
|
else:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\Direct3D")
|
||||||
|
|
||||||
|
# Copied from winecfg
|
||||||
|
winversions = (
|
||||||
|
( "win2003", "Windows 2003", 5, 2, 0xECE, "VER_PLATFORM_WIN32_NT", "Service Pack 1", 1, 0, "ServerNT"),
|
||||||
|
( "winxp", "Windows XP", 5, 1, 0xA28, "VER_PLATFORM_WIN32_NT", "Service Pack 2", 2, 0, "WinNT"),
|
||||||
|
( "win2k", "Windows 2000", 5, 0, 0x893, "VER_PLATFORM_WIN32_NT", "Service Pack 4", 4, 0, "WinNT"),
|
||||||
|
( "winme", "Windows ME", 4, 90, 0xBB8, "VER_PLATFORM_WIN32_WINDOWS", " ", 0, 0, ""),
|
||||||
|
( "win98", "Windows 98", 4, 10, 0x8AE, "VER_PLATFORM_WIN32_WINDOWS", " A ", 0, 0, ""),
|
||||||
|
( "win95", "Windows 95", 4, 0, 0x3B6, "VER_PLATFORM_WIN32_WINDOWS", "", 0, 0, ""),
|
||||||
|
( "nt40", "Windows NT 4.0", 4, 0, 0x565, "VER_PLATFORM_WIN32_NT", "Service Pack 6a", 6, 0, "WinNT"),
|
||||||
|
( "nt351", "Windows NT 3.5", 3, 51, 0x421, "VER_PLATFORM_WIN32_NT", "Service Pack 2", 0, 0, "WinNT"),
|
||||||
|
( "win31", "Windows 3.1", 2, 10, 0, "VER_PLATFORM_WIN32s", "Win32s 1.3", 0, 0, ""),
|
||||||
|
( "win30", "Windows 3.0", 3, 0, 0, "VER_PLATFORM_WIN32s", "Win32s 1.3", 0, 0, ""),
|
||||||
|
( "win20", "Windows 2.0", 2, 0, 0, "VER_PLATFORM_WIN32s", "Win32s 1.3", 0, 0, ""))
|
||||||
|
|
||||||
|
def GetGeneralWineSettings(app = None):
|
||||||
|
""" Returns a dictionary of the general wine Settings, including the windows version """
|
||||||
|
if not app:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine")
|
||||||
|
else:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app)
|
||||||
|
|
||||||
|
def GetApps():
|
||||||
|
"""
|
||||||
|
Returns a list of the applications which have keys for application
|
||||||
|
specific settings.
|
||||||
|
"""
|
||||||
|
error = os.system("wine regedit /E .registryapps.reg HKEY_CURRENT_USER\\\\Software\\\\Wine\\\\AppDefaults")
|
||||||
|
if error != 0:
|
||||||
|
return []
|
||||||
|
|
||||||
|
settingsfile=open('.registryapps.reg')
|
||||||
|
settingsfilelines = settingsfile.readlines()
|
||||||
|
settingsfile.close()
|
||||||
|
os.remove('.registryapps.reg')
|
||||||
|
|
||||||
|
apps = set([])
|
||||||
|
|
||||||
|
del(settingsfilelines[:3])
|
||||||
|
|
||||||
|
for line in settingsfilelines:
|
||||||
|
if line[0] == '[':
|
||||||
|
line = line.split('\\')
|
||||||
|
line[4] = line[4].strip(']\r\n')
|
||||||
|
apps.add(line[4])
|
||||||
|
|
||||||
|
apps = list(apps)
|
||||||
|
apps.sort()
|
||||||
|
|
||||||
|
return apps
|
||||||
|
|
||||||
|
builtin_only = set(("advapi32",
|
||||||
|
"capi2032",
|
||||||
|
"dbghelp",
|
||||||
|
"ddraw",
|
||||||
|
"gdi32",
|
||||||
|
"glu32",
|
||||||
|
"icmp",
|
||||||
|
"iphlpapi",
|
||||||
|
"joystick.drv",
|
||||||
|
"kernel32",
|
||||||
|
"mswsock",
|
||||||
|
"ntdll",
|
||||||
|
"opengl32",
|
||||||
|
"stdole2.tlb",
|
||||||
|
"stdole32.tlb",
|
||||||
|
"twain_32",
|
||||||
|
"unicows",
|
||||||
|
"user32",
|
||||||
|
"vdmdbg",
|
||||||
|
"w32skrnl",
|
||||||
|
"winealsa.drv",
|
||||||
|
"winearts.drv",
|
||||||
|
"wineaudioio.drv",
|
||||||
|
"wined3d",
|
||||||
|
"winedos",
|
||||||
|
"wineesd.drv",
|
||||||
|
"winejack.drv",
|
||||||
|
"winemp3.acm",
|
||||||
|
"winenas.drv",
|
||||||
|
"wineoss.drv",
|
||||||
|
"wineps",
|
||||||
|
"wineps.drv",
|
||||||
|
"winex11.drv",
|
||||||
|
"winmm",
|
||||||
|
"wintab32",
|
||||||
|
"wnaspi32",
|
||||||
|
"wow32",
|
||||||
|
"ws2_32",
|
||||||
|
"wsock32"))
|
||||||
|
|
||||||
|
def GetDllsList():
|
||||||
|
""" Returns a list of dlls that can be overridden """
|
||||||
|
origdlls = os.listdir(GetWineBuildPath())
|
||||||
|
dlls = [""]
|
||||||
|
|
||||||
|
for dll in origdlls:
|
||||||
|
dll = dll.rstrip('.so')
|
||||||
|
dots = dll.count('.')
|
||||||
|
if dots != 1:
|
||||||
|
continue
|
||||||
|
dll, extension = dll.split('.')
|
||||||
|
if not (extension != "dll" or dll in builtin_only):
|
||||||
|
dlls.append(dll)
|
||||||
|
|
||||||
|
dlls.sort()
|
||||||
|
return dlls
|
||||||
|
|
||||||
|
def GetDllOverrides(app = None):
|
||||||
|
""" Returns a dictionary of overridden dlls """
|
||||||
|
if not app:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides")
|
||||||
|
else:
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\DllOverrides")
|
||||||
|
|
||||||
|
|
||||||
|
# --- Getting and Setting the Default browser ---
|
||||||
|
|
||||||
|
# WineBrowser>Browsers
|
||||||
|
# List of browsers that Wine will attempt to launch when running winebrowser
|
||||||
|
# command or clicking on a link in a windows application. Default value is
|
||||||
|
default_browserlist = ["firefox","konqueror","mozilla","netscape","galeon","opera","dillo"]
|
||||||
|
|
||||||
|
# WineBrowser>Mailers
|
||||||
|
# List of mail clients that Wine will attempt to launch when running winebrowser
|
||||||
|
# Default value is
|
||||||
|
default_mailerlist = ["mozilla-thunderbird","thunderbird","evolution","kmail"]
|
||||||
|
|
||||||
|
#with firefox installed
|
||||||
|
browser_formats = ["CHROME","FirefoxHTML","HTML","htmlfile","FTP","GOPHER","http","https"]
|
||||||
|
|
||||||
|
default_browser_formats = ["htmlfile","http","https"] # just "winebrowser"
|
||||||
|
|
||||||
|
default_mailer_formats = ["mailto"] # "winebrowser %1"
|
||||||
|
|
||||||
|
def GetBrowser():
|
||||||
|
""" Returns the default browser """
|
||||||
|
browser = GetValue("HKEY_LOCAL_MACHINE\\Software\\Classes\\http\\shell\\open\\command",'@')
|
||||||
|
|
||||||
|
if browser == "winebrowser":
|
||||||
|
return GetWineBrowser()
|
||||||
|
else:
|
||||||
|
return browser
|
||||||
|
|
||||||
|
def GetWineBrowser():
|
||||||
|
""" Returns the first browser tried by winebrowser """
|
||||||
|
browserlist = GetValue("HKEY_CURRENT_USER\\Software\\Wine\\WineBrowser","Browsers")
|
||||||
|
if browserlist:
|
||||||
|
browser = browserlist.split(',')[0].strip()
|
||||||
|
return browser
|
||||||
|
else:
|
||||||
|
return default_browserlist[0]
|
||||||
|
|
||||||
|
#def GetWinBrowserList():
|
||||||
|
|
||||||
|
def GetNativeBrowserList():
|
||||||
|
""" Returns the list of browsers tried by winebrowser """
|
||||||
|
browserlist = GetValue("HKEY_CURRENT_USER\\Software\\Wine\\WineBrowser","Browsers")
|
||||||
|
if browserlist:
|
||||||
|
browserlist = list(set(browserlist.split(',')))
|
||||||
|
for i,item in enumerate(browserlist):
|
||||||
|
browserlist[i] = item.strip()
|
||||||
|
return browserlist
|
||||||
|
else:
|
||||||
|
return default_browserlist
|
||||||
|
|
||||||
|
def GetMailer():
|
||||||
|
""" Returns the default mail client """
|
||||||
|
mailer = GetValue("HKEY_LOCAL_MACHINE\\Software\\Classes\\mailto\\shell\\open\\command",'@')
|
||||||
|
|
||||||
|
if mailer == "winebrowser" or mailer == "winebrowser %1":
|
||||||
|
return GetWineMailer()
|
||||||
|
else:
|
||||||
|
return mailer
|
||||||
|
|
||||||
|
def GetWineMailer():
|
||||||
|
""" Returns the first mail client tried by winebrowser """
|
||||||
|
mailerlist = GetValue("HKEY_CURRENT_USER\\Software\\Wine\\WineBrowser","Mailers")
|
||||||
|
if mailerlist:
|
||||||
|
mailer = mailerlist.split(',')[0].strip()
|
||||||
|
return mailer
|
||||||
|
else:
|
||||||
|
# Default first mailer to try in wine is mozilla-thunderbird
|
||||||
|
return default_mailerlist[0]
|
||||||
|
|
||||||
|
def GetNativeMailerList():
|
||||||
|
""" Returns the list of mail clients tried by winebrowser """
|
||||||
|
mailerlist = GetValue("HKEY_CURRENT_USER\\Software\\Wine\\WineBrowser","Mailers")
|
||||||
|
if mailerlist:
|
||||||
|
mailerlist = list(set(mailerlist.split(',')))
|
||||||
|
for i,item in enumerate(mailerlist):
|
||||||
|
mailerlist[i] = item.strip()
|
||||||
|
return mailerlist
|
||||||
|
else:
|
||||||
|
return default_mailerlist
|
||||||
|
|
||||||
|
|
||||||
|
# ----- Theming -----
|
||||||
|
|
||||||
|
def GetThemesList():
|
||||||
|
""" Returns a list of installed thiemes """
|
||||||
|
if not os.path.exists(winepath + "/dosdevices/c:/windows/Resources/Themes"):
|
||||||
|
return []
|
||||||
|
origthemes = os.listdir(winepath + "/dosdevices/c:/windows/Resources/Themes")
|
||||||
|
themes = []
|
||||||
|
|
||||||
|
for i,theme in enumerate(origthemes):
|
||||||
|
if os.path.exists(winepath +\
|
||||||
|
"/dosdevices/c:/windows/Resources/Themes/" + theme +\
|
||||||
|
"/" + theme + ".msstyles"):
|
||||||
|
themes.append(theme)
|
||||||
|
|
||||||
|
themes.sort()
|
||||||
|
return themes
|
||||||
|
|
||||||
|
def GetCurrentTheme():
|
||||||
|
""" Returns the current (theme,color,size), None if none is set """
|
||||||
|
themeinfo = GetKeyValues("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager")
|
||||||
|
|
||||||
|
if not themeinfo or themeinfo["ThemeActive"] == "0":
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
# themename from themename.msstyles
|
||||||
|
themename = themeinfo["DllName"].split('\\\\')[-1].split('.')[0]
|
||||||
|
theme = (themename, themeinfo["ColorName"], themeinfo["SizeName"])
|
||||||
|
return theme
|
||||||
|
|
||||||
|
def GetColorSettings():
|
||||||
|
""" Returns a dictionary of the set colors """
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Control Panel\\Colors")
|
||||||
|
|
||||||
|
def GetWindowMetrics():
|
||||||
|
""" Returns a dictionary of the WindowMetrics settings """
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics")
|
||||||
|
|
||||||
|
def GetDesktopSettings():
|
||||||
|
""" Returns a dictionary of the control panel \ Desktop settings """
|
||||||
|
return GetKeyValues("HKEY_CURRENT_USER\\Control Panel\\Desktop")
|
||||||
|
|
||||||
|
def SetWinePath(path):
|
||||||
|
""" Sets the winepath to path """
|
||||||
|
global winepath
|
||||||
|
winepath = path
|
||||||
|
|
||||||
|
def GetWinePath():
|
||||||
|
return winepath
|
||||||
|
|
||||||
|
def VerifyWineDrive(path = None):
|
||||||
|
""" Does a very basic check of if the given path is a valid fake windows installation
|
||||||
|
Returns False if there is no C: drive """
|
||||||
|
if not path:
|
||||||
|
path = self.default_winepath
|
||||||
|
|
||||||
|
return os.path.exists(path + "/dosdevices/c:/windows/profiles/" + os.environ['USER']) and \
|
||||||
|
os.path.exists(path + "/dosdevices/c:/windows/system32") and \
|
||||||
|
os.path.exists(path + "/system.reg") and os.path.exists(path + "/userdef.reg") and \
|
||||||
|
os.path.exists(path + "/user.reg")
|
@ -0,0 +1,489 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
###########################################################################
|
||||||
|
# winewrite.py - description #
|
||||||
|
# ------------------------------ #
|
||||||
|
# begin : Fri Mar 26 2004 #
|
||||||
|
# copyright : (C) 2006 by Yuriy Kozlov #
|
||||||
|
# email : yuriy.kozlov@gmail.com #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
# #
|
||||||
|
# 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. #
|
||||||
|
# #
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import wineread
|
||||||
|
import random
|
||||||
|
|
||||||
|
""" Provides functions for changings settings in wine """
|
||||||
|
|
||||||
|
def SetDriveMappings(drives):
|
||||||
|
""" Sets wine's drive settings """
|
||||||
|
driveletters = os.listdir(wineread.winepath + "/dosdevices")
|
||||||
|
set(driveletters)
|
||||||
|
|
||||||
|
for drive in drives[:26]:
|
||||||
|
letter = drive[1].lower()
|
||||||
|
defineDrive = False
|
||||||
|
if letter in driveletters: # The drive exists
|
||||||
|
if drive[2]: # The drive is in use
|
||||||
|
# Compare for changes
|
||||||
|
changed = False
|
||||||
|
# Check if the mapping changed
|
||||||
|
if drive[2] != os.readlink(wineread.winepath + "/dosdevices/" + letter):
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
# If it's changed, it will be recreated
|
||||||
|
if changed:
|
||||||
|
os.unlink(wineread.winepath + "/dosdevices/" + letter)
|
||||||
|
defineDrive = True
|
||||||
|
else:
|
||||||
|
# Remove the drive
|
||||||
|
os.unlink(wineread.winepath + "/dosdevices/" + letter)
|
||||||
|
else: # The drive doesn't exist
|
||||||
|
if drive[2]: # The drive is in use
|
||||||
|
# Create it
|
||||||
|
defineDrive = True
|
||||||
|
else:
|
||||||
|
# Do nothing
|
||||||
|
continue
|
||||||
|
|
||||||
|
if defineDrive:
|
||||||
|
os.symlink(drive[2], wineread.winepath + "/dosdevices/" + letter)
|
||||||
|
|
||||||
|
SetDriveTypes(drives[:26])
|
||||||
|
SetShellLinks(drives[26:])
|
||||||
|
|
||||||
|
def SetShellLinks(shelllinks):
|
||||||
|
existingshelllinks = os.listdir(wineread.winepath + "/dosdevices/c:/windows/profiles/" + os.environ['USER'])
|
||||||
|
set(existingshelllinks)
|
||||||
|
shellregistry = wineread.GetShellRegistry()
|
||||||
|
|
||||||
|
for link in shelllinks:
|
||||||
|
createLink = False
|
||||||
|
if link[1] in existingshelllinks: # The link exists
|
||||||
|
linkpath = wineread.winepath + "/dosdevices/c:/windows/profiles/" + os.environ['USER'] + "/" + link[1]
|
||||||
|
if link[2]: # The folder is mapped
|
||||||
|
# Compare for changes
|
||||||
|
changed = False
|
||||||
|
# Check if the mapping changed
|
||||||
|
if os.path.islink(linkpath) and link[2] != os.readlink(linkpath):
|
||||||
|
changed = True
|
||||||
|
elif not os.path.islink(linkpath) and link[2] != linkpath:
|
||||||
|
changed = True
|
||||||
|
elif link[5] != shellregistry.get(link[1], wineread.defaultwinfolderspath + "\\" + link[1]):
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
# If it's changed, it will be recreated
|
||||||
|
if changed:
|
||||||
|
if os.path.islink(linkpath):
|
||||||
|
os.unlink(linkpath)
|
||||||
|
else:
|
||||||
|
os.rename(linkpath,linkpath + "-backup" + str(random.randint(1,1000000)))
|
||||||
|
createLink = True
|
||||||
|
else:
|
||||||
|
# Remove the link
|
||||||
|
os.unlink(linkpath)
|
||||||
|
else: # The link doesn't exist
|
||||||
|
if link[2]: # The folder is mapped
|
||||||
|
# Create it
|
||||||
|
createLink = True
|
||||||
|
else:
|
||||||
|
# Do nothing
|
||||||
|
continue
|
||||||
|
|
||||||
|
if createLink:
|
||||||
|
os.symlink(link[2], wineread.winepath + "/dosdevices/c:/windows/profiles/" + os.environ['USER'] + "/" + link[1])
|
||||||
|
if shellregistry.has_key(link[1]):
|
||||||
|
SetShellRegistry(link)
|
||||||
|
|
||||||
|
|
||||||
|
def SetShellRegistry(link):
|
||||||
|
shellfile=open('.registryshellw.reg','w')
|
||||||
|
shellfile.write("REGEDIT4\n\n[HKEY_USERS\\.Default\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders]\n")
|
||||||
|
|
||||||
|
link[5] = link[5].replace("\\","\\\\")
|
||||||
|
shellfile.write('"' + link[1] + '"="' + link[5] + '"\n')
|
||||||
|
|
||||||
|
shellfile.write("\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders]\n")
|
||||||
|
|
||||||
|
link[5] = link[5].replace("\\","\\\\")
|
||||||
|
shellfile.write('"' + link[1] + '"="' + link[5] + '"\n')
|
||||||
|
|
||||||
|
shellfile.write("\n[HKEY_USERS\\.Default\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders]\n")
|
||||||
|
|
||||||
|
shellfile.write('"' + link[1] + '"="' + "%USERPROFILE%\\\\" + link[1] + '"')
|
||||||
|
|
||||||
|
shellfile.write("\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders]\n")
|
||||||
|
|
||||||
|
shellfile.write('"' + link[1] + '"="' + "%USERPROFILE%\\\\" + link[1] + '"')
|
||||||
|
shellfile.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registryshellw.reg")
|
||||||
|
os.remove(".registryshellw.reg")
|
||||||
|
|
||||||
|
def SetKeyValues(key,settings):
|
||||||
|
""" Sets all the values in key to those from the dictionary settings """
|
||||||
|
file=open('.registrykey.reg','w')
|
||||||
|
file.write("REGEDIT4\n\n[" + key + "]\n")
|
||||||
|
|
||||||
|
for setting in settings:
|
||||||
|
# Casting to a python string is necessary for older versions of pyQT
|
||||||
|
if str(settings[setting])[:4] == 'hex:':
|
||||||
|
file.write('"'+str(setting)+'"='+str(settings[setting])+'\n')
|
||||||
|
else:
|
||||||
|
file.write('"'+str(setting)+'"="'+str(settings[setting])+'"\n')
|
||||||
|
|
||||||
|
file.close()
|
||||||
|
os.system("wine regedit .registrykey.reg")
|
||||||
|
os.remove(".registrykey.reg")
|
||||||
|
|
||||||
|
def SetValue(key,value,data):
|
||||||
|
""" Sets the value in key to data """
|
||||||
|
file=open('.registryvalue.reg','w')
|
||||||
|
file.write("REGEDIT4\n\n[" + key + "]\n")
|
||||||
|
file.write('"' + value + '"="' + data + '"')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registryvalue.reg")
|
||||||
|
os.remove(".registryvalue.reg")
|
||||||
|
|
||||||
|
def SetDriveTypes(drives):
|
||||||
|
""" Sets the type for the drives in the registry """
|
||||||
|
drivesfile=open('.registrydrives.reg','w')
|
||||||
|
drivesfile.write("REGEDIT4\n\n[HKEY_LOCAL_MACHINE\\Software\\Wine\\Drives]\n")
|
||||||
|
|
||||||
|
for drive in drives:
|
||||||
|
mapping = drive[2]
|
||||||
|
if mapping:
|
||||||
|
drivesfile.write('"' + drive[1] + '"="' + drive[3] + '"\n')
|
||||||
|
|
||||||
|
drivesfile.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registrydrives.reg")
|
||||||
|
os.remove(".registrydrives.reg")
|
||||||
|
|
||||||
|
def SetAudioDriver(driver):
|
||||||
|
""" Sets the audio driver in the registry """
|
||||||
|
SetValue("HKEY_CURRENT_USER\\Software\\Wine\\Drivers","Audio",driver)
|
||||||
|
|
||||||
|
def SetDSoundSettings(settings, app = None):
|
||||||
|
""" Sets the settings for Direct Sound in the registry """
|
||||||
|
if not app:
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\DirectSound", settings)
|
||||||
|
else:
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\DirectSound", settings)
|
||||||
|
|
||||||
|
def SetWindowSettings(settings, app = None):
|
||||||
|
""" Sets the window settings in the registry """
|
||||||
|
windowsfile=open('.registrywindows.reg','w')
|
||||||
|
if not app:
|
||||||
|
windowsfile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine\\X11 Driver]\n")
|
||||||
|
else:
|
||||||
|
windowsfile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\X11 Driver]\n")
|
||||||
|
|
||||||
|
# There is a bug in wine that doesn't allow removing of registry entries from
|
||||||
|
# a reg file, so unchecking emulate desktop can't be implemented this way yet.
|
||||||
|
|
||||||
|
for setting in settings:
|
||||||
|
if settings[setting]:
|
||||||
|
windowsfile.write('"'+str(setting)+'"="'+str(settings[setting])+'"\n')
|
||||||
|
else:
|
||||||
|
# winecfg removes the value when the emulate desktop checkbox is unchecked
|
||||||
|
windowsfile.write('"'+str(setting)+'"=-\n')
|
||||||
|
|
||||||
|
windowsfile.close()
|
||||||
|
os.system("wine regedit .registrywindows.reg")
|
||||||
|
os.remove(".registrywindows.reg")
|
||||||
|
|
||||||
|
def SetD3DSettings(settings, app = None):
|
||||||
|
""" Sets the settings for Direct3D in the registry """
|
||||||
|
if not app:
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D", settings)
|
||||||
|
else:
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\Direct3D", settings)
|
||||||
|
|
||||||
|
def SetDesktopSettings(settings):
|
||||||
|
""" Sets the control panel \ Desktop settings in the registry """
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Control Panel\\Desktop", settings)
|
||||||
|
|
||||||
|
def SetWinVersion(version, app = None):
|
||||||
|
"""
|
||||||
|
Sets the windows version in the registry
|
||||||
|
Sample format for version:
|
||||||
|
( "winxp", "Windows XP", 5, 1, 0xA28, "VER_PLATFORM_WIN32_NT", "Service Pack 2", 2, 0, "WinNT")
|
||||||
|
"""
|
||||||
|
winverfile=open('.registrywinver.reg','w')
|
||||||
|
if not app:
|
||||||
|
winverfile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine]\n")
|
||||||
|
winverfile.write('"Version"="' + version[0] + '"\n')
|
||||||
|
|
||||||
|
Key9x = "\n[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion]\n"
|
||||||
|
KeyNT = "\n[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion]\n"
|
||||||
|
KeyProdNT = "\n[HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\ProductOptions]\n"
|
||||||
|
KeyWindNT = "\n[HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Windows\n"
|
||||||
|
KeyEnvNT = "\n[HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment]\n"
|
||||||
|
|
||||||
|
versionnumber9x = str(version[2]) + '.' + str(version[3]) + '.' + str(version[4])
|
||||||
|
versionnumberNT = str(version[2]) + '.' + str(version[3])
|
||||||
|
|
||||||
|
if version[5] == "VER_PLATFORM_WIN32_WINDOWS":
|
||||||
|
winverfile.write(Key9x + '"VersionNumber"="' + versionnumber9x + '"\n')
|
||||||
|
winverfile.write(Key9x + '"SubVersionNumber"="' + str(version[6]) + '"\n')
|
||||||
|
|
||||||
|
winverfile.write(KeyNT + '"CSDVersion"=-\n')
|
||||||
|
winverfile.write(KeyNT + '"CurrentVersion"=-\n')
|
||||||
|
winverfile.write(KeyNT + '"CurrentBuildNumber"=-\n')
|
||||||
|
winverfile.write(KeyProdNT + '"ProductType"=-\n')
|
||||||
|
winverfile.write(KeyWindNT + '"CSDVersion"=-\n')
|
||||||
|
winverfile.write(KeyEnvNT + '"OS"=-\n')
|
||||||
|
elif version[5] == "VER_PLATFORM_WIN32_NT":
|
||||||
|
winverfile.write(KeyNT + '"CurrentVersion"="' + versionnumberNT + '"\n')
|
||||||
|
winverfile.write(KeyNT + '"CSDVersion"="' + str(version[6]) + '"\n')
|
||||||
|
winverfile.write(KeyNT + '"CurrentBuildNumber"="' + str(version[4]) + '"\n')
|
||||||
|
winverfile.write(KeyProdNT + '"ProductType"="' + str(version[9]) + '"\n')
|
||||||
|
winverfile.write(KeyWindNT + '"CSDVersion"=dword:00000' + str(version[7]) + '00\n')
|
||||||
|
winverfile.write(KeyEnvNT + '"OS"="Windows_NT"\n')
|
||||||
|
|
||||||
|
winverfile.write(Key9x + '"VersionNumber"=-\n')
|
||||||
|
winverfile.write(Key9x + '"SubVersionNumber"=-\n')
|
||||||
|
elif version[5] == "VER_PLATFORM_WIN32s":
|
||||||
|
winverfile.write(Key9x + '"VersionNumber"=-\n')
|
||||||
|
winverfile.write(Key9x + '"SubVersionNumber"=-\n')
|
||||||
|
winverfile.write(KeyNT + '"CSDVersion"=-\n')
|
||||||
|
winverfile.write(KeyNT + '"CurrentVersion"=-\n')
|
||||||
|
winverfile.write(KeyNT + '"CurrentBuildNumber"=-\n')
|
||||||
|
winverfile.write(KeyProdNT + '"ProductType"=-\n')
|
||||||
|
winverfile.write(KeyWindNT + '"CSDVersion"=-\n')
|
||||||
|
winverfile.write(KeyEnvNT + '"OS"=-\n')
|
||||||
|
else:
|
||||||
|
winverfile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "]\n")
|
||||||
|
if version[0] == "global":
|
||||||
|
winverfile.write('"Version"=-\n')
|
||||||
|
else:
|
||||||
|
winverfile.write('"Version"="' + version[0] + '"\n')
|
||||||
|
|
||||||
|
winverfile.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registrywinver.reg")
|
||||||
|
os.remove(".registrywinver.reg")
|
||||||
|
|
||||||
|
def SetApps(apps):
|
||||||
|
""" Adds and removes keys for app specific settings for apps """
|
||||||
|
oldapps = wineread.GetApps()
|
||||||
|
newapps = []
|
||||||
|
|
||||||
|
# Add new app keys
|
||||||
|
for app in apps:
|
||||||
|
if app not in oldapps:
|
||||||
|
newapps.append(app)
|
||||||
|
AddApps(newapps)
|
||||||
|
|
||||||
|
# Remove removed app keys
|
||||||
|
for app in oldapps:
|
||||||
|
if app not in apps:
|
||||||
|
RemoveApp(app)
|
||||||
|
|
||||||
|
def RemoveApp(app):
|
||||||
|
""" Removes the key for settings for app """
|
||||||
|
os.system("wine regedit /D HKEY_USERS\\\\S-1-5-4\\\\Software\\\\Wine\\\\AppDefaults\\\\" +\
|
||||||
|
app)
|
||||||
|
|
||||||
|
def AddApps(apps):
|
||||||
|
""" Adds a key for app """
|
||||||
|
appsfile=open('.registryapps.reg','w')
|
||||||
|
appsfile.write("REGEDIT4\n\n")
|
||||||
|
|
||||||
|
for app in apps:
|
||||||
|
appsfile.write('[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\' +\
|
||||||
|
app + ']\n')
|
||||||
|
|
||||||
|
appsfile.close()
|
||||||
|
os.system("wine regedit .registryapps.reg")
|
||||||
|
os.remove(".registryapps.reg")
|
||||||
|
|
||||||
|
def SetDllOverrides(overrides, app = None):
|
||||||
|
""" Sets the dll override settings in the registry """
|
||||||
|
dllfile=open('.registrydll.reg','w')
|
||||||
|
if not app:
|
||||||
|
dllfile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine\\DllOverrides]\n")
|
||||||
|
else:
|
||||||
|
dllfile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\" +\
|
||||||
|
app + "\\DllOverrides]\n")
|
||||||
|
|
||||||
|
origoverrides = wineread.GetDllOverrides(app)
|
||||||
|
|
||||||
|
for dll in overrides.keys():
|
||||||
|
dllfile.write('"'+str(dll)+'"="'+str(overrides[dll])+'"\n')
|
||||||
|
|
||||||
|
for dll in origoverrides.keys():
|
||||||
|
if dll not in overrides:
|
||||||
|
dllfile.write('"'+str(dll)+'"=-\n')
|
||||||
|
|
||||||
|
dllfile.close()
|
||||||
|
os.system("wine regedit .registrydll.reg")
|
||||||
|
os.remove(".registrydll.reg")
|
||||||
|
|
||||||
|
def SetDefaultBrowser(browser):
|
||||||
|
"""
|
||||||
|
Sets the default browser to browser
|
||||||
|
Doesn't set windows browsers, leaves it for the program to do.
|
||||||
|
"""
|
||||||
|
file=open('.registrybrowser.reg','w')
|
||||||
|
file.write("REGEDIT4\n")
|
||||||
|
|
||||||
|
if browser[1] == ':':
|
||||||
|
for format in wineread.default_browser_formats:
|
||||||
|
file.write("\n[HKEY_LOCAL_MACHINE\\Software\\Classes\\" +\
|
||||||
|
format + "\\shell\\open\\command]\n")
|
||||||
|
file.write('@="' + browser + '"\n')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registrybrowser.reg")
|
||||||
|
os.remove(".registrybrowser.reg")
|
||||||
|
else: # winebrowser
|
||||||
|
for format in wineread.default_browser_formats:
|
||||||
|
file.write("\n[HKEY_LOCAL_MACHINE\\Software\\Classes\\" +\
|
||||||
|
format + "\\shell\\open\\command]\n")
|
||||||
|
file.write('@="winebrowser"\n')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registrybrowser.reg")
|
||||||
|
os.remove(".registrybrowser.reg")
|
||||||
|
|
||||||
|
SetFirstBrowser(browser)
|
||||||
|
|
||||||
|
def SetDefaultMailer(mailer):
|
||||||
|
"""
|
||||||
|
Sets the default mailer to mailer
|
||||||
|
Doesn't set windows mailers, leaves it for the program to do.
|
||||||
|
"""
|
||||||
|
file=open('.registrymailer.reg','w')
|
||||||
|
file.write("REGEDIT4\n")
|
||||||
|
|
||||||
|
if mailer[1] == ':':
|
||||||
|
for format in wineread.default_mailer_formats:
|
||||||
|
file.write("\n[HKEY_LOCAL_MACHINE\\Software\\Classes\\" +\
|
||||||
|
format + "\\shell\\open\\command]\n")
|
||||||
|
file.write('@="' + mailer + '"\n')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registrymailer.reg")
|
||||||
|
os.remove(".registrymailer.reg")
|
||||||
|
else: # winebrowser
|
||||||
|
for format in wineread.default_mailer_formats:
|
||||||
|
file.write("\n[HKEY_LOCAL_MACHINE\\Software\\Classes\\" +\
|
||||||
|
format + "\\shell\\open\\command]\n")
|
||||||
|
file.write('@="winebrowser %1"\n')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
os.system("wine regedit .registrymailer.reg")
|
||||||
|
os.remove(".registrymailer.reg")
|
||||||
|
|
||||||
|
SetFirstMailer(mailer)
|
||||||
|
|
||||||
|
def SetFirstBrowser(browser):
|
||||||
|
""" Sets the first in the list of browsers for winebrowser to use to browser """
|
||||||
|
originalbrowserlist = wineread.GetNativeBrowserList()
|
||||||
|
|
||||||
|
if browser in originalbrowserlist:
|
||||||
|
originalbrowserlist.remove(browser)
|
||||||
|
browserlist = [browser] + originalbrowserlist
|
||||||
|
|
||||||
|
browserlist = str(browserlist).strip('[]')
|
||||||
|
browserlist = browserlist.replace("'","")
|
||||||
|
browserlist = browserlist.replace(", ",",")
|
||||||
|
|
||||||
|
SetValue("HKEY_CURRENT_USER\\Software\\Wine\\WineBrowser","Browsers",browserlist)
|
||||||
|
|
||||||
|
def SetFirstMailer(mailer):
|
||||||
|
""" Sets the first in the list of mailers for winebrowser to use to mailer """
|
||||||
|
originalmailerlist = wineread.GetNativeMailerList()
|
||||||
|
|
||||||
|
if mailer in originalmailerlist:
|
||||||
|
originalmailerlist.remove(mailer)
|
||||||
|
mailerlist = [mailer] + originalmailerlist
|
||||||
|
|
||||||
|
mailerlist = str(mailerlist).strip('[]')
|
||||||
|
mailerlist = mailerlist.replace("'","")
|
||||||
|
mailerlist = mailerlist.replace(", ",",")
|
||||||
|
|
||||||
|
SetValue("HKEY_CURRENT_USER\\Software\\Wine\\WineBrowser","Mailers",mailerlist)
|
||||||
|
|
||||||
|
def CreateWineDrive(path = None):
|
||||||
|
"""
|
||||||
|
Creates a fake windows installation in path
|
||||||
|
"""
|
||||||
|
if not path:
|
||||||
|
path = wineread.default_winepath
|
||||||
|
|
||||||
|
os.system("WINEPREFIX=" + path + " wineprefixcreate --wait")
|
||||||
|
|
||||||
|
# ----- Theming -----
|
||||||
|
|
||||||
|
def SetCurrentTheme(theme):
|
||||||
|
"""
|
||||||
|
Sets the current theme
|
||||||
|
theme = (theme,color,size), None if none is set
|
||||||
|
"""
|
||||||
|
if not theme:
|
||||||
|
theme = ("", "", "")
|
||||||
|
|
||||||
|
themesettings = {"ColorName":theme[1],
|
||||||
|
"SizeName":theme[2],
|
||||||
|
"ThemeActive":"1"}
|
||||||
|
|
||||||
|
if not theme[0]:
|
||||||
|
themesettings["DllName"] = ""
|
||||||
|
themesettings["ThemeActive"] = "0"
|
||||||
|
else:
|
||||||
|
themesettings["DllName"] = "C:\\\\windows\\\\Resources\\\\Themes\\\\" +\
|
||||||
|
theme[0] + "\\\\" + theme[0] +".msstyles"
|
||||||
|
|
||||||
|
themefile=open('.registrytheme.reg','w')
|
||||||
|
themefile.write("REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager]\n")
|
||||||
|
for setting in themesettings:
|
||||||
|
if themesettings[setting]:
|
||||||
|
themefile.write('"'+str(setting)+'"="'+str(themesettings[setting])+'"\n')
|
||||||
|
else:
|
||||||
|
themefile.write('"'+str(setting)+'"=-\n')
|
||||||
|
|
||||||
|
themefile.close()
|
||||||
|
os.system("wine regedit .registrytheme.reg")
|
||||||
|
os.remove(".registrytheme.reg")
|
||||||
|
|
||||||
|
def SetColorSettings(colors):
|
||||||
|
""" Takes a dictionary of color settings and sets them in the registry """
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Control Panel\\Colors",colors)
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager\\Control Panel\\Colors",colors)
|
||||||
|
|
||||||
|
def SetWindowMetrics(metrics):
|
||||||
|
"""
|
||||||
|
Takes a dictionary of WindowMetrics settings and sets them in the registry
|
||||||
|
"""
|
||||||
|
SetKeyValues("HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics",metrics)
|
||||||
|
|
||||||
|
ports_translation = {"lp":"lpt","ttyS":"com"}
|
||||||
|
|
||||||
|
def CreatePorts(ports = None):
|
||||||
|
"""
|
||||||
|
Creates links to ports in dosdevices
|
||||||
|
"""
|
||||||
|
if not ports:
|
||||||
|
# Find ports in /dev
|
||||||
|
ports = ["lp0"]
|
||||||
|
|
||||||
|
for port in ports:
|
||||||
|
winport = ports_translation[port.rstrip("012345678")] +\
|
||||||
|
str(int(port.lstrip("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) + 1)
|
||||||
|
os.symlink("/dev/" + port, wineread.winepath + "/dosdevices/" + winport)
|
||||||
|
|