1999-11-11 22:12:27 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-11-11 22:12:27 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1999-11-11 22:12:27 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-11-11 22:12:27 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-11-11 22:12:27 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
#include "gdkproperty.h"
|
|
|
|
#include "gdkselection.h"
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
#include "gdkprivate.h"
|
|
|
|
#include "gdkprivate-win32.h"
|
2000-07-25 17:31:05 +00:00
|
|
|
#include "gdkwindow-win32.h"
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
/* We emulate the GDK_SELECTION window properties by storing
|
|
|
|
* it's data in a per-window hashtable.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
guchar *data;
|
|
|
|
gint length;
|
|
|
|
gint format;
|
|
|
|
GdkAtom type;
|
|
|
|
} GdkSelProp;
|
|
|
|
|
|
|
|
static GHashTable *sel_prop_table = NULL;
|
|
|
|
|
|
|
|
void
|
1999-11-20 01:22:57 +00:00
|
|
|
gdk_win32_selection_init (void)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
|
|
|
if (sel_prop_table == NULL)
|
|
|
|
sel_prop_table = g_hash_table_new (g_int_hash, g_int_equal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_sel_prop_store (GdkWindow *owner,
|
|
|
|
GdkAtom type,
|
|
|
|
gint format,
|
|
|
|
guchar *data,
|
|
|
|
gint length)
|
|
|
|
{
|
|
|
|
GdkSelProp *prop;
|
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
prop = g_hash_table_lookup (sel_prop_table, &GDK_WINDOW_HWND (owner));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (prop != NULL)
|
|
|
|
{
|
|
|
|
g_free (prop->data);
|
2000-07-25 17:31:05 +00:00
|
|
|
g_hash_table_remove (sel_prop_table, &GDK_WINDOW_HWND (owner));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
prop = g_new (GdkSelProp, 1);
|
|
|
|
prop->data = data;
|
|
|
|
prop->length = length;
|
|
|
|
prop->format = format;
|
|
|
|
prop->type = type;
|
2000-07-25 17:31:05 +00:00
|
|
|
g_hash_table_insert (sel_prop_table, &GDK_WINDOW_HWND (owner), prop);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
gboolean
|
1999-11-11 22:12:27 +00:00
|
|
|
gdk_selection_owner_set (GdkWindow *owner,
|
|
|
|
GdkAtom selection,
|
|
|
|
guint32 time,
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
gboolean send_event)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
|
|
|
gchar *sel_name;
|
|
|
|
HWND xwindow;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
(sel_name = gdk_atom_name (selection),
|
|
|
|
g_print ("gdk_selection_owner_set: %#x %#x (%s)\n",
|
2000-10-03 21:00:49 +00:00
|
|
|
(owner ? (guint) GDK_WINDOW_HWND (owner) : 0),
|
|
|
|
(guint) selection, sel_name),
|
1999-11-11 22:12:27 +00:00
|
|
|
g_free (sel_name)));
|
|
|
|
|
|
|
|
if (selection != gdk_clipboard_atom)
|
2001-08-19 18:34:59 +00:00
|
|
|
{
|
|
|
|
if (!owner)
|
|
|
|
return FALSE;
|
|
|
|
gdk_sel_prop_store (owner, selection, 0, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
if (owner != NULL)
|
2000-11-12 15:46:55 +00:00
|
|
|
{
|
|
|
|
if (GDK_WINDOW_DESTROYED (owner))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
xwindow = GDK_WINDOW_HWND (owner);
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
else
|
|
|
|
xwindow = NULL;
|
|
|
|
|
2000-10-03 21:00:49 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n", (guint) xwindow));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (!OpenClipboard (xwindow))
|
|
|
|
{
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("OpenClipboard");
|
1999-11-11 22:12:27 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...EmptyClipboard()\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (!EmptyClipboard ())
|
|
|
|
{
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("EmptyClipboard");
|
1999-11-11 22:12:27 +00:00
|
|
|
CloseClipboard ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
/* No delayed rendering */
|
|
|
|
if (xwindow != NULL)
|
|
|
|
SetClipboardData (CF_TEXT, NULL);
|
|
|
|
#endif
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...CloseClipboard()\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (!CloseClipboard ())
|
|
|
|
{
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("CloseClipboard");
|
1999-11-11 22:12:27 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (owner != NULL)
|
|
|
|
{
|
|
|
|
/* Send ourselves an ersatz selection request message so that
|
|
|
|
* gdk_property_change will be called to store the clipboard data.
|
|
|
|
*/
|
|
|
|
SendMessage (xwindow, gdk_selection_request_msg,
|
|
|
|
selection, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
/* callback for g_hash_table_for_each */
|
|
|
|
typedef struct {
|
|
|
|
GdkAtom atom;
|
|
|
|
GdkNativeWindow hwnd;
|
|
|
|
} SelectionAndHwnd;
|
|
|
|
|
|
|
|
static void
|
|
|
|
window_from_selection (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GdkSelProp *selprop = (GdkSelProp *)value;
|
|
|
|
SelectionAndHwnd *sah = (SelectionAndHwnd *) user_data;
|
|
|
|
|
|
|
|
if (selprop->type == sah->atom)
|
|
|
|
sah->hwnd = *(GdkNativeWindow*) key;
|
|
|
|
}
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
GdkWindow*
|
|
|
|
gdk_selection_owner_get (GdkAtom selection)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
|
|
|
gchar *sel_name;
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
#if 0
|
1999-11-11 22:12:27 +00:00
|
|
|
/* XXX Hmm, gtk selections seem to work best with this. This causes
|
|
|
|
* gtk to always get the clipboard contents from Windows, and not
|
|
|
|
* from the editable's own stashed-away copy.
|
|
|
|
*/
|
|
|
|
return NULL;
|
|
|
|
#else
|
2001-08-19 18:34:59 +00:00
|
|
|
/* HB: The above is no longer true with recent changes to get
|
|
|
|
* inter-app drag&drop working ...
|
|
|
|
*/
|
1999-11-11 22:12:27 +00:00
|
|
|
if (selection != gdk_clipboard_atom)
|
2001-08-19 18:34:59 +00:00
|
|
|
{
|
|
|
|
SelectionAndHwnd sah;
|
|
|
|
sah.atom = selection;
|
|
|
|
sah.hwnd = 0;
|
|
|
|
|
|
|
|
g_hash_table_foreach (sel_prop_table, window_from_selection, &sah);
|
|
|
|
|
|
|
|
window = gdk_win32_handle_table_lookup (sah.hwnd);
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
else
|
2001-08-19 18:34:59 +00:00
|
|
|
window = gdk_win32_handle_table_lookup ((GdkNativeWindow) GetClipboardOwner ());
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
(sel_name = gdk_atom_name (selection),
|
|
|
|
g_print ("gdk_selection_owner_get: %#x (%s) = %#x\n",
|
2000-10-03 21:00:49 +00:00
|
|
|
(guint) selection, sel_name,
|
|
|
|
(window ? (guint) GDK_WINDOW_HWND (window) : 0)),
|
1999-11-11 22:12:27 +00:00
|
|
|
g_free (sel_name)));
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_selection_convert (GdkWindow *requestor,
|
|
|
|
GdkAtom selection,
|
|
|
|
GdkAtom target,
|
|
|
|
guint32 time)
|
|
|
|
{
|
|
|
|
HGLOBAL hdata;
|
|
|
|
guchar *ptr, *data, *datap, *p;
|
|
|
|
guint i, length, slength;
|
|
|
|
gchar *sel_name, *tgt_name;
|
|
|
|
|
|
|
|
g_return_if_fail (requestor != NULL);
|
2000-07-25 17:31:05 +00:00
|
|
|
if (GDK_WINDOW_DESTROYED (requestor))
|
1999-11-11 22:12:27 +00:00
|
|
|
return;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
(sel_name = gdk_atom_name (selection),
|
|
|
|
tgt_name = gdk_atom_name (target),
|
|
|
|
g_print ("gdk_selection_convert: %#x %#x (%s) %#x (%s)\n",
|
2000-10-03 21:00:49 +00:00
|
|
|
(guint) GDK_WINDOW_HWND (requestor),
|
|
|
|
(guint) selection, sel_name,
|
|
|
|
(guint) target, tgt_name),
|
1999-11-11 22:12:27 +00:00
|
|
|
g_free (sel_name),
|
|
|
|
g_free (tgt_name)));
|
|
|
|
|
|
|
|
if (selection == gdk_clipboard_atom)
|
|
|
|
{
|
|
|
|
/* Converting the CLIPBOARD selection means he wants the
|
|
|
|
* contents of the clipboard. Get the clipboard data,
|
|
|
|
* and store it for later.
|
|
|
|
*/
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n",
|
2000-10-03 21:00:49 +00:00
|
|
|
(guint) GDK_WINDOW_HWND (requestor)));
|
2000-07-25 17:31:05 +00:00
|
|
|
if (!OpenClipboard (GDK_WINDOW_HWND (requestor)))
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
2000-02-13 14:52:47 +00:00
|
|
|
WIN32_API_FAILED ("OpenClipboard");
|
1999-11-11 22:12:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...GetClipboardData(CF_TEXT)\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
if ((hdata = GetClipboardData (CF_TEXT)) != NULL)
|
|
|
|
{
|
|
|
|
if ((ptr = GlobalLock (hdata)) != NULL)
|
|
|
|
{
|
|
|
|
length = GlobalSize (hdata);
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...got data: %d bytes: %.10s\n",
|
|
|
|
length, ptr));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
slength = 0;
|
|
|
|
p = ptr;
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
if (*p == '\0')
|
|
|
|
break;
|
|
|
|
else if (*p != '\r')
|
|
|
|
slength++;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = datap = g_malloc (slength + 1);
|
|
|
|
p = ptr;
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
if (*p == '\0')
|
|
|
|
break;
|
|
|
|
else if (*p != '\r')
|
|
|
|
*datap++ = *p;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
*datap++ = '\0';
|
|
|
|
gdk_sel_prop_store (requestor, GDK_TARGET_STRING, 8,
|
|
|
|
data, strlen (data) + 1);
|
|
|
|
|
|
|
|
GlobalUnlock (hdata);
|
|
|
|
}
|
|
|
|
}
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...CloseClipboard()\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
CloseClipboard ();
|
|
|
|
|
|
|
|
|
|
|
|
/* Send ourselves an ersatz selection notify message so that we actually
|
|
|
|
* fetch the data.
|
|
|
|
*/
|
2000-07-25 17:31:05 +00:00
|
|
|
SendMessage (GDK_WINDOW_HWND (requestor), gdk_selection_notify_msg, selection, target);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
else if (selection == gdk_win32_dropfiles_atom)
|
|
|
|
{
|
|
|
|
/* This means he wants the names of the dropped files.
|
|
|
|
* gdk_dropfiles_filter already has stored the text/uri-list
|
|
|
|
* data, tempoarily on gdk_root_parent's selection "property".
|
|
|
|
*/
|
|
|
|
GdkSelProp *prop;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
prop = g_hash_table_lookup (sel_prop_table,
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
&GDK_WINDOW_HWND (_gdk_parent_root));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
if (prop != NULL)
|
|
|
|
{
|
1999-11-20 01:22:57 +00:00
|
|
|
g_hash_table_remove (sel_prop_table,
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
&GDK_WINDOW_HWND (_gdk_parent_root));
|
1999-11-11 22:12:27 +00:00
|
|
|
gdk_sel_prop_store (requestor, prop->type, prop->format,
|
|
|
|
prop->data, prop->length);
|
|
|
|
g_free (prop);
|
2000-07-25 17:31:05 +00:00
|
|
|
SendMessage (GDK_WINDOW_HWND (requestor), gdk_selection_notify_msg, selection, target);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("gdk_selection_convert: General case not implemented");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_selection_property_get (GdkWindow *requestor,
|
|
|
|
guchar **data,
|
|
|
|
GdkAtom *ret_type,
|
|
|
|
gint *ret_format)
|
|
|
|
{
|
|
|
|
GdkSelProp *prop;
|
|
|
|
|
|
|
|
g_return_val_if_fail (requestor != NULL, 0);
|
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
|
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
if (GDK_WINDOW_DESTROYED (requestor))
|
1999-11-11 22:12:27 +00:00
|
|
|
return 0;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_selection_property_get: %#x\n",
|
2000-10-03 21:00:49 +00:00
|
|
|
(guint) GDK_WINDOW_HWND (requestor)));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
prop = g_hash_table_lookup (sel_prop_table, &GDK_WINDOW_HWND (requestor));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
if (prop == NULL)
|
|
|
|
{
|
|
|
|
*data = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*data = g_malloc (prop->length);
|
|
|
|
if (prop->length > 0)
|
|
|
|
memmove (*data, prop->data, prop->length);
|
|
|
|
if (ret_type)
|
|
|
|
*ret_type = prop->type;
|
|
|
|
if (ret_format)
|
|
|
|
*ret_format = prop->format;
|
|
|
|
|
|
|
|
return prop->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_selection_property_delete (GdkWindow *window)
|
|
|
|
{
|
|
|
|
GdkSelProp *prop;
|
|
|
|
|
2000-07-25 17:31:05 +00:00
|
|
|
prop = g_hash_table_lookup (sel_prop_table, &GDK_WINDOW_HWND (window));
|
1999-11-11 22:12:27 +00:00
|
|
|
if (prop != NULL)
|
|
|
|
{
|
|
|
|
g_free (prop->data);
|
2000-07-25 17:31:05 +00:00
|
|
|
g_hash_table_remove (sel_prop_table, &GDK_WINDOW_HWND (window));
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
g_warning ("huh?");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_selection_send_notify (guint32 requestor,
|
|
|
|
GdkAtom selection,
|
|
|
|
GdkAtom target,
|
|
|
|
GdkAtom property,
|
|
|
|
guint32 time)
|
|
|
|
{
|
|
|
|
gchar *sel_name, *tgt_name, *prop_name;
|
|
|
|
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
(sel_name = gdk_atom_name (selection),
|
|
|
|
tgt_name = gdk_atom_name (target),
|
|
|
|
prop_name = gdk_atom_name (property),
|
|
|
|
g_print ("gdk_selection_send_notify: %#x %#x (%s) %#x (%s) %#x (%s)\n",
|
|
|
|
requestor,
|
2000-10-03 21:00:49 +00:00
|
|
|
(guint) selection, sel_name,
|
|
|
|
(guint) target, tgt_name,
|
|
|
|
(guint) property, prop_name),
|
1999-11-11 22:12:27 +00:00
|
|
|
g_free (sel_name),
|
|
|
|
g_free (tgt_name),
|
|
|
|
g_free (prop_name)));
|
|
|
|
|
|
|
|
/* Send ourselves a selection clear message so that gtk thinks we don't
|
|
|
|
* have the selection, and will claim it anew when needed, and
|
|
|
|
* we thus get a chance to store data in the Windows clipboard.
|
|
|
|
* Otherwise, if a gtkeditable does a copy to clipboard several times
|
|
|
|
* only the first one actually gets copied to the Windows clipboard,
|
|
|
|
* as only he first one causes a call to gdk_property_change.
|
|
|
|
*
|
|
|
|
* Hmm, there is something fishy with this. Cut and paste inside the
|
|
|
|
* same app didn't work, the gtkeditable immediately forgot the
|
|
|
|
* clipboard contents in gtk_editable_selection_clear as a result of
|
|
|
|
* this message. OTOH, when I changed gdk_selection_owner_get to
|
|
|
|
* always return NULL, it works. Sigh.
|
|
|
|
*/
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
SendMessage ((HWND) requestor,
|
|
|
|
gdk_selection_clear_msg,
|
|
|
|
selection,
|
|
|
|
target);
|
1999-11-11 22:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2000-03-16 21:58:35 +00:00
|
|
|
gdk_text_property_to_text_list (GdkAtom encoding,
|
|
|
|
gint format,
|
|
|
|
const guchar *text,
|
|
|
|
gint length,
|
|
|
|
gchar ***list)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
1999-11-20 01:22:57 +00:00
|
|
|
GDK_NOTE (MISC,
|
1999-11-11 22:12:27 +00:00
|
|
|
g_print ("gdk_text_property_to_text_list not implemented\n"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_free_text_list (gchar **list)
|
|
|
|
{
|
|
|
|
g_return_if_fail (list != NULL);
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2000-03-16 21:58:35 +00:00
|
|
|
gdk_string_to_compound_text (const gchar *str,
|
|
|
|
GdkAtom *encoding,
|
|
|
|
gint *format,
|
|
|
|
guchar **ctext,
|
|
|
|
gint *length)
|
1999-11-11 22:12:27 +00:00
|
|
|
{
|
|
|
|
g_warning ("gdk_string_to_compound_text: Not implemented");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_free_compound_text (guchar *ctext)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_free_compound_text: Not implemented");
|
|
|
|
}
|
2000-10-03 21:00:49 +00:00
|
|
|
|
|
|
|
/* These are lifted from gdkselection-x11.c, just to get GTK+ to build.
|
|
|
|
* These functions probably don't make much sense at all in Windows.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
static gint
|
|
|
|
make_list (const gchar *text,
|
|
|
|
gint length,
|
|
|
|
gboolean latin1,
|
|
|
|
gchar ***list)
|
|
|
|
{
|
|
|
|
GSList *strings = NULL;
|
|
|
|
gint n_strings = 0;
|
|
|
|
gint i;
|
|
|
|
const gchar *p = text;
|
|
|
|
const gchar *q;
|
|
|
|
GSList *tmp_list;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
while (p < text + length)
|
|
|
|
{
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
q = p;
|
|
|
|
while (*q && q < text + length)
|
|
|
|
q++;
|
|
|
|
|
|
|
|
if (latin1)
|
|
|
|
{
|
|
|
|
str = g_convert (p, q - p,
|
|
|
|
"UTF-8", "ISO-8859-1",
|
|
|
|
NULL, NULL, &error);
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
{
|
|
|
|
g_warning ("Error converting selection from STRING: %s",
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
str = g_strndup (p, q - p);
|
|
|
|
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
strings = g_slist_prepend (strings, str);
|
|
|
|
n_strings++;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = q + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
*list = g_new (gchar *, n_strings + 1);
|
|
|
|
|
|
|
|
(*list)[n_strings] = NULL;
|
|
|
|
|
|
|
|
i = n_strings;
|
|
|
|
tmp_list = strings;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (list)
|
|
|
|
(*list)[--i] = tmp_list->data;
|
|
|
|
else
|
|
|
|
g_free (tmp_list->data);
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (strings);
|
|
|
|
|
|
|
|
return n_strings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_text_property_to_utf8_list:
|
|
|
|
* @encoding: an atom representing the encoding of the text
|
|
|
|
* @format: the format of the property
|
|
|
|
* @text: the text to convert
|
|
|
|
* @length: the length of @text, in bytes
|
|
|
|
* @list: location to store the list of strings or %NULL. The
|
|
|
|
* list should be freed with g_strfreev().
|
|
|
|
*
|
|
|
|
* Convert a text property in the giving encoding to
|
|
|
|
* a list of UTF-8 strings.
|
|
|
|
*
|
|
|
|
* Return value: the number of strings in the resulting
|
|
|
|
* list.
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gdk_text_property_to_utf8_list (GdkAtom encoding,
|
|
|
|
gint format,
|
|
|
|
const guchar *text,
|
|
|
|
gint length,
|
|
|
|
gchar ***list)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (text != NULL, 0);
|
|
|
|
g_return_val_if_fail (length >= 0, 0);
|
|
|
|
|
|
|
|
if (encoding == GDK_TARGET_STRING)
|
|
|
|
{
|
|
|
|
return make_list ((gchar *)text, length, TRUE, list);
|
|
|
|
}
|
|
|
|
else if (encoding == gdk_atom_intern ("UTF8_STRING", FALSE))
|
|
|
|
{
|
|
|
|
return make_list ((gchar *)text, length, FALSE, list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar **local_list;
|
|
|
|
gint local_count;
|
|
|
|
gint i;
|
|
|
|
gchar *charset = NULL;
|
|
|
|
gboolean need_conversion= g_get_charset (&charset);
|
|
|
|
gint count = 0;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
/* Probably COMPOUND text, we fall back to Xlib routines
|
|
|
|
*/
|
|
|
|
local_count = gdk_text_property_to_text_list (encoding,
|
|
|
|
format,
|
|
|
|
text,
|
|
|
|
length,
|
|
|
|
&local_list);
|
|
|
|
if (list)
|
|
|
|
*list = g_new (gchar *, local_count + 1);
|
|
|
|
|
|
|
|
for (i=0; i<local_count; i++)
|
|
|
|
{
|
|
|
|
/* list contains stuff in our default encoding
|
|
|
|
*/
|
|
|
|
if (need_conversion)
|
|
|
|
{
|
|
|
|
gchar *utf = g_convert (local_list[i], -1,
|
|
|
|
"UTF-8", charset,
|
|
|
|
NULL, NULL, &error);
|
|
|
|
if (utf)
|
|
|
|
{
|
|
|
|
if (list)
|
|
|
|
(*list)[count++] = utf;
|
|
|
|
else
|
|
|
|
g_free (utf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Error converting to UTF-8 from '%s': %s",
|
|
|
|
charset, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (list)
|
|
|
|
(*list)[count++] = g_strdup (local_list[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_free_text_list (local_list);
|
|
|
|
(*list)[count] = NULL;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The specifications for COMPOUND_TEXT and STRING specify that C0 and
|
|
|
|
* C1 are not allowed except for \n and \t, however the X conversions
|
|
|
|
* routines for COMPOUND_TEXT only enforce this in one direction,
|
|
|
|
* causing cut-and-paste of \r and \r\n separated text to fail.
|
|
|
|
* This routine strips out all non-allowed C0 and C1 characters
|
|
|
|
* from the input string and also canonicalizes \r, \r\n, and \n\r to \n
|
|
|
|
*/
|
|
|
|
static gchar *
|
|
|
|
sanitize_utf8 (const gchar *src)
|
|
|
|
{
|
|
|
|
gint len = strlen (src);
|
|
|
|
GString *result = g_string_sized_new (len);
|
|
|
|
const gchar *p = src;
|
|
|
|
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (*p == '\r' || *p == '\n')
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
if (*p == '\r' || *p == '\n')
|
|
|
|
p++;
|
|
|
|
|
|
|
|
g_string_append_c (result, '\n');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gunichar ch = g_utf8_get_char (p);
|
|
|
|
char buf[7];
|
|
|
|
gint buflen;
|
|
|
|
|
|
|
|
if (!((ch < 0x20 && ch != '\t') || (ch >= 0x7f && ch < 0xa0)))
|
|
|
|
{
|
|
|
|
buflen = g_unichar_to_utf8 (ch, buf);
|
|
|
|
g_string_append_len (result, buf, buflen);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = g_utf8_next_char (p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_string_free (result, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_utf8_to_string_target:
|
|
|
|
* @str: a UTF-8 string
|
|
|
|
*
|
|
|
|
* Convert an UTF-8 string into the best possible representation
|
|
|
|
* as a STRING. The representation of characters not in STRING
|
|
|
|
* is not specified; it may be as pseudo-escape sequences
|
|
|
|
* \x{ABCD}, or it may be in some other form of approximation.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated string, or %NULL if the
|
|
|
|
* conversion failed. (It should not fail for
|
|
|
|
* any properly formed UTF-8 string.)
|
|
|
|
**/
|
|
|
|
gchar *
|
|
|
|
gdk_utf8_to_string_target (const gchar *str)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
gchar *tmp_str = sanitize_utf8 (str);
|
|
|
|
gchar *result = g_convert_with_fallback (tmp_str, -1,
|
|
|
|
"ISO-8859-1", "UTF-8",
|
|
|
|
NULL, NULL, NULL, &error);
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
g_warning ("Error converting from UTF-8 to STRING: %s",
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (tmp_str);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_utf8_to_compound_text:
|
|
|
|
* @str: a UTF-8 string
|
|
|
|
* @encoding: location to store resulting encoding
|
|
|
|
* @format: location to store format of the result
|
|
|
|
* @ctext: location to store the data of the result
|
|
|
|
* @length: location to store the length of the data
|
|
|
|
* stored in @ctext
|
|
|
|
*
|
|
|
|
* Convert from UTF-8 to compound text.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the conversion succeeded, otherwise
|
|
|
|
* false.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gdk_utf8_to_compound_text (const gchar *str,
|
|
|
|
GdkAtom *encoding,
|
|
|
|
gint *format,
|
|
|
|
guchar **ctext,
|
|
|
|
gint *length)
|
|
|
|
{
|
|
|
|
gboolean need_conversion;
|
|
|
|
gchar *charset;
|
|
|
|
gchar *locale_str, *tmp_str;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (str != NULL, FALSE);
|
|
|
|
|
|
|
|
need_conversion = g_get_charset (&charset);
|
|
|
|
|
|
|
|
tmp_str = sanitize_utf8 (str);
|
|
|
|
|
|
|
|
if (need_conversion)
|
|
|
|
{
|
|
|
|
locale_str = g_convert_with_fallback (tmp_str, -1,
|
|
|
|
charset, "UTF-8",
|
|
|
|
NULL, NULL, NULL, &error);
|
|
|
|
g_free (tmp_str);
|
|
|
|
|
|
|
|
if (!locale_str)
|
|
|
|
{
|
|
|
|
g_warning ("Error converting from UTF-8 to '%s': %s",
|
|
|
|
charset, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
|
|
|
|
if (encoding)
|
|
|
|
*encoding = GDK_NONE;
|
|
|
|
if (format)
|
|
|
|
*format = GDK_NONE;
|
|
|
|
if (ctext)
|
|
|
|
*ctext = NULL;
|
|
|
|
if (length)
|
|
|
|
*length = 0;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
locale_str = tmp_str;
|
|
|
|
|
|
|
|
result = gdk_string_to_compound_text (locale_str,
|
|
|
|
encoding, format, ctext, length);
|
|
|
|
|
|
|
|
g_free (locale_str);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|