[Goodies-dev] Hello + New Feature for Xfce4-time-out-plugin
James Broadhead
jamesbroadhead at gmail.com
Mon Oct 19 21:55:14 CEST 2009
Hey guys-
I've decided to take a look at the timeout plugin, to add a couple of
features. I've used a couple of programs like this in Linux, and I
really like the presentation of the lock dialog in this one. I want to
improve it to add features recommended by RSI / computer use research,
such as microbreaks and break-skip penalties. Longer-term, I want to
add input monitoring, so that the counter only runs while the it is in
use.
I took a look at the bugzilla after starting looking at this, and
intend to address bugs 3220, 3846, 3367 and 5869. (although I intend
to solve the problem presented in 5869 in a different manner)
After a bit of hacking today, I've added a 'Skip Break' feature, which
can be enabled/disabled from the config window.
I fixed two compiler warnings, removing an unused variable and an
always-true conditional.
I have also applied the patch from Og Maciel from bug #4287 and fixed
bug #3690 before noticing the patch from Gleidson Echeli (thanks
anyway!).
I've applied for git access, and would appreciate any feedback -
especially from people who use the program or are interested in RSI.
autogen updated some files automatically, which has bloated the diff a little.
James Broadhead
-------------- next part --------------
diff --git a/INSTALL b/INSTALL
index 095b1eb..8b82ade 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,16 +1,19 @@
Installation Instructions
*************************
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free
-Software Foundation, Inc.
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008 Free Software Foundation, Inc.
-This file is free documentation; the Free Software Foundation gives
+ This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
-These are generic installation instructions.
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
@@ -23,9 +26,9 @@ debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. (Caching is
+the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
-cache files.)
+cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
@@ -35,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
+ `./configure' to configure the package for your system.
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
2. Type `make' to compile the package.
@@ -67,51 +67,66 @@ The simplest way to compile this package is:
all sorts of other programs in order to regenerate files that came
with the distribution.
+ 6. Often, you can also type `make uninstall' to remove the installed
+ files again.
+
Compilers and Options
=====================
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about. Run `./configure --help' for
-details on some of the pertinent environment variables.
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
- ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
-You can compile the package for more than one kind of computer at the
+ You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
+own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
- If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory. After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
Installation Names
==================
-By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PREFIX'.
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PREFIX', the package will
-use PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
@@ -125,7 +140,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
-Some packages pay attention to `--enable-FEATURE' options to
+ Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
@@ -137,14 +152,36 @@ find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
Specifying the System Type
==========================
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
@@ -159,7 +196,7 @@ where SYSTEM can have one of these forms:
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
+use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
@@ -170,9 +207,9 @@ eventually be run) with `--host=TYPE'.
Sharing Defaults
================
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
@@ -181,7 +218,7 @@ A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
-Variables not defined in a site shell script can be set in the
+ Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
@@ -189,17 +226,30 @@ them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
-will cause the specified gcc to be used as the C compiler (unless it is
+causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
`configure' Invocation
======================
-`configure' recognizes the following options to control how it operates.
+ `configure' recognizes the following options to control how it
+operates.
`--help'
`-h'
- Print a summary of the options to `configure', and exit.
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
`--version'
`-V'
@@ -226,6 +276,16 @@ overridden in the site shell script).
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
+`--prefix=DIR'
+ Use DIR as the installation prefix. *Note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
diff --git a/panel-plugin/time-out-countdown.c b/panel-plugin/time-out-countdown.c
index 8c4e6fd..83ff80e 100644
--- a/panel-plugin/time-out-countdown.c
+++ b/panel-plugin/time-out-countdown.c
@@ -228,12 +228,9 @@ time_out_countdown_finalize (GObject *object)
/* Destroy timer */
g_timer_destroy (countdown->timer);
- /* Unregister timeout if necessary */
- if (G_LIKELY (countdown->timeout_id >= 0))
- {
- g_source_remove (countdown->timeout_id);
- countdown->timeout_id = -1;
- }
+ /* Unregister timeout */
+ g_source_remove (countdown->timeout_id);
+ countdown->timeout_id = -1;
}
diff --git a/panel-plugin/time-out-lock-screen.c b/panel-plugin/time-out-lock-screen.c
index 3a9ec23..2a6c80f 100644
--- a/panel-plugin/time-out-lock-screen.c
+++ b/panel-plugin/time-out-lock-screen.c
@@ -36,6 +36,9 @@ static void time_out_lock_screen_init (TimeOutLockScreen *lock_sc
static void time_out_lock_screen_finalize (GObject *object);
static void time_out_lock_screen_postpone (GtkButton *button,
TimeOutLockScreen *lock_screen);
+static void time_out_lock_screen_skip (GtkButton *button,
+ TimeOutLockScreen *lock_screen);
+
@@ -45,9 +48,11 @@ struct _TimeOutLockScreenClass
/* Signals */
void (*postpone) (TimeOutLockScreen *lock_screen);
+ void (*skip) (TimeOutLockScreen *lock_screen);
/* Signal identifiers */
guint postpone_signal_id;
+ guint skip_signal_id;
};
struct _TimeOutLockScreen
@@ -60,6 +65,9 @@ struct _TimeOutLockScreen
/* Whether to allow postpone */
guint allow_postpone : 1;
+ /* Whether to allow postpone */
+ guint allow_skip : 1;
+
/* Whether to display seconds */
guint display_seconds : 1;
@@ -70,6 +78,7 @@ struct _TimeOutLockScreen
GtkWidget *window;
GtkWidget *time_label;
GtkWidget *postpone_button;
+ GtkWidget *skip_button;
/* Fade out */
TimeOutFadeout *fadeout;
@@ -131,7 +140,19 @@ time_out_lock_screen_class_init (TimeOutLockScreenClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ /* Register 'skip' signal */
+ klass->skip_signal_id = g_signal_new ("skip",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (TimeOutLockScreenClass, skip),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
+
+
@@ -146,6 +167,7 @@ time_out_lock_screen_init (TimeOutLockScreen *lock_screen)
lock_screen->display_seconds = TRUE;
lock_screen->allow_postpone = TRUE;
+ lock_screen->allow_skip = TRUE;
lock_screen->display_hours = FALSE;
lock_screen->fadeout = NULL;
@@ -190,6 +212,14 @@ time_out_lock_screen_init (TimeOutLockScreen *lock_screen)
gtk_box_pack_start (GTK_BOX (vbox), lock_screen->postpone_button, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (lock_screen->postpone_button), "clicked", G_CALLBACK (time_out_lock_screen_postpone), lock_screen);
gtk_widget_show (lock_screen->postpone_button);
+
+ /* Create skip button */
+ lock_screen->skip_button = gtk_button_new_with_mnemonic (_("_Skip"));
+ gtk_box_pack_start (GTK_BOX (vbox), lock_screen->skip_button, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (lock_screen->skip_button), "clicked", G_CALLBACK (time_out_lock_screen_skip), lock_screen);
+ gtk_widget_show (lock_screen->skip_button);
+
+
}
@@ -311,6 +341,22 @@ time_out_lock_screen_set_allow_postpone (TimeOutLockScreen *lock_screen,
}
+void
+time_out_lock_screen_set_allow_skip (TimeOutLockScreen *lock_screen,
+ gboolean allow_skip)
+{
+ g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen));
+
+ /* Set allow postpone attribute */
+ lock_screen->allow_skip = allow_skip;
+
+ /* Enable/disable postpone button */
+ if (G_LIKELY (allow_skip))
+ gtk_widget_show (lock_screen->skip_button);
+ else
+ gtk_widget_hide (lock_screen->skip_button);
+}
+
void
time_out_lock_screen_set_display_seconds (TimeOutLockScreen *lock_screen,
@@ -335,7 +381,7 @@ time_out_lock_screen_set_display_hours (TimeOutLockScreen *lock_screen,
}
-
+/* Postpones the break for extra time) */
static void
time_out_lock_screen_postpone (GtkButton *button,
TimeOutLockScreen *lock_screen)
@@ -346,3 +392,15 @@ time_out_lock_screen_postpone (GtkButton *button,
/* Emit postpone signal */
g_signal_emit_by_name (lock_screen, "postpone", NULL);
}
+
+/* Ends the break prematurely + restarts the counter */
+static void
+time_out_lock_screen_skip (GtkButton *button,
+ TimeOutLockScreen *lock_screen)
+{
+ g_return_if_fail (GTK_IS_BUTTON (button));
+ g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen));
+
+ /* Emit postpone signal */
+ g_signal_emit_by_name (lock_screen, "skip", NULL);
+}
diff --git a/panel-plugin/time-out-lock-screen.h b/panel-plugin/time-out-lock-screen.h
index 30f49c2..2d2e935 100644
--- a/panel-plugin/time-out-lock-screen.h
+++ b/panel-plugin/time-out-lock-screen.h
@@ -49,6 +49,9 @@ void time_out_lock_screen_set_display_hours (TimeOutLockScreen *
gboolean display_hours);
void time_out_lock_screen_set_allow_postpone (TimeOutLockScreen *lock_screen,
gboolean allow_postpone);
+void time_out_lock_screen_set_allow_skip (TimeOutLockScreen *lock_screen,
+ gboolean allow_skip);
+
G_END_DECLS;
diff --git a/panel-plugin/time-out.c b/panel-plugin/time-out.c
index fbc6269..14743d6 100644
--- a/panel-plugin/time-out.c
+++ b/panel-plugin/time-out.c
@@ -38,6 +38,7 @@
/* Default settings */
#define DEFAULT_ENABLED TRUE
#define DEFAULT_ALLOW_POSTPONE TRUE
+#define DEFAULT_ALLOW_SKIP TRUE
#define DEFAULT_DISPLAY_SECONDS TRUE
#define DEFAULT_DISPLAY_HOURS FALSE
#define DEFAULT_DISPLAY_TIME TRUE
@@ -66,6 +67,7 @@ struct _TimeOutPlugin
guint display_seconds : 1;
guint display_hours : 1;
guint allow_postpone : 1;
+ guint allow_skip : 1;
guint display_time : 1;
/* Lock screen to be shown during breaks */
@@ -92,799 +94,870 @@ static gboolean time_out_size_changed (XfcePanelPlug
static void time_out_orientation_changed (XfcePanelPlugin *plugin,
GtkOrientation orientation,
TimeOutPlugin *time_out);
-static void time_out_configure (XfcePanelPlugin *plugin,
- TimeOutPlugin *time_out);
-static void time_out_end_configure (GtkDialog *dialog,
- gint response_id,
- TimeOutPlugin *time_out);
-static void time_out_lock_countdown_seconds_changed (GtkSpinButton *spin_button,
- TimeOutPlugin *time_out);
-static void time_out_postpone_countdown_seconds_changed (GtkSpinButton *spin_button,
- TimeOutPlugin *time_out);
-static void time_out_allow_postpone_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out);
-static void time_out_display_time_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out);
-static void time_out_display_seconds_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out);
-static void time_out_display_hours_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out);
-static void time_out_load_settings (TimeOutPlugin *time_out);
-static void time_out_save_settings (TimeOutPlugin *time_out);
-static void time_out_take_break (GtkMenuItem *menu_item,
- TimeOutPlugin *time_out);
-static void time_out_enabled_toggled (GtkCheckMenuItem *menu_item,
- TimeOutPlugin *time_out);
-static void time_out_start_break_countdown (TimeOutPlugin *time_out,
- gint seconds);
-static void time_out_stop_break_countdown (TimeOutPlugin *time_out);
-static void time_out_start_lock_countdown (TimeOutPlugin *time_out);
-static void time_out_stop_lock_countdown (TimeOutPlugin *time_out);
-static void time_out_postpone (TimeOutLockScreen *lock_screen,
- TimeOutPlugin *time_out);
-static void time_out_break_countdown_update (TimeOutCountdown *countdown,
- gint seconds_remaining,
- TimeOutPlugin *plugin);
-static void time_out_break_countdown_finish (TimeOutCountdown *countdown,
- TimeOutPlugin *plugin);
-static void time_out_lock_countdown_update (TimeOutCountdown *countdown,
- gint seconds_remaining,
- TimeOutPlugin *plugin);
-static void time_out_lock_countdown_finish (TimeOutCountdown *countdown,
- TimeOutPlugin *plugin);
-
-
-
-/* Register the plugin */
-XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (time_out_construct);
-
-
-
-static TimeOutPlugin*
-time_out_new (XfcePanelPlugin *plugin)
-{
- TimeOutPlugin *time_out;
- GtkWidget *label;
- GtkOrientation orientation;
-
- /* Allocate memory for the plugin structure */
- time_out = panel_slice_new0 (TimeOutPlugin);
-
- /* Store pointer to the plugin */
- time_out->plugin = plugin;
-
- /* Create lock screen */
- time_out->lock_screen = time_out_lock_screen_new ();
-
- /* Connect to 'postpone' signal of the lock screen */
- g_signal_connect (G_OBJECT (time_out->lock_screen), "postpone", G_CALLBACK (time_out_postpone), time_out);
-
- /* Create countdowns */
- time_out->break_countdown = time_out_countdown_new ();
- time_out->lock_countdown = time_out_countdown_new ();
-
- /* Connect to break countdown signals */
- g_signal_connect (G_OBJECT (time_out->break_countdown), "update", G_CALLBACK (time_out_break_countdown_update), time_out);
- g_signal_connect (G_OBJECT (time_out->break_countdown), "finish", G_CALLBACK (time_out_break_countdown_finish), time_out);
-
- /* Connect to lock countdown signals */
- g_signal_connect (G_OBJECT (time_out->lock_countdown), "update", G_CALLBACK (time_out_lock_countdown_update), time_out);
- g_signal_connect (G_OBJECT (time_out->lock_countdown), "finish", G_CALLBACK (time_out_lock_countdown_finish), time_out);
-
- /* Get the current orientation */
- orientation = xfce_panel_plugin_get_orientation (plugin);
-
- /* Create event box to catch user events */
- time_out->ebox = gtk_event_box_new ();
- gtk_widget_show (time_out->ebox);
-
- /* Create flexible box which can do both, horizontal and vertical layout */
- time_out->hvbox = xfce_hvbox_new (orientation, FALSE, 2);
- gtk_container_add (GTK_CONTAINER (time_out->ebox), time_out->hvbox);
- gtk_widget_show (time_out->hvbox);
-
- /* Create time out icon */
- time_out->panel_icon = gtk_image_new_from_icon_name ("xfce4-time-out-plugin", GTK_ICON_SIZE_DIALOG);
- gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), xfce_panel_plugin_get_size (time_out->plugin) - 8);
- gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->panel_icon, TRUE, TRUE, 0);
- gtk_widget_show (time_out->panel_icon);
-
- /* Create label for displaying the remaining time until the next break */
- time_out->time_label = gtk_label_new ("Inactive");
- gtk_misc_set_alignment (GTK_MISC (time_out->time_label), 0.5, 0.5);
- gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->time_label, TRUE, TRUE, 0);
- gtk_widget_show (time_out->time_label);
-
- /* Create tooltips group */
- time_out->tooltips = gtk_tooltips_new ();
-
- return time_out;
-}
-
-
-
-static void
-time_out_free (XfcePanelPlugin *plugin,
- TimeOutPlugin *time_out)
-{
- /* Stop the countdowns */
- g_object_unref (time_out->break_countdown);
- g_object_unref (time_out->lock_countdown);
-
- /* Destroy lock screen */
- g_object_unref (time_out->lock_screen);
-
- /* Destroy the plugin widgets */
- gtk_widget_destroy (time_out->hvbox);
-
- /* Free the plugin structure */
- panel_slice_free (TimeOutPlugin, time_out);
-}
-
-
-
-static void
-time_out_construct (XfcePanelPlugin *plugin)
-{
- TimeOutPlugin *time_out;
- GtkWidget *menu_item;
-
- /* Setup translation domain */
- xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
-
- /* Create the plugin */
- time_out = time_out_new (plugin);
-
- /* Load the settings */
- time_out_load_settings (time_out);
-
- /* Add the event box to the panel */
- gtk_container_add (GTK_CONTAINER (plugin), time_out->ebox);
-
- /* Create menu item for taking an instant break */
- menu_item = gtk_menu_item_new_with_label (_("Take a break"));
- xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (menu_item));
- gtk_widget_show (GTK_WIDGET (menu_item));
-
- /* Connect to the menu item to react on break requests */
- g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (time_out_take_break), time_out);
-
- /* Create menu item for enabling/disabling the countdown */
- menu_item = gtk_check_menu_item_new_with_label (_("Enabled"));
- xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (menu_item));
- gtk_widget_show (GTK_WIDGET (menu_item));
-
- /* Connect to the check menu item to react on toggle events */
- g_signal_connect (G_OBJECT (menu_item), "toggled", G_CALLBACK (time_out_enabled_toggled), time_out);
-
- /* Set enabled state according to the settings */
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), time_out->enabled);
-
- /* Connect plugin signals */
- g_signal_connect (G_OBJECT (plugin), "free-data", G_CALLBACK (time_out_free), time_out);
- g_signal_connect (G_OBJECT (plugin), "size-changed", G_CALLBACK (time_out_size_changed), time_out);
- g_signal_connect (G_OBJECT (plugin), "configure-plugin", G_CALLBACK (time_out_configure), time_out);
- g_signal_connect (G_OBJECT (plugin), "orientation-changed", G_CALLBACK (time_out_orientation_changed), time_out);
-
- /* Display the configure menu item */
- xfce_panel_plugin_menu_show_configure (plugin);
-
- /* Display the about menu item */
- xfce_panel_plugin_menu_show_about (plugin);
-
- /* Start break countdown if the plugin is active */
- if (G_LIKELY (time_out->enabled))
- time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
-}
-
-
-
-static void
-time_out_take_break (GtkMenuItem *menu_item,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
- g_return_if_fail (time_out != NULL);
-
- /* Stop break countdown */
- time_out_stop_break_countdown (time_out);
-
- /* Start lock countdown */
- time_out_start_lock_countdown (time_out);
-}
-
-
-
-static void
-time_out_enabled_toggled (GtkCheckMenuItem *menu_item,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
- g_return_if_fail (time_out != NULL);
-
- /* Set enabled state */
- time_out->enabled = gtk_check_menu_item_get_active (menu_item);
-
- if (time_out->enabled)
- {
- /* Start/continue the break countdown */
- time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
- }
- else
- {
- /* Pause break countdown */
- time_out_countdown_pause (time_out->break_countdown);
- }
-
- /* Save plugin configuration */
- time_out_save_settings (time_out);
-}
-
-
+ static void time_out_about (XfcePanelPlugin *plugin);
+ static void time_out_configure (XfcePanelPlugin *plugin,
+ TimeOutPlugin *time_out);
+ static void time_out_end_configure (GtkDialog *dialog,
+ gint response_id,
+ TimeOutPlugin *time_out);
+ static void time_out_lock_countdown_seconds_changed (GtkSpinButton *spin_button,
+ TimeOutPlugin *time_out);
+ static void time_out_postpone_countdown_seconds_changed (GtkSpinButton *spin_button,
+ TimeOutPlugin *time_out);
+ static void time_out_allow_postpone_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out);
+ static void time_out_allow_skip_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out);
+ static void time_out_display_time_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out);
+ static void time_out_display_seconds_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out);
+ static void time_out_display_hours_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out);
+ static void time_out_load_settings (TimeOutPlugin *time_out);
+ static void time_out_save_settings (TimeOutPlugin *time_out);
+ static void time_out_take_break (GtkMenuItem *menu_item,
+ TimeOutPlugin *time_out);
+ static void time_out_enabled_toggled (GtkCheckMenuItem *menu_item,
+ TimeOutPlugin *time_out);
+ static void time_out_start_break_countdown (TimeOutPlugin *time_out,
+ gint seconds);
+ static void time_out_stop_break_countdown (TimeOutPlugin *time_out);
+ static void time_out_start_lock_countdown (TimeOutPlugin *time_out);
+ static void time_out_stop_lock_countdown (TimeOutPlugin *time_out);
+ static void time_out_postpone (TimeOutLockScreen *lock_screen,
+ TimeOutPlugin *time_out);
+ static void time_out_skip (TimeOutLockScreen *lock_screen,
+ TimeOutPlugin *time_out);
+ static void time_out_break_countdown_update (TimeOutCountdown *countdown,
+ gint seconds_remaining,
+ TimeOutPlugin *plugin);
+ static void time_out_break_countdown_finish (TimeOutCountdown *countdown,
+ TimeOutPlugin *plugin);
+ static void time_out_lock_countdown_update (TimeOutCountdown *countdown,
+ gint seconds_remaining,
+ TimeOutPlugin *plugin);
+ static void time_out_lock_countdown_finish (TimeOutCountdown *countdown,
+ TimeOutPlugin *plugin);
+
+
+
+ /* Register the plugin */
+ XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (time_out_construct);
+
+
+
+ static TimeOutPlugin*
+ time_out_new (XfcePanelPlugin *plugin)
+ {
+ TimeOutPlugin *time_out;
+ GtkOrientation orientation;
+
+ /* Allocate memory for the plugin structure */
+ time_out = panel_slice_new0 (TimeOutPlugin);
+
+ /* Store pointer to the plugin */
+ time_out->plugin = plugin;
+
+ /* Create lock screen */
+ time_out->lock_screen = time_out_lock_screen_new ();
+
+ /* Connect to 'postpone' signal of the lock screen */
+ g_signal_connect (G_OBJECT (time_out->lock_screen), "postpone", G_CALLBACK (time_out_postpone), time_out);
+
+ /* Connect to 'skip' signal of the lock screen */
+ g_signal_connect (G_OBJECT (time_out->lock_screen), "skip", G_CALLBACK (time_out_skip), time_out);
+
+ /* Create countdowns */
+ time_out->break_countdown = time_out_countdown_new ();
+ time_out->lock_countdown = time_out_countdown_new ();
+
+ /* Connect to break countdown signals */
+ g_signal_connect (G_OBJECT (time_out->break_countdown), "update", G_CALLBACK (time_out_break_countdown_update), time_out);
+ g_signal_connect (G_OBJECT (time_out->break_countdown), "finish", G_CALLBACK (time_out_break_countdown_finish), time_out);
+
+ /* Connect to lock countdown signals */
+ g_signal_connect (G_OBJECT (time_out->lock_countdown), "update", G_CALLBACK (time_out_lock_countdown_update), time_out);
+ g_signal_connect (G_OBJECT (time_out->lock_countdown), "finish", G_CALLBACK (time_out_lock_countdown_finish), time_out);
+
+ /* Get the current orientation */
+ orientation = xfce_panel_plugin_get_orientation (plugin);
+
+ /* Create event box to catch user events */
+ time_out->ebox = gtk_event_box_new ();
+ gtk_widget_show (time_out->ebox);
+
+ /* Create flexible box which can do both, horizontal and vertical layout */
+ time_out->hvbox = xfce_hvbox_new (orientation, FALSE, 2);
+ gtk_container_add (GTK_CONTAINER (time_out->ebox), time_out->hvbox);
+ gtk_widget_show (time_out->hvbox);
+
+ /* Create time out icon */
+ time_out->panel_icon = gtk_image_new_from_icon_name ("xfce4-time-out-plugin", GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), xfce_panel_plugin_get_size (time_out->plugin) - 8);
+ gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->panel_icon, TRUE, TRUE, 0);
+ gtk_widget_show (time_out->panel_icon);
+
+ /* Create label for displaying the remaining time until the next break */
+ time_out->time_label = gtk_label_new ("Inactive");
+ gtk_misc_set_alignment (GTK_MISC (time_out->time_label), 0.5, 0.5);
+ gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->time_label, TRUE, TRUE, 0);
+ gtk_widget_show (time_out->time_label);
-static gboolean
-time_out_size_changed (XfcePanelPlugin *plugin,
- gint size,
- TimeOutPlugin *time_out)
-{
- GtkOrientation orientation;
+ /* Create tooltips group */
+ time_out->tooltips = gtk_tooltips_new ();
- g_return_val_if_fail (plugin != NULL, FALSE);
- g_return_val_if_fail (time_out != NULL, FALSE);
+ return time_out;
+ }
- /* Get the orientation of the panel */
- orientation = xfce_panel_plugin_get_orientation (plugin);
- /* Update icon size */
- gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), size - 8);
- /* Update widget size */
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size);
- else
- gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1);
+ static void
+ time_out_free (XfcePanelPlugin *plugin,
+ TimeOutPlugin *time_out)
+ {
+ /* Stop the countdowns */
+ g_object_unref (time_out->break_countdown);
+ g_object_unref (time_out->lock_countdown);
- /* We handled the orientation */
- return TRUE;
-}
+ /* Destroy lock screen */
+ g_object_unref (time_out->lock_screen);
+ /* Destroy the plugin widgets */
+ gtk_widget_destroy (time_out->hvbox);
+ /* Free the plugin structure */
+ panel_slice_free (TimeOutPlugin, time_out);
+ }
-static void
-time_out_orientation_changed (XfcePanelPlugin *plugin,
- GtkOrientation orientation,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (plugin != NULL);
- g_return_if_fail (time_out != NULL);
- /* Apply orientation to hvbox */
- xfce_hvbox_set_orientation (XFCE_HVBOX (time_out->hvbox), orientation);
-}
+ static void
+ time_out_construct (XfcePanelPlugin *plugin)
+ {
+ TimeOutPlugin *time_out;
+ GtkWidget *menu_item;
+ /* Setup translation domain */
+ xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
-static void
-time_out_configure (XfcePanelPlugin *plugin,
- TimeOutPlugin *time_out)
-{
- GtkWidget *dialog;
- GtkWidget *framebox;
- GtkWidget *timebin;
- GtkWidget *behaviourbin;
- GtkWidget *appearancebin;
- GtkWidget *table;
- GtkWidget *vbox;
- GtkWidget *label;
- GtkWidget *spin;
- GtkWidget *checkbutton;
-
- g_return_if_fail (plugin != NULL);
- g_return_if_fail (time_out != NULL);
-
- /* Pause break timer for the time we're configuring */
- if (G_LIKELY (time_out_countdown_get_running (time_out->break_countdown)))
- time_out_countdown_pause (time_out->break_countdown);
-
- /* Block plugin context menu */
- xfce_panel_plugin_block_menu (plugin);
-
- /* Create properties dialog */
- dialog = xfce_titled_dialog_new_with_buttons (_("Time Out"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
- NULL);
-
- /* Set dialog property */
- g_object_set_data (G_OBJECT (plugin), "dialog", dialog);
-
- /* Be notified when the properties dialog is closed */
- g_signal_connect (dialog, "response", G_CALLBACK (time_out_end_configure), time_out);
-
- /* Basic dialog window setup */
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-time-out-plugin");
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-
- /* Create time settings section */
- framebox = xfce_create_framebox (_("Time settings"), &timebin);
- gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
- gtk_widget_show (framebox);
-
- /* Create time settings table */
- table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_add (GTK_CONTAINER (timebin), table);
- gtk_widget_show (table);
-
- /* Create break countdown time label */
- label = gtk_label_new (_("Time between breaks (minutes):"));
- gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
- gtk_widget_show (label);
-
- /* Create break countdown time spin */
- spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->break_countdown_seconds / 60);
- gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
- gtk_widget_show (spin);
-
- /* Store reference on the spin button in the plugin */
- g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin", spin);
-
- /* Create lock countdown time label */
- label = gtk_label_new (_("Break length (minutes):"));
- gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
- gtk_widget_show (label);
-
- /* Create lock countdown time spin */
- spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->lock_countdown_seconds / 60);
- g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_lock_countdown_seconds_changed), time_out);
- gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
- gtk_widget_show (spin);
-
- /* Create postpone countdown time label */
- label = gtk_label_new (_("Postpone length (minutes):"));
- gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
- gtk_widget_show (label);
-
- /* Create postpone countdown time spin */
- spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->postpone_countdown_seconds / 60);
- g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_postpone_countdown_seconds_changed), time_out);
- gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
- gtk_widget_show (spin);
-
- /* Create behaviour section */
- framebox = xfce_create_framebox (_("Behaviour"), &behaviourbin);
- gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
- gtk_widget_show (framebox);
-
- /* Create postpone check button */
- checkbutton = gtk_check_button_new_with_label (_("Allow postpone"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->allow_postpone);
- g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_allow_postpone_toggled), time_out);
- gtk_container_add (GTK_CONTAINER (behaviourbin), checkbutton);
- gtk_widget_show (checkbutton);
-
- /* Create appearance section */
- framebox = xfce_create_framebox (_("Appearance"), &appearancebin);
- gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
- gtk_widget_show (framebox);
-
- /* Create appearance box */
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (appearancebin), vbox);
- gtk_widget_show (vbox);
-
- /* Create display time check button */
- checkbutton = gtk_check_button_new_with_label (_("Display remaining time in the panel"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_time);
- g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_time_toggled), time_out);
- gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
- gtk_widget_show (checkbutton);
-
- /* Create display hours check button */
- checkbutton = gtk_check_button_new_with_label (_("Display hours"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_hours);
- g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_hours_toggled), time_out);
- gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
- gtk_widget_show (checkbutton);
-
- /* Create display seconds check button */
- checkbutton = gtk_check_button_new_with_label (_("Display seconds"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_seconds);
- g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_seconds_toggled), time_out);
- gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
- gtk_widget_show (checkbutton);
-
- /* Show the entire dialog */
- gtk_widget_show (dialog);
-}
+ /* Create the plugin */
+ time_out = time_out_new (plugin);
+ /* Load the settings */
+ time_out_load_settings (time_out);
+ /* Add the event box to the panel */
+ gtk_container_add (GTK_CONTAINER (plugin), time_out->ebox);
-static void
-time_out_end_configure (GtkDialog *dialog,
- gint response_id,
- TimeOutPlugin *time_out)
-{
- GtkWidget *spin;
- gint value;
- gboolean restart = FALSE;
+ /* Create menu item for taking an instant break */
+ menu_item = gtk_menu_item_new_with_label (_("Take a break"));
+ xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (menu_item));
+ gtk_widget_show (GTK_WIDGET (menu_item));
- /* Remove the dialog data from the plugin */
- g_object_set_data (G_OBJECT (time_out->plugin), "dialog", NULL);
+ /* Connect to the menu item to react on break requests */
+ g_signal_connect (G_OBJECT (menu_item), "activate", G_CALLBACK (time_out_take_break), time_out);
- /* Unlock the panel menu */
- xfce_panel_plugin_unblock_menu (time_out->plugin);
+ /* Create menu item for enabling/disabling the countdown */
+ menu_item = gtk_check_menu_item_new_with_label (_("Enabled"));
+ xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (menu_item));
+ gtk_widget_show (GTK_WIDGET (menu_item));
- /* Get spin button value for the break countdown settings */
- spin = g_object_get_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin");
- value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)) * 60;
- g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin", NULL);
+ /* Connect to the check menu item to react on toggle events */
+ g_signal_connect (G_OBJECT (menu_item), "toggled", G_CALLBACK (time_out_enabled_toggled), time_out);
- /* Check if the break countdown seconds have changed */
- restart = value != time_out->break_countdown_seconds;
+ /* Set enabled state according to the settings */
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), time_out->enabled);
- /* Apply new break countdown seconds */
- time_out->break_countdown_seconds = value;
+ /* Connect plugin signals */
+ g_signal_connect (G_OBJECT (plugin), "free-data", G_CALLBACK (time_out_free), time_out);
+ g_signal_connect (G_OBJECT (plugin), "size-changed", G_CALLBACK (time_out_size_changed), time_out);
+ g_signal_connect (G_OBJECT (plugin), "configure-plugin", G_CALLBACK (time_out_configure), time_out);
+ g_signal_connect (G_OBJECT (plugin), "orientation-changed", G_CALLBACK (time_out_orientation_changed), time_out);
+ g_signal_connect (G_OBJECT (plugin), "about", G_CALLBACK (time_out_about), NULL);
+ /* Display the configure menu item */
+ xfce_panel_plugin_menu_show_configure (plugin);
- /* Save plugin configuration */
- time_out_save_settings (time_out);
+ /* Display the about menu item */
+ xfce_panel_plugin_menu_show_about (plugin);
- /* Restart or resume break countdown */
- if (G_UNLIKELY (restart && time_out->enabled))
- {
- time_out_stop_break_countdown (time_out);
- time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
- }
- else
- time_out_countdown_resume (time_out->break_countdown);
+ /* Start break countdown if the plugin is active */
+ if (G_LIKELY (time_out->enabled))
+ time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
+ }
- /* Destroy the properties dialog */
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
+ static void
+ time_out_take_break (GtkMenuItem *menu_item,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
+ g_return_if_fail (time_out != NULL);
+
+ /* Stop break countdown */
+ time_out_stop_break_countdown (time_out);
-static void
-time_out_lock_countdown_seconds_changed (GtkSpinButton *spin_button,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
- g_return_if_fail (time_out != NULL);
+ /* Start lock countdown */
+ time_out_start_lock_countdown (time_out);
+ }
+
+
+
+ static void
+ time_out_enabled_toggled (GtkCheckMenuItem *menu_item,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set enabled state */
+ time_out->enabled = gtk_check_menu_item_get_active (menu_item);
+
+ if (time_out->enabled)
+ {
+ /* Start/continue the break countdown */
+ time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
+ }
+ else
+ {
+ /* Pause break countdown */
+ time_out_countdown_pause (time_out->break_countdown);
+ }
+
+ /* Save plugin configuration */
+ time_out_save_settings (time_out);
+ }
+
+
+
+ static gboolean
+ time_out_size_changed (XfcePanelPlugin *plugin,
+ gint size,
+ TimeOutPlugin *time_out)
+ {
+ GtkOrientation orientation;
+
+ g_return_val_if_fail (plugin != NULL, FALSE);
+ g_return_val_if_fail (time_out != NULL, FALSE);
+
+ /* Get the orientation of the panel */
+ orientation = xfce_panel_plugin_get_orientation (plugin);
+
+ /* Update icon size */
+ gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), size - 8);
+
+ /* Update widget size */
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size);
+ else
+ gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1);
+
+ /* We handled the orientation */
+ return TRUE;
+ }
+
+
+
+ static void
+ time_out_orientation_changed (XfcePanelPlugin *plugin,
+ GtkOrientation orientation,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (plugin != NULL);
+ g_return_if_fail (time_out != NULL);
+
+ /* Apply orientation to hvbox */
+ xfce_hvbox_set_orientation (XFCE_HVBOX (time_out->hvbox), orientation);
+ }
+
+ static void
+ time_out_about (XfcePanelPlugin *plugin)
+ {
+ static const gchar *authors[] =
+ {
+ "Jannis Pohlmann", "jannis at xfce.org",
+ NULL
+ };
+
+ gtk_show_about_dialog (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
+ "authors", authors,
+ "comments", _("Xfce Panel plugin for taking a break from computer work every now and then."),
+ "destroy-with-parent", TRUE,
+ "logo-icon-name", "xfce4-time-out-plugin",
+ "program-name", PACKAGE_NAME,
+ "name", PACKAGE_NAME,
+ "version", PACKAGE_VERSION,
+ "translator-credits", _("translator-credits"),
+ "license", XFCE_LICENSE_GPL,
+ "website", "http://www.xfce.org/",
+ NULL);
+ }
+
+
+ static void
+ time_out_configure (XfcePanelPlugin *plugin,
+ TimeOutPlugin *time_out)
+ {
+ GtkWidget *dialog;
+ GtkWidget *framebox;
+ GtkWidget *timebin;
+ GtkWidget *behaviourbin;
+ GtkWidget *appearancebin;
+ GtkWidget *table;
+ GtkWidget *vbox;
+ GtkWidget *label;
+ GtkWidget *spin;
+ GtkWidget *checkbutton;
+
+ g_return_if_fail (plugin != NULL);
+ g_return_if_fail (time_out != NULL);
+
+ /* Pause break timer for the time we're configuring */
+ if (G_LIKELY (time_out_countdown_get_running (time_out->break_countdown)))
+ time_out_countdown_pause (time_out->break_countdown);
+
+ /* Block plugin context menu */
+ xfce_panel_plugin_block_menu (plugin);
+
+ /* Create properties dialog */
+ dialog = xfce_titled_dialog_new_with_buttons (_("Time Out"),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+ NULL);
+
+ /* Set dialog property */
+ g_object_set_data (G_OBJECT (plugin), "dialog", dialog);
+
+ /* Be notified when the properties dialog is closed */
+ g_signal_connect (dialog, "response", G_CALLBACK (time_out_end_configure), time_out);
+
+ /* Basic dialog window setup */
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-time-out-plugin");
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+
+ /* Create time settings section */
+ framebox = xfce_create_framebox (_("Time settings"), &timebin);
+ gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
+ gtk_widget_show (framebox);
+
+ /* Create time settings table */
+ table = gtk_table_new (2, 2, FALSE);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+ gtk_container_add (GTK_CONTAINER (timebin), table);
+ gtk_widget_show (table);
+
+ /* Create break countdown time label */
+ label = gtk_label_new (_("Time between breaks (minutes):"));
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
+ gtk_widget_show (label);
+
+ /* Create break countdown time spin */
+ spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->break_countdown_seconds / 60);
+ gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
+ gtk_widget_show (spin);
+
+ /* Store reference on the spin button in the plugin */
+ g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin", spin);
+
+ /* Create lock countdown time label */
+ label = gtk_label_new (_("Break length (minutes):"));
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
+ gtk_widget_show (label);
+
+ /* Create lock countdown time spin */
+ spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->lock_countdown_seconds / 60);
+ g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_lock_countdown_seconds_changed), time_out);
+ gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
+ gtk_widget_show (spin);
+
+ /* Create postpone countdown time label */
+ label = gtk_label_new (_("Postpone length (minutes):"));
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
+ gtk_widget_show (label);
+
+ /* Create postpone countdown time spin */
+ spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->postpone_countdown_seconds / 60);
+ g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_postpone_countdown_seconds_changed), time_out);
+ gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
+ gtk_widget_show (spin);
+
+ /* Create behaviour section =====================================================*/
+ framebox = xfce_create_framebox (_("Behaviour"), &behaviourbin);
+ gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
+ gtk_widget_show (framebox);
+
+ /* Create behaviour box */
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (behaviourbin), vbox);
+ gtk_widget_show (vbox);
+
+ /* Create postpone check button */
+ checkbutton = gtk_check_button_new_with_label (_("Allow postponing of breaks"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->allow_postpone);
+ g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_allow_postpone_toggled), time_out);
+ gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
+ gtk_widget_show (checkbutton);
+
+ /* Create skip check button */
+ checkbutton = gtk_check_button_new_with_label (_("Allow break skipping"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->allow_skip);
+ g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_allow_skip_toggled), time_out);
+ gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
+ gtk_widget_show (checkbutton);
+
+ /* Create appearance section =====================================================*/
+ framebox = xfce_create_framebox (_("Appearance"), &appearancebin);
+ gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
+ gtk_widget_show (framebox);
+
+ /* Create appearance box */
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (appearancebin), vbox);
+ gtk_widget_show (vbox);
+
+ /* Create display time check button */
+ checkbutton = gtk_check_button_new_with_label (_("Display remaining time in the panel"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_time);
+ g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_time_toggled), time_out);
+ gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
+ gtk_widget_show (checkbutton);
+
+ /* Create display hours check button */
+ checkbutton = gtk_check_button_new_with_label (_("Display hours"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_hours);
+ g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_hours_toggled), time_out);
+ gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
+ gtk_widget_show (checkbutton);
+
+ /* Create display seconds check button */
+ checkbutton = gtk_check_button_new_with_label (_("Display seconds"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_seconds);
+ g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_seconds_toggled), time_out);
+ gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
+ gtk_widget_show (checkbutton);
+
+ /* Show the entire dialog */
+ gtk_widget_show (dialog);
+ }
+
+
+
+ static void
+ time_out_end_configure (GtkDialog *dialog,
+ gint response_id,
+ TimeOutPlugin *time_out)
+ {
+ GtkWidget *spin;
+ gint value;
+ gboolean restart = FALSE;
+
+ /* Remove the dialog data from the plugin */
+ g_object_set_data (G_OBJECT (time_out->plugin), "dialog", NULL);
+
+ /* Unlock the panel menu */
+ xfce_panel_plugin_unblock_menu (time_out->plugin);
+
+ /* Get spin button value for the break countdown settings */
+ spin = g_object_get_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin");
+ value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)) * 60;
+ g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin", NULL);
+
+ /* Check if the break countdown seconds have changed */
+ restart = value != time_out->break_countdown_seconds;
+
+ /* Apply new break countdown seconds */
+ time_out->break_countdown_seconds = value;
+
+ /* Save plugin configuration */
+ time_out_save_settings (time_out);
+
+ /* Restart or resume break countdown */
+ if (G_UNLIKELY (restart && time_out->enabled))
+ {
+ time_out_stop_break_countdown (time_out);
+ time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
+ }
+ else
+ time_out_countdown_resume (time_out->break_countdown);
+
+ /* Destroy the properties dialog */
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+
+
+
+ static void
+ time_out_lock_countdown_seconds_changed (GtkSpinButton *spin_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set plugin attribute */
+ time_out->lock_countdown_seconds = gtk_spin_button_get_value_as_int (spin_button) * 60;
+ }
+
+
+
+ static void
+ time_out_postpone_countdown_seconds_changed (GtkSpinButton *spin_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set plugin attribute */
+ time_out->postpone_countdown_seconds = gtk_spin_button_get_value_as_int (spin_button) * 60;
+ }
+
+
+
+ static void
+ time_out_allow_postpone_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set postpone attribute */
+ time_out->allow_postpone = gtk_toggle_button_get_active (toggle_button);
+ }
+
+ static void
+ time_out_allow_skip_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set postpone attribute */
+ time_out->allow_skip = gtk_toggle_button_get_active (toggle_button);
+ }
+
+ static void
+ time_out_display_time_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set display time attribute */
+ time_out->display_time = gtk_toggle_button_get_active (toggle_button);
+
+ /* Hide or display the time label */
+ if (time_out->display_time)
+ gtk_widget_show (time_out->time_label);
+ else
+ gtk_widget_hide (time_out->time_label);
+ }
+
+
+
+ static void
+ time_out_display_seconds_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set display seconds attribute */
+ time_out->display_seconds = gtk_toggle_button_get_active (toggle_button);
+ }
+
+
+
+ static void
+ time_out_display_hours_toggled (GtkToggleButton *toggle_button,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+ g_return_if_fail (time_out != NULL);
+
+ /* Set display hours attribute */
+ time_out->display_hours = gtk_toggle_button_get_active (toggle_button);
+ }
+
+
+
+ static void
+ time_out_load_settings (TimeOutPlugin *time_out)
+ {
+ XfceRc *rc;
+ gchar *filename;
+
+ /* Default settings */
+ gint break_countdown_seconds = DEFAULT_BREAK_COUNTDOWN_SECONDS;
+ gint lock_countdown_seconds = DEFAULT_LOCK_COUNTDOWN_SECONDS;
+ gint postpone_countdown_seconds = DEFAULT_POSTPONE_COUNTDOWN_SECONDS;
+ gboolean enabled = DEFAULT_ENABLED;
+ gboolean display_seconds = DEFAULT_DISPLAY_SECONDS;
+ gboolean display_hours = DEFAULT_DISPLAY_HOURS;
+ gboolean display_time = DEFAULT_DISPLAY_TIME;
+ gboolean allow_postpone = DEFAULT_ALLOW_POSTPONE;
+ gboolean allow_skip = DEFAULT_ALLOW_SKIP;
+
+ g_return_if_fail (time_out != NULL);
+
+ /* Search for the config file */
+ filename = xfce_panel_plugin_save_location (time_out->plugin, FALSE);
+
+ /* Only try to read the file if it exists */
+ if (G_LIKELY (filename != NULL))
+ {
+ /* Open file handle */
+ rc = xfce_rc_simple_open (filename, TRUE);
+
+ /* Check if the file could be opened */
+ if (G_LIKELY (rc != NULL))
+ {
+ /* Read settings */
+ break_countdown_seconds = xfce_rc_read_int_entry (rc, "break-countdown-seconds", break_countdown_seconds);
+ lock_countdown_seconds = xfce_rc_read_int_entry (rc, "lock-countdown-seconds", lock_countdown_seconds);
+ postpone_countdown_seconds = xfce_rc_read_int_entry (rc, "postpone-countdown-seconds", postpone_countdown_seconds);
+ enabled = xfce_rc_read_bool_entry (rc, "enabled", enabled);
+ display_seconds = xfce_rc_read_bool_entry (rc, "display-seconds", display_seconds);
+ display_hours = xfce_rc_read_bool_entry (rc, "display-hours", display_hours);
+ display_time = xfce_rc_read_bool_entry (rc, "display-time", display_time);
+ allow_postpone = xfce_rc_read_bool_entry (rc, "allow-postpone", allow_postpone);
+ allow_skip = xfce_rc_read_bool_entry (rc, "allow-skip", allow_skip);
+
+ /* Close file handle */
+ xfce_rc_close (rc);
+ }
+
+ /* Free filename */
+ g_free (filename);
+ }
+
+ /* Apply settings */
+ time_out->break_countdown_seconds = break_countdown_seconds;
+ time_out->lock_countdown_seconds = lock_countdown_seconds;
+ time_out->postpone_countdown_seconds = postpone_countdown_seconds;
+ time_out->enabled = enabled;
+ time_out->display_seconds = display_seconds;
+ time_out->display_hours = display_hours;
+ time_out->display_time = display_time;
+ time_out->allow_postpone = allow_postpone;
+ time_out->allow_skip = allow_skip;
+ }
+
+
+
+ static void
+ time_out_save_settings (TimeOutPlugin *time_out)
+ {
+ XfceRc *rc;
+ gchar *filename;
+
+ g_return_if_fail (time_out != NULL);
- /* Set plugin attribute */
- time_out->lock_countdown_seconds = gtk_spin_button_get_value_as_int (spin_button) * 60;
-}
+ /* Search for config file */
+ filename = xfce_panel_plugin_save_location (time_out->plugin, TRUE);
+
+ /* Only try to write to the file if it exists */
+ if (G_LIKELY (filename != NULL))
+ {
+ /* Open file handle */
+ rc = xfce_rc_simple_open (filename, FALSE);
+ /* Check if the file could be opened */
+ if (G_LIKELY (rc != NULL))
+ {
+ /* Write settings */
+ xfce_rc_write_int_entry (rc, "break-countdown-seconds", time_out->break_countdown_seconds);
+ xfce_rc_write_int_entry (rc, "lock-countdown-seconds", time_out->lock_countdown_seconds);
+ xfce_rc_write_int_entry (rc, "postpone-countdown-seconds", time_out->postpone_countdown_seconds);
+ xfce_rc_write_bool_entry (rc, "enabled", time_out->enabled);
+ xfce_rc_write_bool_entry (rc, "display-seconds", time_out->display_seconds);
+ xfce_rc_write_bool_entry (rc, "display-hours", time_out->display_hours);
+ xfce_rc_write_bool_entry (rc, "display-time", time_out->display_time);
+ xfce_rc_write_bool_entry (rc, "allow-postpone", time_out->allow_postpone);
+ xfce_rc_write_bool_entry (rc, "allow-skip", time_out->allow_skip);
+
+ /* Close file handle */
+ xfce_rc_close (rc);
+ }
+
+ /* Free filename */
+ g_free (filename);
+ }
+ }
+
+
+
+ static void
+ time_out_start_break_countdown (TimeOutPlugin *time_out,
+ gint seconds)
+ {
+ g_return_if_fail (time_out != NULL);
+
+ if (G_UNLIKELY (!time_out->enabled))
+ return;
+
+ /* Resume the countdown if it is paused, otherwise start it */
+ if (G_UNLIKELY (time_out_countdown_get_paused (time_out->break_countdown)))
+ time_out_countdown_resume (time_out->break_countdown);
+ else
+ time_out_countdown_start (time_out->break_countdown, seconds);
+ }
+
+
+
+ static void
+ time_out_start_lock_countdown (TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (time_out != NULL);
+ /* Resume countdown if it was paused, otherwise start it */
+ if (G_UNLIKELY (time_out_countdown_get_paused (time_out->lock_countdown)))
+ time_out_countdown_resume (time_out->lock_countdown);
+ else
+ time_out_countdown_start (time_out->lock_countdown, time_out->lock_countdown_seconds);
-static void
-time_out_postpone_countdown_seconds_changed (GtkSpinButton *spin_button,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
- g_return_if_fail (time_out != NULL);
+ /* Set whether to allow postpone or not */
+ time_out_lock_screen_set_allow_postpone (time_out->lock_screen, time_out->allow_postpone);
+
+ /* Set whether to allow skip or not */
+ time_out_lock_screen_set_allow_skip (time_out->lock_screen, time_out->allow_skip);
- /* Set plugin attribute */
- time_out->postpone_countdown_seconds = gtk_spin_button_get_value_as_int (spin_button) * 60;
-}
+ /* Display the lock screen */
+ time_out_lock_screen_show (time_out->lock_screen);
+ }
-static void
-time_out_allow_postpone_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
- g_return_if_fail (time_out != NULL);
- /* Set postpone attribute */
- time_out->allow_postpone = gtk_toggle_button_get_active (toggle_button);
-}
+ static void
+ time_out_stop_break_countdown (TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (time_out != NULL);
+ /* Stop the countdown */
+ time_out_countdown_stop (time_out->break_countdown);
+ }
-static void
-time_out_display_time_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
- g_return_if_fail (time_out != NULL);
- /* Set display time attribute */
- time_out->display_time = gtk_toggle_button_get_active (toggle_button);
+ static void
+ time_out_stop_lock_countdown (TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (time_out != NULL);
- /* Hide or display the time label */
- if (time_out->display_time)
- gtk_widget_show (time_out->time_label);
- else
- gtk_widget_hide (time_out->time_label);
-}
+ /* Stop the countdown */
+ time_out_countdown_stop (time_out->lock_countdown);
+ /* Unlock the screen */
+ time_out_lock_screen_hide (time_out->lock_screen);
+ }
-static void
-time_out_display_seconds_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
- g_return_if_fail (time_out != NULL);
- /* Set display seconds attribute */
- time_out->display_seconds = gtk_toggle_button_get_active (toggle_button);
-}
+ static void
+ time_out_postpone (TimeOutLockScreen *lock_screen,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen));
+ g_return_if_fail (time_out != NULL);
+ /* Stop lock countdown */
+ time_out_stop_lock_countdown (time_out);
+ /* Start break countdown with postpone time */
+ time_out_start_break_countdown (time_out, time_out->postpone_countdown_seconds);
+ }
-static void
-time_out_display_hours_toggled (GtkToggleButton *toggle_button,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
- g_return_if_fail (time_out != NULL);
+ static void
+ time_out_skip (TimeOutLockScreen *lock_screen,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen));
+ g_return_if_fail (time_out != NULL);
- /* Set display hours attribute */
- time_out->display_hours = gtk_toggle_button_get_active (toggle_button);
-}
-
-
-
-static void
-time_out_load_settings (TimeOutPlugin *time_out)
-{
- XfceRc *rc;
- gchar *filename;
-
- /* Default settings */
- gint break_countdown_seconds = DEFAULT_BREAK_COUNTDOWN_SECONDS;
- gint lock_countdown_seconds = DEFAULT_LOCK_COUNTDOWN_SECONDS;
- gint postpone_countdown_seconds = DEFAULT_POSTPONE_COUNTDOWN_SECONDS;
- gboolean enabled = DEFAULT_ENABLED;
- gboolean display_seconds = DEFAULT_DISPLAY_SECONDS;
- gboolean display_hours = DEFAULT_DISPLAY_HOURS;
- gboolean display_time = DEFAULT_DISPLAY_TIME;
- gboolean allow_postpone = DEFAULT_ALLOW_POSTPONE;
-
- g_return_if_fail (time_out != NULL);
-
- /* Search for the config file */
- filename = xfce_panel_plugin_save_location (time_out->plugin, FALSE);
-
- /* Only try to read the file if it exists */
- if (G_LIKELY (filename != NULL))
- {
- /* Open file handle */
- rc = xfce_rc_simple_open (filename, TRUE);
-
- /* Check if the file could be opened */
- if (G_LIKELY (rc != NULL))
- {
- /* Read settings */
- break_countdown_seconds = xfce_rc_read_int_entry (rc, "break-countdown-seconds", break_countdown_seconds);
- lock_countdown_seconds = xfce_rc_read_int_entry (rc, "lock-countdown-seconds", lock_countdown_seconds);
- postpone_countdown_seconds = xfce_rc_read_int_entry (rc, "postpone-countdown-seconds", postpone_countdown_seconds);
- enabled = xfce_rc_read_bool_entry (rc, "enabled", enabled);
- display_seconds = xfce_rc_read_bool_entry (rc, "display-seconds", display_seconds);
- display_hours = xfce_rc_read_bool_entry (rc, "display-hours", display_hours);
- display_time = xfce_rc_read_bool_entry (rc, "display-time", display_time);
- allow_postpone = xfce_rc_read_bool_entry (rc, "allow-postpone", allow_postpone);
-
- /* Close file handle */
- xfce_rc_close (rc);
- }
-
- /* Free filename */
- g_free (filename);
- }
-
- /* Apply settings */
- time_out->break_countdown_seconds = break_countdown_seconds;
- time_out->lock_countdown_seconds = lock_countdown_seconds;
- time_out->postpone_countdown_seconds = postpone_countdown_seconds;
- time_out->enabled = enabled;
- time_out->display_seconds = display_seconds;
- time_out->display_hours = display_hours;
- time_out->display_time = display_time;
- time_out->allow_postpone = allow_postpone;
-}
-
-
-
-static void
-time_out_save_settings (TimeOutPlugin *time_out)
-{
- XfceRc *rc;
- gchar *filename;
-
- g_return_if_fail (time_out != NULL);
-
- /* Search for config file */
- filename = xfce_panel_plugin_save_location (time_out->plugin, TRUE);
-
- /* Only try to write to the file if it exists */
- if (G_LIKELY (filename != NULL))
- {
- /* Open file handle */
- rc = xfce_rc_simple_open (filename, FALSE);
-
- /* Check if the file could be opened */
- if (G_LIKELY (rc != NULL))
- {
- /* Write settings */
- xfce_rc_write_int_entry (rc, "break-countdown-seconds", time_out->break_countdown_seconds);
- xfce_rc_write_int_entry (rc, "lock-countdown-seconds", time_out->lock_countdown_seconds);
- xfce_rc_write_int_entry (rc, "postpone-countdown-seconds", time_out->postpone_countdown_seconds);
- xfce_rc_write_bool_entry (rc, "enabled", time_out->enabled);
- xfce_rc_write_bool_entry (rc, "display-seconds", time_out->display_seconds);
- xfce_rc_write_bool_entry (rc, "display-hours", time_out->display_hours);
- xfce_rc_write_bool_entry (rc, "display-time", time_out->display_time);
-
- /* Close file handle */
- xfce_rc_close (rc);
- }
-
- /* Free filename */
- g_free (filename);
- }
-}
+ /* Stop lock countdown */
+ time_out_stop_lock_countdown (time_out);
+ /* Start break countdown with time from settings */
+ time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
+ }
+ static void
+ time_out_break_countdown_update (TimeOutCountdown *countdown,
+ gint seconds_remaining,
+ TimeOutPlugin *time_out)
+ {
+ GString *short_time_string;
+ GString *long_time_string;
-static void
-time_out_start_break_countdown (TimeOutPlugin *time_out,
- gint seconds)
-{
- g_return_if_fail (time_out != NULL);
+ g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
+ g_return_if_fail (time_out != NULL);
- if (G_UNLIKELY (!time_out->enabled))
- return;
+ /* Get time strings */
+ short_time_string = time_out_countdown_seconds_to_string (seconds_remaining, time_out->display_seconds, time_out->display_hours, TRUE);
+ long_time_string = time_out_countdown_seconds_to_string (seconds_remaining, TRUE, TRUE, FALSE);
- /* Resume the countdown if it is paused, otherwise start it */
- if (G_UNLIKELY (time_out_countdown_get_paused (time_out->break_countdown)))
- time_out_countdown_resume (time_out->break_countdown);
- else
- time_out_countdown_start (time_out->break_countdown, seconds);
-}
+ /* Set label text */
+ gtk_label_set_text (GTK_LABEL (time_out->time_label), short_time_string->str);
+ /* Update tooltips */
+ gtk_tooltips_set_tip (GTK_TOOLTIPS (time_out->tooltips), time_out->ebox, long_time_string->str, long_time_string->str);
+ /* Free time strings */
+ g_string_free (short_time_string, TRUE);
+ g_string_free (long_time_string, TRUE);
+ }
-static void
-time_out_start_lock_countdown (TimeOutPlugin *time_out)
-{
- g_return_if_fail (time_out != NULL);
- /* Resume countdown if it was paused, otherwise start it */
- if (G_UNLIKELY (time_out_countdown_get_paused (time_out->lock_countdown)))
- time_out_countdown_resume (time_out->lock_countdown);
- else
- time_out_countdown_start (time_out->lock_countdown, time_out->lock_countdown_seconds);
- /* Set whether to allow postpone or not */
- time_out_lock_screen_set_allow_postpone (time_out->lock_screen, time_out->allow_postpone);
-
- /* Display the lock screen */
- time_out_lock_screen_show (time_out->lock_screen);
-}
+ static void
+ time_out_break_countdown_finish (TimeOutCountdown *countdown,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
+ g_return_if_fail (time_out != NULL);
+ /* Lock the screen and start the lock countdown */
+ time_out_start_lock_countdown (time_out);
+ }
-static void
-time_out_stop_break_countdown (TimeOutPlugin *time_out)
-{
- g_return_if_fail (time_out != NULL);
+ static void
+ time_out_lock_countdown_update (TimeOutCountdown *countdown,
+ gint seconds_remaining,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
+ g_return_if_fail (time_out != NULL);
- /* Stop the countdown */
- time_out_countdown_stop (time_out->break_countdown);
-}
+ /* Update lock screen */
+ time_out_lock_screen_set_display_seconds (time_out->lock_screen, time_out->display_seconds);
+ time_out_lock_screen_set_display_hours (time_out->lock_screen, time_out->display_hours);
+ time_out_lock_screen_set_remaining (time_out->lock_screen, seconds_remaining);
+ }
-static void
-time_out_stop_lock_countdown (TimeOutPlugin *time_out)
-{
- g_return_if_fail (time_out != NULL);
-
- /* Stop the countdown */
- time_out_countdown_stop (time_out->lock_countdown);
-
- /* Unlock the screen */
- time_out_lock_screen_hide (time_out->lock_screen);
-}
-
-
-
-static void
-time_out_postpone (TimeOutLockScreen *lock_screen,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen));
- g_return_if_fail (time_out != NULL);
-
- /* Stop lock countdown */
- time_out_stop_lock_countdown (time_out);
-
- /* Start break countdown with postpone time */
- time_out_start_break_countdown (time_out, time_out->postpone_countdown_seconds);
-}
-
-
-
-static void
-time_out_break_countdown_update (TimeOutCountdown *countdown,
- gint seconds_remaining,
- TimeOutPlugin *time_out)
-{
- GString *short_time_string;
- GString *long_time_string;
-
- g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
- g_return_if_fail (time_out != NULL);
-
- /* Get time strings */
- short_time_string = time_out_countdown_seconds_to_string (seconds_remaining, time_out->display_seconds, time_out->display_hours, TRUE);
- long_time_string = time_out_countdown_seconds_to_string (seconds_remaining, TRUE, TRUE, FALSE);
-
- /* Set label text */
- gtk_label_set_text (GTK_LABEL (time_out->time_label), short_time_string->str);
-
- /* Update tooltips */
- gtk_tooltips_set_tip (GTK_TOOLTIPS (time_out->tooltips), time_out->ebox, long_time_string->str, long_time_string->str);
-
- /* Free time strings */
- g_string_free (short_time_string, TRUE);
- g_string_free (long_time_string, TRUE);
-}
-
-
-
-static void
-time_out_break_countdown_finish (TimeOutCountdown *countdown,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
- g_return_if_fail (time_out != NULL);
-
- /* Lock the screen and start the lock countdown */
- time_out_start_lock_countdown (time_out);
-}
-
-
-static void
-time_out_lock_countdown_update (TimeOutCountdown *countdown,
- gint seconds_remaining,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
- g_return_if_fail (time_out != NULL);
-
- /* Update lock screen */
- time_out_lock_screen_set_display_seconds (time_out->lock_screen, time_out->display_seconds);
- time_out_lock_screen_set_display_hours (time_out->lock_screen, time_out->display_hours);
- time_out_lock_screen_set_remaining (time_out->lock_screen, seconds_remaining);
-}
-
-
-
-static void
-time_out_lock_countdown_finish (TimeOutCountdown *countdown,
- TimeOutPlugin *time_out)
-{
- g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
- g_return_if_fail (time_out != NULL);
+ static void
+ time_out_lock_countdown_finish (TimeOutCountdown *countdown,
+ TimeOutPlugin *time_out)
+ {
+ g_return_if_fail (IS_TIME_OUT_COUNTDOWN (countdown));
+ g_return_if_fail (time_out != NULL);
- /* Stop lock countdown */
- time_out_stop_lock_countdown (time_out);
+ /* Stop lock countdown */
+ time_out_stop_lock_countdown (time_out);
- /* Start break countdown */
- time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
+ /* Start break countdown */
+ time_out_start_break_countdown (time_out, time_out->break_countdown_seconds);
}
diff --git a/po/xfce4-time-out-plugin.pot b/po/xfce4-time-out-plugin.pot
deleted file mode 100644
index c1c441b..0000000
--- a/po/xfce4-time-out-plugin.pot
+++ /dev/null
@@ -1,257 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-05-06 23:27+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
-"Language-Team: LANGUAGE <LL at li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=CHARSET\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#. Create menu item for taking an instant break
-#: ../panel-plugin/time-out.c:245
-msgid "Take a break"
-msgstr ""
-
-#. Create menu item for enabling/disabling the countdown
-#: ../panel-plugin/time-out.c:253
-msgid "Enabled"
-msgstr ""
-
-#. Create properties dialog
-#: ../panel-plugin/time-out.c:390
-#: ../panel-plugin/xfce4-time-out-plugin.desktop.in.in.h:2
-msgid "Time Out"
-msgstr ""
-
-#. Create time settings section
-#: ../panel-plugin/time-out.c:407
-msgid "Time settings"
-msgstr ""
-
-#. Create break countdown time label
-#: ../panel-plugin/time-out.c:420
-msgid "Time between breaks (minutes):"
-msgstr ""
-
-#. Create lock countdown time label
-#: ../panel-plugin/time-out.c:435
-msgid "Break length (minutes):"
-msgstr ""
-
-#. Create postpone countdown time label
-#: ../panel-plugin/time-out.c:448
-msgid "Postpone length (minutes):"
-msgstr ""
-
-#. Create behaviour section
-#: ../panel-plugin/time-out.c:461
-msgid "Behaviour"
-msgstr ""
-
-#. Create postpone check button
-#: ../panel-plugin/time-out.c:467
-msgid "Allow postpone"
-msgstr ""
-
-#. Create appearance section
-#: ../panel-plugin/time-out.c:474
-msgid "Appearance"
-msgstr ""
-
-#. Create display time check button
-#: ../panel-plugin/time-out.c:485
-msgid "Display remaining time in the panel"
-msgstr ""
-
-#. Create display hours check button
-#: ../panel-plugin/time-out.c:492
-msgid "Display hours"
-msgstr ""
-
-#. Create display seconds check button
-#: ../panel-plugin/time-out.c:499
-msgid "Display seconds"
-msgstr ""
-
-#. Create postpone button
-#: ../panel-plugin/time-out-lock-screen.c:185
-msgid "_Postpone"
-msgstr ""
-
-#. Hours:minutes:seconds
-#: ../panel-plugin/time-out-countdown.c:396
-#: ../panel-plugin/time-out-countdown.c:461
-#, c-format
-msgid "%02d:%02d:%02d"
-msgstr ""
-
-#. Minutes:seconds
-#. Hours:minutes
-#. Minutes:seconds
-#: ../panel-plugin/time-out-countdown.c:401
-#: ../panel-plugin/time-out-countdown.c:409
-#: ../panel-plugin/time-out-countdown.c:466
-#: ../panel-plugin/time-out-countdown.c:474
-#, c-format
-msgid "%02d:%02d"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:424
-#: ../panel-plugin/time-out-countdown.c:431
-#: ../panel-plugin/time-out-countdown.c:496
-#: ../panel-plugin/time-out-countdown.c:626
-#, c-format
-msgid "Time left: %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:426
-#: ../panel-plugin/time-out-countdown.c:501
-#: ../panel-plugin/time-out-countdown.c:584
-#: ../panel-plugin/time-out-countdown.c:631
-#: ../panel-plugin/time-out-countdown.c:650
-msgid "Time left: 1 minute"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:433
-#: ../panel-plugin/time-out-countdown.c:505
-#: ../panel-plugin/time-out-countdown.c:635
-#, c-format
-msgid "Time left: 1 minute %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:439
-#: ../panel-plugin/time-out-countdown.c:514
-#: ../panel-plugin/time-out-countdown.c:644
-#, c-format
-msgid "Time left: %d minutes %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:441
-#: ../panel-plugin/time-out-countdown.c:510
-#: ../panel-plugin/time-out-countdown.c:588
-#: ../panel-plugin/time-out-countdown.c:640
-#: ../panel-plugin/time-out-countdown.c:652
-#, c-format
-msgid "Time left: %d minutes"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:447
-#: ../panel-plugin/time-out-countdown.c:574
-#, c-format
-msgid "Time left: %d hours %d minutes %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:449
-#: ../panel-plugin/time-out-countdown.c:570
-#: ../panel-plugin/time-out-countdown.c:610
-#, c-format
-msgid "Time left: %d hours %d minutes"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:494
-#: ../panel-plugin/time-out-countdown.c:624
-msgid "Time left: 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:503
-#: ../panel-plugin/time-out-countdown.c:633
-msgid "Time left: 1 minute 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:512
-#: ../panel-plugin/time-out-countdown.c:642
-#, c-format
-msgid "Time left: %d minutes 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:522
-msgid "Time left: 1 hour"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:524
-msgid "Time left: 1 hour 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:526
-#, c-format
-msgid "Time left: 1 hour %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:531
-#: ../panel-plugin/time-out-countdown.c:595
-msgid "Time left: 1 hour 1 minute"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:533
-msgid "Time left: 1 hour 1 minute 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:535
-#, c-format
-msgid "Time left: 1 hour 1 minute %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:540
-#: ../panel-plugin/time-out-countdown.c:599
-#, c-format
-msgid "Time left: 1 hour %d minutes"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:542
-#, c-format
-msgid "Time left: 1 hour %d minutes 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:544
-#, c-format
-msgid "Time left: 1 hour %d minutes %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:552
-#, c-format
-msgid "Time left: %d hours"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:554
-#, c-format
-msgid "Time left: %d hours 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:556
-#, c-format
-msgid "Time left: %d hours %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:561
-#: ../panel-plugin/time-out-countdown.c:606
-#, c-format
-msgid "Time left: %d hours 1 minute"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:563
-#, c-format
-msgid "Time left: %d hours 1 minute 1 second"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:565
-#, c-format
-msgid "Time left: %d hours 1 minute %d seconds"
-msgstr ""
-
-#: ../panel-plugin/time-out-countdown.c:572
-#, c-format
-msgid "Time left: %d hours %d minutes 1 second"
-msgstr ""
-
-#: ../panel-plugin/xfce4-time-out-plugin.desktop.in.in.h:1
-msgid "Automatically controlled time outs and breaks"
-msgstr ""
More information about the Goodies-dev
mailing list