summaryrefslogtreecommitdiff
path: root/gtk/gtkstatusicon.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-04-28 23:00:37 -0400
committerMatthias Clasen <mclasen@redhat.com>2010-04-29 17:01:25 -0400
commit556531b16f10f6d04cd541c064cfbcba23937355 (patch)
tree7dc5b1d2dfa5ca26d08ae4c434042c9b57877bbe /gtk/gtkstatusicon.c
parent13352755481200ae784b3d3cf6f9151cc36f2bbe (diff)
downloadgtk+-556531b16f10f6d04cd541c064cfbcba23937355.tar.gz
Get symbolic colors for statusicons from systray
Uses the X property _NET_SYSTEM_TRAY_COLORS.
Diffstat (limited to 'gtk/gtkstatusicon.c')
-rw-r--r--gtk/gtkstatusicon.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c
index dab6ff65e5..146b8f09c9 100644
--- a/gtk/gtkstatusicon.c
+++ b/gtk/gtkstatusicon.c
@@ -170,6 +170,10 @@ static void gtk_status_icon_screen_changed (GtkStatusIcon *status_icon,
GdkScreen *old_screen);
static void gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon);
static void gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon);
+static void gtk_status_icon_fg_changed (GtkStatusIcon *status_icon);
+static void gtk_status_icon_color_changed (GtkTrayIcon *tray,
+ GParamSpec *pspec,
+ GtkStatusIcon *status_icon);
static gboolean gtk_status_icon_scroll (GtkStatusIcon *status_icon,
GdkEventScroll *event);
static gboolean gtk_status_icon_query_tooltip (GtkStatusIcon *status_icon,
@@ -827,7 +831,7 @@ gtk_status_icon_init (GtkStatusIcon *status_icon)
priv = G_TYPE_INSTANCE_GET_PRIVATE (status_icon, GTK_TYPE_STATUS_ICON,
GtkStatusIconPrivate);
status_icon->priv = priv;
-
+
priv->storage_type = GTK_IMAGE_EMPTY;
priv->visible = TRUE;
@@ -850,6 +854,14 @@ gtk_status_icon_init (GtkStatusIcon *status_icon)
G_CALLBACK (gtk_status_icon_embedded_changed), status_icon);
g_signal_connect_swapped (priv->tray_icon, "notify::orientation",
G_CALLBACK (gtk_status_icon_orientation_changed), status_icon);
+ g_signal_connect_swapped (priv->tray_icon, "notify::fg-color",
+ G_CALLBACK (gtk_status_icon_fg_changed), status_icon);
+ g_signal_connect (priv->tray_icon, "notify::error-color",
+ G_CALLBACK (gtk_status_icon_color_changed), status_icon);
+ g_signal_connect (priv->tray_icon, "notify::warning-color",
+ G_CALLBACK (gtk_status_icon_color_changed), status_icon);
+ g_signal_connect (priv->tray_icon, "notify::success-color",
+ G_CALLBACK (gtk_status_icon_color_changed), status_icon);
g_signal_connect_swapped (priv->tray_icon, "button-press-event",
G_CALLBACK (gtk_status_icon_button_press), status_icon);
g_signal_connect_swapped (priv->tray_icon, "button-release-event",
@@ -975,6 +987,10 @@ gtk_status_icon_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (priv->tray_icon,
gtk_status_icon_orientation_changed, status_icon);
g_signal_handlers_disconnect_by_func (priv->tray_icon,
+ gtk_status_icon_fg_changed, status_icon);
+ g_signal_handlers_disconnect_by_func (priv->tray_icon,
+ gtk_status_icon_color_changed, status_icon);
+ g_signal_handlers_disconnect_by_func (priv->tray_icon,
gtk_status_icon_button_press, status_icon);
g_signal_handlers_disconnect_by_func (priv->tray_icon,
gtk_status_icon_button_release, status_icon);
@@ -1690,6 +1706,48 @@ gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon)
g_object_notify (G_OBJECT (status_icon), "orientation");
}
+static void
+gtk_status_icon_fg_changed (GtkStatusIcon *status_icon)
+{
+ GtkStatusIconPrivate *priv = status_icon->priv;
+ GdkColor color;
+
+ g_object_get (priv->tray_icon, "fg-color", &color, NULL);
+ gtk_widget_modify_fg (priv->image, GTK_STATE_NORMAL, &color);
+}
+
+static void
+gtk_status_icon_color_changed (GtkTrayIcon *tray,
+ GParamSpec *pspec,
+ GtkStatusIcon *status_icon)
+{
+ GtkStatusIconPrivate *priv = status_icon->priv;
+ const gchar *name;
+ GdkColor color;
+
+ switch (pspec->name[0])
+ {
+ case 'e':
+ name = "error";
+ break;
+ case 'w':
+ name = "warning";
+ break;
+ case 's':
+ name = "success";
+ break;
+ default:
+ name = NULL;
+ break;
+ }
+
+ if (name)
+ {
+ g_object_get (priv->tray_icon, pspec->name, &color, NULL);
+ gtk_widget_modify_symbolic_color (priv->image, name, &color);
+ }
+}
+
static gboolean
gtk_status_icon_key_press (GtkStatusIcon *status_icon,
GdkEventKey *event)