X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gdk%2Fgdkselection.c;h=b8f1c9ff60962cd9e80c47a9f09aa98ac16d3a86;hb=2a8d32a760f90646be84c50172841388e3c4f5fe;hp=6bd4251100ee786be8804904c42433d202698779;hpb=9508b76bd2401b6b9e289b5c8ec9fc0e08909283;p=~andy%2Fgtk diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c index 6bd425110..b8f1c9ff6 100644 --- a/gdk/gdkselection.c +++ b/gdk/gdkselection.c @@ -20,6 +20,7 @@ #include #include "gdk.h" #include "gdkprivate.h" +#include "gdkx.h" gint @@ -28,13 +29,17 @@ gdk_selection_owner_set (GdkWindow *owner, guint32 time, gint send_event) { - GdkWindowPrivate *private; Display *xdisplay; Window xwindow; if (owner) { + GdkWindowPrivate *private; + private = (GdkWindowPrivate*) owner; + if (private->destroyed) + return FALSE; + xdisplay = private->xdisplay; xwindow = private->xwindow; } @@ -72,6 +77,8 @@ gdk_selection_convert (GdkWindow *requestor, g_return_if_fail (requestor != NULL); private = (GdkWindowPrivate*) requestor; + if (private->destroyed) + return; XConvertSelection (private->xdisplay, selection, target, gdk_selection_property, private->xwindow, time); @@ -98,6 +105,8 @@ gdk_selection_property_get (GdkWindow *requestor, moderate length, to avoid two round trips to the server */ private = (GdkWindowPrivate*) requestor; + if (private->destroyed) + return 0; XGetWindowProperty (private->xdisplay, private->xwindow, gdk_selection_property, 0, 0, False, @@ -166,3 +175,71 @@ gdk_selection_send_notify (guint32 requestor, XSendEvent (gdk_display, requestor, False, NoEventMask, (XEvent*) &xevent); } + +gint +gdk_text_property_to_text_list (GdkAtom encoding, gint format, + guchar *text, gint length, + gchar ***list) +{ + XTextProperty property; + gint count = 0; + gint res; + + if (!list) + return 0; + + property.value = text; + property.encoding = encoding; + property.format = format; + property.nitems = length; + res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count); + + if (res == XNoMemory || res == XLocaleNotSupported || + res == XConverterNotFound) + return 0; + else + return count; +} + +void +gdk_free_text_list (gchar **list) +{ + XFreeStringList (list); +} + +gint +gdk_string_to_compound_text (gchar *str, + GdkAtom *encoding, gint *format, + guchar **ctext, gint *length) +{ + gint res; + XTextProperty property; + + res = XmbTextListToTextProperty (GDK_DISPLAY(), + &str, 1, XCompoundTextStyle, + &property); + if (res != Success) + { + property.encoding = None; + property.format = None; + property.value = NULL; + property.nitems = 0; + } + + if (encoding) + *encoding = property.encoding; + if (format) + *format = property.format; + if (ctext) + *ctext = property.value; + if (length) + *length = property.nitems; + + return res; +} + +void gdk_free_compound_text (guchar *ctext) +{ + if (ctext) + XFree (ctext); +}