[drwright] Reimport
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [drwright] Reimport
- Date: Sat, 20 Nov 2010 22:14:12 +0000 (UTC)
commit 691667c00c88e614fa47c92df8c3ae38f87cd868
Author: Christian Persch <chpe gnome org>
Date: Thu Nov 18 18:31:01 2010 +0100
Reimport
Import the typing-break code from gnome-settings-daemon and
gnome-control-centre.
ChangeLog | 471 --------------
Makefile.am | 43 +-
NEWS | 15 +-
README | 1 -
autogen.sh | 164 +-----
configure.in | 231 ++++----
data/.cvsignore | 2 -
data/Makefile.am | 1 -
data/glade/.cvsignore | 3 -
data/glade/Makefile.am | 4 -
data/glade/drw-preferences.glade | 601 ------------------
data/images/.cvsignore | 2 -
data/images/Makefile.am | 4 -
data/images/bar-disabled.png | Bin 473 -> 0 bytes
data/images/bar-green.png | Bin 253 -> 0 bytes
data/images/bar-red.png | Bin 258 -> 0 bytes
data/images/bar.png | Bin 331 -> 0 bytes
data/images/stop.png | Bin 2248 -> 0 bytes
drwright.spec.in | 70 ---
git.mk | 196 ++++++
po/POTFILES.in | 4 +-
src/.cvsignore | 9 -
src/Makefile.am | 137 ++++-
src/bar-disabled.png | Bin 0 -> 496 bytes
src/bar-green.png | Bin 0 -> 286 bytes
src/bar-red.png | Bin 0 -> 277 bytes
src/bar.png | Bin 0 -> 362 bytes
src/dbus.c | 111 ----
src/dbus.h | 32 -
src/drw-break-window.c | 513 +++++++++-------
src/drw-break-window.h | 15 +-
src/drw-monitor.c | 37 +-
src/drw-monitor.h | 2 +-
src/drw-preferences.c | 307 ----------
src/drw-selection.c | 28 +-
src/drw-selection.h | 2 +-
src/{drw-preferences.h => drw-timer.c} | 38 +-
src/drw-timer.h | 42 ++
src/drw-utils.c | 155 ++++--
src/drw-utils.h | 2 +
src/drwright.c | 943 +++++++++++++----------------
src/drwright.h | 2 +-
src/drwright.schemas | 108 ----
src/drwright.schemas.in | 28 +
src/eggtrayicon.c | 341 -----------
src/eggtrayicon.h | 76 ---
src/gnome-settings-profile.h | 53 ++
src/gsd-typing-break-manager.c | 339 +++++++++++
src/gsd-typing-break-manager.h | 57 ++
src/gsd-typing-break-plugin.c | 108 ++++
src/gsd-typing-break-plugin.h | 59 ++
src/main.c | 147 ++---
{data/images => src}/ocean-stripes.png | Bin 274 -> 274 bytes
{data/images => src}/stock_stop.png | Bin 1451 -> 1451 bytes
src/typing-break.gnome-settings-plugin.in | 8 +
src/typing-monitor.png | Bin 0 -> 3292 bytes
src/typing-monitor.svg | 336 ++++++++++
57 files changed, 2447 insertions(+), 3400 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9060963..e69de29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,471 +0,0 @@
-2007-10-14 Yannig Marchegay <yannig marchegay org>
-
- * configure.in: Added 'oc' to ALL_LINGUAS.
-
-2007-02-24 Matic Zgur <mr zgur gmail com>
-
- * configure.in: Added 'sl' to ALL_LINGUAS.
-
-2007-01-24 Pema Geyleg <pema geyleg gmail com>
-
- * configure.in: Added 'dz' to ALL_LINGUAS.
-
-2006-04-18 Kjartan Maraas <kmaraas gnome org>
-
- * configure.in: Rename no to nb
- * po/nb.po: Add
- * po/no.po: Remove
-
-2006-01-24 Clytie Siddall <clytie riverland net au>
-
- * configure.in Added vi in ALL_LINGUAS line.
-
- 2006-01-07 Ilkka Tuohela <hile iki fi>
-
- * configure.in: Added fi to ALL_LINGUAS.
-
-2005-11-03 Frederic Crozat <fcrozat mandriva com>
-
- * configure.in:
- * src/dbus.c: (dbus_init_service):
- Update to use dbus 0.50 API.
-
-2005-07-17 Pawan Chitrakar <pawan nplinux org>
-
- * configure.in: Added ne in ALL_LINGUAS
-
-2005-04-01 Steve Murphy <murf e-tools com>
-
- * configure.in: Added "rw" to ALL_LINGUAS.
-
-2004-12-06 Pablo Saratxaga <pablo mandrakesoft com>
-
- * configure.in: Added Walloon (wa) to ALL_LINGUAS.
-
-2004-09-28 Richard Hult <richard imendio com>
-
- Release 0.18.
-
- * configure.in: Bump to 0.18 and make a release for non-GNOME
- users.
-
- * Makefile.am: Fix distcheck.
-
- * src/dbus.c: Update for dbus 0.22.
-
-2004-08-11 Ankit Patel <ankit redhat com>
-
- * configure.in: Added "gu" to ALL_LINGUAS.
-
-2004-04-30 Adam Weinberger <adamw gnome org>
-
- * configure.in: Added en_CA to ALL_LINGUAS.
-
-2004-04-09 Samúel Jón Gunnarsson <sammi techattack nu>
-
- * configure.in: Added "is" to All_LINGUAS
-
-2004-04-06 Yuriy Syrota <rasta cvs gnome org>
-
- * configure.in: Added "uk" (Ukrainian) to ALL_LINGUAS
-
-2004-04-01 Gareth Owen <gowen72 yahoo com>
-
- * configure.in: Added en_GB to ALL_LINGUAS
-
-2004-03-21 Richard Hult <richard imendio com>
-
- * configure.in:
- * src/Makefile.in: Try improving the Xss detection.
-
-2004-03-20 Richard Hult <richard imendio com>
-
- * src/drw-monitor.c (drw_monitor_timeout): Raise the threshold for
- activity, makes totem not trigger typing breaks.
-
-2004-02-28 Richard Hult <richard imendio com>
-
- * src/drw-monitor.c: Remove old crufty includes. Fixes bug
- #135300.
-
-2004-02-17 Richard Hult <richard imendio com>
-
- * src/drwright.c:
- * src/drw-break-window.c: Merge from typing-monitor.
-
-2004-02-02 Richard Hult <richard imendio com>
-
- * configure.in: Add auto option for dbus and default to that.
-
- * src/drw-break-window.c (drw_break_window_init): Add mnemonic to
- postpone button.
-
- * src/drwright.c: Grab the keyboard to make the mnemonic work.
-
-2004-02-01 Robert Sedak <robert sedak sk htnet hr>
-
- * configure.in: Added "hr" (Croatian) to ALL_LINGUAS.
-
-2004-01-13 Laurent Dhima <laurenti alblinux net>
-
- * configure.in: Added "sq" to ALL_LINGUAS.
-
-2004-01-04 Richard Hult <richard imendio com>
-
- * autogen.sh:
- * .cvsignore:
- * Makefile.am: intltool-foo.
-
- * configure.in:
- * src/Makefile.am:
- * src/drw-break-window.c:
- * src/drwright.c: Merge from typing-monitor and add some
- experimental d-bus stuff.
-
-2003-12-03 Sanlig Badral <badral openmn org>
-
- * configure.in: Added "mn" to ALL_LINGUAS.
-
-2003-10-05 Marcel Telka <marcel telka sk>
-
- * configure.in (ALL_LINGUAS): Added sk.
-
-2003-09-01 Metin Amiroff <metin karegen com>
-
- configure.in: Added "az" in ALL_LINGUAS.
-
-2003-08-28 Hasbullah Bin Pit <sebol ikhlas com>
-
- * configure.in: Added 'ms' (Malay) to ALL_LINGUAS.
-
-2003-08-24 Kjartan Maraas <kmaraas gnome org>
-
- * configure.in: Added "no" to ALL_LINGUAS.
-
-2003-07-20 Danilo Å egan <dsegan gmx net>
-
- * configure.in: Added "sr Latn" to ALL_LINGUAS.
-
-2003-06-29 Richard Hult <richard imendio com>
-
- * src/*.c: Include gnome-i18n.h instead of drw-intl.h. Use macro
- for gconf path instead of hard coding it throughout the code.
-
- * src/drwright.c: Tweak the popup menu a bit, fix the tooltip, and
- a few other small fixes.
-
-2003-06-26 Richard Hult <richard imendio com>
-
- * src/drwright.c (popup_about_cb): Remove cool (according to Ross)
- weak ref and add boring gtk_widget_destroyed to get rid of strict
- aliasing warning with gcc 3.3.
-
-2003-06-24 Richard Hult <richard imendio com>
-
- * drwright.spec.in: Update description and release.
-
-2003-06-24 Richard Hult <richard imendio com>
-
- * configure.in: Bump version.
-
- * src/drwright.schemas: Add allow_postpone key.
-
- * data/glade/drw-preferences.glade:
- * src/drw-break-window.c: Clean up some unlock/postpone confusion.
-
-2003-06-17 Richard Hult <richard imendio com>
-
- * src/drw-break-window.c (unlock_clicked_cb): Disable unlock
- phrase for now.
-
-2003-06-16 Richard Hult <richard imendio com>
-
- * src/drwright.c (popup_quit_cb): Don't use Yes/No buttons.
-
-2003-06-13 Richard Hult <richard imendio com>
-
- * *: Update contact information.
-
-2003-05-27 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (popup_break_cb): Add "take a break" feature.
- (drwright_new, gconf_notify_cb): Make take a break item sensitive
- only when drwright is enabled.
-
-2003-05-24 Richard Hult <rhult codefactory se>
-
- * src/disclosure-widget.[ch]: Remove.
-
- * src/drwright.c (popup_menu_cb): Popup context menu on
- shift-f10. Fixes part of bug #112474.
- (icon_event_box_expose_event_cb): Draw focus rectangle.
-
- * data/images: Use colors from the HIG palette and crop the icons
- a bit.
-
-2003-05-22 Richard Hult <rhult codefactory se>
-
- * Makefile.am:
- * data/glade/drw-preferences.glade:
- * src/Makefile.am:
- * src/drw-break-window.c: (drw_break_window_class_init),
- (drw_break_window_init), (clock_timeout_cb),
- (unlock_entry_activate_cb), (unlock_clicked_cb),
- (get_layout_location), (label_expose_event_cb):
- * src/drw-preferences.c: (gconf_notify_cb), (drw_preferences_new):
- * src/drwright.c: (setup_debug_values), (update_icon),
- (blink_timeout_cb), (start_blinking), (stop_blinking),
- (maybe_change_state), (update_tooltip), (gconf_notify_cb),
- (break_window_done_cb), (break_window_postpone_cb), (drwright_new):
-
- Lots of changes, remove unlock feature and replace it with a
- postpone feature, and remove all the crap that was a workaround
- for not having that before. Always update the icon and tooltip
- after postponing, or after a break is finished.
-
-2003-05-19 Richard Hult <rhult codefactory se>
-
- * Makefile.am (SUBDIRS): Add data.
-
-2003-05-24 Duarte Loreto <happyguy_pt hotmail com>
-
- * configure.in: Added Portuguese (pt) to ALL_LINGUAS.
-
-2003-05-21 Miloslav Trmac <mitr volny cz>
-
- * configure.in: Added "cs" to ALL_LINGUAS.
-
-2003-05-20 Abel Cheung <maddog linux org hk>
-
- * configure.in: Added "bg" "cy" "ja" "pt_BR" "sr" "zh_CN" to ALL_LINGUAS.
-
-2003-04-17 Richard Hult <rhult codefactory se>
-
- * Release 0.16.
-
-2003-03-17 Richard Hult <rhult codefactory se>
-
- * src/main.c (session_save): Fix stupid memory bug.
-
- * src/drwright.c (popup_quit_cb): Destroy the dialog immediately,
- and remove from session.
- (popup_about_cb): Don't translate the copyright string and the
- program name.
-
- * src/main.c (main): Set priority and restart style.
-
- * src/drwright.c: Change quit menu item to "Remove Icon".
-
- * src/main.c (main): Add -n, to skip notification area checking.
-
- * configure.in (GETTEXT_PACKAGE): Add translations.
-
-2003-03-05 Richard Hult <rhult codefactory se>
-
- * Version marker.
-
-2003-02-28 Richard Hult <rhult codefactory se>
-
- * configure.in: Add new translations and bump version to 0.15.
-
-2003-02-26 Richard Hult <rhult codefactory se>
-
- * src/main.c (have_tray): Add.
- (main): Check if we have a tray, otherwise show dialog.
-
-2003-01-26 Richard Hult <rhult codefactory se>
-
- * src/drw-break-window.c (unlock_entry_key_press_event_cb): Remove
- the source if the unlock entry is cancelled.
-
-2003-01-20 Richard Hult <rhult codefactory se>
-
- * src/main.c (session_save): Doh. Do it right this time.
-
- * src/drw-break-window.c (drw_break_window_init): Remove obsolete
- code.
- (clock_timeout_cb): Destroy the break window when the break is
- over.
-
-2003-01-19 Richard Hult <rhult codefactory se>
-
- * src/drw-break-window.c (label_expose_event_cb)
- (label_size_request_cb, get_layout_location)
- (drw_break_window_init): Add drop shadow to the break labels,
- borrowed and modified from eel.
-
-2003-01-18 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (blink_timeout_cb): Tweak the blinking speed a
- bit, start out slower and stop incresing the speed a bit sooner.
- (maybe_change_state): Change the suspend detection to not restart
- the countdown unless we get a longer delay than the warning
- time.
-
- * src/drw-preferences.c (window_destroy_cb): Plug leak.
- (drw_preferences_new): Dup the string we get from gconf.
-
- * configure.in: Bump.
-
- * src/drwright.c (drwright_new): Update the tooltip every 15
- seconds, instead of 30.
- (maybe_change_state): Update tooltip when we get to start state.
-
- * src/drw-break-window.c (unlock_clicked_cb):
- (grab_on_window, unlock_entry_activate_cb): Implement unlocking.
- (unlock_entry_changed_cb, unlock_cancel_cb): Hide the entry (and
- remove the grab) after a time of inactivity.
- (unlock_clicked_cb): Make the unlock button unlock if pressed
- while the entry is visible and the right phrase is entered.
- (unlock_entry_key_press_event_cb): Hide the entry on escape.
-
-2003-01-17 Richard Hult <rhult codefactory se>
-
- * src/Makefile.am: Add -export-dynamic so custom widgets work with
- libglade.
-
- * src/drw-preferences.c (unlock_phrase_update)
- (allow_unlock_update): Add unlock stuff.
-
- * src/drwright.schemas: Add unlock keys.
-
- * src/drw-preferences.c (drw_preferences_new): Add unlocking
- widgets, and move warning method to advanced section and put a
- disclosure widget there to hide it.
-
- * src/drwright.c (maybe_change_state): If we get 10 seconds
- between our 0.5 second callback, we probably were suspended so
- start over. Should make DrWright happier with APM.
-
- * src/drw-break-window.c (unlock_clicked_cb): Implement, destroy
- the window.
-
- * src/drwright.c (popup_quit_cb): Fix typo spotted by Ross Burton.
- (break_window_destroy_cb): Handle the break window being
- destroyed by ending the break.
-
- * src/drw-break-window.c (drw_break_window_init): Don't need to
- show the window here, now that we don't grab. Don't listen for key
- presses. Get unlock preference, and show unlock button if enabled.
-
- * drwright.desktop.in (Terminal): Remove the icon, I don't have
- one.
-
-2003-01-14 Anders Carlsson <andersca gnu org>
-
- * configure.in (ALL_LINGUAS): Add Danish translation
- by Kim Schultz.
-
-2003-01-10 Richard Hult <rhult codefactory se>
-
- * Release 0.14.
-
- * src/drw-break-window.c (drw_break_window_init): Don't grab the
- keyboard, makes XScreensaver complain.
-
-2002-11-29 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (update_tooltip): Don't show a time if we're
- disabled.
-
-2002-11-26 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (init_tray_icon): Handle destruction a bit
- better. Should work for panel crashing and tray removal now.
-
-2002-11-23 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (init_tray_icon): Refactor tray icon creation.
- (icon_destroy_event_cb): Create tray icon if the tray is
- destroyed.
-
-2002-11-22 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (stop_blinking): Fix hiding the warn dialog.
- (update_warning_dialog): Don't put 0:00 in the label.
-
-2002-11-21 Richard Hult <rhult codefactory se>
-
- * src/drwright.c (show_warning_dialog): Hide the dialog when the
- button is clicked.
-
-2002-11-20 Richard Hult <rhult codefactory se>
-
- * src/drw-preferences.c: Implement warning window preference.
-
- * src/drwright.c (popup_about_cb): Clean up.
- (gconf_notify_cb): Don't restart unless we change time
- preferences. Implement warning window all over the place.
-
- * src/drw-break-window.c (clock_timeout_cb): Rip out the markup
- from the translatable part of the string.
-
- * src/drwright.schemas: Remove break text (ye ye you shouldn't
- remove keys, but I don't care ;).
-
- * src/drw-break-window.c (drw_break_window_init): Don't get the
- break text from GConf, that's too silly.
-
- * src/drw-preferences.glade: Remove the frame.
-
- * configure.in (GETTEXT_PACKAGE): Add Italian translation from
- Luca Ferretti <elle uca genie it>.
-
- * src/drwright.c: Apply a slightly modified patch from Luc
- Roobrouck <luc roobrouck pandora be> to show a tooltip with the
- time until break.
-
- * configure.in (GETTEXT_PACKAGE): Add Dutch translation from Luc
- Roobrouck <luc roobrouck pandora be>
-
-2002-11-09 Richard Hult <rhult codefactory se>
-
- * src/drw-preferences.c: Remove enabled setting.
-
- * src/drwright.c (icon_destroy_cb, drwright_new,
- popup_enabled_cb): Quit if our window is destroyed. Use stock
- item for About. Remove "Break now" and add "Enabled" toggle item.
-
-2002-10-30 Richard Hult <rhult codefactory se>
-
- * configure.in: Require libgnomeui. Bump version.
-
- * src/main.c (main): Connect to session manager. Initialize GNOME
- stuff. Use Owens selection voodoo to get only one instance running
- at a time.
-
-2002-10-29 Richard Hult <rhult codefactory se>
-
- * src/drwright.schemas: Change defaults to 60/5/5.
-
- * src/drwright.c (popup_break_cb): Add "take a break" menu item.
-
- * src/drwright-preferences.glade: Fix up, patch from Jonathan.
-
- * src/*.png: Make the bar a bit wider.
-
-2002-10-09 Richard Hult <rhult codefactory se>
-
- * src/drwright.c: Fix up about box.
-
- * po/sv.po: Update.
-
- * drwright.spec.in:
- * configure.in: Release 0.12.
-
-2002-10-08 Anders Carlsson <andersca gnu org>
-
- * src/Makefile.am:
- * src/drw-monitor.c: (drw_monitor_class_init), (drw_monitor_init),
- (drw_monitor_finalize), (drw_monitor_timeout), (drw_monitor_setup):
- * src/drw-monitor.h:
- * src/drw-preferences.c: (enabled_update), (gconf_notify_cb),
- (drw_preferences_new):
- * src/drw-preferences.glade:
- * src/drwright.c: (gconf_notify_cb), (drwright_new):
- Use Xss for determining idle time + general cleanup.
-
-2002-07-16 Richard Hult <rhult codefactory se>
-
- * Release 0.8.
-
diff --git a/Makefile.am b/Makefile.am
index fbbab9b..86ade4e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,11 +1,8 @@
-SUBDIRS = src po data
+SUBDIRS = src po
-desktop_in_files=drwright.desktop.in
-desktop_files=$(desktop_in_files:.desktop.in=.desktop)
- INTLTOOL_DESKTOP_RULE@
+ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
-Applicationsdir = $(datadir)/applications
-Applications_DATA = $(desktop_files)
+DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install
INTLTOOL = \
intltool-extract.in \
@@ -15,9 +12,6 @@ INTLTOOL = \
EXTRA_DIST = \
AUTHORS \
ChangeLog \
- README \
- drwright.spec \
- drwright.spec.in \
$(INTLTOOL) \
$(desktop_in_files) \
$(desktop_files) \
@@ -30,4 +24,33 @@ DISTCLEANFILES = \
intltool-update \
$(desktop_files)
-DISTCHECK_CONFIGURE_FLAGS = --enable-dbus=no
+MAINTAINERCLEANFILES = \
+ $(srcdir)/INSTALL \
+ $(srcdir)/aclocal.m4 \
+ $(srcdir)/autoscan.log \
+ $(srcdir)/compile \
+ $(srcdir)/config.guess \
+ $(srcdir)/config.h.in \
+ $(srcdir)/config.sub \
+ $(srcdir)/configure.scan \
+ $(srcdir)/depcomp \
+ $(srcdir)/install-sh \
+ $(srcdir)/ltmain.sh \
+ $(srcdir)/missing \
+ $(srcdir)/mkinstalldirs \
+ $(srcdir)/omf.make \
+ $(srcdir)/xmldocs.make \
+ $(srcdir)/gnome-doc-utils.make \
+ `find "$(srcdir)" -type f -name Makefile.in -print` \
+ $(NULL)
+
+# Build ChangeLog from GIT history
+ChangeLog:
+ $(AM_V_GEN) if test -d $(top_srcdir)/.git; then \
+ GIT_DIR="$(top_srcdir)/.git" git log --stat > $@; \
+ fi
+
+dist: ChangeLog
+
+.PHONY: ChangeLog
+-include $(top_srcdir)/git.mk
diff --git a/NEWS b/NEWS
index 4c902a0..332dff8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,13 +1,4 @@
-DrWright 0.16
-=============
+Typing Break 2.33.0
+===================
-* Bug fixes
-* Updated translations
-
-DrWright 0.15
-=============
-
-* Unlocking feature
-* Cleaned up preferences dialog
-* Handle suspend, e.g. power saving
-* Updated translations (da, de, zh_TW, es)
+Ressurrected!
diff --git a/autogen.sh b/autogen.sh
index 5a178aa..fb712cd 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,167 +1,17 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
-: ${AUTOCONF=autoconf}
-: ${AUTOHEADER=autoheader}
-: ${AUTOMAKE=automake}
-: ${ACLOCAL=aclocal}
-: ${LIBTOOLIZE=libtoolize}
-: ${INTLTOOLIZE=intltoolize}
-: ${LIBTOOL=libtool}
-
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
-ORIGDIR=`pwd`
-cd $srcdir
-PROJECT=drwright
-TEST_TYPE=-f
-FILE=src/drwright.c
-CONFIGURE=configure.in
-
-DIE=0
-
-# if GNOME2_DIR set, modify ACLOCAL_FLAGS ...
-if [ -n "$GNOME2_DIR" ]; then
- ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS"
-fi
-
-($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have autoconf installed to compile $PROJECT."
- echo "Download the appropriate package for your distribution,"
- echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
- DIE=1
-}
-
-(grep "^AC_PROG_INTLTOOL" $srcdir/configure.in >/dev/null) && {
- ($INTLTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have \`intltoolize' installed to compile $PROJECT."
- echo "Get ftp://ftp.gnome.org/pub/GNOME/stable/sources/intltool/intltool-0.22.tar.gz"
- echo "(or a newer version if it is available)"
- DIE=1
- }
-}
-
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have automake installed to compile $PROJECT."
- echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz"
- echo "(or a newer version if it is available)"
- DIE=1
-}
-
-(grep "^AM_PROG_LIBTOOL" configure.in >/dev/null) && {
- ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "**Error**: You must have \`libtool' installed to compile $PROJECT."
- echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
- echo "(or a newer version if it is available)"
- DIE=1
- }
-}
-
-if grep "^AM_[A-Z0-9_]\{1,\}_GETTEXT" "$CONFIGURE" >/dev/null; then
- if grep "sed.*POTFILES" "$CONFIGURE" >/dev/null; then
- GETTEXTIZE=""
- else
- if grep "^AM_GLIB_GNU_GETTEXT" "$CONFIGURE" >/dev/null; then
- GETTEXTIZE="glib-gettextize"
- GETTEXTIZE_URL="ftp://ftp.gtk.org/pub/gtk/v2.0/glib-2.0.0.tar.gz"
- else
- GETTEXTIZE="gettextize"
- GETTEXTIZE_URL="ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
- fi
-
- $GETTEXTIZE --version < /dev/null > /dev/null 2>&1
- if test $? -ne 0; then
- echo
- echo "**Error**: You must have \`$GETTEXTIZE' installed to compile $PKG_NAME."
- echo "Get $GETTEXTIZE_URL"
- echo "(or a newer version if it is available)"
- DIE=1
- fi
- fi
-fi
+REQUIRED_AUTOMAKE_VERSION=1.9
+REQUIRED_INTLTOOL_VERSION=0.40.4
-if test "$DIE" -eq 1; then
- exit 1
-fi
+PKG_NAME="typing-break"
-test $TEST_TYPE $FILE || {
- echo "You must run this script in the top-level $PROJECT directory"
- exit 1
+which gnome-autogen.sh || {
+ echo "You need to install gnome-common from the GNOME SVN"
+ exit 1
}
-if test -z "$*"; then
- echo "I am going to run ./configure with no arguments - if you wish "
- echo "to pass any to it, please specify them on the $0 command line."
-fi
-
-case $CC in
-*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
-esac
-
-for coin in .
-do
- dr=`dirname $coin`
- if test -f $dr/NO-AUTO-GEN; then
- echo skipping $dr -- flagged as no auto-gen
- else
- echo processing $dr
- macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
- ( cd $dr
- aclocalinclude="$ACLOCAL_FLAGS"
- for k in $macrodirs; do
- if test -d $k; then
- aclocalinclude="$aclocalinclude -I $k"
- ##else
- ## echo "**Warning**: No such directory \`$k'. Ignored."
- fi
- done
- if grep "^AM_GLIB_GNU_GETTEXT" configure.in >/dev/null; then
- if grep "sed.*POTFILES" configure.in >/dev/null; then
- : do nothing -- we still have an old unmodified configure.in
- else
- echo "Creating $dr/aclocal.m4 ..."
- test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
- echo "Running glib-gettextize... Ignore non-fatal messages."
- echo "no" | glib-gettextize --force --copy
- echo "Making $dr/aclocal.m4 writable ..."
- test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
- fi
- fi
- if grep "^AC_PROG_INTLTOOL" configure.in >/dev/null; then
- echo "Running intltoolize..."
- intltoolize --copy --force --automake
- fi
- if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
- echo "Running $LIBTOOLIZE..."
- $LIBTOOLIZE --force --copy
- fi
- echo "Running $ACLOCAL $aclocalinclude ..."
- $ACLOCAL $aclocalinclude
- if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
- echo "Running $AUTOHEADER..."
- $AUTOHEADER
- fi
- echo "Running $AUTOMAKE --gnu $am_opt ..."
- $AUTOMAKE --add-missing --gnu $am_opt
- echo "Running $AUTOCONF ..."
- $AUTOCONF
- )
- fi
-done
-
-conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
-
-cd "$ORIGDIR"
-
-if test x$NOCONFIGURE = x; then
- echo Running $srcdir/configure $conf_flags "$@" ...
- $srcdir/configure $conf_flags "$@" \
- && echo Now type \`make\' to compile $PROJECT || exit 1
-else
- echo Skipping configure process.
-fi
+. gnome-autogen.sh
diff --git a/configure.in b/configure.in
index c74a8e7..af8779d 100644
--- a/configure.in
+++ b/configure.in
@@ -1,123 +1,107 @@
-AC_INIT(src)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(drwright, 0.18)
-
+# This programme 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 programme is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this programme; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+AC_INIT([Typing Break],
+ [2.33.0],
+ [http://bugzilla.gnome.org/enter_bug.cgi?product=drwright],
+ [drwright])
+
+AC_CONFIG_SRCDIR([src/main.c])
+AC_CONFIG_HEADERS([config.h])
+
+AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-bzip2])
+
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+
+if test -z "$enable_maintainer_mode"; then
+ enable_maintainer_mode=yes
+fi
AM_MAINTAINER_MODE
-AC_ISC_POSIX
-AC_PROG_CC
AC_STDC_HEADERS
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_HEADER_STDC
AM_PROG_LIBTOOL
-AC_PATH_XTRA
-AM_PATH_GLIB_2_0
-
-AC_PROG_INTLTOOL([0.29])
-
-dnl ==========================================================================
-dnl
-dnl Library Dependencies, uses pkg-config to detect correct version, etc
-dnl
-dnl ==========================================================================
-
-dnl If you add a version number here, you *must* add an AC_SUBST line for
-dnl it too, or it will never make it into the spec file!
-
-GLIB_REQUIRED=2.2.0
-PANGO_REQUIRED=1.2
-GTK_REQUIRED=2.2.0
-GCONF_REQUIRED=1.2.0
-LIBGLADE_REQUIRED=2.0.0
-LIBGNOMEUI_REQUIRED=2.0.0
-DESKTOP_FILE_UTILS_REQUIRED=0.2.90
-
-AC_SUBST(GLIB_REQUIRED)
-AC_SUBST(PANGO_REQUIRED)
-AC_SUBST(GTK_REQUIRED)
-AC_SUBST(GCONF_REQUIRED)
-AC_SUBST(LIBGLADE_REQUIRED)
-AC_SUBST(LIBGNOMEUI_REQUIRED)
-AC_SUBST(DESKTOP_FILE_UTILS_REQUIRED)
-
-dnl D-BUS
-dnl ==========================
-AC_ARG_ENABLE(dbus, [ --enable-dbus=[no/yes/auto] compile with d-bus support.],,enable_dbus=auto)
-
-if test "x$enable_dbus" != "xno"; then
- dbus_pkgconfig="dbus-1 >= 0.50 dbus-glib-1"
- PKG_CHECK_MODULES(DBUS, $dbus_pkgconfig, have_dbus=yes, have_dbus=no)
- if test x$have_dbus = xyes; then
- AC_DEFINE(HAVE_DBUS, 1, d-bus support)
- fi
-else
- have_dbus=no
- dbus_pkgconfig=
-fi
-if test "x$have_dbus" != "xyes"; then
- if test "x$enable_dbus" = "xyes"; then
- AC_MSG_ERROR([Couldn't find d-bus.])
- else
- dbus_pkgconfig=
- fi
-fi
+# ************
+# Typing Break
+# ************
-AM_CONDITIONAL(HAVE_DBUS, test x$have_dbus = xyes)
-
-dnl ================================
-dnl | Pkg-Config dependency checks |---------------------------
-dnl ================================
-
-PKG_CHECK_MODULES(DRWRIGHT,
-[
- glib-2.0 >= $GLIB_REQUIRED
- gobject-2.0
- gtk+-2.0 >= $GTK_REQUIRED
- gconf-2.0 >= $GCONF_REQUIRED
- libglade-2.0 >= $LIBGLADE_REQUIRED
- libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED
- $dbus_pkgconfig
-])
+GLIB_REQUIRED=2.12.0
+GTK_REQUIRED=2.91.0
+LIBCANBERRA_REQUIRED=0
-AC_SUBST(DRWRIGHT_CFLAGS)
-AC_SUBST(DRWRIGHT_LIBS)
-dnl -----------------------------------------------------------
-
-dnl
-dnl Check for XScreenSaver extension
-dnl
-
-dnl Check for XScreenSaver
-old_LIBS="$LIBS"
-old_CFLAGS="$CFLAGS"
-LIBS="$LIBS -L$x_libraries"
-CFLAGS="$CFLAGS -I$x_includes"
-AC_CHECK_LIB(Xext, XScreenSaverQueryInfo,[XSS_LIBS="-L$x_libraries"],[],[-lX11 -lXext -lm])
-AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,[XSS_LIBS="-L$x_libraries -lXss"],[],[-lX11 -lXext -lm])
-LIBS="$old_LIBS"
-CFLAGS="$old_CFLAGS"
-if test "x$XSS_LIBS" = "x"; then
- AC_MSG_ERROR([XScreenSaver extension not found])
-fi
-AC_SUBST(XSS_LIBS)
-
-dnl ------------------
-dnl | Language Support |---------------------------------------
-dnl ------------------
-GETTEXT_PACKAGE=drwright
-AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", "")
+PKG_CHECK_MODULES([TYPING],[
+ glib-2.0 >= $GLIB_REQUIRED
+ gconf-2.0
+ gtk+-3.0 >= $GTK_REQUIRED
+ libcanberra-gtk3 >= $LIBCANBERRA_REQUIRED
+ x11])
-ALL_LINGUAS="ar az bg ca cs cy da de dz el en_CA en_GB es fi fr gu hr is it ja ko ml mn ms nb ne nl oc pl pt pt_BR ru rw sk sl sq sr sr Latn sv tr uk vi wa zh_CN zh_TW"
-
-AM_GLIB_GNU_GETTEXT
-
-if test "x$prefix" = "xNONE"; then
- DRWRIGHT_LOCALEDIR=$ac_default_prefix/share/locale
-else
- DRWRIGHT_LOCALEDIR=$prefix/share/locale
-fi
-AC_DEFINE_UNQUOTED(DRWRIGHT_LOCALEDIR, "$DRWRIGHT_LOCALEDIR", "")
-dnl -----------------------------------------------------------
+AC_PATH_XTRA
+x_libs="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
+
+SCREENSAVER_LIBS=
+AC_CHECK_FUNC(XScreenSaverQueryInfo, [], [
+ save_LIBS=$LIBS
+ LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lXss -lXext -lX11"
+ AC_CHECK_LIB(Xss, XScreenSaverQueryInfo, [
+ SCREENSAVER_LIBS="$X_PRE_LIBS $X_LIBS -lXss -lXext -lX11"], [
+ LIBS=$save_LIBS
+ LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lXext -lX11"
+ AC_CHECK_LIB(Xext, XScreenSaverQueryInfo, [
+ SCREENSAVER_LIBS="$X_PRE_LIBS $X_LIBS -lXext -lX11"],[])])
+ LIBS=$save_LIBS])
+AC_SUBST(SCREENSAVER_LIBS)
+
+# **********
+# GSD plugin
+# **********
+
+GSD_REQUIRED=2.91.0
+
+PKG_CHECK_MODULES([GSD_PLUGIN],[
+ gnome-settings-daemon >= $GSD_REQUIRED
+ gtk+-3.0
+ gdk-x11-3.0
+ gconf-2.0])
+
+gsd_plugindir=`$PKG_CONFIG --variable plugindir gnome-settings-daemon`
+AC_SUBST([gsd_plugindir])
+
+GSD_INTLTOOL_PLUGIN_RULE='%.gnome-settings-plugin: %.gnome-settings-plugin.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
+AC_SUBST([GSD_INTLTOOL_PLUGIN_RULE])
+
+GSD_PLUGIN_LDFLAGS="-export_dynamic -module -avoid-version -no-undefined"
+case $host_os in
+ darwin*)
+ GSD_PLUGIN_LDFLAGS="${GSD_PLUGIN_LDFLAGS} -Wl,-bundle_loader,\$(top_builddir)/gnome-settings-daemon/gnome-settings-daemon"
+ ;;
+esac
+AC_SUBST([GSD_PLUGIN_LDFLAGS])
+
+
+# *****************
+# Optional features
+# *****************
+
+AM_CONDITIONAL([HAVE_APP_INDICATOR],[false])
+
+# *****
+# GConf
+# *****
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
@@ -127,16 +111,23 @@ fi
AM_GCONF_SOURCE_2
-AC_OUTPUT([
+# ****
+# i18n
+# ****
+
+GETTEXT_PACKAGE=drwright
+AC_SUBST([GETTEXT_PACKAGE])
+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
+AM_GLIB_GNU_GETTEXT
+IT_PROG_INTLTOOL([0.35.0])
+
+# ******************************************************************************
+# ******************************************************************************
+
+AC_CONFIG_FILES([
Makefile
src/Makefile
po/Makefile.in
-data/Makefile
-data/images/Makefile
-data/glade/Makefile
-drwright.spec
])
-echo
-echo D-BUS support: $have_dbus
-echo
+AC_OUTPUT
diff --git a/git.mk b/git.mk
new file mode 100644
index 0000000..894adb4
--- /dev/null
+++ b/git.mk
@@ -0,0 +1,196 @@
+# git.mk
+#
+# Copyright 2009, Red Hat, Inc.
+# Written by Behdad Esfahbod
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+#
+# The canonical source for this file is pango/git.mk, or whereever the
+# header of pango/git.mk suggests in the future.
+#
+# To use in your project, import this file in your git repo's toplevel,
+# then do "make -f git.mk". This modifies all Makefile.am files in
+# your project to include git.mk.
+#
+# This enables automatic .gitignore generation. If you need to ignore
+# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
+# But think twice before doing that. If a file has to be in .gitignore,
+# chances are very high that it's a generated file and should be in one
+# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
+#
+# The only case that you need to manually add a file to GITIGNOREFILES is
+# when remove files in one of mostlyclean-local, clean-local, distclean-local,
+# or maintainer-clean-local.
+#
+# Note that for files like editor backup, etc, there are better places to
+# ignore them. See "man gitignore".
+#
+# If "make maintainer-clean" removes the files but they are not recognized
+# by this script (that is, if "git status" shows untracked files still), send
+# me the output of "git status" as well as your Makefile.am and Makefile for
+# the directories involved.
+#
+# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
+# pango/Makefile.am.
+#
+# Don't EXTRA_DIST this file. It is supposed to only live in git clones,
+# not tarballs. It serves no useful purpose in tarballs and clutters the
+# build dir.
+#
+# This file knows how to handle autoconf, automake, libtool, gtk-doc,
+# gnome-doc-utils, intltool, gsettings.
+#
+#
+# KNOWN ISSUES:
+#
+# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
+# submodule doesn't find us. If you have configure.{in,ac} files in
+# subdirs, add a proxy git.mk file in those dirs that simply does:
+# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
+# And add those files to git. See vte/gnome-pty-helper/git.mk for
+# example.
+#
+
+git-all: git-mk-install
+
+git-mk-install:
+ @echo Installing git makefile
+ @any_failed=; find $(top_srcdir) -name Makefile.am | while read x; do \
+ if grep 'include .*/git.mk' $$x >/dev/null; then \
+ echo $$x already includes git.mk; \
+ else \
+ failed=; \
+ echo "Updating $$x"; \
+ { cat $$x; \
+ echo ''; \
+ echo '-include $$(top_srcdir)/git.mk'; \
+ } > $$x.tmp || failed=1; \
+ if test x$$failed = x; then \
+ mv $$x.tmp $$x || failed=1; \
+ fi; \
+ if test x$$failed = x; then : else \
+ echo Failed updating $$x; >&2 \
+ any_failed=1; \
+ fi; \
+ fi; done; test -z "$$any_failed"
+
+.PHONY: git-all git-mk-install
+
+
+### .gitignore generation
+
+$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
+ $(AM_V_GEN) \
+ { \
+ if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
+ for x in \
+ $(DOC_MODULE)-decl-list.txt \
+ $(DOC_MODULE)-decl.txt \
+ tmpl/$(DOC_MODULE)-unused.sgml \
+ "tmpl/*.bak" \
+ xml html \
+ ; do echo /$$x; done; \
+ fi; \
+ if test "x$(DOC_MODULE)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
+ for x in \
+ $(_DOC_C_DOCS) \
+ $(_DOC_LC_DOCS) \
+ $(_DOC_OMF_ALL) \
+ $(_DOC_DSK_ALL) \
+ $(_DOC_HTML_ALL) \
+ $(_DOC_MOFILES) \
+ $(_DOC_POFILES) \
+ $(DOC_H_FILE) \
+ "*/.xml2po.mo" \
+ "*/*.omf.out" \
+ ; do echo /$$x; done; \
+ fi; \
+ if test "x$(gsettings_SCHEMAS)" = x; then :; else \
+ for x in \
+ $(gsettings_SCHEMAS:.xml=.valid) \
+ $(gsettings__enum_file) \
+ ; do echo /$$x; done; \
+ fi; \
+ if test -f $(srcdir)/po/Makefile.in.in; then \
+ for x in \
+ po/Makefile.in.in \
+ po/Makefile.in \
+ po/Makefile \
+ po/POTFILES \
+ po/stamp-it \
+ po/.intltool-merge-cache \
+ "po/*.gmo" \
+ "po/*.mo" \
+ po/$(GETTEXT_PACKAGE).pot \
+ intltool-extract.in \
+ intltool-merge.in \
+ intltool-update.in \
+ ; do echo /$$x; done; \
+ fi; \
+ if test -f $(srcdir)/configure; then \
+ for x in \
+ autom4te.cache \
+ configure \
+ config.h \
+ stamp-h1 \
+ libtool \
+ config.lt \
+ ; do echo /$$x; done; \
+ fi; \
+ for x in \
+ .gitignore \
+ $(GITIGNOREFILES) \
+ $(CLEANFILES) \
+ $(PROGRAMS) \
+ $(check_PROGRAMS) \
+ $(EXTRA_PROGRAMS) \
+ $(LTLIBRARIES) \
+ so_locations \
+ .libs _libs \
+ $(MOSTLYCLEANFILES) \
+ "*.$(OBJEXT)" \
+ "*.lo" \
+ $(DISTCLEANFILES) \
+ $(am__CONFIG_DISTCLEAN_FILES) \
+ $(CONFIG_CLEAN_FILES) \
+ TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
+ "*.tab.c" \
+ $(MAINTAINERCLEANFILES) \
+ $(BUILT_SOURCES) \
+ $(DEPDIR) \
+ Makefile \
+ Makefile.in \
+ "*.orig" \
+ "*.rej" \
+ "*.bak" \
+ "*~" \
+ ".*.sw[nop]" \
+ ".dirstamp" \
+ ; do echo /$$x; done; \
+ } | \
+ sed "s ^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
+ sed 's@/[.]/@/@g' | \
+ LC_ALL=C sort | uniq > $ tmp && \
+ mv $ tmp $@;
+
+all: $(srcdir)/.gitignore gitignore-recurse-maybe
+gitignore-recurse-maybe:
+ @if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \
+ $(MAKE) $(AM_MAKEFLAGS) gitignore-recurse; \
+ fi;
+gitignore-recurse:
+ @for subdir in $(DIST_SUBDIRS); do \
+ case " $(SUBDIRS) " in \
+ *" $$subdir "*) :;; \
+ *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir");; \
+ esac; \
+ done
+gitignore: $(srcdir)/.gitignore gitignore-recurse
+
+maintainer-clean: gitignore-clean
+gitignore-clean:
+ -rm -f $(srcdir)/.gitignore
+
+.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 29c7f78..c563fc9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,7 +1,5 @@
-data/glade/drw-preferences.glade
src/main.c
src/drwright.c
src/drw-break-window.c
src/drw-monitor.c
-src/drw-preferences.c
-src/eggtrayicon.c
+src/drwright.schemas.in
diff --git a/src/Makefile.am b/src/Makefile.am
index 2e1395d..9c25169 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,45 +1,128 @@
-INCLUDES = \
- @DRWRIGHT_CFLAGS@ \
- -DGLADEDIR=\"$(datadir)/drwright\" \
- -DIMAGEDIR=\"$(datadir)/drwright\" \
- -DDBUS_API_SUBJECT_TO_CHANGE=1
-
-if HAVE_DBUS
-dbus_sources = dbus.c dbus.h
-endif
+NULL =
+
+# Typing break
-bin_PROGRAMS = drwright
+bin_PROGRAMS = gnome-typing-monitor
-drwright_SOURCES = \
- $(dbus_sources) \
+gnome_typing_monitor_SOURCES = \
main.c \
drwright.c \
drwright.h \
drw-break-window.c \
drw-break-window.h \
- drw-utils.c \
- drw-utils.h \
drw-monitor.c \
drw-monitor.h \
- drw-preferences.c \
- drw-preferences.h \
- eggtrayicon.c \
- eggtrayicon.h \
+ drw-utils.c \
+ drw-utils.h \
drw-selection.c \
- drw-selection.h
+ drw-selection.h \
+ drw-timer.c \
+ drw-timer.h
+
+gnome_typing_monitor_CPPFLAGS = \
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ -DIMAGEDIR=\"$(pkgdatadir)/pixmaps\" \
+ $(AM_CPPFLAGS)
+gnome_typing_monitor_CFLAGS = \
+ $(TYPING_CFLAGS) \
+ $(AM_CFLAGS)
+
+gnome_typing_monitor_LDADD = $(TYPING_LIBS) $(SCREENSAVER_LIBS)
+
+if HAVE_APP_INDICATOR
+ gnome_typing_monitor_CFLAGS += -DHAVE_APP_INDICATOR $(APP_INDICATOR_CFLAGS)
+ gnome_typing_monitor_LDADD += $(APP_INDICATOR_LIBS)
+endif
+
+imagedir = $(pkgdatadir)/pixmaps
+dist_image_DATA = bar.png bar-red.png bar-green.png bar-disabled.png ocean-stripes.png
+
+# Themeable application icon
+icondir = $(datadir)/icons/hicolor/48x48/apps
+dist_icon_DATA = typing-monitor.png
+svgicondir = $(datadir)/icons/hicolor/scalable/apps
+dist_svgicon_DATA = typing-monitor.svg
+gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
+install-data-hook: update-icon-cache
+uninstall-hook: update-icon-cache
+update-icon-cache:
+ @-if test -z "$(DESTDIR)"; then \
+ echo "Updating Gtk icon cache."; \
+ $(gtk_update_icon_cache); \
+ else \
+ echo "*** Icon cache not updated. After (un)install, run this:"; \
+ echo "*** $(gtk_update_icon_cache)"; \
+ fi
+
+
+# GSD plugin
-drwright_LDADD = @DRWRIGHT_LIBS@ @XSS_LIBS@
+gsd_plugin_LTLIBRARIES = \
+ libtyping-break.la \
+ $(NULL)
-schemadir = @GCONF_SCHEMA_FILE_DIR@
+libtyping_break_la_SOURCES = \
+ gsd-typing-break-plugin.h \
+ gsd-typing-break-plugin.c \
+ gsd-typing-break-manager.h \
+ gsd-typing-break-manager.c \
+ gnome-settings-profile.h \
+ $(NULL)
+
+libtyping_break_la_CPPFLAGS = \
+ -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+ $(AM_CPPFLAGS)
+
+libtyping_break_la_CFLAGS = \
+ $(GSD_PLUGIN_CFLAGS) \
+ $(AM_CFLAGS)
+
+libtyping_break_la_LDFLAGS = \
+ $(GSD_PLUGIN_LDFLAGS) \
+ $(NULL)
+
+libtyping_break_la_LIBADD = \
+ $(GSD_PLUGIN_LIBS) \
+ $(NULL)
+
+gsd_plugin_in_files = \
+ typing-break.gnome-settings-plugin.in \
+ $(NULL)
+
+gsd_plugin_DATA = $(gsd_plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
+
+ GSD_INTLTOOL_PLUGIN_RULE@
+
+# GConf schema
+
+schemadir = $(GCONF_SCHEMA_FILE_DIR)
+schema_in_files = drwright.schemas.in
schema_DATA = drwright.schemas
if GCONF_SCHEMAS_INSTALL
install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schema_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p ; \
- done \
- fi
+ GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/src/$(schema_DATA)
endif
-EXTRA_DIST = $(schema_DATA) $(dbus_sources)
+ INTLTOOL_SCHEMAS_RULE@
+
+# Clean
+
+EXTRA_DIST = \
+ $(gsd_plugin_in_files) \
+ $(schema_in_files) \
+ $(NULL)
+
+CLEANFILES = \
+ $(gsd_plugin_DATA) \
+ $(schema_DATA) \
+ $(NULL)
+
+DISTCLEANFILES = \
+ $(gsd_plugin_DATA) \
+ $(schema_DATA) \
+ $(NULL)
+
+# includes
+
+-include $(top_srcdir)/git.mk
diff --git a/src/bar-disabled.png b/src/bar-disabled.png
new file mode 100644
index 0000000..247e976
Binary files /dev/null and b/src/bar-disabled.png differ
diff --git a/src/bar-green.png b/src/bar-green.png
new file mode 100644
index 0000000..8979d10
Binary files /dev/null and b/src/bar-green.png differ
diff --git a/src/bar-red.png b/src/bar-red.png
new file mode 100644
index 0000000..dd3db76
Binary files /dev/null and b/src/bar-red.png differ
diff --git a/src/bar.png b/src/bar.png
new file mode 100644
index 0000000..4eead01
Binary files /dev/null and b/src/bar.png differ
diff --git a/src/drw-break-window.c b/src/drw-break-window.c
index a91b776..6af4a11 100644
--- a/src/drw-break-window.c
+++ b/src/drw-break-window.c
@@ -1,8 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2003-2004 Imendio HB
- * Copyright (C) 2002-2003 Richard Hult <richard imendio com>
* Copyright (C) 2002 CodeFactory AB
+ * Copyright (C) 2002-2003 Richard Hult <richard imendio com>
*
* This program is free software; you can redistribute it and/or
@@ -24,30 +23,41 @@
#include <config.h>
#include <string.h>
#include <math.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gconf/gconf-client.h>
-#include <libgnome/gnome-i18n.h>
+
+#ifdef HAVE_CANBERRA_GTK
+#include <canberra-gtk.h>
+#endif
+
#include "drwright.h"
#include "drw-utils.h"
#include "drw-break-window.h"
+#include "drw-timer.h"
-struct _DrwBreakWindowPriv {
+struct _DrwBreakWindowPrivate {
GtkWidget *clock_label;
GtkWidget *break_label;
GtkWidget *image;
+ GtkWidget *postpone_entry;
GtkWidget *postpone_button;
-
- GTimer *timer;
+
+ DrwTimer *timer;
gint break_time;
-
gchar *break_text;
guint clock_timeout_id;
+ guint postpone_timeout_id;
guint postpone_sensitize_id;
};
+#define DRW_BREAK_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DRW_TYPE_BREAK_WINDOW, DrwBreakWindowPrivate))
+
+#define POSTPONE_CANCEL 30
+
/* Signals */
enum {
DONE,
@@ -61,56 +71,28 @@ static void drw_break_window_finalize (GObject *object)
static void drw_break_window_dispose (GObject *object);
static gboolean postpone_sensitize_cb (DrwBreakWindow *window);
static gboolean clock_timeout_cb (DrwBreakWindow *window);
-static void postpone_clicked_cb (GtkWidget *button,
+static void postpone_clicked_cb (GtkWidget *button,
GtkWidget *window);
-static gboolean label_expose_event_cb (GtkLabel *label,
- GdkEventExpose *event,
+static gboolean label_draw_event_cb (GtkLabel *label,
+ cairo_t *cr,
gpointer user_data);
static void label_size_request_cb (GtkLabel *label,
GtkRequisition *requisition,
gpointer user_data);
-static GObjectClass *parent_class;
-static guint signals[LAST_SIGNAL];
+G_DEFINE_TYPE (DrwBreakWindow, drw_break_window, GTK_TYPE_WINDOW)
-GType
-drw_break_window_get_type (void)
-{
- static GType object_type = 0;
-
- if (!object_type) {
- static const GTypeInfo object_info = {
- sizeof (DrwBreakWindowClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) drw_break_window_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (DrwBreakWindow),
- 0, /* n_preallocs */
- (GInstanceInitFunc) drw_break_window_init,
- };
-
- object_type = g_type_register_static (GTK_TYPE_WINDOW,
- "DrwBreakWindow",
- &object_info,
- 0);
- }
-
- return object_type;
-}
+static guint signals[LAST_SIGNAL];
static void
drw_break_window_class_init (DrwBreakWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
-
+
object_class->finalize = drw_break_window_finalize;
object_class->dispose = drw_break_window_dispose;
- signals[POSTPONE] =
+ signals[POSTPONE] =
g_signal_new ("postpone",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -118,8 +100,8 @@ drw_break_window_class_init (DrwBreakWindowClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
- signals[DONE] =
+
+ signals[DONE] =
g_signal_new ("done",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -127,119 +109,136 @@ drw_break_window_class_init (DrwBreakWindowClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ g_type_class_add_private (klass, sizeof (DrwBreakWindowPrivate));
}
static void
drw_break_window_init (DrwBreakWindow *window)
{
- DrwBreakWindowPriv *priv;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *frame;
- GtkWidget *align;
- gchar *str;
- GtkWidget *outer_vbox;
- GtkWidget *button_box;
- gboolean allow_postpone;
-
- GdkScreen *screen;
- GdkDisplay *display;
- GdkRectangle geometry;
- gint monitor;
- gfloat w, h;
-
- priv = g_new0 (DrwBreakWindowPriv, 1);
- window->priv = priv;
-
- priv->break_time = 60 * gconf_client_get_int (gconf_client_get_default (),
+ DrwBreakWindowPrivate *priv;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *align;
+ GtkWidget *monitor_box;
+ gchar *str;
+ GtkWidget *outer_vbox;
+ GtkWidget *button_box;
+ gboolean allow_postpone;
+
+ gint root_monitor = 0;
+ GdkScreen *screen = NULL;
+ GdkRectangle monitor;
+ gint right_padding;
+ gint bottom_padding;
+ GConfClient *client;
+
+ priv = DRW_BREAK_WINDOW_GET_PRIVATE (window);
+ window->priv = priv;
+
+ client = gconf_client_get_default ();
+
+ priv->break_time = 60 * gconf_client_get_int (client,
GCONF_PATH "/break_time",
NULL);
-
- allow_postpone = gconf_client_get_bool (gconf_client_get_default (),
+
+ allow_postpone = gconf_client_get_bool (client,
GCONF_PATH "/allow_postpone",
NULL);
+ g_object_unref (client);
- GTK_WINDOW (window)->type = GTK_WINDOW_POPUP;
+ g_object_set (window, "type", GTK_WINDOW_POPUP, NULL);
+ gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ gtk_window_set_modal (GTK_WINDOW (window), TRUE);
+
+ screen = gdk_screen_get_default ();
+ gdk_screen_get_monitor_geometry (screen, root_monitor, &monitor);
gtk_window_set_default_size (GTK_WINDOW (window),
- gdk_screen_width (),
- gdk_screen_height ());
-
- gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
- gtk_widget_realize (GTK_WIDGET (window));
+ gdk_screen_get_width (screen),
+ gdk_screen_get_height (screen));
+ gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
+ gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
drw_setup_background (GTK_WIDGET (window));
-
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_widget_show (frame);
-
- display = gdk_display_get_default ();
- screen = gdk_display_get_default_screen (display);
-
- if (gdk_screen_get_n_monitors (screen) != 1) {
- monitor = gdk_screen_get_monitor_at_point (screen,
- (gint) 0.5 * gdk_screen_width (),
- (gint) 0.5 * gdk_screen_height ());
- gdk_screen_get_monitor_geometry (screen, monitor, &geometry);
-
- w = (0.5 * geometry.width + geometry.x) / gdk_screen_width ();
- h = (0.5 * geometry.height + geometry.y) / gdk_screen_height ();
- align = gtk_alignment_new (w, h, 0.0, 0.0);
- } else {
- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- }
-
+
+ align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_widget_show (align);
outer_vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (outer_vbox);
-
- gtk_container_add (GTK_CONTAINER (window), outer_vbox);
+
+ right_padding = gdk_screen_get_width (screen) - monitor.width - monitor.x;
+ bottom_padding = gdk_screen_get_height (screen) - monitor.height - monitor.y;
+
+ monitor_box = gtk_alignment_new (0.5, 0.5, 1, 1);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (monitor_box),
+ monitor.y,
+ bottom_padding,
+ monitor.x,
+ right_padding);
+ gtk_widget_show (monitor_box);
+
+ gtk_container_add (GTK_CONTAINER (window), monitor_box);
+ gtk_container_add (GTK_CONTAINER (monitor_box), outer_vbox);
gtk_box_pack_start (GTK_BOX (outer_vbox), align, TRUE, TRUE, 0);
if (allow_postpone) {
button_box = gtk_hbox_new (FALSE, 0);
gtk_widget_show (button_box);
-
+
gtk_container_set_border_width (GTK_CONTAINER (button_box), 12);
- priv->postpone_button = gtk_button_new_with_mnemonic (_("_Postpone break"));
+ priv->postpone_button = gtk_button_new_with_mnemonic (_("_Postpone Break"));
gtk_widget_show (priv->postpone_button);
-
+
gtk_widget_set_sensitive (priv->postpone_button, FALSE);
if (priv->postpone_sensitize_id) {
g_source_remove (priv->postpone_sensitize_id);
}
-
- priv->postpone_sensitize_id = g_timeout_add (500,
- (GSourceFunc) postpone_sensitize_cb,
- window);
-
+
+ priv->postpone_sensitize_id = g_timeout_add_seconds (5,
+ (GSourceFunc) postpone_sensitize_cb,
+ window);
+
g_signal_connect (priv->postpone_button,
"clicked",
G_CALLBACK (postpone_clicked_cb),
window);
-
+
gtk_box_pack_end (GTK_BOX (button_box), priv->postpone_button, FALSE, TRUE, 0);
+ priv->postpone_entry = gtk_entry_new ();
+ gtk_entry_set_has_frame (GTK_ENTRY (priv->postpone_entry), FALSE);
+
+ gtk_box_pack_end (GTK_BOX (button_box), priv->postpone_entry, FALSE, TRUE, 4);
+
gtk_box_pack_end (GTK_BOX (outer_vbox), button_box, FALSE, TRUE, 0);
}
-
+
vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox);
-
- gtk_container_add (GTK_CONTAINER (align), frame);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ gtk_container_add (GTK_CONTAINER (align), vbox);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
+
+ priv->image = gtk_image_new_from_stock (GTK_STOCK_STOP, GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (priv->image), 1, 0.5);
+ gtk_widget_show (priv->image);
+ gtk_box_pack_start (GTK_BOX (hbox), priv->image, TRUE, TRUE, 8);
priv->break_label = gtk_label_new (NULL);
gtk_widget_show (priv->break_label);
g_signal_connect (priv->break_label,
- "expose_event",
- G_CALLBACK (label_expose_event_cb),
+ "draw",
+ G_CALLBACK (label_draw_event_cb),
NULL);
g_signal_connect_after (priv->break_label,
@@ -251,101 +250,118 @@ drw_break_window_init (DrwBreakWindow *window)
_("Take a break!"));
gtk_label_set_markup (GTK_LABEL (priv->break_label), str);
g_free (str);
-
- gtk_box_pack_start (GTK_BOX (vbox), priv->break_label, FALSE, FALSE, 12);
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0);
-
- priv->image = gtk_image_new_from_file (IMAGEDIR "/stop.png");
- gtk_misc_set_alignment (GTK_MISC (priv->image), 1, 0.5);
- gtk_widget_show (priv->image);
- gtk_box_pack_start (GTK_BOX (hbox), priv->image, TRUE, TRUE, 8);
-
+ gtk_box_pack_start (GTK_BOX (hbox), priv->break_label, FALSE, FALSE, 12);
+
+
priv->clock_label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (priv->clock_label), 0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->clock_label), 0.5, 0.5);
gtk_widget_show (priv->clock_label);
- gtk_box_pack_start (GTK_BOX (hbox), priv->clock_label, TRUE, TRUE, 8);
+ gtk_box_pack_start (GTK_BOX (vbox), priv->clock_label, TRUE, TRUE, 8);
g_signal_connect (priv->clock_label,
- "expose_event",
- G_CALLBACK (label_expose_event_cb),
+ "draw",
+ G_CALLBACK (label_draw_event_cb),
NULL);
-
+
g_signal_connect_after (priv->clock_label,
"size_request",
G_CALLBACK (label_size_request_cb),
NULL);
gtk_window_stick (GTK_WINDOW (window));
-
- priv->timer = g_timer_new ();
-
+
+ priv->timer = drw_timer_new ();
+
/* Make sure we have a valid time label from the start. */
clock_timeout_cb (window);
-
+
priv->clock_timeout_id = g_timeout_add (1000,
(GSourceFunc) clock_timeout_cb,
window);
+#ifdef HAVE_CANBERRA_GTK
+ ca_context_play (ca_gtk_context_get (), 0, CA_PROP_EVENT_ID, "desktop-screen-lock", NULL);
+#endif
}
static void
drw_break_window_finalize (GObject *object)
{
- DrwBreakWindow *window = DRW_BREAK_WINDOW (object);
- DrwBreakWindowPriv *priv;
-
- priv = window->priv;
+ DrwBreakWindow *window = DRW_BREAK_WINDOW (object);
+ DrwBreakWindowPrivate *priv;
+
+ priv = window->priv;
if (priv->clock_timeout_id != 0) {
g_source_remove (priv->clock_timeout_id);
}
+ if (priv->postpone_timeout_id != 0) {
+ g_source_remove (priv->postpone_timeout_id);
+ }
+
if (priv->postpone_sensitize_id != 0) {
g_source_remove (priv->postpone_sensitize_id);
}
-
- g_free (priv);
+
window->priv = NULL;
- if (G_OBJECT_CLASS (parent_class)->finalize) {
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (drw_break_window_parent_class)->finalize) {
+ (* G_OBJECT_CLASS (drw_break_window_parent_class)->finalize) (object);
}
}
static void
drw_break_window_dispose (GObject *object)
{
- DrwBreakWindow *window = DRW_BREAK_WINDOW (object);
- DrwBreakWindowPriv *priv;
-
- priv = window->priv;
+ DrwBreakWindow *window = DRW_BREAK_WINDOW (object);
+ DrwBreakWindowPrivate *priv;
+
+ priv = window->priv;
+
+ if (priv->timer) {
+ drw_timer_destroy (priv->timer);
+ priv->timer = NULL;
+ }
if (priv->clock_timeout_id != 0) {
g_source_remove (priv->clock_timeout_id);
priv->clock_timeout_id = 0;
}
+ if (priv->postpone_timeout_id != 0) {
+ g_source_remove (priv->postpone_timeout_id);
+ priv->postpone_timeout_id = 0;
+ }
+
if (priv->postpone_sensitize_id != 0) {
g_source_remove (priv->postpone_sensitize_id);
}
-
- if (G_OBJECT_CLASS (parent_class)->dispose) {
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
- }
+
+ if (G_OBJECT_CLASS (drw_break_window_parent_class)->dispose) {
+ (* G_OBJECT_CLASS (drw_break_window_parent_class)->dispose) (object);
+ }
}
GtkWidget *
drw_break_window_new (void)
{
- return g_object_new (DRW_TYPE_BREAK_WINDOW, NULL);
+ GObject *object;
+
+ object = g_object_new (DRW_TYPE_BREAK_WINDOW,
+ "type", GTK_WINDOW_POPUP,
+ "skip-taskbar-hint", TRUE,
+ "skip-pager-hint", TRUE,
+ "focus-on-map", TRUE,
+ NULL);
+
+ return GTK_WIDGET (object);
}
static gboolean
postpone_sensitize_cb (DrwBreakWindow *window)
{
- DrwBreakWindowPriv *priv;
+ DrwBreakWindowPrivate *priv;
priv = window->priv;
@@ -358,16 +374,16 @@ postpone_sensitize_cb (DrwBreakWindow *window)
static gboolean
clock_timeout_cb (DrwBreakWindow *window)
{
- DrwBreakWindowPriv *priv;
- gchar *txt;
- gint minutes;
- gint seconds;
+ DrwBreakWindowPrivate *priv;
+ gchar *txt;
+ gint minutes;
+ gint seconds;
g_return_val_if_fail (DRW_IS_BREAK_WINDOW (window), FALSE);
priv = window->priv;
-
- seconds = 1 + priv->break_time - g_timer_elapsed (priv->timer, NULL);
+
+ seconds = 1 + priv->break_time - drw_timer_elapsed (priv->timer);
seconds = MAX (0, seconds);
if (seconds == 0) {
@@ -377,6 +393,9 @@ clock_timeout_cb (DrwBreakWindow *window)
*/
priv->clock_timeout_id = 0;
+#ifdef HAVE_CANBERRA_GTK
+ ca_context_play (ca_gtk_context_get (), 0, CA_PROP_EVENT_ID, "alarm-clock-elapsed", NULL);
+#endif
g_signal_emit (window, signals[DONE], 0, NULL);
return FALSE;
@@ -394,6 +413,31 @@ clock_timeout_cb (DrwBreakWindow *window)
return TRUE;
}
+static void
+postpone_entry_activate_cb (GtkWidget *entry,
+ DrwBreakWindow *window)
+{
+ const gchar *str;
+ gchar *phrase;
+ GConfClient *client = gconf_client_get_default();
+
+ str = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ phrase = gconf_client_get_string (client,
+ GCONF_PATH "/unlock_phrase",
+ NULL);
+ g_object_unref (client);
+
+ if (!strcmp (str, phrase)) {
+ g_signal_emit (window, signals[POSTPONE], 0, NULL);
+ g_free (phrase);
+ return;
+ }
+
+ g_free (phrase);
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+}
+
static gboolean
grab_on_window (GdkWindow *window,
guint32 activate_time)
@@ -415,89 +459,120 @@ grab_on_window (GdkWindow *window,
return FALSE;
}
-static void
-postpone_clicked_cb (GtkWidget *button,
- GtkWidget *window)
+static gboolean
+postpone_cancel_cb (DrwBreakWindow *window)
{
- g_signal_emit (window, signals[POSTPONE], 0, NULL);
+ DrwBreakWindowPrivate *priv;
+
+ priv = window->priv;
+
+ gtk_entry_set_text (GTK_ENTRY (priv->postpone_entry), "");
+ gtk_widget_hide (priv->postpone_entry);
+
+ priv->postpone_timeout_id = 0;
+
+ return FALSE;
}
-static void
-get_layout_location (GtkLabel *label,
- gint *xp,
- gint *yp)
+static gboolean
+postpone_entry_key_press_event_cb (GtkEntry *entry,
+ GdkEventKey *event,
+ DrwBreakWindow *window)
{
- GtkMisc *misc;
- GtkWidget *widget;
- gfloat xalign;
- gint x, y;
-
- misc = GTK_MISC (label);
- widget = GTK_WIDGET (label);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) {
- xalign = misc->xalign;
- } else {
- xalign = 1.0 - misc->xalign;
+ DrwBreakWindowPrivate *priv;
+
+ priv = window->priv;
+
+ if (event->keyval == GDK_KEY_Escape) {
+ if (priv->postpone_timeout_id) {
+ g_source_remove (priv->postpone_timeout_id);
+ }
+
+ postpone_cancel_cb (window);
+
+ return TRUE;
}
-
- x = floor (widget->allocation.x + (int)misc->xpad
- + ((widget->allocation.width - widget->requisition.width - 1) * xalign)
- + 0.5);
-
- y = floor (widget->allocation.y + (int)misc->ypad
- + ((widget->allocation.height - widget->requisition.height - 1) * misc->yalign)
- + 0.5);
-
- if (xp) {
- *xp = x;
+
+ g_source_remove (priv->postpone_timeout_id);
+
+ priv->postpone_timeout_id = g_timeout_add_seconds (POSTPONE_CANCEL, (GSourceFunc) postpone_cancel_cb, window);
+
+ return FALSE;
+}
+
+static void
+postpone_clicked_cb (GtkWidget *button,
+ GtkWidget *window)
+{
+ DrwBreakWindow *bw = DRW_BREAK_WINDOW (window);
+ DrwBreakWindowPrivate *priv = bw->priv;
+ gchar *phrase;
+
+ /* Disable the phrase for now. */
+ phrase = NULL; /*gconf_client_get_string (gconf_client_get_default (),
+ GCONF_PATH "/unlock_phrase",
+ NULL);*/
+
+ if (!phrase || !phrase[0]) {
+ g_signal_emit (window, signals[POSTPONE], 0, NULL);
+ return;
}
-
- if (yp) {
- *yp = y;
+
+ if (gtk_widget_get_visible (priv->postpone_entry)) {
+ gtk_widget_activate (priv->postpone_entry);
+ return;
}
+
+ gtk_widget_show (priv->postpone_entry);
+
+ priv->postpone_timeout_id = g_timeout_add_seconds (POSTPONE_CANCEL, (GSourceFunc) postpone_cancel_cb, bw);
+
+ grab_on_window (gtk_widget_get_window (priv->postpone_entry), gtk_get_current_event_time ());
+
+ gtk_widget_grab_focus (priv->postpone_entry);
+
+ g_signal_connect (priv->postpone_entry,
+ "activate",
+ G_CALLBACK (postpone_entry_activate_cb),
+ bw);
+
+ g_signal_connect (priv->postpone_entry,
+ "key_press_event",
+ G_CALLBACK (postpone_entry_key_press_event_cb),
+ bw);
}
static gboolean
-label_expose_event_cb (GtkLabel *label,
- GdkEventExpose *event,
- gpointer user_data)
+label_draw_event_cb (GtkLabel *label,
+ cairo_t *cr,
+ gpointer user_data)
{
- gint x, y;
- GdkColor color;
- GtkWidget *widget;
- GdkGC *gc;
-
- color.red = 0;
- color.green = 0;
- color.blue = 0;
- color.pixel = 0;
+ gint x, y;
+ GtkWidget *widget;
+ GdkWindow *window;
- get_layout_location (label, &x, &y);
+ gtk_label_get_layout_offsets (label, &x, &y);
widget = GTK_WIDGET (label);
- gc = gdk_gc_new (widget->window);
- gdk_gc_set_rgb_fg_color (gc, &color);
- gdk_gc_set_clip_rectangle (gc, &event->area);
-
- gdk_draw_layout_with_colors (widget->window,
- gc,
- x + 1,
- y + 1,
- label->layout,
- &color,
- NULL);
- g_object_unref (gc);
-
- gtk_paint_layout (widget->style,
- widget->window,
- GTK_WIDGET_STATE (widget),
+ window = gtk_widget_get_window (widget);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ /* Can't use pango_cairo_show_layout() here as we need to override
+ * the layout's colors with our shadow color.
+ */
+ cairo_move_to (cr, x + 1, y + 1);
+ pango_cairo_layout_path (cr, gtk_label_get_layout (label));
+ cairo_fill (cr);
+
+ gtk_paint_layout (gtk_widget_get_style (widget),
+ cr,
+ gtk_widget_get_state (widget),
FALSE,
- &event->area,
widget,
"label",
x, y,
- label->layout);
+ gtk_label_get_layout (label));
return TRUE;
}
diff --git a/src/drw-break-window.h b/src/drw-break-window.h
index d3c1971..a856cd3 100644
--- a/src/drw-break-window.h
+++ b/src/drw-break-window.h
@@ -22,7 +22,9 @@
#ifndef __DRW_BREAK_WINDOW_H__
#define __DRW_BREAK_WINDOW_H__
-#include <gtk/gtkwindow.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
#define DRW_TYPE_BREAK_WINDOW (drw_break_window_get_type ())
#define DRW_BREAK_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DRW_TYPE_BREAK_WINDOW, DrwBreakWindow))
@@ -31,14 +33,14 @@
#define DRW_IS_BREAK_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DRW_TYPE_BREAK_WINDOW))
#define DRW_BREAK_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DRW_TYPE_BREAK_WINDOW, DrwBreakWindowClass))
-typedef struct _DrwBreakWindow DrwBreakWindow;
-typedef struct _DrwBreakWindowClass DrwBreakWindowClass;
-typedef struct _DrwBreakWindowPriv DrwBreakWindowPriv;
+typedef struct _DrwBreakWindow DrwBreakWindow;
+typedef struct _DrwBreakWindowClass DrwBreakWindowClass;
+typedef struct _DrwBreakWindowPrivate DrwBreakWindowPrivate;
struct _DrwBreakWindow {
- GtkWindow parent;
+ GtkWindow parent;
- DrwBreakWindowPriv *priv;
+ DrwBreakWindowPrivate *priv;
};
struct _DrwBreakWindowClass {
@@ -48,5 +50,6 @@ struct _DrwBreakWindowClass {
GType drw_break_window_get_type (void) G_GNUC_CONST;
GtkWidget * drw_break_window_new (void);
+G_END_DECLS
#endif /* __DRW_BREAK_WINDOW_H__ */
diff --git a/src/drw-monitor.c b/src/drw-monitor.c
index f410565..e9dc57b 100644
--- a/src/drw-monitor.c
+++ b/src/drw-monitor.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2002-2004 Richard Hult <richard imendio com>
* Copyright (C) 2002 CodeFactory AB
+ * Copyright (C) 2002 Richard Hult <richard imendio com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -22,7 +22,15 @@
#include <config.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
#include <math.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <X11/Xlib.h>
#include <X11/extensions/scrnsaver.h>
#include "drw-monitor.h"
@@ -134,19 +142,21 @@ static gboolean
drw_monitor_timeout (DrwMonitor *monitor)
{
DrwMonitorPriv *priv;
- time_t now;
+ time_t now;
priv = monitor->priv;
-
- if (XScreenSaverQueryInfo (GDK_DISPLAY (), DefaultRootWindow (GDK_DISPLAY ()), priv->ss_info) != 0) {
+
+ if (XScreenSaverQueryInfo (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ DefaultRootWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())),
+ priv->ss_info) != 0) {
if (priv->ss_info->idle < priv->last_idle) {
- now = time (NULL);
-
- if (now - priv->last_activity < 25) {
- g_signal_emit (monitor, signals[ACTIVITY], 0, NULL);
- }
-
- priv->last_activity = now;
+ now = time (NULL);
+
+ if (now - priv->last_activity < 25) {
+ g_signal_emit (monitor, signals[ACTIVITY], 0, NULL);
+ }
+
+ priv->last_activity = now;
}
priv->last_idle = priv->ss_info->idle;
@@ -164,7 +174,8 @@ drw_monitor_setup (DrwMonitor *monitor)
priv = monitor->priv;
- if (!XScreenSaverQueryExtension (GDK_DISPLAY (), &event_base, &error_base)) {
+ if (!XScreenSaverQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ &event_base, &error_base)) {
return FALSE;
}
@@ -172,7 +183,7 @@ drw_monitor_setup (DrwMonitor *monitor)
priv->last_activity = time (NULL);
- priv->timeout_id = g_timeout_add (3000, (GSourceFunc) drw_monitor_timeout, monitor);
+ priv->timeout_id = g_timeout_add_seconds (3, (GSourceFunc) drw_monitor_timeout, monitor);
return TRUE;
}
diff --git a/src/drw-monitor.h b/src/drw-monitor.h
index e3ef9c2..3b5ef67 100644
--- a/src/drw-monitor.h
+++ b/src/drw-monitor.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2002 CodeFactory AB
- * Copyright (C) 2002 Richard Hult <richard imendio com>
+ * Copyright (C) 2002 Richard Hult <richard imendi com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/src/drw-selection.c b/src/drw-selection.c
index a0aa235..9607df9 100644
--- a/src/drw-selection.c
+++ b/src/drw-selection.c
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Owen Taylor, Red Hat, Inc.
@@ -46,10 +46,10 @@ drw_selection_reset (DrwSelection *drw_selection)
if (drw_selection->owner_window) {
gdk_window_remove_filter (drw_selection->owner_window,
drw_selection_filter, drw_selection);
- gdk_window_unref (drw_selection->owner_window);
+ g_object_unref (drw_selection->owner_window);
drw_selection->owner_window = NULL;
}
-
+
if (drw_selection->invisible) {
gtk_widget_destroy (drw_selection->invisible);
drw_selection->invisible = NULL;
@@ -70,7 +70,7 @@ drw_selection_clear (GtkWidget *widget,
static gboolean
drw_selection_find_existing (DrwSelection *drw_selection)
{
- Display *xdisplay = GDK_DISPLAY ();
+ Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
Window old;
gdk_error_trap_push ();
@@ -81,20 +81,20 @@ drw_selection_find_existing (DrwSelection *drw_selection)
drw_selection->owner_window = gdk_window_foreign_new (old);
}
XSync (xdisplay, False);
-
+
if (gdk_error_trap_pop () == 0 && drw_selection->owner_window) {
gdk_window_add_filter (drw_selection->owner_window,
drw_selection_filter, drw_selection);
-
+
XUngrabServer (xdisplay);
-
+
return TRUE;
} else {
if (drw_selection->owner_window) {
- gdk_window_unref (drw_selection->owner_window);
+ g_object_unref (drw_selection->owner_window);
drw_selection->owner_window = NULL;
}
-
+
return FALSE;
}
}
@@ -105,8 +105,8 @@ drw_selection_claim (DrwSelection *drw_selection)
drw_selection->invisible = gtk_invisible_new ();
g_signal_connect (drw_selection->invisible, "selection-clear-event",
G_CALLBACK (drw_selection_clear), drw_selection);
-
-
+
+
if (gtk_selection_owner_set (drw_selection->invisible,
gdk_atom_intern (SELECTION_NAME, FALSE),
GDK_CURRENT_TIME)) {
@@ -120,7 +120,7 @@ drw_selection_claim (DrwSelection *drw_selection)
static void
drw_selection_negotiate (DrwSelection *drw_selection)
{
- Display *xdisplay = GDK_DISPLAY ();
+ Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
gboolean found = FALSE;
/* We don't need both the XGrabServer() and the loop here;
@@ -164,10 +164,10 @@ drw_selection_filter (GdkXEvent *xevent,
}
DrwSelection *
-drw_selection_start ()
+drw_selection_start (void)
{
DrwSelection *drw_selection = g_new (DrwSelection, 1);
-
+
drw_selection->owner_window = NULL;
drw_selection->invisible = NULL;
diff --git a/src/drw-selection.h b/src/drw-selection.h
index 54fd779..f384a4e 100644
--- a/src/drw-selection.h
+++ b/src/drw-selection.h
@@ -26,7 +26,7 @@
typedef struct _DrwSelection DrwSelection;
-DrwSelection * drw_selection_start ();
+DrwSelection * drw_selection_start (void);
void drw_selection_stop (DrwSelection *drw_selection);
gboolean drw_selection_is_master (DrwSelection *drw_selection);
diff --git a/src/drw-preferences.h b/src/drw-timer.c
similarity index 54%
rename from src/drw-preferences.h
rename to src/drw-timer.c
index fbdb87c..8eafc53 100644
--- a/src/drw-preferences.h
+++ b/src/drw-timer.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2002 Richard Hult <richard imendio com>
+ * Copyright (C) 2009 Nathaniel Smith <njs pobox com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,7 +9,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
@@ -18,11 +18,35 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef __DRW_PREFERENCES_H__
-#define __DRW_PREFERENCES_H__
+#include <glib.h>
+#include "drw-timer.h"
-typedef struct _DrwPreferences DrwPreferences;
+struct _DrwTimer
+{
+ GTimeVal start_time;
+};
-DrwPreferences * drw_preferences_new (void);
+DrwTimer * drw_timer_new (void)
+{
+ DrwTimer * timer = g_new0 (DrwTimer, 1);
+ drw_timer_start (timer);
+ return timer;
+}
+
+void drw_timer_start (DrwTimer *timer)
+{
+ g_get_current_time (&timer->start_time);
+}
+
+double drw_timer_elapsed (DrwTimer *timer)
+{
+ GTimeVal now;
+ g_get_current_time (&now);
+ return now.tv_sec - timer->start_time.tv_sec;
+}
+
+void drw_timer_destroy (DrwTimer *timer)
+{
+ g_free (timer);
+}
-#endif /* __DRW_PREFERENCES_H__ */
diff --git a/src/drw-timer.h b/src/drw-timer.h
new file mode 100644
index 0000000..09392d2
--- /dev/null
+++ b/src/drw-timer.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Nathaniel Smith <njs pobox 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 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __DRW_TIMER_H__
+#define __DRW_TIMER_H__
+
+/*
+ * This file defines a timer interface similar to GTimer, but defined in real
+ * wall-clock time. A GTimer may stop counting while the computer is suspended
+ * or the process is stopped:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=552994
+ * but a DrwTimer keeps counting regardless.
+ *
+ * Currently this only provides second resolution as compared to GTimer's
+ * microsecond resolution, but a typing break program doesn't really need
+ * microsecond resolution anyway.
+ */
+
+typedef struct _DrwTimer DrwTimer;
+DrwTimer * drw_timer_new (void);
+void drw_timer_start (DrwTimer *timer);
+double drw_timer_elapsed (DrwTimer *timer);
+void drw_timer_destroy (DrwTimer *timer);
+
+#endif /* __DRW_TIMER_H__ */
diff --git a/src/drw-utils.c b/src/drw-utils.c
index 10db6ae..9242fa2 100644
--- a/src/drw-utils.c
+++ b/src/drw-utils.c
@@ -20,6 +20,7 @@
#include <config.h>
#include <gdk/gdk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
#include "drw-utils.h"
@@ -89,41 +90,83 @@ create_tile_pixbuf (GdkPixbuf *dest_pixbuf,
return dest_pixbuf;
}
-void
-drw_setup_background (GtkWidget *window)
+static gboolean
+window_draw_event (GtkWidget *widget,
+ cairo_t *context,
+ gpointer data)
+{
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ int width;
+ int height;
+
+ cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
+ gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+
+ surface = cairo_surface_create_similar (cairo_get_target (context),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ width,
+ height);
+
+ if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
+ goto done;
+ }
+
+ cr = cairo_create (surface);
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ goto done;
+ }
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_paint (cr);
+
+ /* draw a box */
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 0.5);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
+ cairo_set_source_surface (context, surface, 0, 0);
+ cairo_paint (context);
+
+ done:
+ if (surface != NULL) {
+ cairo_surface_destroy (surface);
+ }
+
+ return FALSE;
+}
+
+static void
+set_surface_background (GtkWidget *window)
{
GdkScreen *screen;
- GdkPixbuf *tmp_pixbuf, *pixbuf, *tile_pixbuf;
- GdkPixmap *pixmap;
+ GdkPixbuf *pixbuf, *tile_pixbuf;
+ cairo_surface_t *surface;
+ cairo_pattern_t *pattern;
GdkRectangle rect;
GdkColor color;
gint width, height;
+ cairo_t *cr;
- screen = gtk_widget_get_screen (window);
+ gtk_widget_realize (window);
+ screen = gtk_widget_get_screen (window);
width = gdk_screen_get_width (screen);
height = gdk_screen_get_height (screen);
-
- tmp_pixbuf = gdk_pixbuf_get_from_drawable (NULL,
- gdk_screen_get_root_window (screen),
- gdk_screen_get_system_colormap (screen),
- 0,
- 0,
- 0,
- 0,
- width, height);
-
+
pixbuf = gdk_pixbuf_new_from_file (IMAGEDIR "/ocean-stripes.png", NULL);
rect.x = 0;
rect.y = 0;
rect.width = width;
rect.height = height;
-
+
color.red = 0;
color.blue = 0;
color.green = 0;
-
+
tile_pixbuf = create_tile_pixbuf (NULL,
pixbuf,
&rect,
@@ -132,42 +175,50 @@ drw_setup_background (GtkWidget *window)
g_object_unref (pixbuf);
- gdk_pixbuf_composite (tile_pixbuf,
- tmp_pixbuf,
- 0,
- 0,
- width,
- height,
- 0,
- 0,
- 1,
- 1,
- GDK_INTERP_NEAREST,
- 225);
-
+ cr = gdk_cairo_create (gtk_widget_get_window (window));
+ surface = cairo_surface_create_similar (cairo_get_target (cr),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ width,
+ height);
+ cairo_destroy (cr);
+
+ cr = cairo_create (surface);
+ gdk_cairo_set_source_pixbuf (cr, tile_pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
g_object_unref (tile_pixbuf);
- pixmap = gdk_pixmap_new (GTK_WIDGET (window)->window,
- width,
- height,
- -1);
-
- gdk_pixbuf_render_to_drawable_alpha (tmp_pixbuf,
- pixmap,
- 0,
- 0,
- 0,
- 0,
- width,
- height,
- GDK_PIXBUF_ALPHA_BILEVEL,
- 0,
- GDK_RGB_DITHER_NONE,
- 0,
- 0);
- g_object_unref (tmp_pixbuf);
-
- gdk_window_set_back_pixmap (window->window, pixmap, FALSE);
- g_object_unref (pixmap);
+ pattern = cairo_pattern_create_for_surface (surface);
+ cairo_surface_destroy (surface);
+
+ gdk_window_set_background_pattern (gtk_widget_get_window (window), pattern);
+ cairo_pattern_destroy (pattern);
+}
+
+void
+drw_setup_background (GtkWidget *window)
+{
+ GdkScreen *screen;
+ GdkVisual *visual;
+ gboolean is_composited;
+
+ screen = gtk_widget_get_screen (window);
+ visual = gdk_screen_get_rgba_visual (screen);
+ if (visual == NULL) {
+ visual = gdk_screen_get_system_visual (screen);
+ }
+
+ if (visual != NULL && gdk_screen_is_composited (screen)) {
+ gtk_widget_set_visual (GTK_WIDGET (window), visual);
+ is_composited = TRUE;
+ } else {
+ is_composited = FALSE;
+ }
+
+ if (is_composited) {
+ g_signal_connect (window, "draw", G_CALLBACK (window_draw_event), window);
+ } else {
+ set_surface_background (window);
+ }
}
diff --git a/src/drw-utils.h b/src/drw-utils.h
index 968f531..9ef75bb 100644
--- a/src/drw-utils.h
+++ b/src/drw-utils.h
@@ -21,6 +21,8 @@
#ifndef __DRW_UTILS_H__
#define __DRW_UTILS_H__
+#include <gtk/gtk.h>
+
void drw_setup_background (GtkWidget *window);
diff --git a/src/drwright.c b/src/drwright.c
index 5f35ed1..5e8674d 100644
--- a/src/drwright.c
+++ b/src/drwright.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Copyright (C) 2002-2004 Richard Hult <richard imendio com>
+ * Copyright (C) 2003-2005 Imendio HB
+ * Copyright (C) 2002-2003 Richard Hult <richard imendio com>
* Copyright (C) 2002 CodeFactory AB
*
* This program is free software; you can redistribute it and/or
@@ -20,61 +21,64 @@
*/
#include <config.h>
-#include <time.h>
#include <string.h>
#include <math.h>
+#include <glib/gi18n.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
-#include <libgnomeui/gnome-stock-icons.h>
-#include <libgnomeui/gnome-client.h>
-#include <libgnome/gnome-i18n.h>
#include <gconf/gconf-client.h>
+
+#ifdef HAVE_APP_INDICATOR
+#include <libappindicator/app-indicator.h>
+#endif /* HAVE_APP_INDICATOR */
+
#include "drwright.h"
#include "drw-break-window.h"
#include "drw-monitor.h"
-#include "drw-preferences.h"
-#include "eggtrayicon.h"
-
-#ifdef HAVE_DBUS
-#include "dbus.h"
-#endif
+#include "drw-utils.h"
+#include "drw-timer.h"
+#ifndef HAVE_APP_INDICATOR
#define BLINK_TIMEOUT 200
#define BLINK_TIMEOUT_MIN 120
#define BLINK_TIMEOUT_FACTOR 100
+#endif /* HAVE_APP_INDICATOR */
#define POPUP_ITEM_ENABLED 1
#define POPUP_ITEM_BREAK 2
typedef enum {
STATE_START,
- STATE_IDLE,
- STATE_TYPE,
- STATE_WARN_TYPE,
- STATE_WARN_IDLE,
+ STATE_RUNNING,
+ STATE_WARN,
STATE_BREAK_SETUP,
STATE_BREAK,
STATE_BREAK_DONE_SETUP,
STATE_BREAK_DONE
} DrwState;
+#ifdef HAVE_APP_INDICATOR
+#define TYPING_MONITOR_ACTIVE_ICON "bar-green"
+#define TYPING_MONITOR_ATTENTION_ICON "bar-red"
+#endif /* HAVE_APP_INDICATOR */
+
struct _DrWright {
/* Widgets. */
GtkWidget *break_window;
+ GList *secondary_break_windows;
DrwMonitor *monitor;
- GtkItemFactory *popup_factory;
-
+ GtkUIManager *ui_manager;
+
DrwState state;
- GTimer *timer;
- GTimer *idle_timer;
+ DrwTimer *timer;
+ DrwTimer *idle_timer;
gint last_elapsed_time;
-
- gboolean is_active;
-
+ gint save_last_time;
+
/* Time settings. */
gint type_time;
gint break_time;
@@ -83,69 +87,56 @@ struct _DrWright {
gboolean enabled;
guint clock_timeout_id;
+#ifdef HAVE_APP_INDICATOR
+ AppIndicator *indicator;
+#else
guint blink_timeout_id;
gboolean blink_on;
- EggTrayIcon *icon;
- GtkWidget *icon_image;
- GtkWidget *icon_event_box;
- GtkTooltips *tooltips;
+ GtkStatusIcon *icon;
GdkPixbuf *neutral_bar;
GdkPixbuf *red_bar;
GdkPixbuf *green_bar;
GdkPixbuf *disabled_bar;
GdkPixbuf *composite_bar;
+#endif /* HAVE_APP_INDICATOR */
GtkWidget *warn_dialog;
};
-static void activity_detected_cb (DrwMonitor *monitor,
- DrWright *drwright);
-static gboolean maybe_change_state (DrWright *drwright);
-static gboolean update_tooltip (DrWright *drwright);
-static gboolean icon_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- DrWright *drwright);
-static void break_window_done_cb (GtkWidget *window,
- DrWright *dr);
-static void break_window_postpone_cb (GtkWidget *window,
- DrWright *dr);
-static void popup_enabled_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void popup_break_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void popup_preferences_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void popup_quit_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void popup_about_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static gchar * item_factory_trans_cb (const gchar *path,
- gpointer data);
-static void init_tray_icon (DrWright *dr);
-
-
-#define GIF_CB(x) ((GtkItemFactoryCallback)(x))
-
-static GtkItemFactoryEntry popup_items[] = {
- { N_("/_Enabled"), NULL, GIF_CB (popup_enabled_cb), POPUP_ITEM_ENABLED, "<ToggleItem>", NULL },
- { N_("/_Take a Break"), NULL, GIF_CB (popup_break_cb), POPUP_ITEM_BREAK, "<Item>", NULL },
- { "/sep1", NULL, 0, 0, "<Separator>", NULL },
- { N_("/_Preferences"), NULL, GIF_CB (popup_preferences_cb), 0, "<StockItem>", GTK_STOCK_PREFERENCES },
- { N_("/_About"), NULL, GIF_CB (popup_about_cb), 0, "<StockItem>", GNOME_STOCK_ABOUT },
- { "/sep2", NULL, 0, 0, "<Separator>", NULL },
- { N_("/_Remove Icon"), "", GIF_CB (popup_quit_cb), 0, "<StockItem>", GTK_STOCK_REMOVE }
+static void activity_detected_cb (DrwMonitor *monitor,
+ DrWright *drwright);
+static gboolean maybe_change_state (DrWright *drwright);
+static gint get_time_left (DrWright *drwright);
+static gboolean update_status (DrWright *drwright);
+static void break_window_done_cb (GtkWidget *window,
+ DrWright *dr);
+static void break_window_postpone_cb (GtkWidget *window,
+ DrWright *dr);
+static void break_window_destroy_cb (GtkWidget *window,
+ DrWright *dr);
+static void popup_break_cb (GtkAction *action,
+ DrWright *dr);
+static void popup_preferences_cb (GtkAction *action,
+ DrWright *dr);
+static void popup_about_cb (GtkAction *action,
+ DrWright *dr);
+#ifdef HAVE_APP_INDICATOR
+static void init_app_indicator (DrWright *dr);
+#else
+static void init_tray_icon (DrWright *dr);
+#endif /* HAVE_APP_INDICATOR */
+static GList * create_secondary_break_windows (void);
+
+static const GtkActionEntry actions[] = {
+ {"Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL, G_CALLBACK (popup_preferences_cb)},
+ {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK (popup_about_cb)},
+ {"TakeABreak", NULL, N_("_Take a Break"), NULL, NULL, G_CALLBACK (popup_break_cb)}
};
-GConfClient *gconf_client = NULL;
-gboolean debug;
+extern gboolean debug;
static void
setup_debug_values (DrWright *dr)
@@ -155,6 +146,31 @@ setup_debug_values (DrWright *dr)
dr->break_time = 10;
}
+#ifdef HAVE_APP_INDICATOR
+static void
+update_app_indicator (DrWright *dr)
+{
+ AppIndicatorStatus new_status;
+
+ if (!dr->enabled) {
+ app_indicator_set_status (dr->indicator,
+ APP_INDICATOR_STATUS_PASSIVE);
+ return;
+ }
+
+ switch (dr->state) {
+ case STATE_WARN:
+ case STATE_BREAK_SETUP:
+ case STATE_BREAK:
+ new_status = APP_INDICATOR_STATUS_ATTENTION;
+ break;
+ default:
+ new_status = APP_INDICATOR_STATUS_ACTIVE;
+ }
+
+ app_indicator_set_status (dr->indicator, new_status);
+}
+#else
static void
update_icon (DrWright *dr)
{
@@ -166,10 +182,11 @@ update_icon (DrWright *dr)
gboolean set_pixbuf;
if (!dr->enabled) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), dr->disabled_bar);
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ dr->disabled_bar);
return;
}
-
+
tmp_pixbuf = gdk_pixbuf_copy (dr->neutral_bar);
width = gdk_pixbuf_get_width (tmp_pixbuf);
@@ -182,29 +199,23 @@ update_icon (DrWright *dr)
case STATE_BREAK_SETUP:
r = 1;
break;
-
+
case STATE_BREAK_DONE:
case STATE_BREAK_DONE_SETUP:
case STATE_START:
r = 0;
break;
-
- case STATE_WARN_IDLE:
- case STATE_WARN_TYPE:
- r = ((float)(dr->type_time - dr->warn_time) / dr->type_time) +
- (float) g_timer_elapsed (dr->timer, NULL) / (float) dr->warn_time;
- break;
default:
- r = (float) g_timer_elapsed (dr->timer, NULL) / (float) dr->type_time;
+ r = (float) (drw_timer_elapsed (dr->timer) + dr->save_last_time) /
+ (float) dr->type_time;
break;
}
offset = CLAMP ((height - 0) * (1.0 - r), 1, height - 0);
switch (dr->state) {
- case STATE_WARN_TYPE:
- case STATE_WARN_IDLE:
+ case STATE_WARN:
pixbuf = dr->red_bar;
set_pixbuf = FALSE;
break;
@@ -216,8 +227,8 @@ update_icon (DrWright *dr)
default:
pixbuf = dr->green_bar;
- }
-
+ }
+
gdk_pixbuf_composite (pixbuf,
tmp_pixbuf,
0,
@@ -230,11 +241,12 @@ update_icon (DrWright *dr)
1.0,
GDK_INTERP_BILINEAR,
255);
-
+
if (set_pixbuf) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), tmp_pixbuf);
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ tmp_pixbuf);
}
-
+
if (dr->composite_bar) {
g_object_unref (dr->composite_bar);
}
@@ -247,20 +259,22 @@ blink_timeout_cb (DrWright *dr)
{
gfloat r;
gint timeout;
-
- r = (dr->warn_time - g_timer_elapsed (dr->timer, NULL)) / dr->warn_time;
+
+ r = (dr->type_time - drw_timer_elapsed (dr->timer) - dr->save_last_time) / dr->warn_time;
timeout = BLINK_TIMEOUT + BLINK_TIMEOUT_FACTOR * r;
if (timeout < BLINK_TIMEOUT_MIN) {
timeout = BLINK_TIMEOUT_MIN;
}
-
+
if (dr->blink_on || timeout == 0) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), dr->composite_bar);
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ dr->composite_bar);
} else {
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), dr->neutral_bar);
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ dr->neutral_bar);
}
-
+
dr->blink_on = !dr->blink_on;
if (timeout) {
@@ -270,30 +284,35 @@ blink_timeout_cb (DrWright *dr)
} else {
dr->blink_timeout_id = 0;
}
-
+
return FALSE;
}
+#endif /* HAVE_APP_INDICATOR */
static void
start_blinking (DrWright *dr)
{
+#ifndef HAVE_APP_INDICATOR
if (!dr->blink_timeout_id) {
dr->blink_on = TRUE;
blink_timeout_cb (dr);
}
/*gtk_widget_show (GTK_WIDGET (dr->icon));*/
+#endif /* HAVE_APP_INDICATOR */
}
static void
stop_blinking (DrWright *dr)
{
+#ifndef HAVE_APP_INDICATOR
if (dr->blink_timeout_id) {
g_source_remove (dr->blink_timeout_id);
dr->blink_timeout_id = 0;
}
/*gtk_widget_hide (GTK_WIDGET (dr->icon));*/
+#endif /* HAVE_APP_INDICATOR */
}
static gboolean
@@ -301,7 +320,7 @@ grab_keyboard_on_window (GdkWindow *window,
guint32 activate_time)
{
GdkGrabStatus status;
-
+
status = gdk_keyboard_grab (window, TRUE, activate_time);
if (status == GDK_GRAB_SUCCESS) {
return TRUE;
@@ -311,17 +330,27 @@ grab_keyboard_on_window (GdkWindow *window,
}
static gboolean
+break_window_map_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ DrWright *dr)
+{
+ grab_keyboard_on_window (gtk_widget_get_window (dr->break_window), gtk_get_current_event_time ());
+
+ return FALSE;
+}
+
+static gboolean
maybe_change_state (DrWright *dr)
{
gint elapsed_time;
gint elapsed_idle_time;
if (debug) {
- g_timer_reset (dr->idle_timer);
+ drw_timer_start (dr->idle_timer);
}
-
- elapsed_time = g_timer_elapsed (dr->timer, NULL);
- elapsed_idle_time = g_timer_elapsed (dr->idle_timer, NULL);
+
+ elapsed_time = drw_timer_elapsed (dr->timer) + dr->save_last_time;
+ elapsed_idle_time = drw_timer_elapsed (dr->idle_timer);
if (elapsed_time > dr->last_elapsed_time + dr->warn_time) {
/* If the timeout is delayed by the amount of warning time, then
@@ -338,62 +367,37 @@ maybe_change_state (DrWright *dr)
dr->break_window = NULL;
}
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), dr->neutral_bar);
+#ifndef HAVE_APP_INDICATOR
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ dr->neutral_bar);
+#endif /* HAVE_APP_INDICATOR */
+
+ dr->save_last_time = 0;
- g_timer_start (dr->timer);
- g_timer_start (dr->idle_timer);
+ drw_timer_start (dr->timer);
+ drw_timer_start (dr->idle_timer);
if (dr->enabled) {
- dr->state = STATE_IDLE;
+ dr->state = STATE_RUNNING;
}
-
- update_tooltip (dr);
+
+ update_status (dr);
stop_blinking (dr);
break;
- case STATE_IDLE:
+ case STATE_RUNNING:
+ case STATE_WARN:
if (elapsed_idle_time >= dr->break_time) {
- g_timer_start (dr->timer);
- g_timer_start (dr->idle_timer);
- } else if (dr->is_active) {
- dr->state = STATE_TYPE;
- }
- break;
-
- case STATE_TYPE:
- if (elapsed_time >= dr->type_time - dr->warn_time) {
- dr->state = STATE_WARN_TYPE;
- g_timer_start (dr->timer);
-
- start_blinking (dr);
+ dr->state = STATE_BREAK_DONE_SETUP;
} else if (elapsed_time >= dr->type_time) {
dr->state = STATE_BREAK_SETUP;
- }
- else if (!dr->is_active) {
- dr->state = STATE_IDLE;
- g_timer_start (dr->idle_timer);
- }
- break;
-
- case STATE_WARN_TYPE:
- if (elapsed_time >= dr->warn_time) {
- dr->state = STATE_BREAK_SETUP;
- }
- else if (!dr->is_active) {
- dr->state = STATE_WARN_IDLE;
+ } else if (dr->state != STATE_WARN
+ && elapsed_time >= dr->type_time - dr->warn_time) {
+ dr->state = STATE_WARN;
+ start_blinking (dr);
}
break;
- case STATE_WARN_IDLE:
- if (elapsed_idle_time >= dr->break_time) {
- dr->state = STATE_BREAK_DONE_SETUP;
- }
- else if (dr->is_active) {
- dr->state = STATE_WARN_TYPE;
- }
-
- break;
-
case STATE_BREAK_SETUP:
/* Don't allow more than one break window to coexist, can happen
* if a break is manually enforced.
@@ -402,14 +406,21 @@ maybe_change_state (DrWright *dr)
dr->state = STATE_BREAK;
break;
}
-
+
stop_blinking (dr);
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), dr->red_bar);
+#ifndef HAVE_APP_INDICATOR
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ dr->red_bar);
+#endif /* HAVE_APP_INDICATOR */
- g_timer_start (dr->timer);
+ drw_timer_start (dr->timer);
dr->break_window = drw_break_window_new ();
+ g_signal_connect (dr->break_window, "map_event",
+ G_CALLBACK (break_window_map_event_cb),
+ dr);
+
g_signal_connect (dr->break_window,
"done",
G_CALLBACK (break_window_done_cb),
@@ -420,99 +431,120 @@ maybe_change_state (DrWright *dr)
G_CALLBACK (break_window_postpone_cb),
dr);
+ g_signal_connect (dr->break_window,
+ "destroy",
+ G_CALLBACK (break_window_destroy_cb),
+ dr);
+
+ dr->secondary_break_windows = create_secondary_break_windows ();
+
gtk_widget_show (dr->break_window);
- grab_keyboard_on_window (dr->break_window->window, gtk_get_current_event_time ());
-
-#ifdef HAVE_DBUS
- dbus_emit_break (TRUE);
-#endif
-
+ dr->save_last_time = elapsed_time;
dr->state = STATE_BREAK;
break;
-
+
case STATE_BREAK:
- if (elapsed_time >= dr->break_time) {
+ if (elapsed_time - dr->save_last_time >= dr->break_time) {
dr->state = STATE_BREAK_DONE_SETUP;
}
break;
case STATE_BREAK_DONE_SETUP:
stop_blinking (dr);
- gtk_image_set_from_pixbuf (GTK_IMAGE (dr->icon_image), dr->green_bar);
+#ifndef HAVE_APP_INDICATOR
+ gtk_status_icon_set_from_pixbuf (dr->icon,
+ dr->green_bar);
+#endif /* HAVE_APP_INDICATOR */
dr->state = STATE_BREAK_DONE;
break;
-
+
case STATE_BREAK_DONE:
- if (dr->is_active) {
- dr->state = STATE_START;
- if (dr->break_window) {
- gtk_widget_destroy (dr->break_window);
- dr->break_window = NULL;
- }
+ dr->state = STATE_START;
+ if (dr->break_window) {
+ gtk_widget_destroy (dr->break_window);
+ dr->break_window = NULL;
}
break;
}
- dr->is_active = FALSE;
dr->last_elapsed_time = elapsed_time;
-
+
+#ifdef HAVE_APP_INDICATOR
+ update_app_indicator (dr);
+#else
update_icon (dr);
-
+#endif /* HAVE_APP_INDICATOR */
+
return TRUE;
}
static gboolean
-update_tooltip (DrWright *dr)
+update_status (DrWright *dr)
{
- gint elapsed_time, min;
- gchar *str;
+ gint min;
+ gchar *str;
+#ifdef HAVE_APP_INDICATOR
+ GtkWidget *item;
+#endif /* HAVE_APP_INDICATOR */
if (!dr->enabled) {
- gtk_tooltips_set_tip (GTK_TOOLTIPS (dr->tooltips),
- dr->icon_event_box,
- _("Disabled"), _("Disabled"));
+#ifdef HAVE_APP_INDICATOR
+ app_indicator_set_status (dr->indicator,
+ APP_INDICATOR_STATUS_PASSIVE);
+#else
+ gtk_status_icon_set_tooltip_text (dr->icon,
+ _("Disabled"));
+#endif /* HAVE_APP_INDICATOR */
return TRUE;
}
-
- elapsed_time = g_timer_elapsed (dr->timer, NULL);
- switch (dr->state) {
- case STATE_WARN_TYPE:
- case STATE_WARN_IDLE:
- min = floor (0.5 + (dr->warn_time - elapsed_time) / 60.0);
- break;
-
- default:
- min = floor (0.5 + (dr->type_time - elapsed_time) / 60.0);
- break;
- }
+ min = get_time_left (dr);
- if (min > 1) {
- str = g_strdup_printf (_("%d minutes until the next break"), min);
- }
- else if (min == 1) {
- str = g_strdup_printf (_("One minute until the next break"));
+ if (min >= 1) {
+#ifdef HAVE_APP_INDICATOR
+ str = g_strdup_printf (_("Take a break now (next in %dm)"), min);
+#else
+ str = g_strdup_printf (ngettext("%d minute until the next break",
+ "%d minutes until the next break",
+ min), min);
+#endif /* HAVE_APP_INDICATOR */
} else {
+#ifdef HAVE_APP_INDICATOR
+ str = g_strdup_printf (_("Take a break now (next in less than one minute)"));
+#else
str = g_strdup_printf (_("Less than one minute until the next break"));
+#endif /* HAVE_APP_INDICATOR */
}
-
- gtk_tooltips_set_tip (GTK_TOOLTIPS (dr->tooltips),
- dr->icon_event_box,
- str, str);
+
+#ifdef HAVE_APP_INDICATOR
+ item = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop/TakeABreak");
+ gtk_menu_item_set_label (GTK_MENU_ITEM (item), str);
+#else
+ gtk_status_icon_set_tooltip_text (dr->icon, str);
+#endif /* HAVE_APP_INDICATOR */
g_free (str);
return TRUE;
}
+static gint
+get_time_left (DrWright *dr)
+{
+ gint elapsed_time;
+
+ elapsed_time = drw_timer_elapsed (dr->timer);
+
+ return floor (0.5 + (dr->type_time - elapsed_time - dr->save_last_time) / 60.0);
+}
+
static void
activity_detected_cb (DrwMonitor *monitor,
DrWright *dr)
{
- dr->is_active = TRUE;
- g_timer_start (dr->idle_timer);
+ drw_timer_start (dr->idle_timer);
}
static void
@@ -523,12 +555,12 @@ gconf_notify_cb (GConfClient *client,
{
DrWright *dr = user_data;
GtkWidget *item;
-
+
if (!strcmp (entry->key, GCONF_PATH "/type_time")) {
if (entry->value->type == GCONF_VALUE_INT) {
dr->type_time = 60 * gconf_value_get_int (entry->value);
dr->warn_time = MIN (dr->type_time / 10, 5*60);
-
+
dr->state = STATE_START;
}
}
@@ -543,44 +575,20 @@ gconf_notify_cb (GConfClient *client,
dr->enabled = gconf_value_get_bool (entry->value);
dr->state = STATE_START;
- item = gtk_item_factory_get_widget_by_action (dr->popup_factory,
- POPUP_ITEM_BREAK);
+ item = gtk_ui_manager_get_widget (dr->ui_manager,
+ "/Pop/TakeABreak");
gtk_widget_set_sensitive (item, dr->enabled);
-
- update_tooltip (dr);
+
+ update_status (dr);
}
}
-
- maybe_change_state (dr);
-}
-
-static void
-popup_enabled_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
-{
- DrWright *dr = callback_data;
- GtkWidget *item;
- gboolean enabled;
-
- item = gtk_item_factory_get_widget_by_action (dr->popup_factory,
- POPUP_ITEM_ENABLED);
- enabled = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item));
-
- gconf_client_set_bool (gconf_client,
- GCONF_PATH "/enabled",
- enabled,
- NULL);
+ maybe_change_state (dr);
}
static void
-popup_break_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+popup_break_cb (GtkAction *action, DrWright *dr)
{
- DrWright *dr = callback_data;
-
if (dr->enabled) {
dr->state = STATE_BREAK_SETUP;
maybe_change_state (dr);
@@ -588,317 +596,213 @@ popup_break_cb (gpointer callback_data,
}
static void
-popup_preferences_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+popup_preferences_cb (GtkAction *action, DrWright *dr)
{
- drw_preferences_new ();
-}
+ GdkScreen *screen;
+ GError *error = NULL;
+ GtkWidget *menu;
-static void
-popup_quit_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
-{
- GtkWidget *dialog;
- gchar *str;
- gint response;
- GnomeClient *client;
-
- str = g_strdup_printf ("<b>%s</b>\n%s",
- _("Quit DrWright?"),
- _("Don't forget to take regular breaks."));
-
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- str);
+ menu = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop");
+ screen = gtk_widget_get_screen (menu);
- g_free (str);
+ if (!gdk_spawn_command_line_on_screen (screen, "gnome-keyboard-properties --typing-break", &error)) {
+ GtkWidget *error_dialog;
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("Don't Quit"),
- GTK_RESPONSE_NO);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("Quit"),
- GTK_RESPONSE_YES);
-
- g_object_set (GTK_MESSAGE_DIALOG (dialog)->label,
- "use-markup", TRUE,
- "wrap", TRUE,
- NULL);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response != GTK_RESPONSE_DELETE_EVENT) {
- gtk_widget_destroy (dialog);
- }
-
- if (response == GTK_RESPONSE_YES) {
- client = gnome_master_client ();
- gnome_client_set_restart_style (client, GNOME_RESTART_NEVER);
-
- gtk_main_quit ();
- }
-}
+ error_dialog = gtk_message_dialog_new (NULL, 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Unable to bring up the typing break properties dialog with the following error: %s"),
+ error->message);
+ g_signal_connect (error_dialog,
+ "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_set_resizable (GTK_WINDOW (error_dialog), FALSE);
+ gtk_widget_show (error_dialog);
-static void
-popup_about_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
-{
- static GtkWidget *about_window;
- GtkWidget *vbox;
- GtkWidget *label;
- GdkPixbuf *icon;
- gchar *markup;
-
- if (about_window) {
- gtk_window_present (GTK_WINDOW (about_window));
- return;
- }
-
- about_window = gtk_dialog_new ();
-
- g_signal_connect (about_window,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &about_window);
-
- gtk_dialog_add_button (GTK_DIALOG (about_window),
- GTK_STOCK_OK, GTK_RESPONSE_OK);
- gtk_dialog_set_default_response (GTK_DIALOG (about_window),
- GTK_RESPONSE_OK);
-
- gtk_window_set_title (GTK_WINDOW (about_window), _("About DrWright"));
-
- icon = NULL; /* Should get one... */
- if (icon != NULL) {
- gtk_window_set_icon (GTK_WINDOW (about_window), icon);
- g_object_unref (icon);
+ g_error_free (error);
}
-
- gtk_window_set_resizable (GTK_WINDOW (about_window), FALSE);
- gtk_window_set_position (GTK_WINDOW (about_window),
- GTK_WIN_POS_CENTER_ON_PARENT);
- gtk_window_set_type_hint (GTK_WINDOW (about_window),
- GDK_WINDOW_TYPE_HINT_DIALOG);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about_window)->vbox), vbox, FALSE, FALSE, 0);
-
- label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
- markup = g_strdup_printf ("<span size=\"xx-large\" weight=\"bold\">DrWright " VERSION "</span>\n\n"
- "%s\n\n"
- "<span size=\"small\">%s</span>\n"
- "<span size=\"small\">%s</span>\n",
- _("A computer break reminder."),
- _("Written by Richard Hult <richard imendio com>"),
- _("Eye candy added by Anders Carlsson"));
- gtk_label_set_markup (GTK_LABEL (label), markup);
- g_free (markup);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
-
- gtk_widget_show_all (about_window);
- gtk_dialog_run (GTK_DIALOG (about_window));
- gtk_widget_destroy (about_window);
}
static void
-popup_menu_position_cb (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer data)
-{
- GtkWidget *w = data;
- GtkRequisition requisition;
- gint wx, wy;
-
- g_return_if_fail (w != NULL);
-
- gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
-
- gdk_window_get_origin (w->window, &wx, &wy);
-
- if (*x < wx)
- *x = wx;
- else if (*x > wx + w->allocation.width)
- *x = wx + w->allocation.width;
-
- if (*x + requisition.width > gdk_screen_width())
- *x = gdk_screen_width() - requisition.width;
-
- if (*y < wy)
- *y = wy;
- else if (*y > wy + w->allocation.height)
- *y = wy + w->allocation.height;
-
- if (*y + requisition.height > gdk_screen_height())
- *y = gdk_screen_height() - requisition.height;
-
- *push_in = TRUE;
-}
-
-static gboolean
-icon_button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- DrWright *dr)
+popup_about_cb (GtkAction *action, DrWright *dr)
{
- GtkWidget *menu;
-
- if (event->button == 3) {
- menu = gtk_item_factory_get_widget (dr->popup_factory, "");
-
- gtk_menu_popup (GTK_MENU (menu),
- NULL,
- NULL,
- popup_menu_position_cb,
- dr->icon,
- event->button,
- event->time);
-
- return TRUE;
- }
-
- return FALSE;
+ gint i;
+ gchar *authors[] = {
+ N_("Written by Richard Hult <richard imendio com>"),
+ N_("Eye candy added by Anders Carlsson"),
+ NULL
+ };
+
+ for (i = 0; authors [i]; i++)
+ authors [i] = _(authors [i]);
+
+ gtk_show_about_dialog (NULL,
+ "authors", authors,
+ "comments", _("A computer break reminder."),
+ "logo-icon-name", "typing-monitor",
+ "translator-credits", _("translator-credits"),
+ "version", VERSION,
+ NULL);
}
+#ifndef HAVE_APP_INDICATOR
static void
popup_menu_cb (GtkWidget *widget,
+ guint button,
+ guint activate_time,
DrWright *dr)
{
GtkWidget *menu;
-
- menu = gtk_item_factory_get_widget (dr->popup_factory, "");
-
+
+ menu = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop");
+
gtk_menu_popup (GTK_MENU (menu),
NULL,
NULL,
- popup_menu_position_cb,
+ gtk_status_icon_position_menu,
dr->icon,
0,
- gtk_get_current_event_time());
+ gtk_get_current_event_time ());
}
+#endif /* HAVE_APP_INDICATOR */
static void
break_window_done_cb (GtkWidget *window,
DrWright *dr)
{
gtk_widget_destroy (dr->break_window);
-
+
dr->state = STATE_BREAK_DONE_SETUP;
dr->break_window = NULL;
-
- maybe_change_state (dr);
-#ifdef HAVE_DBUS
- dbus_emit_break (FALSE);
-#endif
+ update_status (dr);
+ maybe_change_state (dr);
}
static void
break_window_postpone_cb (GtkWidget *window,
DrWright *dr)
{
+ gint elapsed_time;
+
gtk_widget_destroy (dr->break_window);
- dr->state = STATE_WARN_TYPE;
+ dr->state = STATE_RUNNING;
dr->break_window = NULL;
- g_timer_start (dr->timer);
- start_blinking (dr);
- update_icon (dr);
- update_tooltip (dr);
+ elapsed_time = drw_timer_elapsed (dr->timer);
-#ifdef HAVE_DBUS
- dbus_emit_break (FALSE);
-#endif
-}
+ if (elapsed_time + dr->save_last_time >= dr->type_time) {
+ /* Typing time has expired, but break was postponed.
+ * We'll warn again in (elapsed * sqrt (typing_time))^2 */
+ gfloat postpone_time = (((float) elapsed_time) / dr->break_time)
+ * sqrt (dr->type_time);
+ postpone_time *= postpone_time;
+ dr->save_last_time = dr->type_time - MAX (dr->warn_time, (gint) postpone_time);
+ }
-static char *
-item_factory_trans_cb (const gchar *path,
- gpointer data)
-{
- return _((gchar*) path);
+ drw_timer_start (dr->timer);
+ maybe_change_state (dr);
+ update_status (dr);
+#ifdef HAVE_APP_INDICATOR
+ update_app_indicator (dr);
+#else
+ update_icon (dr);
+#endif /* HAVE_APP_INDICATOR */
}
static void
-icon_event_box_destroy_cb (GtkWidget *widget,
- DrWright *dr)
+break_window_destroy_cb (GtkWidget *window,
+ DrWright *dr)
{
- gtk_widget_destroy (GTK_WIDGET (dr->icon));
- init_tray_icon (dr);
+ GList *l;
+
+ for (l = dr->secondary_break_windows; l; l = l->next) {
+ gtk_widget_destroy (l->data);
+ }
+
+ g_list_free (dr->secondary_break_windows);
+ dr->secondary_break_windows = NULL;
}
-static gboolean
-icon_event_box_expose_event_cb (GtkWidget *widget,
- GdkEventExpose *event,
- DrWright *dr)
+#ifdef HAVE_APP_INDICATOR
+static void
+init_app_indicator (DrWright *dr)
{
- if (GTK_WIDGET_HAS_FOCUS (widget)) {
- gint focus_width, focus_pad;
- gint x, y, width, height;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
- x = widget->allocation.x + focus_pad;
- y = widget->allocation.y + focus_pad;
- width = widget->allocation.width - 2 * focus_pad;
- height = widget->allocation.height - 2 * focus_pad;
-
- gtk_paint_focus (widget->style, widget->window,
- GTK_WIDGET_STATE (widget),
- &event->area, widget, "button",
- x, y, width, height);
+ GtkWidget *indicator_menu;
+
+ dr->indicator =
+ app_indicator_new_with_path ("typing-break-indicator",
+ TYPING_MONITOR_ACTIVE_ICON,
+ APP_INDICATOR_CATEGORY_APPLICATION_STATUS,
+ IMAGEDIR);
+ if (dr->enabled) {
+ app_indicator_set_status (dr->indicator,
+ APP_INDICATOR_STATUS_ACTIVE);
+ } else {
+ app_indicator_set_status (dr->indicator,
+ APP_INDICATOR_STATUS_PASSIVE);
}
- return FALSE;
-}
+ indicator_menu = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop");
+ app_indicator_set_menu (dr->indicator, GTK_MENU (indicator_menu));
+ app_indicator_set_attention_icon (dr->indicator, TYPING_MONITOR_ATTENTION_ICON);
+ update_status (dr);
+ update_app_indicator (dr);
+}
+#else
static void
init_tray_icon (DrWright *dr)
{
- dr->icon = egg_tray_icon_new (_("Break reminder"));
-
- dr->icon_event_box = gtk_event_box_new ();
- dr->icon_image = gtk_image_new_from_pixbuf (dr->neutral_bar);
- gtk_container_add (GTK_CONTAINER (dr->icon_event_box), dr->icon_image);
-
- gtk_widget_add_events (GTK_WIDGET (dr->icon), GDK_BUTTON_PRESS_MASK | GDK_FOCUS_CHANGE_MASK);
- gtk_container_add (GTK_CONTAINER (dr->icon), dr->icon_event_box);
- gtk_widget_show_all (GTK_WIDGET (dr->icon));
-
- GTK_WIDGET_SET_FLAGS (dr->icon_event_box, GTK_CAN_FOCUS);
-
- update_tooltip (dr);
- update_icon (dr);
-
- g_signal_connect (dr->icon,
- "button_press_event",
- G_CALLBACK (icon_button_press_cb),
- dr);
+ dr->icon = gtk_status_icon_new_from_pixbuf (dr->neutral_bar);
- g_signal_connect (dr->icon,
- "destroy",
- G_CALLBACK (icon_event_box_destroy_cb),
- dr);
+ update_status (dr);
+ update_icon (dr);
g_signal_connect (dr->icon,
"popup_menu",
G_CALLBACK (popup_menu_cb),
dr);
-
- g_signal_connect_after (dr->icon_event_box,
- "expose_event",
- G_CALLBACK (icon_event_box_expose_event_cb),
- dr);
+}
+#endif /* HAVE_APP_INDICATOR */
+
+static GList *
+create_secondary_break_windows (void)
+{
+ GdkDisplay *display;
+ GdkScreen *screen;
+ GtkWidget *window;
+ gint i;
+ GList *windows = NULL;
+
+ display = gdk_display_get_default ();
+
+ for (i = 0; i < gdk_display_get_n_screens (display); i++) {
+ screen = gdk_display_get_screen (display, i);
+
+ if (screen == gdk_screen_get_default ()) {
+ /* Handled by DrwBreakWindow. */
+ continue;
+ }
+
+ window = gtk_window_new (GTK_WINDOW_POPUP);
+
+ windows = g_list_prepend (windows, window);
+
+ gtk_window_set_screen (GTK_WINDOW (window), screen);
+
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ gdk_screen_get_width (screen),
+ gdk_screen_get_height (screen));
+
+ gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+ drw_setup_background (GTK_WIDGET (window));
+ gtk_window_stick (GTK_WINDOW (window));
+ gtk_widget_show (window);
+ }
+
+ return windows;
}
DrWright *
@@ -906,60 +810,67 @@ drwright_new (void)
{
DrWright *dr;
GtkWidget *item;
+ GConfClient *client;
+ GtkActionGroup *action_group;
+
+ static const char ui_description[] =
+ "<ui>"
+ " <popup name='Pop'>"
+ " <menuitem action='Preferences'/>"
+ " <menuitem action='About'/>"
+ " <separator/>"
+ " <menuitem action='TakeABreak'/>"
+ " </popup>"
+ "</ui>";
dr = g_new0 (DrWright, 1);
- gconf_client = gconf_client_get_default ();
+ client = gconf_client_get_default ();
- gconf_client_add_dir (gconf_client, GCONF_PATH "",
+ gconf_client_add_dir (client,
+ GCONF_PATH,
GCONF_CLIENT_PRELOAD_NONE,
NULL);
-
- gconf_client_notify_add (gconf_client, GCONF_PATH "",
+
+ gconf_client_notify_add (client, GCONF_PATH,
gconf_notify_cb,
dr,
NULL,
NULL);
-
+
dr->type_time = 60 * gconf_client_get_int (
- gconf_client, GCONF_PATH "/type_time", NULL);
-
- dr->warn_time = MIN (dr->type_time / 10, 60*5);
-
+ client, GCONF_PATH "/type_time", NULL);
+
+ dr->warn_time = MIN (dr->type_time / 12, 60*3);
+
dr->break_time = 60 * gconf_client_get_int (
- gconf_client, GCONF_PATH "/break_time", NULL);
+ client, GCONF_PATH "/break_time", NULL);
dr->enabled = gconf_client_get_bool (
- gconf_client,
+ client,
GCONF_PATH "/enabled",
NULL);
+ g_object_unref (client);
+
if (debug) {
setup_debug_values (dr);
}
-
- dr->popup_factory = gtk_item_factory_new (GTK_TYPE_MENU,
- "<main>",
- NULL);
- gtk_item_factory_set_translate_func (dr->popup_factory,
- item_factory_trans_cb,
- NULL,
- NULL);
-
- gtk_item_factory_create_items (dr->popup_factory,
- G_N_ELEMENTS (popup_items),
- popup_items,
- dr);
-
- item = gtk_item_factory_get_widget_by_action (dr->popup_factory, POPUP_ITEM_ENABLED);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), dr->enabled);
-
- item = gtk_item_factory_get_widget_by_action (dr->popup_factory, POPUP_ITEM_BREAK);
+
+ dr->ui_manager = gtk_ui_manager_new ();
+
+ action_group = gtk_action_group_new ("MenuActions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group, actions, G_N_ELEMENTS (actions), dr);
+ gtk_ui_manager_insert_action_group (dr->ui_manager, action_group, 0);
+ gtk_ui_manager_add_ui_from_string (dr->ui_manager, ui_description, -1, NULL);
+
+ item = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop/TakeABreak");
gtk_widget_set_sensitive (item, dr->enabled);
-
- dr->timer = g_timer_new ();
- dr->idle_timer = g_timer_new ();
-
+
+ dr->timer = drw_timer_new ();
+ dr->idle_timer = drw_timer_new ();
+
dr->state = STATE_START;
dr->monitor = drw_monitor_new ();
@@ -969,22 +880,24 @@ drwright_new (void)
G_CALLBACK (activity_detected_cb),
dr);
+#ifdef HAVE_APP_INDICATOR
+ init_app_indicator (dr);
+#else
dr->neutral_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar.png", NULL);
dr->red_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-red.png", NULL);
dr->green_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-green.png", NULL);
dr->disabled_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-disabled.png", NULL);
- dr->tooltips = gtk_tooltips_new ();
-
init_tray_icon (dr);
-
- g_timeout_add (15*1000,
- (GSourceFunc) update_tooltip,
- dr);
- g_timeout_add (500,
- (GSourceFunc) maybe_change_state,
- dr);
+#endif /* HAVE_APP_INDICATOR */
+
+ g_timeout_add_seconds (12,
+ (GSourceFunc) update_status,
+ dr);
+
+ g_timeout_add_seconds (1,
+ (GSourceFunc) maybe_change_state,
+ dr);
return dr;
}
-
diff --git a/src/drwright.h b/src/drwright.h
index 256b5ef..df2cf99 100644
--- a/src/drwright.h
+++ b/src/drwright.h
@@ -21,7 +21,7 @@
#ifndef __DR_WRIGHT_H__
#define __DR_WRIGHT_H__
-#define GCONF_PATH "/apps/drwright"
+#define GCONF_PATH "/desktop/gnome/typing_break"
typedef struct _DrWright DrWright;
diff --git a/src/drwright.schemas.in b/src/drwright.schemas.in
new file mode 100644
index 0000000..f04fe2f
--- /dev/null
+++ b/src/drwright.schemas.in
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gconfschemafile>
+ <schemalist>
+ <schema>
+ <key>/schemas/apps/gnome_settings_daemon/plugins/typing-break/active</key>
+ <applyto>/apps/gnome_settings_daemon/plugins/typing-break/active</applyto>
+ <owner>gnome-settings-daemon</owner>
+ <type>bool</type>
+ <default>TRUE</default>
+ <locale name="C">
+ <short>Enable typing breaks plugin</short>
+ <long>Set to True to enable the plugin to manage typing breaks.</long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/gnome_settings_daemon/plugins/typing-break/priority</key>
+ <applyto>/apps/gnome_settings_daemon/plugins/typing-break/priority</applyto>
+ <owner>gnome-settings-daemon</owner>
+ <type>int</type>
+ <default>200</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+ </schemalist>
+</gconfschemafile>
+
diff --git a/src/gnome-settings-profile.h b/src/gnome-settings-profile.h
new file mode 100644
index 0000000..ff85c1b
--- /dev/null
+++ b/src/gnome-settings-profile.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann jhu edu>
+ *
+ * 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 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors: William Jon McCann <mccann jhu edu>
+ *
+ */
+
+#ifndef __GNOME_SETTINGS_PROFILE_H
+#define __GNOME_SETTINGS_PROFILE_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#ifdef ENABLE_PROFILING
+#ifdef G_HAVE_ISO_VARARGS
+#define gnome_settings_profile_start(...) _gnome_settings_profile_log (G_STRFUNC, "start", __VA_ARGS__)
+#define gnome_settings_profile_end(...) _gnome_settings_profile_log (G_STRFUNC, "end", __VA_ARGS__)
+#define gnome_settings_profile_msg(...) _gnome_settings_profile_log (NULL, NULL, __VA_ARGS__)
+#elif defined(G_HAVE_GNUC_VARARGS)
+#define gnome_settings_profile_start(format...) _gnome_settings_profile_log (G_STRFUNC, "start", format)
+#define gnome_settings_profile_end(format...) _gnome_settings_profile_log (G_STRFUNC, "end", format)
+#define gnome_settings_profile_msg(format...) _gnome_settings_profile_log (NULL, NULL, format)
+#endif
+#else
+#define gnome_settings_profile_start(...)
+#define gnome_settings_profile_end(...)
+#define gnome_settings_profile_msg(...)
+#endif
+
+void _gnome_settings_profile_log (const char *func,
+ const char *note,
+ const char *format,
+ ...) G_GNUC_PRINTF (3, 4);
+
+G_END_DECLS
+
+#endif /* __GNOME_SETTINGS_PROFILE_H */
diff --git a/src/gsd-typing-break-manager.c b/src/gsd-typing-break-manager.c
new file mode 100644
index 0000000..69b60cd
--- /dev/null
+++ b/src/gsd-typing-break-manager.c
@@ -0,0 +1,339 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <locale.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+
+#include "gnome-settings-profile.h"
+#include "gsd-typing-break-manager.h"
+
+#define GSD_TYPING_BREAK_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_TYPING_BREAK_MANAGER, GsdTypingBreakManagerPrivate))
+
+#define GCONF_BREAK_DIR "/desktop/gnome/typing_break"
+
+struct GsdTypingBreakManagerPrivate
+{
+ GPid typing_monitor_pid;
+ guint typing_monitor_idle_id;
+ guint child_watch_id;
+ guint setup_id;
+ guint notify;
+};
+
+static void gsd_typing_break_manager_class_init (GsdTypingBreakManagerClass *klass);
+static void gsd_typing_break_manager_init (GsdTypingBreakManager *typing_break_manager);
+static void gsd_typing_break_manager_finalize (GObject *object);
+
+G_DEFINE_TYPE (GsdTypingBreakManager, gsd_typing_break_manager, G_TYPE_OBJECT)
+
+static gpointer manager_object = NULL;
+
+static gboolean
+typing_break_timeout (GsdTypingBreakManager *manager)
+{
+ if (manager->priv->typing_monitor_pid > 0) {
+ kill (manager->priv->typing_monitor_pid, SIGKILL);
+ }
+
+ manager->priv->typing_monitor_idle_id = 0;
+
+ return FALSE;
+}
+
+static void
+child_watch (GPid pid,
+ int status,
+ GsdTypingBreakManager *manager)
+{
+ if (pid == manager->priv->typing_monitor_pid) {
+ manager->priv->typing_monitor_pid = 0;
+ g_spawn_close_pid (pid);
+ }
+}
+
+static void
+setup_typing_break (GsdTypingBreakManager *manager,
+ gboolean enabled)
+{
+ gnome_settings_profile_start (NULL);
+
+ if (! enabled) {
+ if (manager->priv->typing_monitor_pid != 0) {
+ manager->priv->typing_monitor_idle_id = g_timeout_add_seconds (3, (GSourceFunc) typing_break_timeout, manager);
+ }
+ return;
+ }
+
+ if (manager->priv->typing_monitor_idle_id != 0) {
+ g_source_remove (manager->priv->typing_monitor_idle_id);
+ manager->priv->typing_monitor_idle_id = 0;
+ }
+
+ if (manager->priv->typing_monitor_pid == 0) {
+ GError *error;
+ char *argv[] = { "gnome-typing-monitor", "-n", NULL };
+ gboolean res;
+
+ error = NULL;
+ res = g_spawn_async ("/",
+ argv,
+ NULL,
+ G_SPAWN_STDOUT_TO_DEV_NULL
+ | G_SPAWN_STDERR_TO_DEV_NULL
+ | G_SPAWN_SEARCH_PATH
+ | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL,
+ NULL,
+ &manager->priv->typing_monitor_pid,
+ &error);
+ if (! res) {
+ /* FIXME: put up a warning */
+ g_warning ("failed: %s\n", error->message);
+ g_error_free (error);
+ manager->priv->typing_monitor_pid = 0;
+ return;
+ }
+
+ manager->priv->child_watch_id = g_child_watch_add (manager->priv->typing_monitor_pid,
+ (GChildWatchFunc)child_watch,
+ manager);
+ }
+
+ gnome_settings_profile_end (NULL);
+}
+
+static void
+typing_break_callback (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ GsdTypingBreakManager *manager)
+{
+ if (! strcmp (entry->key, "/desktop/gnome/typing_break/enabled")) {
+ if (entry->value->type == GCONF_VALUE_BOOL) {
+ setup_typing_break (manager, gconf_value_get_bool (entry->value));
+ }
+ }
+}
+
+static gboolean
+really_setup_typing_break (GsdTypingBreakManager *manager)
+{
+ setup_typing_break (manager, TRUE);
+ manager->priv->setup_id = 0;
+ return FALSE;
+}
+
+gboolean
+gsd_typing_break_manager_start (GsdTypingBreakManager *manager,
+ GError **error)
+{
+ GConfClient *client;
+ gboolean enabled;
+
+ g_debug ("Starting typing_break manager");
+ gnome_settings_profile_start (NULL);
+
+ client = gconf_client_get_default ();
+
+ gconf_client_add_dir (client, GCONF_BREAK_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ manager->priv->notify =
+ gconf_client_notify_add (client,
+ GCONF_BREAK_DIR,
+ (GConfClientNotifyFunc) typing_break_callback, manager,
+ NULL, NULL);
+
+ enabled = gconf_client_get_bool (client, GCONF_BREAK_DIR "/enabled", NULL);
+ g_object_unref (client);
+ if (enabled) {
+ manager->priv->setup_id =
+ g_timeout_add_seconds (3,
+ (GSourceFunc) really_setup_typing_break,
+ manager);
+ }
+
+ gnome_settings_profile_end (NULL);
+
+ return TRUE;
+}
+
+void
+gsd_typing_break_manager_stop (GsdTypingBreakManager *manager)
+{
+ GsdTypingBreakManagerPrivate *p = manager->priv;
+
+ g_debug ("Stopping typing_break manager");
+
+ if (p->setup_id != 0) {
+ g_source_remove (p->setup_id);
+ p->setup_id = 0;
+ }
+
+ if (p->child_watch_id != 0) {
+ g_source_remove (p->child_watch_id);
+ p->child_watch_id = 0;
+ }
+
+ if (p->typing_monitor_idle_id != 0) {
+ g_source_remove (p->typing_monitor_idle_id);
+ p->typing_monitor_idle_id = 0;
+ }
+
+ if (p->typing_monitor_pid > 0) {
+ kill (p->typing_monitor_pid, SIGKILL);
+ g_spawn_close_pid (p->typing_monitor_pid);
+ p->typing_monitor_pid = 0;
+ }
+
+ if (p->notify != 0) {
+ GConfClient *client = gconf_client_get_default ();
+ gconf_client_remove_dir (client, GCONF_BREAK_DIR, NULL);
+ gconf_client_notify_remove (client, p->notify);
+ g_object_unref (client);
+ p->notify = 0;
+ }
+}
+
+static void
+gsd_typing_break_manager_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GsdTypingBreakManager *self;
+
+ self = GSD_TYPING_BREAK_MANAGER (object);
+
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsd_typing_break_manager_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsdTypingBreakManager *self;
+
+ self = GSD_TYPING_BREAK_MANAGER (object);
+
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GObject *
+gsd_typing_break_manager_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GsdTypingBreakManager *typing_break_manager;
+ GsdTypingBreakManagerClass *klass;
+
+ klass = GSD_TYPING_BREAK_MANAGER_CLASS (g_type_class_peek (GSD_TYPE_TYPING_BREAK_MANAGER));
+
+ typing_break_manager = GSD_TYPING_BREAK_MANAGER (G_OBJECT_CLASS (gsd_typing_break_manager_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ return G_OBJECT (typing_break_manager);
+}
+
+static void
+gsd_typing_break_manager_dispose (GObject *object)
+{
+ GsdTypingBreakManager *typing_break_manager;
+
+ typing_break_manager = GSD_TYPING_BREAK_MANAGER (object);
+
+ G_OBJECT_CLASS (gsd_typing_break_manager_parent_class)->dispose (object);
+}
+
+static void
+gsd_typing_break_manager_class_init (GsdTypingBreakManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = gsd_typing_break_manager_get_property;
+ object_class->set_property = gsd_typing_break_manager_set_property;
+ object_class->constructor = gsd_typing_break_manager_constructor;
+ object_class->dispose = gsd_typing_break_manager_dispose;
+ object_class->finalize = gsd_typing_break_manager_finalize;
+
+ g_type_class_add_private (klass, sizeof (GsdTypingBreakManagerPrivate));
+}
+
+static void
+gsd_typing_break_manager_init (GsdTypingBreakManager *manager)
+{
+ manager->priv = GSD_TYPING_BREAK_MANAGER_GET_PRIVATE (manager);
+
+}
+
+static void
+gsd_typing_break_manager_finalize (GObject *object)
+{
+ GsdTypingBreakManager *typing_break_manager;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GSD_IS_TYPING_BREAK_MANAGER (object));
+
+ typing_break_manager = GSD_TYPING_BREAK_MANAGER (object);
+
+ g_return_if_fail (typing_break_manager->priv != NULL);
+
+ G_OBJECT_CLASS (gsd_typing_break_manager_parent_class)->finalize (object);
+}
+
+GsdTypingBreakManager *
+gsd_typing_break_manager_new (void)
+{
+ if (manager_object != NULL) {
+ g_object_ref (manager_object);
+ } else {
+ manager_object = g_object_new (GSD_TYPE_TYPING_BREAK_MANAGER, NULL);
+ g_object_add_weak_pointer (manager_object,
+ (gpointer *) &manager_object);
+ }
+
+ return GSD_TYPING_BREAK_MANAGER (manager_object);
+}
diff --git a/src/gsd-typing-break-manager.h b/src/gsd-typing-break-manager.h
new file mode 100644
index 0000000..ac10138
--- /dev/null
+++ b/src/gsd-typing-break-manager.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_TYPING_BREAK_MANAGER_H
+#define __GSD_TYPING_BREAK_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_TYPING_BREAK_MANAGER (gsd_typing_break_manager_get_type ())
+#define GSD_TYPING_BREAK_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_TYPING_BREAK_MANAGER, GsdTypingBreakManager))
+#define GSD_TYPING_BREAK_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_TYPING_BREAK_MANAGER, GsdTypingBreakManagerClass))
+#define GSD_IS_TYPING_BREAK_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_TYPING_BREAK_MANAGER))
+#define GSD_IS_TYPING_BREAK_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_TYPING_BREAK_MANAGER))
+#define GSD_TYPING_BREAK_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_TYPING_BREAK_MANAGER, GsdTypingBreakManagerClass))
+
+typedef struct GsdTypingBreakManagerPrivate GsdTypingBreakManagerPrivate;
+
+typedef struct
+{
+ GObject parent;
+ GsdTypingBreakManagerPrivate *priv;
+} GsdTypingBreakManager;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} GsdTypingBreakManagerClass;
+
+GType gsd_typing_break_manager_get_type (void);
+
+GsdTypingBreakManager * gsd_typing_break_manager_new (void);
+gboolean gsd_typing_break_manager_start (GsdTypingBreakManager *manager,
+ GError **error);
+void gsd_typing_break_manager_stop (GsdTypingBreakManager *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_TYPING_BREAK_MANAGER_H */
diff --git a/src/gsd-typing-break-plugin.c b/src/gsd-typing-break-plugin.c
new file mode 100644
index 0000000..28621fa
--- /dev/null
+++ b/src/gsd-typing-break-plugin.c
@@ -0,0 +1,108 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include "gsd-typing-break-plugin.h"
+#include "gsd-typing-break-manager.h"
+
+struct GsdTypingBreakPluginPrivate {
+ GsdTypingBreakManager *manager;
+};
+
+#define GSD_TYPING_BREAK_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_TYPING_BREAK_PLUGIN, GsdTypingBreakPluginPrivate))
+
+GNOME_SETTINGS_PLUGIN_REGISTER (GsdTypingBreakPlugin, gsd_typing_break_plugin)
+
+static void
+gsd_typing_break_plugin_class_finalize (GsdTypingBreakPluginClass*klass)
+{
+}
+
+static void
+gsd_typing_break_plugin_init (GsdTypingBreakPlugin *plugin)
+{
+ plugin->priv = GSD_TYPING_BREAK_PLUGIN_GET_PRIVATE (plugin);
+
+ g_debug ("GsdTypingBreakPlugin initializing");
+
+ plugin->priv->manager = gsd_typing_break_manager_new ();
+}
+
+static void
+gsd_typing_break_plugin_finalize (GObject *object)
+{
+ GsdTypingBreakPlugin *plugin;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GSD_IS_TYPING_BREAK_PLUGIN (object));
+
+ g_debug ("GsdTypingBreakPlugin finalizing");
+
+ plugin = GSD_TYPING_BREAK_PLUGIN (object);
+
+ g_return_if_fail (plugin->priv != NULL);
+
+ if (plugin->priv->manager != NULL) {
+ g_object_unref (plugin->priv->manager);
+ }
+
+ G_OBJECT_CLASS (gsd_typing_break_plugin_parent_class)->finalize (object);
+}
+
+static void
+impl_activate (GnomeSettingsPlugin *plugin)
+{
+ gboolean res;
+ GError *error;
+
+ g_debug ("Activating typing_break plugin");
+
+ error = NULL;
+ res = gsd_typing_break_manager_start (GSD_TYPING_BREAK_PLUGIN (plugin)->priv->manager, &error);
+ if (! res) {
+ g_warning ("Unable to start typing_break manager: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+impl_deactivate (GnomeSettingsPlugin *plugin)
+{
+ g_debug ("Deactivating typing_break plugin");
+ gsd_typing_break_manager_stop (GSD_TYPING_BREAK_PLUGIN (plugin)->priv->manager);
+}
+
+static void
+gsd_typing_break_plugin_class_init (GsdTypingBreakPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gsd_typing_break_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+
+ g_type_class_add_private (klass, sizeof (GsdTypingBreakPluginPrivate));
+}
diff --git a/src/gsd-typing-break-plugin.h b/src/gsd-typing-break-plugin.h
new file mode 100644
index 0000000..50bee59
--- /dev/null
+++ b/src/gsd-typing-break-plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * 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, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_TYPING_BREAK_PLUGIN_H__
+#define __GSD_TYPING_BREAK_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include <gnome-settings-daemon/gnome-settings-plugin.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_TYPING_BREAK_PLUGIN (gsd_typing_break_plugin_get_type ())
+#define GSD_TYPING_BREAK_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_TYPING_BREAK_PLUGIN, GsdTypingBreakPlugin))
+#define GSD_TYPING_BREAK_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_TYPING_BREAK_PLUGIN, GsdTypingBreakPluginClass))
+#define GSD_IS_TYPING_BREAK_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_TYPING_BREAK_PLUGIN))
+#define GSD_IS_TYPING_BREAK_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_TYPING_BREAK_PLUGIN))
+#define GSD_TYPING_BREAK_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_TYPING_BREAK_PLUGIN, GsdTypingBreakPluginClass))
+
+typedef struct GsdTypingBreakPluginPrivate GsdTypingBreakPluginPrivate;
+
+typedef struct
+{
+ GnomeSettingsPlugin parent;
+ GsdTypingBreakPluginPrivate *priv;
+} GsdTypingBreakPlugin;
+
+typedef struct
+{
+ GnomeSettingsPluginClass parent_class;
+} GsdTypingBreakPluginClass;
+
+GType gsd_typing_break_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_TYPING_BREAK_PLUGIN_H__ */
diff --git a/src/main.c b/src/main.c
index 4d844a0..ef0a339 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,53 +21,21 @@
#include <config.h>
#include <string.h>
+#include <stdlib.h>
+#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-#include <libgnomeui/libgnomeui.h>
-#include <libgnome/gnome-i18n.h>
+
#include "drw-selection.h"
#include "drwright.h"
gboolean debug = FALSE;
-static gboolean
-session_die (GnomeClient *client, gpointer client_data)
-{
- gtk_main_quit ();
-
- return TRUE;
-}
-
-static gboolean
-session_save (GnomeClient *client,
- gint phase,
- GnomeRestartStyle rstyle,
- gint shutdown,
- GnomeInteractStyle istyle,
- gint fast,
- gpointer user_data)
-{
- gchar *argv[2];
-
- /* Only with glib 2.2:
- * argv[0] = g_get_application_name ();
- */
-
- argv[0] = user_data;
- argv[1] = "-n";
-
- gnome_client_set_clone_command (client, 2, argv);
- gnome_client_set_restart_command (client, 2, argv);
-
- return TRUE;
-}
-
+#ifndef HAVE_APP_INDICATOR
static gboolean
have_tray (void)
{
- Screen *xscreen = DefaultScreenOfDisplay (gdk_display);
+ Screen *xscreen = DefaultScreenOfDisplay (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
Atom selection_atom;
char *selection_atom_name;
@@ -82,92 +50,73 @@ have_tray (void)
return FALSE;
}
}
+#endif /* HAVE_APP_INDICATOR */
int
main (int argc, char *argv[])
{
- gint i;
DrWright *drwright;
DrwSelection *selection;
- GnomeClient *client;
gboolean no_check = FALSE;
-
- bindtextdomain (GETTEXT_PACKAGE, DRWRIGHT_LOCALEDIR);
+ const GOptionEntry options[] = {
+ { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
+ N_("Enable debugging code"), NULL },
+ { "no-check", 'n', 0, G_OPTION_ARG_NONE, &no_check,
+ N_("Don't check whether the notification area exists"), NULL },
+ { NULL }
+ };
+ GOptionContext *option_context;
+ GError *error = NULL;
+ gboolean retval;
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
-
- i = 1;
- while (i < argc) {
- const gchar *arg = argv[i];
-
- if (strcmp (arg, "--debug") == 0 ||
- strcmp (arg, "-d") == 0) {
- debug = TRUE;
- }
- else if (strcmp (arg, "-n") == 0) {
- no_check = TRUE;
- }
- else if (strcmp (arg, "-?") == 0) {
- g_printerr ("Usage: %s [--debug]\n", argv[0]);
- return 0;
- }
-
- ++i;
- }
- gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
- argc, argv, NULL);
+ option_context = g_option_context_new (NULL);
+#if GLIB_CHECK_VERSION (2, 12, 0)
+ g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);
+#endif
+ g_option_context_add_main_entries (option_context, options, GETTEXT_PACKAGE);
+ g_option_context_add_group (option_context, gtk_get_option_group (TRUE));
+
+ retval = g_option_context_parse (option_context, &argc, &argv, &error);
+ g_option_context_free (option_context);
+ if (!retval) {
+ g_print ("%s\n", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ g_set_application_name (_("Typing Monitor"));
+ gtk_window_set_default_icon_name ("typing-monitor");
selection = drw_selection_start ();
if (!drw_selection_is_master (selection)) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL, 0,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- _("DrWright is already running."));
-
- gtk_dialog_run (GTK_DIALOG (dialog));
-
+ g_message ("The typing monitor is already running, exiting.");
return 0;
}
+#ifndef HAVE_APP_INDICATOR
if (!no_check && !have_tray ()) {
GtkWidget *dialog;
- dialog = gtk_message_dialog_new (NULL, 0,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE,
- _("DrWright uses the notification area to display "
- "information. You don't seem to have a notification area "
- "on your panel. You can add it by right-clicking on your "
- "panel and choose 'Add to panel -> Utilities -> Notification area'."));
-
+ dialog = gtk_message_dialog_new (
+ NULL, 0,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CLOSE,
+ _("The typing monitor uses the notification area to display "
+ "information. You don't seem to have a notification area "
+ "on your panel. You can add it by right-clicking on your "
+ "panel and choosing 'Add to panel', selecting 'Notification "
+ "area' and clicking 'Add'."));
+
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+#endif /* HAVE_APP_INDICATOR */
- client = gnome_master_client ();
-
- gnome_client_set_priority (client, 70);
- if (!debug) {
- gnome_client_set_restart_style (client, GNOME_RESTART_IMMEDIATELY);
- } else {
- /* Don't respawn in debug mode. */
- gnome_client_set_restart_style (client, GNOME_RESTART_IF_RUNNING);
- }
-
- g_signal_connect (client,
- "save_yourself",
- G_CALLBACK (session_save),
- argv[0]);
-
- g_signal_connect (client,
- "die",
- G_CALLBACK (session_die),
- NULL);
-
drwright = drwright_new ();
gtk_main ();
diff --git a/data/images/ocean-stripes.png b/src/ocean-stripes.png
similarity index 100%
rename from data/images/ocean-stripes.png
rename to src/ocean-stripes.png
diff --git a/data/images/stock_stop.png b/src/stock_stop.png
similarity index 100%
rename from data/images/stock_stop.png
rename to src/stock_stop.png
diff --git a/src/typing-break.gnome-settings-plugin.in b/src/typing-break.gnome-settings-plugin.in
new file mode 100644
index 0000000..99eef40
--- /dev/null
+++ b/src/typing-break.gnome-settings-plugin.in
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=typing-break
+IAge=0
+_Name=Typing Break
+_Description=Typing break plugin
+Authors=
+Copyright=Copyright © 2007
+Website=
diff --git a/src/typing-monitor.png b/src/typing-monitor.png
new file mode 100644
index 0000000..41ee09c
Binary files /dev/null and b/src/typing-monitor.png differ
diff --git a/src/typing-monitor.svg b/src/typing-monitor.svg
new file mode 100644
index 0000000..b829871
--- /dev/null
+++ b/src/typing-monitor.svg
@@ -0,0 +1,336 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg4908"
+ sodipodi:version="0.32"
+ inkscape:version="0.44+devel"
+ sodipodi:docbase="/home/andreas/project/application icons/48x48"
+ sodipodi:docname="typing-monitor.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/andreas/project/application icons/48x48/typing-monitor.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:modified="TRUE">
+ <defs
+ id="defs4910">
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient7007">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop7009" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop7011" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6997">
+ <stop
+ style="stop-color:#2e3436;stop-opacity:1;"
+ offset="0"
+ id="stop6999" />
+ <stop
+ style="stop-color:#2e3436;stop-opacity:0;"
+ offset="1"
+ id="stop7001" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6987">
+ <stop
+ style="stop-color:#503000;stop-opacity:1"
+ offset="0"
+ id="stop6989" />
+ <stop
+ style="stop-color:#6f4501;stop-opacity:1"
+ offset="1"
+ id="stop6991" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient6979">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop6981" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop6983" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient5962">
+ <stop
+ style="stop-color:#d8d8d0;stop-opacity:1"
+ offset="0"
+ id="stop5964" />
+ <stop
+ style="stop-color:#fafafa;stop-opacity:1"
+ offset="1"
+ id="stop5966" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient5952">
+ <stop
+ style="stop-color:#a9ada4;stop-opacity:0.16494845;"
+ offset="0"
+ id="stop5954" />
+ <stop
+ id="stop5960"
+ offset="0.5"
+ style="stop-color:#dbdcd9;stop-opacity:0.94901961;" />
+ <stop
+ style="stop-color:#9fa399;stop-opacity:0;"
+ offset="1"
+ id="stop5956" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient5938">
+ <stop
+ style="stop-color:#eeeeec;stop-opacity:1;"
+ offset="0"
+ id="stop5940" />
+ <stop
+ id="stop5946"
+ offset="0.5"
+ style="stop-color:#ffffff;stop-opacity:1;" />
+ <stop
+ style="stop-color:#e4e4e1;stop-opacity:1;"
+ offset="1"
+ id="stop5942" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient5918">
+ <stop
+ style="stop-color:#555753;stop-opacity:1;"
+ offset="0"
+ id="stop5920" />
+ <stop
+ style="stop-color:#555753;stop-opacity:0;"
+ offset="1"
+ id="stop5922" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5918"
+ id="radialGradient5924"
+ cx="24.23378"
+ cy="36.63369"
+ fx="24.23378"
+ fy="36.63369"
+ r="16.061426"
+ gradientTransform="matrix(1.0419567,3.4062366e-7,0,0.2338642,-1.0167686,29.144193)"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5938"
+ id="linearGradient5944"
+ x1="9.0885315"
+ y1="29.413193"
+ x2="30.001532"
+ y2="29.514208"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.0030622,0,0,1,-0.1178936,-1.9999983)" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5952"
+ id="linearGradient5958"
+ x1="26.005463"
+ y1="16.791273"
+ x2="35.894749"
+ y2="5.3816786"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.9473685,0,0,0.9266,1.9999999,-0.8531999)" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5962"
+ id="radialGradient5968"
+ cx="17.504116"
+ cy="38.896267"
+ fx="17.504116"
+ fy="38.896267"
+ r="22.160923"
+ gradientTransform="matrix(0.9309009,-1.7410792e-2,4.7534748e-3,0.2323648,7.9437685,28.267387)"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6979"
+ id="linearGradient6985"
+ x1="38.85714"
+ y1="31.5"
+ x2="40.642857"
+ y2="31.5"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(0,-1)" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6987"
+ id="radialGradient6993"
+ cx="23.992792"
+ cy="28.918667"
+ fx="23.992792"
+ fy="28.918667"
+ r="14.691718"
+ gradientTransform="matrix(1.3068587,-1.1013411e-2,2.7605408e-3,0.2917953,-7.2677551,16.22393)"
+ gradientUnits="userSpaceOnUse" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient6997"
+ id="radialGradient7003"
+ cx="24.266502"
+ cy="40.09565"
+ fx="24.266502"
+ fy="40.09565"
+ r="23.964285"
+ gradientTransform="matrix(0.9539749,-7.3807993e-6,-2.5091472e-8,0.2691364,1.132661,29.95978)"
+ gradientUnits="userSpaceOnUse" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient7007"
+ id="radialGradient7013"
+ cx="43.551655"
+ cy="25.449492"
+ fx="43.551655"
+ fy="25.449492"
+ r="1.2435335"
+ gradientTransform="matrix(2.8786818,0,0,3.7781028,-81.819703,-70.701311)"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="9.8994949"
+ inkscape:cx="31.996918"
+ inkscape:cy="27.672311"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="1680"
+ inkscape:window-height="974"
+ inkscape:window-x="0"
+ inkscape:window-y="26" />
+ <metadata
+ id="metadata4913">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ sodipodi:type="arc"
+ style="opacity:0.44021738;fill:url(#radialGradient7003);fill-opacity:1.0;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path6995"
+ sodipodi:cx="24.25"
+ sodipodi:cy="40.75"
+ sodipodi:rx="23.964285"
+ sodipodi:ry="5.8928571"
+ d="M 48.214285 40.75 A 23.964285 5.8928571 0 1 1 0.2857151,40.75 A 23.964285 5.8928571 0 1 1 48.214285 40.75 z"
+ transform="matrix(1.0059613,0,0,1.539394,-0.5017047,-25.658877)" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:1;fill:url(#radialGradient5968);fill-opacity:1;stroke:#888a85;stroke-width:0.92989331;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5912"
+ sodipodi:cx="23.587063"
+ sodipodi:cy="35.171062"
+ sodipodi:rx="21.667772"
+ sodipodi:ry="8.0812206"
+ d="M 45.254835 35.171062 A 21.667772 8.0812206 0 1 1 1.9192905,35.171062 A 21.667772 8.0812206 0 1 1 45.254835 35.171062 z"
+ transform="matrix(1.0384085,0,0,1.1136931,-0.4930076,-3.6697693)" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:0.66847826;fill:url(#radialGradient5924);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5916"
+ sodipodi:cx="24.496199"
+ sodipodi:cy="38.049999"
+ sodipodi:rx="16.061426"
+ sodipodi:ry="3.8385797"
+ d="M 40.557625 38.049999 A 16.061426 3.8385797 0 1 1 8.4347725,38.049999 A 16.061426 3.8385797 0 1 1 40.557625 38.049999 z"
+ transform="matrix(0.9961755,0,0,1.5630783,-0.3014947,-24.475125)" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.00897741;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5970"
+ sodipodi:cx="23.587063"
+ sodipodi:cy="35.171062"
+ sodipodi:rx="21.667772"
+ sodipodi:ry="8.0812206"
+ d="M 45.254835 35.171062 A 21.667772 8.0812206 0 1 1 1.9192905,35.171062 A 21.667772 8.0812206 0 1 1 45.254835 35.171062 z"
+ transform="matrix(0.9922571,0,0,0.9899493,0.6965858,0.6824308)" />
+ <path
+ style="opacity:1;fill:url(#linearGradient5944);fill-opacity:1;stroke:#888a85;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 23.90625,11.5 C 15.95303,11.5 9.4999998,14.082773 9.5,17.25 L 9.5,31.8125 L 10.5,33.25 C 10.5,33.25 9.8205441,38.5 23.8125,38.5 C 37.89254,38.5 37.6875,33.34375 37.6875,33.34375 L 38.5,32.15625 L 38.5,31.5 L 40.71875,31.5 C 42.818921,31.5 44.500001,29.81892 44.5,27.71875 L 44.5,23.28125 C 44.5,21.181079 42.81892,19.5 40.71875,19.5 L 38.5,19.5 L 38.5,17.25 C 38.5,14.082773 31.85947,11.5 23.90625,11.5 z M 38.5,21.5 L 39.03125,21.5 C 40.403909,21.5 41.5,22.596091 41.5,23.96875 L 41.5,27.03125 C 41.500001,28.403909 40.403908,29.5 39.03125,29.5 L 38.5,29.5 L 38.5,21.5 z "
+ id="path5905" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:1;fill:#d3d7cf;fill-opacity:1;stroke:#888a85;stroke-width:0.96812624;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5910"
+ sodipodi:cx="24.748737"
+ sodipodi:cy="22.544155"
+ sodipodi:rx="14.142136"
+ sodipodi:ry="3.7375643"
+ d="M 38.890873 22.544155 A 14.142136 3.7375643 0 1 1 10.606602,22.544155 A 14.142136 3.7375643 0 1 1 38.890873 22.544155 z"
+ transform="matrix(0.88616,0,0,1.2039928,2.1008539,-9.1429975)" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 23.960422,12.500002 C 16.580811,12.500002 10.490543,14.526543 10.490543,17.45916 L 10.515797,31.51384 L 11.526844,33.0544 C 11.526844,33.0544 10.901642,37.500003 23.884461,37.500003 C 36.94901,37.500005 36.757882,32.727848 36.757882,32.727848 L 37.5,31.629548 L 37.49389,17.686444 C 37.49389,14.753828 31.340033,12.500002 23.960422,12.500002 z "
+ id="path5928"
+ sodipodi:nodetypes="ccccscccc" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:1;fill:url(#radialGradient6993);fill-opacity:1;stroke:#888a85;stroke-width:1.09916472;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5948"
+ sodipodi:cx="24.748737"
+ sodipodi:cy="22.544155"
+ sodipodi:rx="14.142136"
+ sodipodi:ry="3.7375643"
+ d="M 38.890873 22.544155 A 14.142136 3.7375643 0 1 1 10.606602,22.544155 A 14.142136 3.7375643 0 1 1 38.890873 22.544155 z"
+ transform="matrix(0.8838835,0,0,0.9364388,2.125,-2.1112202)" />
+ <path
+ style="opacity:0.44021738;fill:url(#linearGradient5958);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 20.00983,18.67847 C 20.00983,18.67847 19.712477,13.206563 22.388669,10.260151 C 25.064862,7.3137393 27.741054,9.207861 30.714602,6.8928232 C 33.688151,4.5777853 34.28286,1 34.28286,1 C 34.28286,1 38.874954,5.7239821 37.851119,8.5764868 C 36.827284,11.428993 31.37694,9.884524 30.187523,12.41002 C 28.998102,14.935515 33.093442,18.67847 33.093442,18.67847 C 33.093442,18.67847 28.051699,20.000002 24.780796,20.000002 C 21.509894,20.000002 20.00983,18.67847 20.00983,18.67847 z "
+ id="path5950"
+ sodipodi:nodetypes="czzczzczc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 38,20.5 L 40.57749,20.5 C 42.034984,20.5 43.5,21.525939 43.5,23 L 43.499941,28.217132 C 43.463947,29.280836 42.266279,30.395048 40.437265,30.499107 L 38,30.4486"
+ id="path6959"
+ sodipodi:nodetypes="cccccc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:url(#linearGradient6985);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 37.928571,30.5 L 40.5,30.5"
+ id="path6961" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:url(#radialGradient7013);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 42,20.696954 C 42.69772,21.313113 43.445947,21.878765 43.487067,23 L 43.487067,28 C 43.423512,28.950077 42.998471,29.694158 42,30.202031"
+ id="path7005"
+ sodipodi:nodetypes="cccc" />
+ </g>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]