]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkselection.c
- Use 'diff -ru' for patches - Explained patch application/rejection -
[~andy/gtk] / gdk / gdkselection.c
index 6bd4251100ee786be8804904c42433d202698779..b8f1c9ff60962cd9e80c47a9f09aa98ac16d3a86 100644 (file)
@@ -20,6 +20,7 @@
 #include <string.h>
 #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);
+}