x11: Add gdk_x11_window_set_utf8_property

A convenience function to manipulate UTF-8 X11 properties; no point
in wrapping each one in individual setters.
This commit is contained in:
Colin Walters 2011-11-25 17:21:05 -05:00 committed by Ryan Lortie
parent 5705a330c2
commit ff38dda9a8
3 changed files with 42 additions and 19 deletions

View File

@ -582,6 +582,7 @@ gdk_x11_window_move_to_current_desktop
gdk_x11_window_set_theme_variant gdk_x11_window_set_theme_variant
gdk_x11_window_set_hide_titlebar_when_maximized gdk_x11_window_set_hide_titlebar_when_maximized
gdk_x11_window_set_user_time gdk_x11_window_set_user_time
gdk_x11_window_set_utf8_property
gdk_x11_xatom_to_atom gdk_x11_xatom_to_atom
gdk_x11_xatom_to_atom_for_display gdk_x11_xatom_to_atom_for_display
#endif #endif

View File

@ -3087,25 +3087,19 @@ gdk_x11_window_set_user_time (GdkWindow *window,
} }
/** /**
* gdk_x11_window_set_theme_variant: * gdk_x11_window_set_utf8_property:
* @window: (type GdkX11Window): a #GdkWindow * @window: (type GdkX11Window): a #GdkWindow
* @variant: the theme variant to export * @name: Property name, will be interned as an X atom
* @value: (allow-none): Property value, or %NULL to delete
* *
* GTK+ applications can request a dark theme variant. In order to * This function modifies or removes an arbitrary X11 window
* make other applications - namely window managers using GTK+ for * property of type UTF8_STRING. If the given @window is
* themeing - aware of this choice, GTK+ uses this function to * not a toplevel window, it is ignored.
* export the requested theme variant as _GTK_THEME_VARIANT property
* on toplevel windows.
*
* Note that this property is automatically updated by GTK+, so this
* function should only be used by applications which do not use GTK+
* to create toplevel windows.
*
* Since: 3.2
*/ */
void void
gdk_x11_window_set_theme_variant (GdkWindow *window, gdk_x11_window_set_utf8_property (GdkWindow *window,
char *variant) const gchar *name,
const gchar *value)
{ {
GdkDisplay *display; GdkDisplay *display;
@ -3114,19 +3108,19 @@ gdk_x11_window_set_theme_variant (GdkWindow *window,
display = gdk_window_get_display (window); display = gdk_window_get_display (window);
if (variant != NULL) if (value != NULL)
{ {
XChangeProperty (GDK_DISPLAY_XDISPLAY (display), XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_GTK_THEME_VARIANT"), gdk_x11_get_xatom_by_name_for_display (display, name),
gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8, gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,
PropModeReplace, (guchar *)variant, strlen (variant)); PropModeReplace, (guchar *)value, strlen (value));
} }
else else
{ {
XDeleteProperty (GDK_DISPLAY_XDISPLAY (display), XDeleteProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "_GTK_THEME_VARIANT")); gdk_x11_get_xatom_by_name_for_display (display, name));
} }
} }
@ -3173,6 +3167,30 @@ gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
} }
} }
/**
* gdk_x11_window_set_theme_variant:
* @window: (type GdkX11Window): a #GdkWindow
* @variant: the theme variant to export
*
* GTK+ applications can request a dark theme variant. In order to
* make other applications - namely window managers using GTK+ for
* themeing - aware of this choice, GTK+ uses this function to
* export the requested theme variant as _GTK_THEME_VARIANT property
* on toplevel windows.
*
* Note that this property is automatically updated by GTK+, so this
* function should only be used by applications which do not use GTK+
* to create toplevel windows.
*
* Since: 3.2
*/
void
gdk_x11_window_set_theme_variant (GdkWindow *window,
char *variant)
{
return gdk_x11_window_set_utf8_property (window, "_GTK_THEME_VARIANT", variant);
}
#define GDK_SELECTION_MAX_SIZE(display) \ #define GDK_SELECTION_MAX_SIZE(display) \
MIN(262144, \ MIN(262144, \
XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \ XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \

View File

@ -158,6 +158,10 @@ GType gdk_window_impl_x11_get_type (void);
void gdk_x11_window_set_user_time (GdkWindow *window, void gdk_x11_window_set_user_time (GdkWindow *window,
guint32 timestamp); guint32 timestamp);
void gdk_x11_window_set_utf8_property (GdkWindow *window,
const gchar *name,
const gchar *value);
GdkToplevelX11 *_gdk_x11_window_get_toplevel (GdkWindow *window); GdkToplevelX11 *_gdk_x11_window_get_toplevel (GdkWindow *window);
void _gdk_x11_window_tmp_unset_bg (GdkWindow *window, void _gdk_x11_window_tmp_unset_bg (GdkWindow *window,
gboolean recurse); gboolean recurse);