Browse Source

* Add option to lcd clock to flash the time separators.

(Old svn revision: 26385)
upstream/xfce4-panel-4.10.1
Nick Schermer 15 years ago
parent
commit
8fdd855dd9
  1. 19
      plugins/clock/clock-dialog.c
  2. 39
      plugins/clock/clock-lcd.c
  3. 26
      plugins/clock/clock.c
  4. 1
      plugins/clock/clock.h

19
plugins/clock/clock-dialog.c

@ -221,6 +221,19 @@ xfce_clock_dialog_show_meridiem_toggled (GtkToggleButton *button,
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 @@ xfce_clock_dialog_options (ClockPlugin *clock)
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);

39
plugins/clock/clock-lcd.c

@ -46,7 +46,7 @@ static void xfce_clock_lcd_get_property (GObject *object,
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 @@ enum
PROP_0,
PROP_SHOW_SECONDS,
PROP_SHOW_MILITARY,
PROP_SHOW_MERIDIEM
PROP_SHOW_MERIDIEM,
PROP_FLASH_SEPARATORS,
};
struct _XfceClockLcdClass
@ -87,6 +88,9 @@ struct _XfceClockLcd
/* whether we display am/pm */
guint show_meridiem : 1;
/* whether to flash the separators */
guint flash_separators : 1;
};
@ -159,6 +163,15 @@ xfce_clock_lcd_class_init (XfceClockLcdClass *klass)
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 @@ xfce_clock_lcd_init (XfceClockLcd *clock)
clock->show_seconds = FALSE;
clock->show_meridiem = FALSE;
clock->show_military = TRUE;
clock->flash_separators = FALSE;
}
@ -204,6 +218,10 @@ xfce_clock_lcd_set_property (GObject *object,
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 @@ xfce_clock_lcd_get_property (GObject *object,
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 @@ xfce_clock_lcd_get_property (GObject *object,
static void
xfce_clock_lcd_size_request (GtkWidget *widget,
GtkRequisition *requisition)
GtkRequisition *requisition)
{
gint width, height;
gdouble ratio;
@ -289,7 +311,7 @@ xfce_clock_lcd_expose_event (GtkWidget *widget,
/* 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 @@ xfce_clock_lcd_expose_event (GtkWidget *widget,
{
/* 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 @@ xfce_clock_lcd_expose_event (GtkWidget *widget,
}
/* 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);

26
plugins/clock/clock.c

@ -88,10 +88,10 @@ xfce_clock_util_get_debug_localtime (struct tm *tm)
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 @@ xfce_clock_util_get_debug_localtime (struct tm *tm)
{
hour = 0;
}
/* set time structure */
tm->tm_sec = sec;
tm->tm_min = min;
@ -379,7 +379,8 @@ xfce_clock_widget_update_settings (ClockPlugin *clock)
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 @@ xfce_clock_widget_update_settings (ClockPlugin *clock)
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 @@ xfce_clock_plugin_read (ClockPlugin *clock)
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_clock_plugin_write (ClockPlugin *clock)
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);

1
plugins/clock/clock.h

@ -79,6 +79,7 @@ struct _ClockPlugin
guint show_military : 1;
guint show_meridiem : 1;
guint true_binary : 1;
guint flash_separators : 1;
};

Loading…
Cancel
Save