gnome-control-center r8755 - trunk/typing-break
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-control-center r8755 - trunk/typing-break
- Date: Sun, 15 Jun 2008 13:54:57 +0000 (UTC)
Author: jensg
Date: Sun Jun 15 13:54:57 2008
New Revision: 8755
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8755&view=rev
Log:
2008-06-15 Jens Granseuer <jensgr gmx net>
Patch by: Andrey Gusev <ronne list ru>
* drwright.c: (update_icon), (blink_timeout_cb),
(maybe_change_state), (update_tooltip), (break_window_postpone_cb):
when postponing a voluntary break, go back to the state before taking
the break instead of going to warn state as we do when a regular
break is postponed (bug #134595)
Modified:
trunk/typing-break/ChangeLog
trunk/typing-break/drwright.c
Modified: trunk/typing-break/drwright.c
==============================================================================
--- trunk/typing-break/drwright.c (original)
+++ trunk/typing-break/drwright.c Sun Jun 15 13:54:57 2008
@@ -69,6 +69,7 @@
GTimer *idle_timer;
gint last_elapsed_time;
+ gint save_last_time;
gboolean is_active;
@@ -177,14 +178,9 @@
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) (g_timer_elapsed (dr->timer, NULL) + dr->save_last_time) /
+ (float) dr->type_time;
break;
}
@@ -237,7 +233,7 @@
gfloat r;
gint timeout;
- r = (dr->warn_time - g_timer_elapsed (dr->timer, NULL)) / dr->warn_time;
+ r = (dr->type_time - g_timer_elapsed (dr->timer, NULL) - dr->save_last_time) / dr->warn_time;
timeout = BLINK_TIMEOUT + BLINK_TIMEOUT_FACTOR * r;
if (timeout < BLINK_TIMEOUT_MIN) {
@@ -321,7 +317,7 @@
g_timer_reset (dr->idle_timer);
}
- elapsed_time = g_timer_elapsed (dr->timer, NULL);
+ elapsed_time = g_timer_elapsed (dr->timer, NULL) + dr->save_last_time;
elapsed_idle_time = g_timer_elapsed (dr->idle_timer, NULL);
if (elapsed_time > dr->last_elapsed_time + dr->warn_time) {
@@ -342,6 +338,8 @@
gtk_status_icon_set_from_pixbuf (dr->icon,
dr->neutral_bar);
+ dr->save_last_time = 0;
+
g_timer_start (dr->timer);
g_timer_start (dr->idle_timer);
@@ -355,8 +353,7 @@
case STATE_IDLE:
if (elapsed_idle_time >= dr->break_time) {
- g_timer_start (dr->timer);
- g_timer_start (dr->idle_timer);
+ dr->state = STATE_BREAK_DONE_SETUP;
} else if (dr->is_active) {
dr->state = STATE_TYPE;
}
@@ -365,7 +362,6 @@
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);
} else if (elapsed_time >= dr->type_time) {
@@ -378,7 +374,7 @@
break;
case STATE_WARN_TYPE:
- if (elapsed_time >= dr->warn_time) {
+ if (elapsed_time >= dr->type_time) {
dr->state = STATE_BREAK_SETUP;
}
else if (!dr->is_active) {
@@ -436,11 +432,12 @@
gtk_widget_show (dr->break_window);
+ 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;
@@ -486,16 +483,7 @@
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 = floor (0.5 + (dr->type_time - elapsed_time - dr->save_last_time) / 60.0);
if (min >= 1) {
str = g_strdup_printf (ngettext("%d minute until the next break",
@@ -661,13 +649,22 @@
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_TYPE;
dr->break_window = NULL;
+ elapsed_time = g_timer_elapsed (dr->timer, NULL) + dr->save_last_time;
+
+ if (elapsed_time >= dr->type_time) {
+ /* time is expired, but break was postponed */
+ dr->save_last_time = dr->type_time - dr->warn_time;
+ }
+
g_timer_start (dr->timer);
- start_blinking (dr);
+ maybe_change_state (dr);
update_icon (dr);
update_tooltip (dr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]