[Xfce4-commits] <xfce4-time-out-plugin:master> Add a progress bar to the lock screen.

Florian Rivoal noreply at xfce.org
Mon Nov 8 15:30:02 CET 2010


Updating branch refs/heads/master
         to 76765b56e3e899b00c79a2d47581c74fc7ec318d (commit)
       from 43b27ee8fec844bc3d39cb0cf649a6a7f55377fa (commit)

commit 76765b56e3e899b00c79a2d47581c74fc7ec318d
Author: Florian Rivoal <frivoal at xfce.org>
Date:   Mon Nov 8 23:05:25 2010 +0900

    Add a progress bar to the lock screen.
    
    Addresses Bug #3222.

 panel-plugin/time-out-lock-screen.c |   19 ++++++++++++++++++-
 panel-plugin/time-out-lock-screen.h |    3 ++-
 panel-plugin/time-out.c             |    2 +-
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/time-out-lock-screen.c b/panel-plugin/time-out-lock-screen.c
index cc3000e..3dfcf69 100644
--- a/panel-plugin/time-out-lock-screen.c
+++ b/panel-plugin/time-out-lock-screen.c
@@ -59,6 +59,9 @@ struct _TimeOutLockScreen
 {
   GObject         __parent__;
 
+  /* Total seconds */
+  gint            max_seconds;
+
   /* Remaining seconds */
   gint            remaining_seconds;
 
@@ -79,6 +82,7 @@ struct _TimeOutLockScreen
   GtkWidget      *time_label;
   GtkWidget      *postpone_button;
   GtkWidget      *resume_button;
+  GtkWidget      *progress;
 
   /* Fade out */
   TimeOutFadeout *fadeout;
@@ -206,6 +210,12 @@ time_out_lock_screen_init (TimeOutLockScreen *lock_screen)
   gtk_box_pack_start (GTK_BOX (vbox), lock_screen->time_label, FALSE, FALSE, 12);
   gtk_widget_show (lock_screen->time_label);
 
+  /* Create a progress bar to visually display the remaining tme */
+  lock_screen->progress = gtk_progress_bar_new ();
+  gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (lock_screen->progress), GTK_PROGRESS_LEFT_TO_RIGHT);
+  gtk_box_pack_start (GTK_BOX (vbox), lock_screen->progress, FALSE, FALSE, 0);
+  gtk_widget_show (lock_screen->progress);
+
   /* Create postpone button */
   lock_screen->postpone_button = gtk_button_new_with_mnemonic (_("_Postpone"));
   gtk_box_pack_start (GTK_BOX (vbox), lock_screen->postpone_button, FALSE, FALSE, 0);
@@ -244,7 +254,7 @@ time_out_lock_screen_new (void)
 
 
 void
-time_out_lock_screen_show (TimeOutLockScreen *lock_screen)
+time_out_lock_screen_show (TimeOutLockScreen *lock_screen, gint max_sec)
 {
   GdkScreen *screen;
   gint       monitor;
@@ -268,6 +278,10 @@ time_out_lock_screen_show (TimeOutLockScreen *lock_screen)
   /* Center window on target monitor */
   xfce_gtk_window_center_on_monitor (GTK_WINDOW (lock_screen->window), screen, monitor);
 
+  lock_screen->max_seconds = max_sec;
+
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (lock_screen->progress), 1.0);
+
   /* Display information window */
   gtk_widget_show_now (lock_screen->window);
   gtk_widget_grab_focus (lock_screen->window);
@@ -314,6 +328,9 @@ time_out_lock_screen_set_remaining (TimeOutLockScreen *lock_screen,
   /* Update widgets */
   gtk_label_set_markup (GTK_LABEL (lock_screen->time_label), time_string->str);
 
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (lock_screen->progress),
+                                 ((gdouble)seconds) / ((gdouble)lock_screen->max_seconds));
+
   /* Free time string */
   g_string_free (time_string, TRUE);
 }
diff --git a/panel-plugin/time-out-lock-screen.h b/panel-plugin/time-out-lock-screen.h
index a6cc032..2549d4c 100644
--- a/panel-plugin/time-out-lock-screen.h
+++ b/panel-plugin/time-out-lock-screen.h
@@ -40,7 +40,8 @@ typedef struct _TimeOutLockScreen      TimeOutLockScreen;
 GType              time_out_lock_screen_get_type            (void) G_GNUC_CONST;
 
 TimeOutLockScreen *time_out_lock_screen_new                 (void) G_GNUC_MALLOC;
-void               time_out_lock_screen_show                (TimeOutLockScreen *lock_screen);
+void               time_out_lock_screen_show                (TimeOutLockScreen *lock_screen,
+                                                             gint               max_sec);
 void               time_out_lock_screen_hide                (TimeOutLockScreen *lock_screen);
 void               time_out_lock_screen_set_remaining       (TimeOutLockScreen *lock_screen,
                                                              gint               seconds);
diff --git a/panel-plugin/time-out.c b/panel-plugin/time-out.c
index 927fce1..b8e0b75 100644
--- a/panel-plugin/time-out.c
+++ b/panel-plugin/time-out.c
@@ -913,7 +913,7 @@ time_out_start_lock_countdown (TimeOutPlugin *time_out)
   time_out_lock_screen_show_resume (time_out->lock_screen, FALSE);
 
   /* Display the lock screen */
-  time_out_lock_screen_show (time_out->lock_screen);
+  time_out_lock_screen_show (time_out->lock_screen, time_out->lock_countdown_seconds);
 }
 
 



More information about the Xfce4-commits mailing list