G_CONST_RETURN patch for gtk+
- From: Cody Russell <bratsche gnome org>
- To: hp redhat com
- Cc: gtk-devel-list gnome org
- Subject: G_CONST_RETURN patch for gtk+
- Date: 09 Mar 2001 10:24:37 -0600
Hi Havoc,
Here is a patch for G_CONST_RETURN functions in gtk+ (mostly in gdk).
The things it changes are listed here, along with their files:
gdk_get_display() - gdk.h, gdkmain-x11.c, gdkmain-win32.c,
gdkmain-nanox.c, gdkmain-fb.c
gdk_set_locale() - gdk.h, gdkim-x11.c, gdkim-win32.c, gdkmain-nanox.c,
gdkim-fb.c
** This one will be slightly bugged on Win32, I think, because it will
return g_win32_getlocale(), which explicitly says in its docs that the
returned string should be deallocated with g_free(). I wasn't sure how
to deal with this, so I didn't.
gdk_keyval_name() - gdkkeys.h, gdkkeys-x11.c, gdkkeys-win32.c,
gdkmain-nanox.c, gdkmain-fb.c
And in gtk/ I changed gtk_text_mark_get_name() in gtktextmark.[ch]. It
was returning const gchar* already, but I changed this to G_CONST_RETURN
gchar*.
I've never contributed to GTK+ before, so I don't know if I'm supposed
to wait for approval to commit or just let you commit.
Cheers,
Cody
? gtk+-bratsche-G_CONST_RETURN.patch
Index: gdk/gdk.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdk.h,v
retrieving revision 1.85
diff -u -r1.85 gdk.h
--- gdk/gdk.h 2001/03/09 20:28:16 1.85
+++ gdk/gdk.h 2001/03/10 04:23:28
@@ -66,7 +66,7 @@
#ifndef GDK_DISABLE_DEPRECATED
void gdk_exit (gint error_code);
#endif /* GDK_DISABLE_DEPRECATED */
-gchar* gdk_set_locale (void);
+G_CONST_RETURN gchar* gdk_set_locale (void);
/* Push and pop error handlers for X errors
*/
@@ -77,7 +77,7 @@
void gdk_set_use_xshm (gboolean use_xshm);
gboolean gdk_get_use_xshm (void);
-gchar* gdk_get_display (void);
+G_CONST_RETURN gchar* gdk_get_display (void);
#ifndef GDK_DISABLE_DEPRECATED
gint gdk_input_add_full (gint source,
Index: gdk/gdkkeys.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkkeys.h,v
retrieving revision 1.1
diff -u -r1.1 gdkkeys.h
--- gdk/gdkkeys.h 2000/12/06 05:31:25 1.1
+++ gdk/gdkkeys.h 2001/03/10 04:23:28
@@ -99,7 +99,7 @@
/* Key values
*/
-gchar* gdk_keyval_name (guint keyval) G_GNUC_CONST;
+G_CONST_RETURN gchar* gdk_keyval_name (guint keyval) G_GNUC_CONST;
guint gdk_keyval_from_name (const gchar *keyval_name);
void gdk_keyval_convert_case (guint symbol,
guint *lower,
Index: gdk/linux-fb/gdkim-fb.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/linux-fb/gdkim-fb.c,v
retrieving revision 1.4
diff -u -r1.4 gdkim-fb.c
--- gdk/linux-fb/gdkim-fb.c 2001/03/09 20:28:17 1.4
+++ gdk/linux-fb/gdkim-fb.c 2001/03/10 04:23:28
@@ -56,7 +56,7 @@
*--------------------------------------------------------------
*/
-gchar*
+G_CONST_RETURN gchar*
gdk_set_locale (void)
{
wchar_t result;
Index: gdk/linux-fb/gdkmain-fb.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/linux-fb/gdkmain-fb.c,v
retrieving revision 1.26
diff -u -r1.26 gdkmain-fb.c
--- gdk/linux-fb/gdkmain-fb.c 2001/01/31 15:31:48 1.26
+++ gdk/linux-fb/gdkmain-fb.c 2001/03/10 04:23:30
@@ -1048,7 +1048,7 @@
gdk_display = NULL;
}
-gchar*
+G_CONST_RETURN gchar*
gdk_keyval_name (guint keyval)
{
return NULL;
@@ -1060,7 +1060,7 @@
return 0;
}
-gchar *
+G_CONST_RETURN gchar *
gdk_get_display(void)
{
gchar *s;
Index: gdk/nanox/gdkmain-nanox.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/nanox/gdkmain-nanox.c,v
retrieving revision 1.3
diff -u -r1.3 gdkmain-nanox.c
--- gdk/nanox/gdkmain-nanox.c 2000/11/13 13:15:38 1.3
+++ gdk/nanox/gdkmain-nanox.c 2001/03/10 04:23:31
@@ -24,7 +24,7 @@
}
-gchar*
+G_CONST_RETURN gchar*
gdk_set_locale (void)
{
return "";
@@ -139,13 +139,13 @@
GrClose();
}
-gchar *
+G_CONST_RETURN gchar *
gdk_get_display (void)
{
return "nano-X";
}
-gchar*
+G_CONST_RETURN gchar*
gdk_keyval_name (guint keyval)
{
static gchar buf[64];
Index: gdk/win32/gdkcolor-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkcolor-win32.c,v
retrieving revision 1.22
diff -u -r1.22 gdkcolor-win32.c
--- gdk/win32/gdkcolor-win32.c 2001/02/11 11:00:13 1.22
+++ gdk/win32/gdkcolor-win32.c 2001/03/10 04:23:35
@@ -2303,7 +2303,7 @@
#ifdef G_ENABLE_DEBUG
-gchar *
+G_CONST_RETURN gchar *
gdk_win32_color_to_string (const GdkColor *color)
{
static char buf[100];
Index: gdk/win32/gdkim-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkim-win32.c,v
retrieving revision 1.16
diff -u -r1.16 gdkim-win32.c
--- gdk/win32/gdkim-win32.c 2001/03/09 20:28:19 1.16
+++ gdk/win32/gdkim-win32.c 2001/03/10 04:23:37
@@ -48,13 +48,13 @@
*--------------------------------------------------------------
*/
-gchar*
+G_CONST_RETURN gchar*
gdk_set_locale (void)
{
if (!setlocale (LC_ALL, ""))
g_warning ("locale not supported by C library");
- return g_win32_getlocale ();
+ return (G_CONST_RETURN gchar *) g_win32_getlocale ();
}
/*
Index: gdk/win32/gdkkeys-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkkeys-win32.c,v
retrieving revision 1.2
diff -u -r1.2 gdkkeys-win32.c
--- gdk/win32/gdkkeys-win32.c 2001/02/19 22:02:23 1.2
+++ gdk/win32/gdkkeys-win32.c 2001/03/10 04:23:39
@@ -260,7 +260,7 @@
static struct gdk_key {
guint keyval;
- const char *name;
+ const gchar *name;
} gdk_keys_by_keyval[] = {
{ 0x000020, "space" },
{ 0x000021, "exclam" },
@@ -1577,7 +1577,7 @@
return (*(int *) pkey) - ((struct gdk_key *) pbase)->keyval;
}
-gchar*
+G_CONST_RETURN gchar*
gdk_keyval_name (guint keyval)
{
struct gdk_key *found =
@@ -1585,7 +1585,7 @@
GDK_NUM_KEYS, sizeof (struct gdk_key),
gdk_keys_keyval_compare);
if (found != NULL)
- return (gchar *) found->name;
+ return (G_CONST_RETURN gchar *) found->name;
else
return NULL;
}
Index: gdk/win32/gdkmain-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkmain-win32.c,v
retrieving revision 1.23
diff -u -r1.23 gdkmain-win32.c
--- gdk/win32/gdkmain-win32.c 2000/12/14 23:14:18 1.23
+++ gdk/win32/gdkmain-win32.c 2001/03/10 04:23:40
@@ -261,7 +261,7 @@
gdk_display_hdc = NULL;
}
-gchar *
+G_CONST_RETURN gchar *
gdk_get_display(void)
{
return "Win32";
Index: gdk/x11/gdkim-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkim-x11.c,v
retrieving revision 1.22
diff -u -r1.22 gdkim-x11.c
--- gdk/x11/gdkim-x11.c 2001/03/09 20:28:20 1.22
+++ gdk/x11/gdkim-x11.c 2001/03/10 04:23:40
@@ -60,7 +60,7 @@
*--------------------------------------------------------------
*/
-gchar*
+G_CONST_RETURN gchar*
gdk_set_locale (void)
{
wchar_t result;
@@ -107,7 +107,7 @@
g_message ("%s multi-byte string functions.",
gdk_use_mb ? "Using" : "Not using"));
- return current_locale;
+ return (G_CONST_RETURN gchar *) current_locale;
}
/*
Index: gdk/x11/gdkkeys-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkkeys-x11.c,v
retrieving revision 1.3
diff -u -r1.3 gdkkeys-x11.c
--- gdk/x11/gdkkeys-x11.c 2001/03/03 21:34:19 1.3
+++ gdk/x11/gdkkeys-x11.c 2001/03/10 04:23:42
@@ -754,10 +754,10 @@
/* Key handling not part of the keymap */
-gchar*
+G_CONST_RETURN gchar*
gdk_keyval_name (guint keyval)
{
- return XKeysymToString (keyval);
+ return (G_CONST_RETURN *) XKeysymToString (keyval);
}
guint
Index: gdk/x11/gdkmain-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkmain-x11.c,v
retrieving revision 1.128
diff -u -r1.128 gdkmain-x11.c
--- gdk/x11/gdkmain-x11.c 2001/03/09 20:28:20 1.128
+++ gdk/x11/gdkmain-x11.c 2001/03/10 04:23:43
@@ -697,10 +697,10 @@
exit(1);
}
-gchar *
+G_CONST_RETURN gchar *
gdk_get_display (void)
{
- return (gchar *)XDisplayName (gdk_display_name);
+ return (G_CONST_RETURN gchar *)XDisplayName (gdk_display_name);
}
gint
Index: gtk/gtktextmark.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextmark.c,v
retrieving revision 1.16
diff -u -r1.16 gtktextmark.c
--- gtk/gtktextmark.c 2001/01/12 23:23:39 1.16
+++ gtk/gtktextmark.c 2001/03/10 04:23:46
@@ -154,7 +154,7 @@
*
* Return value: mark name
**/
-const char *
+G_CONST_RETURN char *
gtk_text_mark_get_name (GtkTextMark *mark)
{
GtkTextLineSegment *seg;
Index: gtk/gtktextmark.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextmark.h,v
retrieving revision 1.12
diff -u -r1.12 gtktextmark.h
--- gtk/gtktextmark.h 2001/01/12 23:23:39 1.12
+++ gtk/gtktextmark.h 2001/03/10 04:23:46
@@ -85,8 +85,7 @@
gboolean setting);
gboolean gtk_text_mark_get_visible (GtkTextMark *mark);
-/* FIXME gconst */
-const char * gtk_text_mark_get_name (GtkTextMark *mark);
+G_CONST_RETURN gchar *gtk_text_mark_get_name (GtkTextMark *mark);
gboolean gtk_text_mark_get_deleted (GtkTextMark *mark);
GtkTextBuffer* gtk_text_mark_get_buffer (GtkTextMark *mark);
gboolean gtk_text_mark_get_left_gravity (GtkTextMark *mark);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]