diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c index d7c1cb5..8ba6138 100644 --- a/panel-plugin/xfce4-cpufreq-configure.c +++ b/panel-plugin/xfce4-cpufreq-configure.c @@ -137,6 +137,21 @@ button_fontname_pressed(GtkWidget *button, return FALSE; } +static gboolean +textbox_fontcolor_lostfocus(GtkWidget *textbox, + CpuFreqPluginConfigure *configure); + +static gboolean +textbox_fontcolor_lostfocus(GtkWidget *textbox, + CpuFreqPluginConfigure *configure) +{ + gchar *fontcolor; + + fontcolor = g_strdup(gtk_entry_get_text(GTK_ENTRY(textbox))); + cpuFreq->options->fontcolor = fontcolor; + cpufreq_update_plugin (TRUE); +} + static void combo_changed (GtkWidget *combo, CpuFreqPluginConfigure *configure) { @@ -176,7 +191,7 @@ cpufreq_configure (XfcePanelPlugin *plugin) gchar *cpu_name; GtkWidget *dialog, *dialog_vbox; GtkWidget *frame, *align, *label, *vbox, *hbox; - GtkWidget *combo, *spinner, *button; + GtkWidget *combo, *spinner, *button, *textbox; GtkSizeGroup *sg0; CpuFreqPluginConfigure *configure; @@ -287,6 +302,24 @@ cpufreq_configure (XfcePanelPlugin *plugin) G_CALLBACK (button_fontname_pressed), configure); button_fontname_update (button, FALSE); + /* font color */ + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new_with_mnemonic (_("_Font color:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); + gtk_label_set_xalign (GTK_LABEL (label), 0); + gtk_size_group_add_widget (sg0, label); + + textbox = configure->fontcolor = gtk_entry_new(); + gtk_entry_set_max_length(GTK_ENTRY(textbox), 9); + gtk_box_pack_start (GTK_BOX (hbox), textbox, FALSE, TRUE, 0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), textbox); + g_signal_connect (G_OBJECT (textbox), "focus-out-event", + G_CALLBACK (textbox_fontcolor_lostfocus), configure); + gtk_entry_set_text(GTK_ENTRY(textbox), cpuFreq->options->fontcolor); + /* which cpu to show in panel */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); diff --git a/panel-plugin/xfce4-cpufreq-configure.h b/panel-plugin/xfce4-cpufreq-configure.h index 3ea3f43..4f7608b 100644 --- a/panel-plugin/xfce4-cpufreq-configure.h +++ b/panel-plugin/xfce4-cpufreq-configure.h @@ -34,6 +34,7 @@ typedef struct GtkWidget *keep_compact; GtkWidget *one_line; GtkWidget *fontname; + GtkWidget *fontcolor; } CpuFreqPluginConfigure; G_BEGIN_DECLS diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c index 1f9e818..5449a5b 100644 --- a/panel-plugin/xfce4-cpufreq-plugin.c +++ b/panel-plugin/xfce4-cpufreq-plugin.c @@ -111,12 +111,25 @@ cpufreq_label_set_font (void) { font = pango_font_description_from_string(cpuFreq->options->fontname); - css = g_strdup_printf("label { font-family: %s; font-size: %dpx; font-style: %s; font-weight: %s }", + css = g_strdup_printf("label { font-family: %s; font-size: %dpx; font-style: %s; font-weight: %s; color: %s }", pango_font_description_get_family (font), pango_font_description_get_size (font) / PANGO_SCALE, (pango_font_description_get_style(font) == PANGO_STYLE_ITALIC || pango_font_description_get_style(font) == PANGO_STYLE_OBLIQUE) ? "italic" : "normal", - (pango_font_description_get_weight(font) >= PANGO_WEIGHT_BOLD) ? "bold" : "normal"); + (pango_font_description_get_weight(font) >= PANGO_WEIGHT_BOLD) ? "bold" : "normal", + cpuFreq->options->fontcolor); + pango_font_description_free (font); + + provider = gtk_css_provider_new (); + + gtk_css_provider_load_from_data (provider, css, -1, NULL); + gtk_style_context_add_provider ( + GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))), + GTK_STYLE_PROVIDER(provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_free(css); + } else if(cpuFreq->options->fontcolor){ + css = g_strdup_printf("label { color: %s }",cpuFreq->options->fontcolor); pango_font_description_free (font); provider = gtk_css_provider_new (); @@ -545,6 +558,11 @@ cpufreq_read_config (void) g_free (cpuFreq->options->fontname); cpuFreq->options->fontname = g_strdup (value); } + value = xfce_rc_read_entry (rc, "fontcolor", NULL); + if (value) { + g_free (cpuFreq->options->fontcolor); + cpuFreq->options->fontcolor = g_strdup (value); + } xfce_rc_close (rc); } @@ -573,6 +591,8 @@ cpufreq_write_config (XfcePanelPlugin *plugin) xfce_rc_write_bool_entry (rc, "one_line", cpuFreq->options->one_line); if (cpuFreq->options->fontname) xfce_rc_write_entry (rc, "fontname", cpuFreq->options->fontname); + if (cpuFreq->options->fontcolor) + xfce_rc_write_entry (rc, "fontcolor", cpuFreq->options->fontcolor); xfce_rc_close (rc); } diff --git a/panel-plugin/xfce4-cpufreq-plugin.h b/panel-plugin/xfce4-cpufreq-plugin.h index 30308d1..f6c6c0e 100644 --- a/panel-plugin/xfce4-cpufreq-plugin.h +++ b/panel-plugin/xfce4-cpufreq-plugin.h @@ -61,6 +61,7 @@ typedef struct gboolean keep_compact; gboolean one_line; gchar *fontname; + gchar *fontcolor; } CpuFreqPluginOptions; typedef struct diff --git a/po/en_GB.po b/po/en_GB.po index a440fa2..98b21cd 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: # Noskcaj , 2013 msgid "" @@ -58,6 +58,10 @@ msgstr "Panel" msgid "_Font:" msgstr "_Font:" +#: ../panel-plugin/xfce4-cpufreq-configure.c:309 +msgid "_Font color:" +msgstr "_Font color:" + #: ../panel-plugin/xfce4-cpufreq-configure.c:275 msgid "_Display CPU:" msgstr "_Display CPU:" diff --git a/po/es.po b/po/es.po index a08baa8..7ec03ec 100644 --- a/po/es.po +++ b/po/es.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: # , 2009 # Adolfo Jayme Barrientos, 2014 @@ -63,6 +63,10 @@ msgstr "Panel" msgid "_Font:" msgstr "_Tipo de Letra:" +#: ../panel-plugin/xfce4-cpufreq-configure.c:309 +msgid "_Font color:" +msgstr "_Color de letra:" + #: ../panel-plugin/xfce4-cpufreq-configure.c:294 msgid "_Display CPU:" msgstr "_Mostrar procesador"