[Xfce4-commits] [panel-plugins/xfce4-verve-plugin] 03/04: Add ability to modify foreground (fg) and background (base) colors from properties dialog
noreply at xfce.org
noreply at xfce.org
Wed Nov 22 23:34:29 CET 2017
This is an automated email from the git hooks/post-receive script.
i s a a c s c h e m m p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-verve-plugin.
commit 980d3a4e82595fef9c98ee2251a655ad2e914f9c
Author: Isaac Schemm <isaacschemm at gmail.com>
Date: Fri Nov 17 10:00:41 2017 -0600
Add ability to modify foreground (fg) and background (base) colors from properties dialog
---
panel-plugin/verve-plugin.c | 135 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 118 insertions(+), 17 deletions(-)
diff --git a/panel-plugin/verve-plugin.c b/panel-plugin/verve-plugin.c
index 72fa08f..442589d 100644
--- a/panel-plugin/verve-plugin.c
+++ b/panel-plugin/verve-plugin.c
@@ -670,27 +670,31 @@ verve_plugin_update_colors (XfcePanelPlugin *plugin,
g_return_val_if_fail (verve != NULL, FALSE);
GdkColor color;
- verve->fg_color_override = FALSE;
- if (gdk_color_parse(fg_color_str, &color)) {
- verve->fg_color_override = TRUE;
- verve->fg_color = color;
+ if (fg_color_str) {
+ verve->fg_color_override = FALSE;
+ if (gdk_color_parse(fg_color_str, &color)) {
+ verve->fg_color_override = TRUE;
+ verve->fg_color = color;
+ }
+ gtk_widget_modify_text (verve->input, GTK_STATE_NORMAL, verve->fg_color_override ? &verve->fg_color : &verve->default_style->text[GTK_STATE_NORMAL]);
}
- verve->bg_color_override = FALSE;
- if (gdk_color_parse(bg_color_str, &color)) {
- verve->bg_color_override = TRUE;
- verve->bg_color = color;
+ if (bg_color_str) {
+ verve->bg_color_override = FALSE;
+ if (gdk_color_parse(bg_color_str, &color)) {
+ verve->bg_color_override = TRUE;
+ verve->bg_color = color;
+ }
+ gtk_widget_modify_bg (verve->input, GTK_STATE_NORMAL, verve->bg_color_override ? &verve->bg_color : &verve->default_style->bg[GTK_STATE_NORMAL]);
}
- verve->base_color_override = FALSE;
- if (gdk_color_parse(base_color_str, &color)) {
- verve->base_color_override = TRUE;
- verve->base_color = color;
+ if (base_color_str) {
+ verve->base_color_override = FALSE;
+ if (gdk_color_parse(base_color_str, &color)) {
+ verve->base_color_override = TRUE;
+ verve->base_color = color;
+ }
+ gtk_widget_modify_base (verve->input, GTK_STATE_NORMAL, verve->base_color_override ? &verve->base_color : &verve->default_style->base[GTK_STATE_NORMAL]);
}
- /* Reset entry colors */
- gtk_widget_modify_base (verve->input, GTK_STATE_NORMAL, verve->base_color_override ? &verve->base_color : &verve->default_style->base[GTK_STATE_NORMAL]);
- gtk_widget_modify_bg (verve->input, GTK_STATE_NORMAL, verve->bg_color_override ? &verve->bg_color : &verve->default_style->bg[GTK_STATE_NORMAL]);
- gtk_widget_modify_text (verve->input, GTK_STATE_NORMAL, verve->fg_color_override ? &verve->fg_color : &verve->default_style->text[GTK_STATE_NORMAL]);
-
return TRUE;
}
@@ -913,6 +917,34 @@ verve_plugin_size_changed (GtkSpinButton *spin,
static void
+verve_plugin_fg_color_changed (GtkEntry *box,
+ VervePlugin *verve)
+{
+ g_return_if_fail (verve != NULL);
+
+ /* Get the entered color */
+ const gchar *color_str = gtk_entry_get_text (box);
+
+ verve_plugin_update_colors (NULL, color_str, NULL, NULL, verve);
+}
+
+
+
+static void
+verve_plugin_base_color_changed (GtkEntry *box,
+ VervePlugin *verve)
+{
+ g_return_if_fail (verve != NULL);
+
+ /* Get the entered color */
+ const gchar *color_str = gtk_entry_get_text (box);
+
+ verve_plugin_update_colors (NULL, NULL, NULL, color_str, verve);
+}
+
+
+
+static void
verve_plugin_label_changed (GtkEntry *box,
VervePlugin *verve)
{
@@ -1073,6 +1105,10 @@ verve_plugin_properties (XfcePanelPlugin *plugin,
GtkWidget *vbox;
GtkWidget *size_label;
GtkWidget *size_spin;
+ GtkWidget *base_color_label;
+ GtkWidget *base_color_box;
+ GtkWidget *fg_color_label;
+ GtkWidget *fg_color_box;
GtkWidget *label_label;
GtkWidget *label_box;
GtkWidget *history_length_label;
@@ -1095,6 +1131,8 @@ verve_plugin_properties (XfcePanelPlugin *plugin,
GtkWidget *command_type_executable;
GtkWidget *command_type_use_shell;
+ gchar *color_str;
+
g_return_if_fail (plugin != NULL);
g_return_if_fail (verve != NULL);
@@ -1187,6 +1225,69 @@ verve_plugin_properties (XfcePanelPlugin *plugin,
/* Be notified when the user requests a different label setting */
g_signal_connect (label_box, "changed", G_CALLBACK (verve_plugin_label_changed), verve);
+ /* Frame for color settings */
+ frame = xfce_gtk_frame_box_new (_("Colors"), &bin1);
+ gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
+ gtk_box_pack_start (GTK_BOX (general_vbox), frame, FALSE, FALSE, 0);
+ gtk_widget_show (frame);
+
+ /* Color settings vertical container */
+ vbox = gtk_vbox_new (FALSE, 8);
+ gtk_container_add (GTK_CONTAINER(bin1), vbox);
+ gtk_widget_show(vbox);
+
+ /* Plugin background color container */
+ hbox = gtk_hbox_new (FALSE, 8);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ /* Plugin background color label */
+ base_color_label = gtk_label_new (_("Background color:"));
+ gtk_box_pack_start (GTK_BOX (hbox), base_color_label, FALSE, TRUE, 0);
+ gtk_widget_show (base_color_label);
+
+ /* Plugin background color entry field */
+ base_color_box = gtk_entry_new();
+
+ /* Set text to current background color */
+ if (verve->base_color_override) {
+ color_str = gdk_color_to_string(&verve->base_color);
+ gtk_entry_set_text(GTK_ENTRY (base_color_box), color_str);
+ g_free (color_str);
+ }
+ gtk_widget_add_mnemonic_label (base_color_box, base_color_label);
+ gtk_box_pack_start (GTK_BOX (hbox), base_color_box, FALSE, TRUE, 0);
+ gtk_widget_show (base_color_box);
+
+ /* Be notified when the user requests a different background color setting */
+ g_signal_connect (base_color_box, "changed", G_CALLBACK (verve_plugin_base_color_changed), verve);
+
+ /* Plugin foreground color container */
+ hbox = gtk_hbox_new (FALSE, 8);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ /* Plugin foreground color label */
+ fg_color_label = gtk_label_new (_("Foreground color:"));
+ gtk_box_pack_start (GTK_BOX (hbox), fg_color_label, FALSE, TRUE, 0);
+ gtk_widget_show (fg_color_label);
+
+ /* Plugin foreground color entry field */
+ fg_color_box = gtk_entry_new();
+
+ /* Set text to current foreground color */
+ if (verve->base_color_override) {
+ color_str = gdk_color_to_string(&verve->fg_color);
+ gtk_entry_set_text(GTK_ENTRY (fg_color_box), color_str);
+ g_free (color_str);
+ }
+ gtk_widget_add_mnemonic_label (fg_color_box, fg_color_label);
+ gtk_box_pack_start (GTK_BOX (hbox), fg_color_box, FALSE, TRUE, 0);
+ gtk_widget_show (fg_color_box);
+
+ /* Be notified when the user requests a different foreground color setting */
+ g_signal_connect (fg_color_box, "changed", G_CALLBACK (verve_plugin_fg_color_changed), verve);
+
/* Frame for behaviour settings */
frame = xfce_gtk_frame_box_new (_("History"), &bin2);
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list