summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-12-13 23:26:23 -0500
committerMatthias Clasen <mclasen@redhat.com>2017-12-13 23:26:23 -0500
commit4c083c1ed42a3ebae97a96fc11ef1113ad769f15 (patch)
treea567ad91921f7bee2a16ff372aad5e826d1f1fb5
parente3e9bf4bea3307e9d0c6728d82f04994b069005f (diff)
downloadgtk+-4c083c1ed42a3ebae97a96fc11ef1113ad769f15.tar.gz
Drop gdk_atom_name
Since atoms are just interned strings now, we can just cast them to const char * where needed.
-rw-r--r--gdk/gdkinternals.h1
-rw-r--r--gdk/gdkproperty.c22
-rw-r--r--gdk/gdkproperty.h2
-rw-r--r--gdk/quartz/gdkselection-quartz.c8
-rw-r--r--gdk/win32/gdkdnd-win32.c3
-rw-r--r--gdk/win32/gdkevents-win32.c11
-rw-r--r--gdk/win32/gdkselection-win32.c63
-rw-r--r--gdk/x11/gdkdevicemanager-xi2.c2
-rw-r--r--gdk/x11/gdkproperty-x11.c12
-rw-r--r--gtk/gtkquartz.c6
10 files changed, 37 insertions, 93 deletions
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index f3f269224f..46a08867cd 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -428,7 +428,6 @@ void gdk_synthesize_window_state (GdkWindow *window,
GdkWindowState unset_flags,
GdkWindowState set_flags);
-const char * _gdk_atom_name_const (GdkAtom atom);
G_END_DECLS
diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c
index 8405828ac3..8f6c9fa022 100644
--- a/gdk/gdkproperty.c
+++ b/gdk/gdkproperty.c
@@ -103,25 +103,3 @@ gdk_atom_intern_static_string (const gchar *atom_name)
return g_intern_static_string (atom_name);
}
-
-/**
- * gdk_atom_name:
- * @atom: a #GdkAtom.
- *
- * Determines the string corresponding to an atom.
- *
- * Returns: a newly-allocated string containing the string
- * corresponding to @atom. When you are done with the
- * return value, you should free it using g_free().
- */
-gchar *
-gdk_atom_name (GdkAtom atom)
-{
- return g_strdup (_gdk_atom_name_const (atom));
-}
-
-const gchar *
-_gdk_atom_name_const (GdkAtom atom)
-{
- return atom;
-}
diff --git a/gdk/gdkproperty.h b/gdk/gdkproperty.h
index 565ca98b92..b3af7051d4 100644
--- a/gdk/gdkproperty.h
+++ b/gdk/gdkproperty.h
@@ -40,8 +40,6 @@ GdkAtom gdk_atom_intern (const gchar *atom_name,
gboolean only_if_exists);
GDK_AVAILABLE_IN_ALL
GdkAtom gdk_atom_intern_static_string (const gchar *atom_name);
-GDK_AVAILABLE_IN_ALL
-gchar* gdk_atom_name (GdkAtom atom);
GDK_AVAILABLE_IN_ALL
diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c
index 855dd39066..2e965a8fac 100644
--- a/gdk/quartz/gdkselection-quartz.c
+++ b/gdk/quartz/gdkselection-quartz.c
@@ -119,10 +119,7 @@ _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *display,
}
else
{
- gchar *enc_name = gdk_atom_name (encoding);
-
- g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled", enc_name);
- g_free (enc_name);
+ g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled", (const char *)encoding);
if (list)
*list = NULL;
@@ -164,9 +161,8 @@ gdk_quartz_target_to_pasteboard_type_libgtk_only (const char *target)
NSString *
gdk_quartz_atom_to_pasteboard_type_libgtk_only (GdkAtom atom)
{
- gchar *target = gdk_atom_name (atom);
+ const char *target = (const char *)atom;
NSString *ret = gdk_quartz_target_to_pasteboard_type_libgtk_only (target);
- g_free (target);
return ret;
}
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index b05cced5a6..9a5ece2a63 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -1083,10 +1083,9 @@ idataobject_getdata (LPDATAOBJECT This,
}
GDK_NOTE (DND, {
- gchar *target_name = gdk_atom_name (target);
+ const char *target_name = (const char *)target;
g_print ("idataobject_getdata will request target 0x%p (%s) ",
target, target_name);
- g_free (target_name);
});
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 4df73d56e6..3476109b86 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -763,7 +763,7 @@ void
_gdk_win32_print_event (const GdkEvent *event)
{
gchar *escaped, *kvname;
- gchar *selection_name, *target_name, *property_name;
+ const char *selection_name, *target_name, *property_name;
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
switch (event->any.type)
@@ -877,14 +877,11 @@ _gdk_win32_print_event (const GdkEvent *event)
case GDK_SELECTION_CLEAR:
case GDK_SELECTION_REQUEST:
case GDK_SELECTION_NOTIFY:
- selection_name = gdk_atom_name (event->selection.selection);
- target_name = gdk_atom_name (event->selection.target);
- property_name = gdk_atom_name (event->selection.property);
+ selection_name = (const char *)event->selection.selection;
+ target_name = (const char *)event->selection.target;
+ property_name = (const char *)event->selection.property;
g_print ("sel:%s tgt:%s prop:%s",
selection_name, target_name, property_name);
- g_free (selection_name);
- g_free (target_name);
- g_free (property_name);
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index 35ef0be45f..bffe61f23d 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -1701,10 +1701,9 @@ convert_clipboard_selection_to_targets_target (GdkWindow *requestor)
g_print ("... ");
for (i = 0; i < targets->len; i++)
{
- gchar *atom_name = gdk_atom_name (g_array_index (targets, GdkSelTargetFormat, i).target);
+ const char *atom_name = (const char *)g_array_index (targets, GdkSelTargetFormat, i).target;
g_print ("%s", atom_name);
- g_free (atom_name);
if (i < targets->len - 1)
g_print (", ");
}
@@ -1743,9 +1742,9 @@ convert_clipboard_selection_to_target (GdkWindow *requestor,
gboolean transmute = FALSE;
GdkAtom result = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_GDK_SELECTION);
gboolean found;
- gchar *atom_name;
+ const char *atom_name;
- atom_name = gdk_atom_name (target);
+ atom_name = (const char *)target;
for (format = 0, found = FALSE;
!found && 0 != (format = EnumClipboardFormats (format));
@@ -1761,8 +1760,6 @@ convert_clipboard_selection_to_target (GdkWindow *requestor,
g_free (format_name);
}
- g_free (atom_name);
-
if (format == 0)
{
gint i;
@@ -2025,12 +2022,11 @@ _gdk_win32_display_set_selection_owner (GdkDisplay *display,
g_return_val_if_fail (selection != NULL, FALSE);
GDK_NOTE (DND, {
- gchar *sel_name = gdk_atom_name (selection);
+ const char *sel_name = (const char *)selection;
g_print ("gdk_selection_owner_set_for_display: %p %s\n",
(owner ? GDK_WINDOW_HWND (owner) : NULL),
sel_name);
- g_free (sel_name);
});
if (selection != GDK_SELECTION_CLIPBOARD)
@@ -2128,12 +2124,11 @@ _gdk_win32_display_get_selection_owner (GdkDisplay *display,
window = NULL;
GDK_NOTE (DND, {
- gchar *sel_name = gdk_atom_name (selection);
+ const char *sel_name = (const char *)selection;
g_print ("gdk_selection_owner_get: %s = %p\n",
sel_name,
(window ? GDK_WINDOW_HWND (window) : NULL));
- g_free (sel_name);
});
return window;
@@ -2263,14 +2258,12 @@ _gdk_win32_display_convert_selection (GdkDisplay *display,
return;
GDK_NOTE (DND, {
- gchar *sel_name = gdk_atom_name (selection);
- gchar *tgt_name = gdk_atom_name (target);
+ const char *sel_name = (const char *)selection;
+ const char *tgt_name = (const char *)target;
g_print ("gdk_selection_convert: %p %s %s\n",
GDK_WINDOW_HWND (requestor),
sel_name, tgt_name);
- g_free (sel_name);
- g_free (tgt_name);
});
if (selection == GDK_SELECTION_CLIPBOARD)
@@ -2421,8 +2414,8 @@ _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel,
}
else
{
- gchar *prop_name = gdk_atom_name (property);
- gchar *type_name = gdk_atom_name (type);
+ const char *prop_name = (const char *)property;
+ const char *type_name = (const char *)type;
gchar *datastring = _gdk_win32_data_to_string (data, MIN (10, format*nelements/8));
g_warning ("Unsupported property change on window 0x%p, %s property %s, %d-bit, target 0x%x of %d bytes: %s",
@@ -2437,8 +2430,6 @@ _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel,
nelements,
datastring);
g_free (datastring);
- g_free (prop_name);
- g_free (type_name);
}
}
@@ -2477,7 +2468,7 @@ _gdk_win32_display_get_selection_property (GdkDisplay *display,
memmove (*data, prop->data, prop->length);
GDK_NOTE (DND, {
- gchar *type_name = gdk_atom_name (prop->target);
+ const char *type_name = (const char *)prop->target;
g_print (" %s format:%d length:%"G_GSIZE_FORMAT"\n", type_name, prop->bitness, prop->length);
g_free (type_name);
@@ -2518,15 +2509,12 @@ _gdk_win32_display_send_selection_notify (GdkDisplay *display,
guint32 time)
{
GDK_NOTE (DND, {
- gchar *sel_name = gdk_atom_name (selection);
- gchar *tgt_name = gdk_atom_name (target);
- gchar *prop_name = gdk_atom_name (property);
+ const char *sel_name = (const char *)selection;
+ const char *tgt_name = (const char *)target;
+ const char *prop_name = (const char *)property;
g_print ("gdk_selection_send_notify_for_display: %p %s %s %s (no-op)\n",
requestor, sel_name, tgt_name, prop_name);
- g_free (sel_name);
- g_free (tgt_name);
- g_free (prop_name);
});
}
@@ -2547,11 +2535,10 @@ gdk_text_property_to_text_list_for_display (GdkDisplay *display,
gchar *source_charset;
GDK_NOTE (DND, {
- gchar *enc_name = gdk_atom_name (encoding);
+ const char *enc_name = (const char *)encoding;
g_print ("gdk_text_property_to_text_list_for_display: %s %d %.20s %d\n",
enc_name, format, text, length);
- g_free (enc_name);
});
if (!list)
@@ -2562,7 +2549,7 @@ gdk_text_property_to_text_list_for_display (GdkDisplay *display,
else if (encoding == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_UTF8_STRING))
source_charset = g_strdup ("UTF-8");
else
- source_charset = gdk_atom_name (encoding);
+ source_charset = g_strdup ((const char *)encoding);
g_get_charset (&charset);
@@ -2678,10 +2665,9 @@ _gdk_win32_display_text_property_to_utf8_list (GdkDisplay *display,
}
else
{
- gchar *enc_name = gdk_atom_name (encoding);
+ const char *enc_name = (const char *)encoding;
g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled\n", enc_name);
- g_free (enc_name);
if (list)
*list = NULL;
@@ -2718,10 +2704,9 @@ gdk_win32_selection_clear_targets (GdkDisplay *display,
}
else
{
- gchar *sel_name = gdk_atom_name (selection);
+ const char *sel_name = (const char *)selection;
g_warning ("Unsupported generic selection %s (0x%p)", sel_name, selection);
- g_free (sel_name);
}
}
@@ -2730,7 +2715,7 @@ _gdk_win32_add_target_to_selformats (GdkAtom target,
GArray *array)
{
gint added_count = 0;
- gchar *target_name;
+ const char *target_name;
wchar_t *target_name_w;
GdkSelTargetFormat fmt;
gint i;
@@ -2764,9 +2749,8 @@ _gdk_win32_add_target_to_selformats (GdkAtom target,
*/
starting_point = array->len;
- target_name = gdk_atom_name (target);
+ target_name = (const char *)target;
target_name_w = g_utf8_to_utf16 (target_name, -1, NULL, NULL, NULL);
- g_free (target_name);
if (target_name_w == NULL)
return added_count;
@@ -2831,19 +2815,17 @@ gdk_win32_display_add_selection_targets (GdkDisplay *display,
gint i;
GDK_NOTE (DND, {
- gchar *sel_name = gdk_atom_name (selection);
+ const char *sel_name = (const char *)selection;
g_print ("gdk_win32_selection_add_targets: %p: %s: ",
owner ? GDK_WINDOW_HWND (owner) : NULL,
sel_name);
- g_free (sel_name);
for (i = 0; i < ntargets; i++)
{
- gchar *tgt_name = gdk_atom_name (targets[i]);
+ const char *tgt_name = (const char *)targets[i];
g_print ("%s", tgt_name);
- g_free (tgt_name);
if (i < ntargets - 1)
g_print (", ");
}
@@ -2875,9 +2857,8 @@ gdk_win32_display_add_selection_targets (GdkDisplay *display,
}
else
{
- gchar *sel_name = gdk_atom_name (selection);
+ const char *sel_name = (const char *)selection;
g_warning ("Unsupported generic selection %s (0x%p)", sel_name, selection);
- g_free (sel_name);
}
}
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 3032dbc5bc..676ed976ea 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -193,7 +193,7 @@ translate_valuator_class (GdkDisplay *display,
label = NULL;
_gdk_device_add_axis (device, label, use, min, max, resolution);
- GDK_NOTE (INPUT, g_message ("\n\taxis: %s %s", gdk_atom_name (label), use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)"));
+ GDK_NOTE (INPUT, g_message ("\n\taxis: %s %s", (const char *)label, use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)"));
}
static void
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index 3894dfab4e..2f3d9a4513 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -99,12 +99,10 @@ gdk_x11_atom_to_xatom_for_display (GdkDisplay *display,
if (!xatom)
{
- char *name = gdk_atom_name (atom);
+ const char *name = (const char *)atom;
xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), name, FALSE);
insert_atom_pair (display, atom, xatom);
-
- g_free (name);
}
return xatom;
@@ -302,7 +300,7 @@ gdk_x11_get_xatom_by_name (const gchar *atom_name)
*
* Returns the name of an X atom for its display. This
* function is meant mainly for debugging, so for convenience, unlike
- * XAtomName() and gdk_atom_name(), the result doesn’t need to
+ * XAtomName() and the result doesn’t need to
* be freed.
*
* Returns: name of the X atom; this string is owned by GDK,
@@ -316,7 +314,7 @@ gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- return _gdk_atom_name_const (gdk_x11_xatom_to_atom_for_display (display, xatom));
+ return (const char *)gdk_x11_xatom_to_atom_for_display (display, xatom);
}
/**
@@ -325,7 +323,7 @@ gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
*
* Returns the name of an X atom for GDK’s default display. This
* function is meant mainly for debugging, so for convenience, unlike
- * XAtomName() and gdk_atom_name(), the result
+ * XAtomName() and the result
* doesn’t need to be freed. Also, this function will never return %NULL,
* even if @xatom is invalid.
*
@@ -335,6 +333,6 @@ gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
const gchar *
gdk_x11_get_xatom_name (Atom xatom)
{
- return _gdk_atom_name_const (gdk_x11_xatom_to_atom (xatom));
+ return (const char *)gdk_x11_xatom_to_atom (xatom);
}
diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
index 183bef6c08..7b9b396646 100644
--- a/gtk/gtkquartz.c
+++ b/gtk/gtkquartz.c
@@ -253,17 +253,15 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
else
{
NSData *data;
- gchar *name;
+ const char *name;
- name = gdk_atom_name (target);
+ name = (const char *)target;
if (strcmp (name, "image/tiff") == 0)
data = [pasteboard dataForType:NSTIFFPboardType];
else
data = [pasteboard dataForType:[NSString stringWithUTF8String:name]];
- g_free (name);
-
if (data)
{
gtk_selection_data_set (selection_data,