summaryrefslogtreecommitdiff
path: root/applets/notification_area/na-tray-manager.c
diff options
context:
space:
mode:
authorRyan Lortie <[email protected]>2011-03-29 23:41:17 +0530
committerinfirit <[email protected]>2015-07-14 13:08:19 +0200
commite9c7cb073d30e30aeac0a2e9fe3c21f1d0f49cd0 (patch)
treea03cf5f3b1cd91ce3042fba7c5f32f48c6cf2fea /applets/notification_area/na-tray-manager.c
parentbe334f90f603df90bee15d43f5f67a052fa07ff2 (diff)
downloadmate-panel-e9c7cb073d30e30aeac0a2e9fe3c21f1d0f49cd0.tar.bz2
mate-panel-e9c7cb073d30e30aeac0a2e9fe3c21f1d0f49cd0.tar.xz
notification applet: support fixed-sized icons
Add a new _NET_SYSTEM_TRAY_ICON_SIZE property that is set to the value of the "icon-size" style property. The result is that all icons in the tray will be hinted to draw themselves with exactly this pixel size (16x16, for example). Bug #645232 Conflicts: applets/notification_area/na-tray-manager.c applets/notification_area/na-tray-manager.h applets/notification_area/na-tray.h
Diffstat (limited to 'applets/notification_area/na-tray-manager.c')
-rw-r--r--applets/notification_area/na-tray-manager.c182
1 files changed, 172 insertions, 10 deletions
diff --git a/applets/notification_area/na-tray-manager.c b/applets/notification_area/na-tray-manager.c
index 45720d3a..df20e7a5 100644
--- a/applets/notification_area/na-tray-manager.c
+++ b/applets/notification_area/na-tray-manager.c
@@ -97,6 +97,25 @@ na_tray_manager_init (NaTrayManager *manager)
{
manager->invisible = NULL;
manager->socket_table = g_hash_table_new (NULL, NULL);
+
+ manager->padding = 0;
+ manager->icon_size = 0;
+
+ manager->fg.red = 0;
+ manager->fg.green = 0;
+ manager->fg.blue = 0;
+
+ manager->error.red = 0xffff;
+ manager->error.green = 0;
+ manager->error.blue = 0;
+
+ manager->warning.red = 0xffff;
+ manager->warning.green = 0xffff;
+ manager->warning.blue = 0;
+
+ manager->success.red = 0;
+ manager->success.green = 0xffff;
+ manager->success.blue = 0;
}
static void
@@ -414,8 +433,6 @@ na_tray_manager_handle_begin_message (NaTrayManager *manager,
}
}
-
-
if (len == 0)
{
g_signal_emit (manager, manager_signals[MESSAGE_SENT], 0,
@@ -631,11 +648,9 @@ na_tray_manager_set_orientation_property (NaTrayManager *manager)
Atom orientation_atom;
gulong data[1];
- if (!manager->invisible)
- return;
+ g_return_if_fail (manager->invisible != NULL);
window = gtk_widget_get_window (manager->invisible);
- if (!window)
- return;
+ g_return_if_fail (window != NULL);
display = gtk_widget_get_display (manager->invisible);
orientation_atom = gdk_x11_get_xatom_by_name_for_display (display,
@@ -664,11 +679,9 @@ na_tray_manager_set_visual_property (NaTrayManager *manager)
Atom visual_atom;
gulong data[1];
- if (!manager->invisible)
- return;
+ g_return_if_fail (manager->invisible != NULL);
window = gtk_widget_get_window (manager->invisible);
- if (!window)
- return;
+ g_return_if_fail (window != NULL);
/* The visual property is a hint to the tray icons as to what visual they
* should use for their windows. If the X server has RGBA colormaps, then
@@ -714,6 +727,101 @@ na_tray_manager_set_visual_property (NaTrayManager *manager)
#endif
}
+static void
+na_tray_manager_set_padding_property (NaTrayManager *manager)
+{
+#ifdef GDK_WINDOWING_X11
+ GdkWindow *window;
+ GdkDisplay *display;
+ Atom atom;
+ gulong data[1];
+
+ 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_PADDING");
+
+ data[0] = manager->padding;
+
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XID (window),
+ atom,
+ XA_CARDINAL, 32,
+ PropModeReplace,
+ (guchar *) &data, 1);
+#endif
+}
+
+static void
+na_tray_manager_set_icon_size_property (NaTrayManager *manager)
+{
+#ifdef GDK_WINDOWING_X11
+ GdkWindow *window;
+ GdkDisplay *display;
+ Atom atom;
+ gulong data[1];
+
+ 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_ICON_SIZE");
+
+ data[0] = manager->icon_size;
+
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XID (window),
+ atom,
+ XA_CARDINAL, 32,
+ PropModeReplace,
+ (guchar *) &data, 1);
+#endif
+}
+
+static void
+na_tray_manager_set_colors_property (NaTrayManager *manager)
+{
+#ifdef GDK_WINDOWING_X11
+ 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);
+#endif
+}
+
#ifdef GDK_WINDOWING_X11
static gboolean
@@ -759,6 +867,9 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
na_tray_manager_set_orientation_property (manager);
na_tray_manager_set_visual_property (manager);
+ na_tray_manager_set_padding_property (manager);
+ na_tray_manager_set_icon_size_property (manager);
+ na_tray_manager_set_colors_property (manager);
window = gtk_widget_get_window (invisible);
@@ -908,6 +1019,57 @@ na_tray_manager_set_orientation (NaTrayManager *manager,
}
}
+void
+na_tray_manager_set_padding (NaTrayManager *manager,
+ gint padding)
+{
+ g_return_if_fail (NA_IS_TRAY_MANAGER (manager));
+
+ if (manager->padding != padding)
+ {
+ manager->padding = padding;
+
+ na_tray_manager_set_padding_property (manager);
+ }
+}
+
+void
+na_tray_manager_set_icon_size (NaTrayManager *manager,
+ gint icon_size)
+{
+ g_return_if_fail (NA_IS_TRAY_MANAGER (manager));
+
+ if (manager->icon_size != icon_size)
+ {
+ manager->icon_size = icon_size;
+
+ na_tray_manager_set_icon_size_property (manager);
+ }
+}
+
+void
+na_tray_manager_set_colors (NaTrayManager *manager,
+ GdkColor *fg,
+ GdkColor *error,
+ GdkColor *warning,
+ GdkColor *success)
+{
+ g_return_if_fail (NA_IS_TRAY_MANAGER (manager));
+
+ if (!gdk_color_equal (&manager->fg, fg) ||
+ !gdk_color_equal (&manager->error, error) ||
+ !gdk_color_equal (&manager->warning, warning) ||
+ !gdk_color_equal (&manager->success, success))
+ {
+ manager->fg = *fg;
+ manager->error = *error;
+ manager->warning = *warning;
+ manager->success = *success;
+
+ na_tray_manager_set_colors_property (manager);
+ }
+}
+
GtkOrientation
na_tray_manager_get_orientation (NaTrayManager *manager)
{