From 2fc1d1e392e3031811633be46b5954f4c54b5e48 Mon Sep 17 00:00:00 2001 From: Julien Lavergne <julien.lavergne@gmail.com> Date: Tue, 21 Dec 2010 22:43:13 +0100 Subject: [PATCH] Center text in dClock (Apply patch from ID 3102621) --- src/plugins/dclock.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/src/plugins/dclock.c b/src/plugins/dclock.c index 00df215..4c57655 100644 --- a/src/plugins/dclock.c +++ b/src/plugins/dclock.c @@ -44,6 +44,7 @@ typedef struct { char * action; /* Command to execute on a click */ gboolean bold; /* True if bold font */ gboolean icon_only; /* True if icon only (no clock value) */ + gboolean center_text; guint timer; /* Timer for periodic update */ enum { AWAITING_FIRST_CHANGE, /* Experimenting to determine interval, waiting for first change */ @@ -311,6 +312,8 @@ static int dclock_constructor(Plugin * p, char ** fp) dc->bold = str2num(bool_pair, s.t[1], 0); else if (g_ascii_strcasecmp(s.t[0], "IconOnly") == 0) dc->icon_only = str2num(bool_pair, s.t[1], 0); + else if (g_ascii_strcasecmp(s.t[0], "CenterText") == 0) + dc->center_text = str2num(bool_pair, s.t[1], 0); else ERR( "dclock: unknown var %s\n", s.t[0]); } @@ -326,7 +329,7 @@ static int dclock_constructor(Plugin * p, char ** fp) p->pwid = gtk_event_box_new(); /* Allocate a horizontal box as the child of the top level. */ - GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + GtkWidget * hbox = gtk_hbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(p->pwid), hbox); gtk_widget_show(hbox); @@ -393,6 +396,15 @@ static void dclock_apply_configuration(Plugin * p) gtk_widget_show(dc->clock_label); gtk_widget_hide(dc->clock_icon); } + + if (dc->center_text) + { + gtk_label_set_justify(dc->clock_label, GTK_JUSTIFY_CENTER); + } + else + { + gtk_label_set_justify(dc->clock_label, GTK_JUSTIFY_LEFT); + } /* Rerun the experiment to determine update interval and update the display. */ g_free(dc->prev_clock_value); @@ -425,6 +437,7 @@ static void dclock_configure(Plugin * p, GtkWindow * parent) _("Action when clicked (default: display calendar)"), &dc->action, CONF_TYPE_STR, _("Bold font"), &dc->bold, CONF_TYPE_BOOL, _("Tooltip only"), &dc->icon_only, CONF_TYPE_BOOL, + _("Center text"), &dc->center_text, CONF_TYPE_BOOL, NULL); gtk_window_present(GTK_WINDOW(dlg)); } @@ -438,6 +451,7 @@ static void dclock_save_configuration(Plugin * p, FILE * fp) lxpanel_put_str(fp, "Action", dc->action); lxpanel_put_int(fp, "BoldFont", dc->bold); lxpanel_put_int(fp, "IconOnly", dc->icon_only); + lxpanel_put_int(fp, "CenterText", dc->center_text); } /* Callback when panel configuration changes. */ -- 1.7.0.1