summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2002-09-19 23:27:10 +0000
committerTor Lillqvist <tml@src.gnome.org>2002-09-19 23:27:10 +0000
commitd8a49627083b777ad66c5923ed3d634260b5dfcf (patch)
treed97eaa57ce65508a8ed799f7de0d5451ade643e2 /gdk
parent944334da7f0d71f4879362d80be91b4a58c1f416 (diff)
downloadgtk+-d8a49627083b777ad66c5923ed3d634260b5dfcf.tar.gz
Delete leftover declarations of the obsolete Win32-only functions
2002-09-20 Tor Lillqvist <tml@iki.fi> * gdk/gdkfont.h: Delete leftover declarations of the obsolete Win32-only functions gdk_font_full_name_get() and gdk_font_full_name_free(). * gdk/gdk.def: Delete from here, too. * gdk/win32/gdkfont-win32.c (logfont_to_xlfd, gdk_font_full_name_get, gdk_font_full_name_free): Delete implementation, and helper functions. (pattern_match, InnerEnumFontFamExProc, EnumFontFamExProc, gdk_font_list_new, gdk_font_list_free): Delete unused functions. (gdk_text_width, gdk_text_width_wc) Instead of code duplication, let gdk_text_extents() and gdk_text_extents_wc() do the job. * gdk/win32/gdkgc-win32.c (gdk_win32_gc_values_to_win32values): Don't use the above removed functions in debugging output. * gdk/win32/gdkdisplay-win32.c * gdk/win32/gdkmain-win32.c * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkselection-win32.c * gdk/win32/gdkinput-win32.h * gdk/win32/gdkinput.c: Make it compile again, pass a GdkDisplay in a couple of places.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdk.def2
-rw-r--r--gdk/gdkfont.h6
-rw-r--r--gdk/win32/gdkdisplay-win32.c8
-rw-r--r--gdk/win32/gdkfont-win32.c367
-rw-r--r--gdk/win32/gdkgc-win32.c8
-rw-r--r--gdk/win32/gdkinput-win32.c4
-rw-r--r--gdk/win32/gdkinput-win32.h2
-rw-r--r--gdk/win32/gdkinput.c4
-rw-r--r--gdk/win32/gdkmain-win32.c5
-rw-r--r--gdk/win32/gdkprivate-win32.h2
-rw-r--r--gdk/win32/gdkselection-win32.c12
11 files changed, 31 insertions, 389 deletions
diff --git a/gdk/gdk.def b/gdk/gdk.def
index 51a11c938d..a65785c323 100644
--- a/gdk/gdk.def
+++ b/gdk/gdk.def
@@ -152,8 +152,6 @@ EXPORTS
gdk_font_equal
gdk_font_from_description
gdk_font_from_description_for_display
- gdk_font_full_name_free
- gdk_font_full_name_get
gdk_font_get_type
gdk_font_id
gdk_font_load
diff --git a/gdk/gdkfont.h b/gdk/gdkfont.h
index 65356f5d76..5ff42873e4 100644
--- a/gdk/gdkfont.h
+++ b/gdk/gdkfont.h
@@ -103,12 +103,6 @@ void gdk_string_extents (GdkFont *font,
GdkDisplay * gdk_font_get_display (GdkFont *font);
-#ifdef GDK_WINDOWING_WIN32
-/* Ditto temporary */
-gchar* gdk_font_full_name_get (GdkFont *font);
-void gdk_font_full_name_free (gchar *name);
-#endif
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 149361d20b..6fa395c920 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -40,7 +40,8 @@ gdk_display_open (const gchar *display_name)
_gdk_display = g_object_new (GDK_TYPE_DISPLAY, NULL);
_gdk_screen = g_object_new (GDK_TYPE_SCREEN, NULL);
- gdk_set_default_display (_gdk_display);
+ gdk_display_manager_set_default_display (gdk_display_manager_get (),
+ _gdk_display);
_gdk_visual_init ();
gdk_screen_set_default_colormap (_gdk_screen,
@@ -48,12 +49,9 @@ gdk_display_open (const gchar *display_name)
_gdk_windowing_window_init ();
_gdk_windowing_image_init ();
_gdk_events_init ();
- _gdk_input_init ();
+ _gdk_input_init (_gdk_display);
_gdk_dnd_init ();
- g_signal_emit_by_name (gdk_display_manager_get (),
- "display_opened", _gdk_display);
-
return _gdk_display;
}
diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c
index a831635eb8..eba638b124 100644
--- a/gdk/win32/gdkfont-win32.c
+++ b/gdk/win32/gdkfont-win32.c
@@ -124,332 +124,6 @@ charset_name (DWORD charset)
return "unknown";
}
-static gint num_fonts;
-static gint font_names_size;
-static gchar **xfontnames;
-
-static gchar *
-logfont_to_xlfd (const LOGFONT *lfp,
- int size,
- int res,
- int avg_width)
-{
- const gchar *weight;
- const gchar *registry, *encoding;
- int point_size;
- static int logpixelsy = 0;
- gchar facename[LF_FACESIZE*5];
- gchar *utf8_facename;
- gchar *p;
- const gchar *q;
-
- if (logpixelsy == 0)
- {
- logpixelsy = GetDeviceCaps (gdk_display_hdc, LOGPIXELSY);
- }
-
- if (lfp->lfWeight >= FW_HEAVY)
- weight = "heavy";
- else if (lfp->lfWeight >= FW_EXTRABOLD)
- weight = "extrabold";
- else if (lfp->lfWeight >= FW_BOLD)
- weight = "bold";
-#ifdef FW_DEMIBOLD
- else if (lfp->lfWeight >= FW_DEMIBOLD)
- weight = "demibold";
-#endif
- else if (lfp->lfWeight >= FW_MEDIUM)
- weight = "medium";
- else if (lfp->lfWeight >= FW_NORMAL)
- weight = "normal";
- else if (lfp->lfWeight >= FW_LIGHT)
- weight = "light";
- else if (lfp->lfWeight >= FW_EXTRALIGHT)
- weight = "extralight";
- else if (lfp->lfWeight >= FW_THIN)
- weight = "thin";
- else
- weight = "regular";
-
- switch (lfp->lfCharSet)
- {
- case ANSI_CHARSET:
- registry = "iso8859";
- encoding = "1";
- break;
- case SHIFTJIS_CHARSET:
- registry = "jisx0208.1983";
- encoding = "0";
- break;
- case HANGEUL_CHARSET:
- registry = "ksc5601.1987";
- encoding = "0";
- break;
- case GB2312_CHARSET:
- registry = "gb2312.1980";
- encoding = "0";
- break;
- case CHINESEBIG5_CHARSET:
- registry = "big5";
- encoding = "0";
- break;
- case GREEK_CHARSET:
- registry = "iso8859";
- encoding = "7";
- break;
- case TURKISH_CHARSET:
- registry = "iso8859";
- encoding = "9";
- break;
-#if 0 /* Not a good idea, I think, to use ISO8859-8 and -6 for the Windows
- * hebrew and arabic codepages, they differ too much.
- */
- case HEBREW_CHARSET:
- registry = "iso8859";
- encoding = "8";
- break;
- case ARABIC_CHARSET:
- registry = "iso8859";
- encoding = "6";
- break;
-#endif
- default:
- registry = "microsoft";
- encoding = charset_name (lfp->lfCharSet);
- }
-
- point_size = (int) (((double) size/logpixelsy) * 720.);
-
- if (res == -1)
- res = logpixelsy;
-
- /* Convert the facename Windows fives us from the locale-dependent
- * codepage to UTF-8.
- */
- utf8_facename = g_filename_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL);
-
- /* Replace characters illegal in an XLFD with hex escapes. */
- p = facename;
- q = utf8_facename;
- while (*q)
- {
- if (*q == '-' || *q == '*' || *q == '?' || *q == '%')
- p += sprintf (p, "%%%.02x", *q);
- else
- *p++ = *q;
- q++;
- }
- *p = '\0';
- g_free (utf8_facename);
-
- return g_strdup_printf
- ("-%s-%s-%s-%s-%s-%s-%d-%d-%d-%d-%s-%d-%s-%s",
- "unknown",
- facename,
- weight,
- (lfp->lfItalic ?
- ((lfp->lfPitchAndFamily & 0xF0) == FF_ROMAN
- || (lfp->lfPitchAndFamily & 0xF0) == FF_SCRIPT ?
- "i" : "o") : "r"),
- "normal",
- "",
- size,
- point_size,
- res,
- res,
- ((lfp->lfPitchAndFamily & 0x03) == FIXED_PITCH ? "m" : "p"),
- avg_width,
- registry, encoding);
-}
-
-gchar *
-gdk_font_full_name_get (GdkFont *font)
-{
- GdkFontPrivateWin32 *private;
- GdkWin32SingleFont *singlefont;
- GSList *list;
- GString *string;
- gchar *result;
- gchar *xlfd;
- LOGFONT logfont;
-
- g_return_val_if_fail (font != NULL, NULL);
-
- private = (GdkFontPrivateWin32 *) font;
-
- list = private->fonts;
- string = g_string_new ("");
-
- while (list)
- {
- singlefont = (GdkWin32SingleFont *) list->data;
-
- if (GetObject (singlefont->hfont, sizeof (LOGFONT), &logfont) == 0)
- {
- WIN32_GDI_FAILED ("GetObject");
- return NULL;
- }
-
- xlfd = logfont_to_xlfd (&logfont, logfont.lfHeight, -1, 0);
- string = g_string_append (string, xlfd);
- g_free (xlfd);
- list = list->next;
- if (list)
- string = g_string_append_c (string, ',');
- }
- result = string->str;
- g_string_free (string, FALSE);
- return result;
-}
-
-void
-gdk_font_full_name_free (gchar *name)
-{
- g_free (name);
-}
-
-static gboolean
-pattern_match (const gchar *pattern,
- const gchar *string)
-{
- const gchar *p = pattern, *n = string;
- gchar c, c1;
-
- /* Common case first */
- if ((pattern[0] == '*'
- && pattern[1] == '\0')
- || (pattern[0] == '-'
- && pattern[1] == '*'
- && pattern[2] == '\0'))
- return TRUE;
-
- while ((c = *p++) != '\0')
- {
- c = tolower (c);
-
- switch (c)
- {
- case '?':
- if (*n == '\0')
- return FALSE;
- break;
-
- case '*':
- for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
- if (c == '?' && *n == '\0')
- return FALSE;
-
- if (c == '\0')
- return TRUE;
-
- c1 = tolower (c);
- for (--p; *n != '\0'; ++n)
- if (tolower (*n) == c1
- && pattern_match (p, n))
- return TRUE;
- return FALSE;
-
- default:
- if (c != tolower (*n))
- return FALSE;
- }
-
- ++n;
- }
-
- if (*n == '\0')
- return TRUE;
-
- return FALSE;
-}
-
-static int CALLBACK
-InnerEnumFontFamExProc (const LOGFONT *lfp,
- const TEXTMETRIC *metrics,
- DWORD fontType,
- LPARAM lParam)
-{
- int size;
- gchar *xlfd;
-
- if (fontType == TRUETYPE_FONTTYPE)
- {
- size = 0;
- }
- else
- {
- size = lfp->lfHeight;
- }
-
- xlfd = logfont_to_xlfd (lfp, size, 0, 0);
-
- if (!pattern_match ((gchar *) lParam, xlfd))
- {
- g_free (xlfd);
- return 1;
- }
-
- num_fonts++;
- if (num_fonts == font_names_size)
- {
- font_names_size *= 2;
- xfontnames = g_realloc (xfontnames, font_names_size * sizeof (gchar *));
- }
- xfontnames[num_fonts-1] = xlfd;
-
- return 1;
-}
-
-static int CALLBACK
-EnumFontFamExProc (const LOGFONT *lfp,
- const TEXTMETRIC *metrics,
- DWORD fontType,
- LPARAM lParam)
-{
- if (fontType == TRUETYPE_FONTTYPE)
- {
- LOGFONT lf;
-
- lf = *lfp;
-
- EnumFontFamiliesEx (gdk_display_hdc, &lf, InnerEnumFontFamExProc, lParam, 0);
- }
- else
- InnerEnumFontFamExProc (lfp, metrics, fontType, lParam);
-
- return 1;
-}
-
-gchar **
-gdk_font_list_new (const gchar *font_pattern,
- gint *n_returned)
-{
- LOGFONT logfont;
- gchar **result;
-
- num_fonts = 0;
- font_names_size = 100;
- xfontnames = g_new (gchar *, font_names_size);
- memset (&logfont, 0, sizeof (logfont));
- logfont.lfCharSet = DEFAULT_CHARSET;
- EnumFontFamiliesEx (gdk_display_hdc, &logfont, EnumFontFamExProc,
- (LPARAM) font_pattern, 0);
-
- result = g_new (gchar *, num_fonts + 1);
- memmove (result, xfontnames, num_fonts * sizeof (gchar *));
- result[num_fonts] = NULL;
- g_free (xfontnames);
-
- *n_returned = num_fonts;
- return result;
-}
-
-void
-gdk_font_list_free (gchar **font_list)
-{
- g_strfreev (font_list);
-}
-
/* This table classifies Unicode characters according to the Microsoft
* Unicode subset numbering. This is based on the table in "Developing
* International Software for Windows 95 and Windows NT". This is almost,
@@ -1929,14 +1603,11 @@ gdk_text_width (GdkFont *font,
const gchar *text,
gint text_length)
{
- gdk_text_size_arg arg;
-
- arg.total.cx = arg.total.cy = 0;
+ gint width = -1;
- if (!gdk_text_size (font, text, text_length, &arg))
- return -1;
+ gdk_text_extents (font, text, text_length, NULL, NULL, &width, NULL, NULL);
- return arg.total.cx;
+ return width;
}
gint
@@ -1944,36 +1615,10 @@ gdk_text_width_wc (GdkFont *font,
const GdkWChar *text,
gint text_length)
{
- gdk_text_size_arg arg;
- wchar_t *wcstr;
- gint i;
-
- g_return_val_if_fail (font != NULL, -1);
- g_return_val_if_fail (text != NULL, -1);
-
- if (text_length == 0)
- return 0;
-
- g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
-
- if (sizeof (wchar_t) != sizeof (GdkWChar))
- {
- wcstr = g_new (wchar_t, text_length);
- for (i = 0; i < text_length; i++)
- wcstr[i] = text[i];
- }
- else
- wcstr = (wchar_t *) text;
-
- arg.total.cx = arg.total.cy = 0;
-
- _gdk_wchar_text_handle (font, wcstr, text_length,
- gdk_text_size_handler, &arg);
-
- if (sizeof (wchar_t) != sizeof (GdkWChar))
- g_free (wcstr);
+ gint width = -1;
- return arg.total.cx;
+ gdk_text_extents_wc (font, text, text_length, NULL, NULL, &width, NULL, NULL);
+ return width;
}
void
diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c
index 939f869f80..374122c860 100644
--- a/gdk/win32/gdkgc-win32.c
+++ b/gdk/win32/gdkgc-win32.c
@@ -148,14 +148,10 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
win32_gc->font = values->font;
if (win32_gc->font != NULL)
{
- gchar *xlfd;
-
gdk_font_ref (win32_gc->font);
win32_gc->values_mask |= GDK_GC_FONT;
- GDK_NOTE (GC, (xlfd = gdk_font_full_name_get (win32_gc->font),
- g_print ("%sfont=%s", s, xlfd),
- s = ",",
- gdk_font_full_name_free (xlfd)));
+ GDK_NOTE (GC, (g_print ("%sfont=%p", s, win32_gc->font),
+ s = ","));
}
else
{
diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c
index 55e0e9d217..5d1e60d971 100644
--- a/gdk/win32/gdkinput-win32.c
+++ b/gdk/win32/gdkinput-win32.c
@@ -1198,12 +1198,12 @@ gdk_device_get_state (GdkDevice *device,
}
void
-_gdk_input_init (void)
+_gdk_input_init (GdkDisplay *display)
{
_gdk_input_ignore_core = FALSE;
_gdk_input_devices = NULL;
- _gdk_init_input_core ();
+ _gdk_init_input_core (display);
#ifdef HAVE_WINTAB
gdk_input_wintab_init ();
#endif /* HAVE_WINTAB */
diff --git a/gdk/win32/gdkinput-win32.h b/gdk/win32/gdkinput-win32.h
index 8a4a7010a9..c58253b29e 100644
--- a/gdk/win32/gdkinput-win32.h
+++ b/gdk/win32/gdkinput-win32.h
@@ -129,7 +129,7 @@ extern GList *_gdk_input_windows;
extern gint _gdk_input_ignore_core;
/* Function declarations */
-void _gdk_init_input_core (void);
+void _gdk_init_input_core (GdkDisplay *display);
GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device,
gint n_events);
diff --git a/gdk/win32/gdkinput.c b/gdk/win32/gdkinput.c
index bec9e40796..f085b26bbd 100644
--- a/gdk/win32/gdkinput.c
+++ b/gdk/win32/gdkinput.c
@@ -33,6 +33,7 @@
#include "config.h"
+#include "gdkdisplay.h"
#include "gdkinput.h"
#include "gdkprivate.h"
@@ -45,6 +46,7 @@
#ifdef HAVE_WINTAB
#include <wintab.h>
#endif
+
#include "gdkinput-win32.h"
static GdkDeviceAxis gdk_input_core_axes[] = {
@@ -60,7 +62,7 @@ GList *_gdk_input_devices;
GList *_gdk_input_windows;
void
-_gdk_init_input_core (void)
+_gdk_init_input_core (GdkDisplay *display)
{
display->core_pointer = g_object_new (GDK_TYPE_DEVICE, NULL);
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 40926eddc0..ac0f39bb75 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -92,7 +92,7 @@ _gdk_windowing_init (gint *argc,
LOCALE_IDEFAULTANSICODEPAGE,
buf, sizeof (buf));
_gdk_input_codepage = atoi (buf);
- GDK_NOTE (MISC, g_print ("input_locale: %#lx, codepage:%d\n",
+ GDK_NOTE (MISC, g_print ("input_locale: %p, codepage:%d\n",
_gdk_input_locale, _gdk_input_codepage));
CoInitialize (NULL);
@@ -181,7 +181,8 @@ gdk_screen_get_height_mm (GdkScreen *screen)
}
void
-gdk_display_set_sm_client_id (const gchar* sm_client_id)
+gdk_display_set_sm_client_id (GdkDisplay *display,
+ const gchar *sm_client_id)
{
g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
}
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index 2e5f18fe54..a3120465bb 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -487,6 +487,6 @@ void _gdk_visual_init (void);
void _gdk_dnd_init (void);
void _gdk_windowing_image_init (void);
void _gdk_events_init (void);
-void _gdk_input_init (void);
+void _gdk_input_init (GdkDisplay *display);
#endif /* __GDK_PRIVATE_WIN32_H__ */
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index ffe6199cfc..632706e9a4 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -560,7 +560,8 @@ gdk_selection_send_notify_for_display (GdkDisplay *display,
/* Simplistic implementations of text list and compound text functions */
gint
-gdk_text_property_to_text_list_for_display (GdkAtom encoding,
+gdk_text_property_to_text_list_for_display (GdkDisplay *display,
+ GdkAtom encoding,
gint format,
const guchar *text,
gint length,
@@ -568,6 +569,8 @@ gdk_text_property_to_text_list_for_display (GdkAtom encoding,
{
gchar *enc_name;
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
+
GDK_NOTE (DND, (enc_name = gdk_atom_name (encoding),
g_print ("gdk_text_property_to_text_list: %s %d %.20s %d\n",
enc_name, format, text, length),
@@ -592,12 +595,17 @@ gdk_free_text_list (gchar **list)
}
gint
-gdk_string_to_compound_text_for_display (const gchar *str,
+gdk_string_to_compound_text_for_display (GdkDisplay *display,
+ const gchar *str,
GdkAtom *encoding,
gint *format,
guchar **ctext,
gint *length)
{
+ g_return_val_if_fail (str != NULL, 0);
+ g_return_val_if_fail (length >= 0, 0);
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
+
GDK_NOTE (DND, g_print ("gdk_string_to_compound_text: %.20s\n", str));
if (encoding)