[Xfce4-commits] [panel-plugins/xfce4-genmon-plugin] 01/01: Enhance plugin CSS styling capabilites

noreply at xfce.org noreply at xfce.org
Thu Mar 2 22:44:24 CET 2017


This is an automated email from the git hooks/post-receive script.

ToZ pushed a commit to branch master
in repository panel-plugins/xfce4-genmon-plugin.

commit eaceb6f6110351e0b5a96291a98997512ca848f8
Author: ToZ <tony.paulic at gmail.com>
Date:   Thu Mar 2 16:44:00 2017 -0500

    Enhance plugin CSS styling capabilites
---
 CSS Styling.txt     | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 panel-plugin/main.c | 46 +++++++++++++++++++++++++++-----
 2 files changed, 115 insertions(+), 6 deletions(-)

diff --git a/CSS Styling.txt b/CSS Styling.txt
new file mode 100644
index 0000000..84c417c
--- /dev/null
+++ b/CSS Styling.txt	
@@ -0,0 +1,75 @@
+xfce4-genmon-plugin CSS Styling
+===============================
+
+The genmon plugin layout is as such:
+[ Component (Gtk widget name) CSS style class (Description) ]
+
++-wEventbox (GtkEventBox) n/a (the main widget to manage events)
+|
+|--wBox (GtkBox) genmon_plugin (the main widget container box - all other widgets within this box)
+|
+|---wTitle (GtkLabel) genmon_label (the optional label from the configuration dialog)
+|
+|---wImgBox (GtkBox) n/a (the container box that contains the optionally clickable image and text outputs)
+|
+|----wImage (GtkImage) genmon_image (the non-clickable output image <img></img>)
+|----wButton (GtkButton) genmon_imagebutton (the clickable output image <click></click>)
+|-----wImageButton (GtkImage) n/a (the image that sits on wButton)
+|    *note: only one of wImage (<img>) or wImgButton (<click>) can exist on the plugin at the same time
+|    
+|----wValue (GtkLabel) genmon_value (the non-clickable output text <txt></txt>)
+|----wValButton (GtkButton) genmon_valuebutton (the clickable output text <txtclick></txtclick>)
+|-----wValButtonLabel (GtkLabel) n/a (the lable that sits on wValButton)
+|    *note: only one of wValue (<txt>) or wValButton (<txtclick>) can exist on the plugin at the same time
+|   
++---wBar (GtkProgressBar) genmon_progressbar (the slider bar (<bar></bar>)
+
+To access each of the genmon-specific css classes use the following format:
+- Gtk 3.16 and Gtk 3.18:
+   style_class_name
+- Gtk 3.20 and Gtk 3.22:
+   .style_class_name
+   
+   
+   
+Examples:
+
+To change the opacity and padding of the clickable image button (<click>):
+
+3.16/3.18:
+genmon_imagebutton {
+   opacity: 0.5;
+   padding: 2px;
+}
+
+3.20/3.22:
+.genmon_imagebutton {
+   opacity: 0.75;
+   padding_left: 2px;
+   padding_top: 2px;
+}
+
+
+To change the text color, font size and centre the font of the value output (<txt>):
+
+3.16/3.18:
+genmon_value {
+	color: rgb(255,0,0);
+	font-size: 8;
+	padding-top: 4;
+}
+
+3.20/3.22:
+.genmon_value {
+	color: rgb(255,0,0);
+	font-size: 8;
+	padding-top: 4;
+}
+
+
+
+References:
+
+To get a list of all available properties, see the Gtk3 Reference Manual at:
+https://developer.gnome.org/gtk3/stable/index.html or configure and use
+the Gtk Inspector: https://wiki.gnome.org/Projects/GTK+/Inspector
\ No newline at end of file
diff --git a/panel-plugin/main.c b/panel-plugin/main.c
index 3081c98..28c8041 100644
--- a/panel-plugin/main.c
+++ b/panel-plugin/main.c
@@ -315,6 +315,7 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
     gchar *default_font;
 
     #if GTK_CHECK_VERSION (3, 16, 0)
+        GtkStyleContext *context;
         GtkCssProvider *css_provider;
         gchar * css;
     #endif
@@ -353,6 +354,10 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
     xfce_panel_plugin_add_action_widget (plugin, poMonitor->wEventBox);
 
     poMonitor->wBox = gtk_box_new (orientation, 0);
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wBox);
+         gtk_style_context_add_class(context,"genmon_plugin");
+    #endif
     gtk_widget_show (poMonitor->wBox);
     gtk_container_set_border_width (GTK_CONTAINER
         (poMonitor->wBox), 0);
@@ -360,6 +365,10 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
         poMonitor->wBox);
 
     poMonitor->wTitle = gtk_label_new (poConf->acTitle);
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wTitle);
+         gtk_style_context_add_class(context,"genmon_label");
+    #endif
     if (poConf->fTitleDisplayed)
         gtk_widget_show (poMonitor->wTitle);
     gtk_box_pack_start (GTK_BOX (poMonitor->wBox),
@@ -367,6 +376,10 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
 
     /* Create a Box to put image and text */
     poMonitor->wImgBox = gtk_box_new (orientation, 0);
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wImgBox);
+         gtk_style_context_add_class(context,"genmon_imagebox");
+    #endif
     gtk_widget_show (poMonitor->wImgBox);
     gtk_container_set_border_width (GTK_CONTAINER
         (poMonitor->wImgBox), 0);
@@ -375,11 +388,19 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
 
     /* Add Image */
     poMonitor->wImage = gtk_image_new ();
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wImage);
+         gtk_style_context_add_class(context,"genmon_image");
+    #endif
     gtk_box_pack_start (GTK_BOX (poMonitor->wImgBox),
         GTK_WIDGET (poMonitor->wImage), TRUE, FALSE, 0);
 
     /* Add Button */
     poMonitor->wButton = xfce_create_panel_button ();
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wButton);
+         gtk_style_context_add_class(context,"genmon_imagebutton");
+    #endif
     xfce_panel_plugin_add_action_widget (plugin, poMonitor->wButton);
     gtk_box_pack_start (GTK_BOX (poMonitor->wImgBox),
         GTK_WIDGET (poMonitor->wButton), TRUE, FALSE, 0);
@@ -391,12 +412,20 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
 
     /* Add Value */
     poMonitor->wValue = gtk_label_new ("");
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wValue);
+         gtk_style_context_add_class(context,"genmon_value");
+    #endif
     gtk_widget_show (poMonitor->wValue);
     gtk_box_pack_start (GTK_BOX (poMonitor->wImgBox),
         GTK_WIDGET (poMonitor->wValue), TRUE, FALSE, 0);
 
     /* Add Value Button */
     poMonitor->wValButton = xfce_create_panel_button ();
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wValButton);
+         gtk_style_context_add_class(context,"genmon_valuebutton");
+    #endif
     xfce_panel_plugin_add_action_widget (plugin, poMonitor->wValButton);
     gtk_box_pack_start (GTK_BOX (poMonitor->wImgBox),
         GTK_WIDGET (poMonitor->wValButton), TRUE, FALSE, 0);
@@ -408,6 +437,10 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
 
     /* Add Bar */
     poMonitor->wBar = gtk_progress_bar_new();
+    #if GTK_CHECK_VERSION (3, 16, 0)
+         context = gtk_widget_get_style_context(poMonitor->wBar);
+         gtk_style_context_add_class(context,"genmon_progressbar");
+    #endif
     gtk_box_pack_start (GTK_BOX (poMonitor->wBox),
         GTK_WIDGET (poMonitor->wBar), FALSE, FALSE, 0);
     if (orientation == GTK_ORIENTATION_HORIZONTAL) {
@@ -419,23 +452,21 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
         gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(poMonitor->wBar), FALSE);
     }
 
-
     /* make widget padding consistent */
     #if GTK_CHECK_VERSION (3, 16, 0)
-    #if GTK_CHECK_VERSION (3, 20, 0)
+     #if GTK_CHECK_VERSION (3, 20, 0)
         css = g_strdup_printf("\
             progressbar.horizontal trough { min-height: 6px; }\
             progressbar.horizontal progress { min-height: 6px; }\
             progressbar.vertical trough { min-width: 6px; }\
             progressbar.vertical progress { min-width: 6px; }");
-    #else
+     #else
         css = g_strdup_printf("\
             .progressbar.horizontal trough { min-height: 6px; }\
             .progressbar.horizontal progress { min-height: 6px; }\
             .progressbar.vertical trough { min-width: 6px; }\
             .progressbar.vertical progress { min-width: 6px; }");
-    #endif
-    #endif
+     #endif
 
     css_provider = gtk_css_provider_new ();
     gtk_css_provider_load_from_data (css_provider, css, strlen(css), NULL);
@@ -463,7 +494,10 @@ static genmon_t *genmon_create_control (XfcePanelPlugin *plugin)
         GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (poMonitor->wBar))),
         GTK_STYLE_PROVIDER (css_provider),
         GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);  
-    g_free(css);
+
+        g_free(css);
+    #endif
+
     g_free(default_font);
 
     return poPlugin;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list