Author: nick
Date: 2007-11-21 10:21:11 +0000 (Wed, 21 Nov 2007)
New Revision: 26385

Modified:
   xfce4-panel/trunk/plugins/clock/clock-dialog.c
   xfce4-panel/trunk/plugins/clock/clock-lcd.c
   xfce4-panel/trunk/plugins/clock/clock.c
   xfce4-panel/trunk/plugins/clock/clock.h
Log:
* Add option to lcd clock to flash the time separators.


Modified: xfce4-panel/trunk/plugins/clock/clock-dialog.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-dialog.c      2007-11-21 09:52:21 UTC 
(rev 26384)
+++ xfce4-panel/trunk/plugins/clock/clock-dialog.c      2007-11-21 10:21:11 UTC 
(rev 26385)
@@ -222,6 +222,19 @@
 
 
 static void
+xfce_clock_dialog_flash_separators_toggled (GtkToggleButton *button,
+                                            ClockPlugin     *clock)
+{
+    /* whether flash the separators */
+    clock->flash_separators = gtk_toggle_button_get_active (button);
+
+    /* update the clock */
+    xfce_clock_dialog_reload_settings (clock);
+}
+
+
+
+static void
 xfce_clock_dialog_true_binary_toggled (GtkToggleButton *button,
                                        ClockPlugin     *clock)
 {
@@ -411,6 +424,12 @@
         g_signal_connect (button, "toggled", G_CALLBACK 
(xfce_clock_dialog_show_military_toggled), clock);
         gtk_widget_show (button);
 
+        button = gtk_check_button_new_with_mnemonic (_("Fl_ash time 
separators"));
+        gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
clock->flash_separators);
+        g_signal_connect (button, "toggled", G_CALLBACK 
(xfce_clock_dialog_flash_separators_toggled), clock);
+        gtk_widget_show (button);
+
         button = gtk_check_button_new_with_mnemonic (_("Sho_w AM/PM"));
         gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
clock->show_meridiem);

Modified: xfce4-panel/trunk/plugins/clock/clock-lcd.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-lcd.c 2007-11-21 09:52:21 UTC (rev 
26384)
+++ xfce4-panel/trunk/plugins/clock/clock-lcd.c 2007-11-21 10:21:11 UTC (rev 
26385)
@@ -46,7 +46,7 @@
                                               GValue            *value,
                                               GParamSpec        *pspec);
 static void      xfce_clock_lcd_size_request (GtkWidget         *widget,
-                                                         GtkRequisition    
*requisition);
+                                              GtkRequisition    *requisition);
 static gboolean  xfce_clock_lcd_expose_event (GtkWidget         *widget,
                                               GdkEventExpose    *event);
 static gdouble   xfce_clock_lcd_get_ratio    (XfceClockLcd      *clock);
@@ -67,7 +67,8 @@
     PROP_0,
     PROP_SHOW_SECONDS,
     PROP_SHOW_MILITARY,
-    PROP_SHOW_MERIDIEM
+    PROP_SHOW_MERIDIEM,
+    PROP_FLASH_SEPARATORS,
 };
 
 struct _XfceClockLcdClass
@@ -87,6 +88,9 @@
 
     /* whether we display am/pm */
     guint    show_meridiem : 1;
+
+    /* whether to flash the separators */
+    guint    flash_separators : 1;
 };
 
 
@@ -159,6 +163,15 @@
                                      g_param_spec_boolean ("show-meridiem", 
"show-meridiem", "show-meridiem",
                                                            TRUE,
                                                            
PANEL_PARAM_READWRITE));
+
+    /**
+     * Whether to flash the time separators
+     **/
+    g_object_class_install_property (gobject_class,
+                                     PROP_FLASH_SEPARATORS,
+                                     g_param_spec_boolean ("flash-separators", 
"flash-separators", "flash-separators",
+                                                           FALSE,
+                                                           
PANEL_PARAM_READWRITE));
 }
 
 
@@ -170,6 +183,7 @@
     clock->show_seconds = FALSE;
     clock->show_meridiem = FALSE;
     clock->show_military = TRUE;
+    clock->flash_separators = FALSE;
 }
 
 
@@ -204,6 +218,10 @@
             clock->show_meridiem = g_value_get_boolean (value);
             break;
 
+        case PROP_FLASH_SEPARATORS:
+            clock->flash_separators = g_value_get_boolean (value);
+            break;
+
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
             break;
@@ -234,6 +252,10 @@
             g_value_set_boolean (value, clock->show_meridiem);
             break;
 
+        case PROP_FLASH_SEPARATORS:
+            g_value_set_boolean (value, clock->flash_separators);
+            break;
+
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
             break;
@@ -244,7 +266,7 @@
 
 static void
 xfce_clock_lcd_size_request (GtkWidget      *widget,
-                                        GtkRequisition *requisition)
+                             GtkRequisition *requisition)
 {
     gint    width, height;
     gdouble ratio;
@@ -289,7 +311,7 @@
 
     /* size of a digit should be a fraction of 10 */
     size = widget->allocation.height - widget->allocation.height % 10;
-    
+
     /* get the width:height ratio */
     ratio = xfce_clock_lcd_get_ratio (XFCE_CLOCK_LCD (widget));
 
@@ -304,14 +326,14 @@
     {
         /* get the local time */
         xfce_clock_util_get_localtime (&tm);
-        
+
         /* draw the hours */
         ticks = tm.tm_hour;
 
         /* convert 24h clock to 12h clock */
         if (!clock->show_military && ticks > 12)
             ticks -= 12;
-            
+
         /* queue a resize when the number of hour digits changed */
         if (G_UNLIKELY ((ticks == 10 || ticks == 0) && tm.tm_min == 0 && 
tm.tm_sec == 0))
           gtk_widget_queue_resize (widget);
@@ -344,7 +366,10 @@
             }
 
             /* draw the dots */
-            offset_x = xfce_clock_lcd_draw_dots (cr, size, offset_x, offset_y);
+            if (clock->flash_separators && (tm.tm_sec % 2) == 1)
+                offset_x += size * RELATIVE_SPACE * 2;
+            else
+                offset_x = xfce_clock_lcd_draw_dots (cr, size, offset_x, 
offset_y);
 
             /* draw the first digit */
             offset_x = xfce_clock_lcd_draw_digit (cr, (ticks - (ticks % 10)) / 
10, size, offset_x, offset_y);

Modified: xfce4-panel/trunk/plugins/clock/clock.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock.c     2007-11-21 09:52:21 UTC (rev 
26384)
+++ xfce4-panel/trunk/plugins/clock/clock.c     2007-11-21 10:21:11 UTC (rev 
26385)
@@ -88,10 +88,10 @@
     static gint hour = 23;
     static gint min = 59;
     static gint sec = 45;
-    
+
     /* add 1 seconds */
     sec++;
-    
+
     /* update times */
     if (sec > 59)
     {
@@ -107,7 +107,7 @@
     {
         hour = 0;
     }
-    
+
     /* set time structure */
     tm->tm_sec = sec;
     tm->tm_min = min;
@@ -379,7 +379,8 @@
             g_object_set (G_OBJECT (clock->widget),
                           "show-seconds", clock->show_seconds,
                           "show-military", clock->show_military,
-                          "show-meridiem", clock->show_meridiem, NULL);
+                          "show-meridiem", clock->show_meridiem,
+                          "flash-separators", clock->flash_separators, NULL);
             break;
     }
 
@@ -392,7 +393,10 @@
     else
     {
         /* interval from setting */
-        clock->interval = clock->show_seconds ? CLOCK_INTERVAL_SECOND : 
CLOCK_INTERVAL_MINUTE;
+        if (clock->mode == XFCE_CLOCK_LCD)
+            clock->interval = (clock->show_seconds || clock->flash_separators) 
? CLOCK_INTERVAL_SECOND : CLOCK_INTERVAL_MINUTE;
+        else
+            clock->interval = clock->show_seconds ? CLOCK_INTERVAL_SECOND : 
CLOCK_INTERVAL_MINUTE;
     }
 }
 
@@ -561,11 +565,12 @@
             clock->mode = xfce_rc_read_int_entry (rc, "ClockType", 
XFCE_CLOCK_DIGITAL);
 
             /* read boolean settings */
-            clock->show_frame    = xfce_rc_read_bool_entry (rc, "ShowFrame", 
TRUE);
-            clock->show_seconds  = xfce_rc_read_bool_entry (rc, "ShowSeconds", 
FALSE);
-            clock->show_military = xfce_rc_read_bool_entry (rc, 
"ShowMilitary", TRUE);
-            clock->show_meridiem = xfce_rc_read_bool_entry (rc, 
"ShowMeridiem", FALSE);
-            clock->true_binary   = xfce_rc_read_bool_entry (rc, "TrueBinary", 
FALSE);
+            clock->show_frame       = xfce_rc_read_bool_entry (rc, 
"ShowFrame", TRUE);
+            clock->show_seconds     = xfce_rc_read_bool_entry (rc, 
"ShowSeconds", FALSE);
+            clock->show_military    = xfce_rc_read_bool_entry (rc, 
"ShowMilitary", TRUE);
+            clock->show_meridiem    = xfce_rc_read_bool_entry (rc, 
"ShowMeridiem", FALSE);
+            clock->true_binary      = xfce_rc_read_bool_entry (rc, 
"TrueBinary", FALSE);
+            clock->flash_separators = xfce_rc_read_bool_entry (rc, 
"FlashSeparators", FALSE);
 
             /* close the rc file */
             xfce_rc_close (rc);
@@ -605,6 +610,7 @@
             xfce_rc_write_bool_entry (rc, "ShowMilitary", 
clock->show_military);
             xfce_rc_write_bool_entry (rc, "ShowMeridiem", 
clock->show_meridiem);
             xfce_rc_write_bool_entry (rc, "TrueBinary", clock->true_binary);
+            xfce_rc_write_bool_entry (rc, "FlashSeparators", 
clock->flash_separators);
 
             /* close the rc file */
             xfce_rc_close (rc);

Modified: xfce4-panel/trunk/plugins/clock/clock.h
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock.h     2007-11-21 09:52:21 UTC (rev 
26384)
+++ xfce4-panel/trunk/plugins/clock/clock.h     2007-11-21 10:21:11 UTC (rev 
26385)
@@ -79,6 +79,7 @@
     guint            show_military : 1;
     guint            show_meridiem : 1;
     guint            true_binary : 1;
+    guint            flash_separators : 1;
 };
 
 

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to