summaryrefslogtreecommitdiff
path: root/applets
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
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')
-rw-r--r--applets/notification_area/main.c13
-rw-r--r--applets/notification_area/na-tray-manager.c182
-rw-r--r--applets/notification_area/na-tray-manager.h26
-rw-r--r--applets/notification_area/na-tray.h17
4 files changed, 214 insertions, 24 deletions
diff --git a/applets/notification_area/main.c b/applets/notification_area/main.c
index 01f7f066..68f9600f 100644
--- a/applets/notification_area/main.c
+++ b/applets/notification_area/main.c
@@ -123,6 +123,7 @@ na_tray_applet_style_updated (GtkWidget *widget)
GdkColor warning;
GdkColor success;
gint padding;
+ gint icon_size;
GTK_WIDGET_CLASS (na_tray_applet_parent_class)->style_updated (widget);
@@ -146,8 +147,10 @@ na_tray_applet_style_updated (GtkWidget *widget)
na_tray_set_colors (applet->priv->tray, &fg, &error, &warning, &success);
gtk_widget_style_get (widget, "icon-padding", &padding, NULL);
-
na_tray_set_padding (applet->priv->tray, padding);
+
+ gtk_widget_style_get (widget, "icon-size", &icon_size, NULL);
+ na_tray_set_icon_size (applet->priv->tray, icon_size);
}
static void
@@ -225,6 +228,14 @@ na_tray_applet_class_init (NaTrayAppletClass *class)
0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ gtk_widget_class_install_style_property (
+ widget_class,
+ g_param_spec_int ("icon-size",
+ "Icon size",
+ "If non-zero, hardcodes the size of the icons in pixels",
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
g_type_class_add_private (class, sizeof (NaTrayAppletPrivate));
}
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)
{
diff --git a/applets/notification_area/na-tray-manager.h b/applets/notification_area/na-tray-manager.h
index e98c4848..a461510b 100644
--- a/applets/notification_area/na-tray-manager.h
+++ b/applets/notification_area/na-tray-manager.h
@@ -31,9 +31,7 @@
#include "na-tray-child.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+G_BEGIN_DECLS
#define NA_TYPE_TRAY_MANAGER (na_tray_manager_get_type ())
#define NA_TRAY_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NA_TYPE_TRAY_MANAGER, NaTrayManager))
@@ -60,6 +58,12 @@ struct _NaTrayManager
GtkWidget *invisible;
GdkScreen *screen;
GtkOrientation orientation;
+ gint padding;
+ gint icon_size;
+ GdkColor fg;
+ GdkColor error;
+ GdkColor warning;
+ GdkColor success;
GList *messages;
GHashTable *socket_table;
@@ -96,9 +100,17 @@ gboolean na_tray_manager_manage_screen (NaTrayManager *manager,
void na_tray_manager_set_orientation (NaTrayManager *manager,
GtkOrientation orientation);
GtkOrientation na_tray_manager_get_orientation (NaTrayManager *manager);
-
-#ifdef __cplusplus
-}
-#endif
+void na_tray_manager_set_padding (NaTrayManager *manager,
+ gint padding);
+void na_tray_manager_set_icon_size (NaTrayManager *manager,
+ gint padding);
+void na_tray_manager_set_colors (NaTrayManager *manager,
+ GdkColor *fg,
+ GdkColor *error,
+ GdkColor *warning,
+ GdkColor *success);
+
+
+G_END_DECLS
#endif /* __NA_TRAY_MANAGER_H__ */
diff --git a/applets/notification_area/na-tray.h b/applets/notification_area/na-tray.h
index 2b642d4a..3e69ce6d 100644
--- a/applets/notification_area/na-tray.h
+++ b/applets/notification_area/na-tray.h
@@ -29,9 +29,7 @@
#endif
#include <gtk/gtk.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+G_BEGIN_DECLS
#define NA_TYPE_TRAY (na_tray_get_type ())
#define NA_TRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NA_TYPE_TRAY, NaTray))
@@ -62,10 +60,17 @@ NaTray *na_tray_new_for_screen (GdkScreen *screen,
void na_tray_set_orientation (NaTray *tray,
GtkOrientation orientation);
GtkOrientation na_tray_get_orientation (NaTray *tray);
+void na_tray_set_padding (NaTray *tray,
+ gint padding);
+void na_tray_set_icon_size (NaTray *tray,
+ gint icon_size);
+void na_tray_set_colors (NaTray *tray,
+ GdkColor *fg,
+ GdkColor *error,
+ GdkColor *warning,
+ GdkColor *success);
void na_tray_force_redraw (NaTray *tray);
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
#endif /* __NA_TRAY_H__ */