mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
x11: Return XSetting without copying
This commit is contained in:
parent
1f95eddbda
commit
63f0797e70
@ -1353,8 +1353,7 @@ gdk_x11_screen_get_setting (GdkScreen *screen,
|
||||
{
|
||||
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
|
||||
const char *xsettings_name = NULL;
|
||||
XSettingsResult result;
|
||||
XSettingsSetting *setting = NULL;
|
||||
const XSettingsSetting *setting;
|
||||
gboolean success = FALSE;
|
||||
GValue tmp_val = G_VALUE_INIT;
|
||||
|
||||
@ -1362,9 +1361,8 @@ gdk_x11_screen_get_setting (GdkScreen *screen,
|
||||
if (!xsettings_name)
|
||||
goto out;
|
||||
|
||||
result = xsettings_client_get_setting (x11_screen->xsettings_client,
|
||||
xsettings_name, &setting);
|
||||
if (result != XSETTINGS_SUCCESS)
|
||||
setting = xsettings_client_get_setting (x11_screen->xsettings_client, xsettings_name);
|
||||
if (setting == NULL)
|
||||
goto out;
|
||||
|
||||
switch (setting->type)
|
||||
@ -1413,9 +1411,6 @@ gdk_x11_screen_get_setting (GdkScreen *screen,
|
||||
g_value_unset (&tmp_val);
|
||||
|
||||
out:
|
||||
if (setting)
|
||||
xsettings_setting_free (setting);
|
||||
|
||||
if (success)
|
||||
return TRUE;
|
||||
else
|
||||
|
@ -531,25 +531,11 @@ xsettings_client_destroy (XSettingsClient *client)
|
||||
free (client);
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
const XSettingsSetting *
|
||||
xsettings_client_get_setting (XSettingsClient *client,
|
||||
const char *name,
|
||||
XSettingsSetting **setting)
|
||||
const char *name)
|
||||
{
|
||||
XSettingsSetting *search;
|
||||
|
||||
if (client->settings == NULL)
|
||||
return XSETTINGS_NO_ENTRY;
|
||||
|
||||
search = g_hash_table_lookup (client->settings, name);
|
||||
|
||||
if (search)
|
||||
{
|
||||
*setting = xsettings_setting_copy (search);
|
||||
return *setting ? XSETTINGS_SUCCESS : XSETTINGS_NO_MEM;
|
||||
}
|
||||
else
|
||||
return XSETTINGS_NO_ENTRY;
|
||||
return g_hash_table_lookup (client->settings, name);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -63,9 +63,9 @@ void xsettings_client_set_ungrab_func (XSettingsClient *client,
|
||||
void xsettings_client_destroy (XSettingsClient *client);
|
||||
Bool xsettings_client_process_event (XSettingsClient *client,
|
||||
XEvent *xev);
|
||||
XSettingsResult xsettings_client_get_setting (XSettingsClient *client,
|
||||
const char *name,
|
||||
XSettingsSetting **setting);
|
||||
const XSettingsSetting *
|
||||
xsettings_client_get_setting (XSettingsClient *client,
|
||||
const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -31,53 +31,6 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmd.h> /* For CARD32 */
|
||||
|
||||
XSettingsSetting *
|
||||
xsettings_setting_copy (XSettingsSetting *setting)
|
||||
{
|
||||
XSettingsSetting *result;
|
||||
size_t str_len;
|
||||
|
||||
result = malloc (sizeof *result);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
str_len = strlen (setting->name);
|
||||
result->name = malloc (str_len + 1);
|
||||
if (!result->name)
|
||||
goto err;
|
||||
|
||||
memcpy (result->name, setting->name, str_len + 1);
|
||||
|
||||
result->type = setting->type;
|
||||
|
||||
switch (setting->type)
|
||||
{
|
||||
case XSETTINGS_TYPE_INT:
|
||||
result->data.v_int = setting->data.v_int;
|
||||
break;
|
||||
case XSETTINGS_TYPE_COLOR:
|
||||
result->data.v_color = setting->data.v_color;
|
||||
break;
|
||||
case XSETTINGS_TYPE_STRING:
|
||||
str_len = strlen (setting->data.v_string);
|
||||
result->data.v_string = malloc (str_len + 1);
|
||||
if (!result->data.v_string)
|
||||
goto err;
|
||||
|
||||
memcpy (result->data.v_string, setting->data.v_string, str_len + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
err:
|
||||
if (result->name)
|
||||
free (result->name);
|
||||
free (result);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
xsettings_setting_equal (XSettingsSetting *setting_a,
|
||||
XSettingsSetting *setting_b)
|
||||
|
@ -38,7 +38,6 @@ extern "C" {
|
||||
#define xsettings_client_set_grab_func _gdk_x11_xsettings_client_set_grab_func
|
||||
#define xsettings_client_set_ungrab_func _gdk_x11_xsettings_client_set_ungrab_func
|
||||
#define xsettings_client_process_event _gdk_x11_xsettings_client_process_event
|
||||
#define xsettings_setting_copy _gdk_x11_xsettings_setting_copy
|
||||
#define xsettings_setting_equal _gdk_x11_xsettings_setting_equal
|
||||
#define xsettings_setting_free _gdk_x11_xsettings_setting_free
|
||||
|
||||
@ -91,7 +90,6 @@ struct _XSettingsSetting
|
||||
} data;
|
||||
};
|
||||
|
||||
XSettingsSetting *xsettings_setting_copy (XSettingsSetting *setting);
|
||||
void xsettings_setting_free (XSettingsSetting *setting);
|
||||
int xsettings_setting_equal (XSettingsSetting *setting_a,
|
||||
XSettingsSetting *setting_b);
|
||||
|
Loading…
Reference in New Issue
Block a user