[Xfce4-commits] [xfce/xfce4-panel] 01/01: systray: Basic support for symbolic icons
noreply at xfce.org
noreply at xfce.org
Sat Jan 18 13:40:08 CET 2020
This is an automated email from the git hooks/post-receive script.
o c h o s i 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 xfce/xfce4-panel.
commit 7db1f872835f522a44c0e935897187444d486ea7
Author: Clement Lefebvre <root at linuxmint.com>
Date: Fri Jan 17 22:48:57 2020 +0100
systray: Basic support for symbolic icons
---
plugins/systray/systray-manager.c | 86 ++++++++++++++++++++++++++++++++++++++-
plugins/systray/systray-manager.h | 6 +++
plugins/systray/systray.c | 32 ++++++++++++++-
3 files changed, 122 insertions(+), 2 deletions(-)
diff --git a/plugins/systray/systray-manager.c b/plugins/systray/systray-manager.c
index 4915649..3901e7b 100644
--- a/plugins/systray/systray-manager.c
+++ b/plugins/systray/systray-manager.c
@@ -78,6 +78,7 @@ static void systray_manager_handle_dock_request (Systr
static gboolean systray_manager_handle_undock_request (GtkSocket *socket,
gpointer user_data);
static void systray_manager_set_visual (SystrayManager *manager);
+static void systray_manager_set_colors_property (SystrayManager *manager);
static void systray_manager_message_free (SystrayMessage *message);
static void systray_manager_message_remove_from_list (SystrayManager *manager,
XClientMessageEvent *xevent);
@@ -109,6 +110,12 @@ struct _SystrayManager
/* list of client sockets */
GHashTable *sockets;
+ /* symbolic colors */
+ GdkColor fg;
+ GdkColor error;
+ GdkColor warning;
+ GdkColor success;
+
/* orientation of the tray */
GtkOrientation orientation;
@@ -218,6 +225,23 @@ systray_manager_init (SystrayManager *manager)
manager->orientation = GTK_ORIENTATION_HORIZONTAL;
manager->messages = NULL;
manager->sockets = g_hash_table_new (NULL, NULL);
+
+ /* initialize symbolic colors */
+ manager->fg.red = 0.0;
+ manager->fg.green = 0.0;
+ manager->fg.blue = 0.0;
+
+ manager->error.red = 1.0;
+ manager->error.green = 0.0;
+ manager->error.blue = 0.0;
+
+ manager->warning.red = 1.0;
+ manager->warning.green = 1.0;
+ manager->warning.blue = 0.0;
+
+ manager->success.red = 0.0;
+ manager->success.green = 1.0;
+ manager->success.blue = 0.0;
}
@@ -344,9 +368,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
/* set the invisible window and take a reference */
manager->invisible = GTK_WIDGET (g_object_ref (G_OBJECT (invisible)));
- /* set the visial property for transparent tray icons */
+ /* set the visual property for transparent tray icons */
systray_manager_set_visual (manager);
+ /* set the property for symbolic color support */
+ systray_manager_set_colors_property (manager);
+
/* get the current x server time stamp */
timestamp = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (invisible)));
@@ -794,6 +821,63 @@ systray_manager_set_visual (SystrayManager *manager)
void
+systray_manager_set_colors (SystrayManager *manager,
+ GdkColor *fg,
+ GdkColor *error,
+ GdkColor *warning,
+ GdkColor *success)
+{
+ panel_return_if_fail (XFCE_IS_SYSTRAY_MANAGER (manager));
+
+ manager->fg = *fg;
+ manager->error = *error;
+ manager->warning = *warning;
+ manager->success = *success;
+
+ systray_manager_set_colors_property (manager);
+}
+
+
+
+static void
+systray_manager_set_colors_property (SystrayManager *manager)
+{
+ GdkWindow *window;
+ GdkDisplay *display;
+ Atom atom;
+ gulong data[12];
+
+ g_return_if_fail (manager->invisible != NULL);
+ window = gtk_widget_get_window (manager->invisible);
+ g_return_if_fail (window != NULL);
+
+ display = gtk_widget_get_display (manager->invisible);
+ atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_SYSTEM_TRAY_COLORS");
+
+ data[0] = manager->fg.red;
+ data[1] = manager->fg.green;
+ data[2] = manager->fg.blue;
+ data[3] = manager->error.red;
+ data[4] = manager->error.green;
+ data[5] = manager->error.blue;
+ data[6] = manager->warning.red;
+ data[7] = manager->warning.green;
+ data[8] = manager->warning.blue;
+ data[9] = manager->success.red;
+ data[10] = manager->success.green;
+ data[11] = manager->success.blue;
+
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XID (window),
+ atom,
+ XA_CARDINAL, 32,
+ PropModeReplace,
+ (guchar *) &data, 12);
+}
+
+
+
+void
systray_manager_set_orientation (SystrayManager *manager,
GtkOrientation orientation)
{
diff --git a/plugins/systray/systray-manager.h b/plugins/systray/systray-manager.h
index f3d6919..0b1024c 100644
--- a/plugins/systray/systray-manager.h
+++ b/plugins/systray/systray-manager.h
@@ -64,6 +64,12 @@ gboolean systray_manager_register (SystrayManager *manag
void systray_manager_unregister (SystrayManager *manager);
+void systray_manager_set_colors (SystrayManager *manager,
+ GdkColor *fg,
+ GdkColor *error,
+ GdkColor *warning,
+ GdkColor *success);
+
void systray_manager_set_orientation (SystrayManager *manager,
GtkOrientation orientation);
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index fbeba04..4e8297d 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -21,6 +21,10 @@
#include <config.h>
#endif
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+
#include <libxfce4util/libxfce4util.h>
#include <libxfce4ui/libxfce4ui.h>
#include <common/panel-private.h>
@@ -34,7 +38,6 @@
#include "systray-manager.h"
#include "systray-dialog_ui.h"
-#define ICON_SIZE (22)
#define BUTTON_SIZE (16)
@@ -508,12 +511,39 @@ systray_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
{
SystrayPlugin *plugin = XFCE_SYSTRAY_PLUGIN (panel_plugin);
+
gtk_orientable_set_orientation (GTK_ORIENTABLE (plugin->hvbox), orientation);
systray_box_set_orientation (XFCE_SYSTRAY_BOX (plugin->box), orientation);
if (G_LIKELY (plugin->manager != NULL))
systray_manager_set_orientation (plugin->manager, orientation);
+ /* apply symbolic colors */
+ if (G_LIKELY (plugin->manager != NULL)) {
+ GtkStyleContext *context;
+ GdkRGBA rgba;
+ GdkColor color;
+ GdkColor fg;
+ GdkColor error;
+ GdkColor warning;
+ GdkColor success;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (plugin->box));
+ gtk_style_context_get_color (context, GTK_STATE_NORMAL, &rgba);
+
+ color.pixel = 0;
+ color.red = rgba.red * G_MAXUSHORT;
+ color.green = rgba.green * G_MAXUSHORT;
+ color.blue = rgba.blue * G_MAXUSHORT;
+
+ g_warning ("setting the symbolic color to: %d %d %d", color.red, color.green, color.blue);
+
+ fg = error = warning = success = color;
+
+ systray_manager_set_colors (plugin->manager, &fg, &error, &warning, &success);
+ }
+
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_set_size_request (plugin->button, BUTTON_SIZE, -1);
else
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list