[Xfce4-commits] r27186 - in xfconf/trunk: common xfconf xfconf-query xfconfd xfsettingsd
Stephan Arts
stephan at xfce.org
Sun Jun 29 23:29:20 CEST 2008
Author: stephan
Date: 2008-06-29 21:29:20 +0000 (Sun, 29 Jun 2008)
New Revision: 27186
Modified:
xfconf/trunk/common/xfconf-types.c
xfconf/trunk/xfconf-query/main.c
xfconf/trunk/xfconf/xfconf-channel.c
xfconf/trunk/xfconf/xfconf.c
xfconf/trunk/xfconfd/main.c
xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c
xfconf/trunk/xfsettingsd/registry.c
Log:
Applied patch from Nick (Bug #4184)
Fixes compiler-warnings
Fixes XCursor Xrdb issue
Modified: xfconf/trunk/common/xfconf-types.c
===================================================================
--- xfconf/trunk/common/xfconf-types.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/common/xfconf-types.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -86,7 +86,7 @@
}
xfconf_g_value_set_uint16(dest_value, (guint16)dest);
} else if(G_VALUE_TYPE(dest_value) == XFCONF_TYPE_INT16) {
- if(dest > SHRT_MAX || dest < SHRT_MIN) {
+ if(dest > (guint64) SHRT_MAX || dest < (guint64) SHRT_MIN) {
g_warning("Converting type \"%s\" to \"%s\" results in overflow",
G_VALUE_TYPE_NAME(src_value),
G_VALUE_TYPE_NAME(dest_value));
Modified: xfconf/trunk/xfconf/xfconf-channel.c
===================================================================
--- xfconf/trunk/xfconf/xfconf-channel.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/xfconf/xfconf-channel.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -309,7 +309,7 @@
xfconf_fixup_16bit_ints(GPtrArray *arr)
{
GPtrArray *arr_new = NULL;
- gint i;
+ guint i;
for(i = 0; i < arr->len; ++i) {
GValue *v = g_ptr_array_index(arr, i);
@@ -494,7 +494,7 @@
{
gchar **values = NULL;
GPtrArray *arr;
- gint i;
+ guint i;
g_return_val_if_fail(XFCONF_IS_CHANNEL(channel) && property, NULL);
@@ -1073,7 +1073,7 @@
GPtrArray *arr = NULL;
GType cur_value_type;
GValue *val;
- gint i;
+ guint i;
arr = xfconf_channel_get_arrayv(channel, property);
if(!arr)
@@ -1528,7 +1528,7 @@
{
GType cur_member_type;
GType *member_types;
- gint n_members;
+ guint n_members;
gsize cur_size = 5; /* FIXME: arbitrary... */
gboolean ret;
@@ -1772,7 +1772,7 @@
{
GType cur_member_type;
GType *member_types;
- gint n_members;
+ guint n_members;
gsize cur_size = 5; /* FIXME: arbitrary... */
gboolean ret;
Modified: xfconf/trunk/xfconf/xfconf.c
===================================================================
--- xfconf/trunk/xfconf/xfconf.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/xfconf/xfconf.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -238,7 +238,7 @@
void
xfconf_array_free(GPtrArray *arr)
{
- gint i;
+ guint i;
if(!arr)
return;
Modified: xfconf/trunk/xfconf-query/main.c
===================================================================
--- xfconf/trunk/xfconf-query/main.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/xfconf-query/main.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -59,7 +59,7 @@
gint *size = user_data;
gchar *property_name = (gchar *)key;
- if (strlen(property_name) > *size)
+ if ((gint) strlen(property_name) > *size)
*size = strlen(property_name);
}
@@ -208,7 +208,7 @@
else
{
GPtrArray *arr = g_value_get_boxed(&value);
- gint i;
+ guint i;
g_print(_("Value is an array with %d items:\n\n"), arr->len);
Modified: xfconf/trunk/xfconfd/main.c
===================================================================
--- xfconf/trunk/xfconfd/main.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/xfconfd/main.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -62,6 +62,7 @@
sighandler(int sig)
{
guint32 sigstate;
+ gint avoid_gcc_warning;
switch(sig) {
case SIGUSR1:
@@ -73,7 +74,7 @@
break;
}
- write(signal_pipe[1], &sigstate, sizeof(sigstate));
+ avoid_gcc_warning = write(signal_pipe[1], &sigstate, sizeof(sigstate));
}
static gboolean
Modified: xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c
===================================================================
--- xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -882,7 +882,7 @@
/* compare versions */
p = strstr(version, ".");
- maj_ver_len = p ? p - version : strlen(version);
+ maj_ver_len = p ? p - version : (gint) strlen(version);
if(maj_ver_len != strlen(FILE_VERSION_MAJOR)
|| strncmp(version, FILE_VERSION_MAJOR, maj_ver_len))
{
@@ -1478,7 +1478,7 @@
*is_array = TRUE;
} else if(XFCONF_TYPE_G_VALUE_ARRAY == G_VALUE_TYPE(value)) {
GPtrArray *arr;
- gint i;
+ guint i;
if(is_array_value)
return FALSE;
@@ -1533,7 +1533,7 @@
GNode *child;
gboolean is_array = FALSE;
- if(depth * 2 > sizeof(spaces) + 1)
+ if(depth * 2 > (gint) sizeof(spaces) + 1)
depth = sizeof(spaces) / 2 - 1;
memset(spaces, ' ', depth * 2);
Modified: xfconf/trunk/xfsettingsd/registry.c
===================================================================
--- xfconf/trunk/xfsettingsd/registry.c 2008-06-29 21:13:45 UTC (rev 27185)
+++ xfconf/trunk/xfsettingsd/registry.c 2008-06-29 21:29:20 UTC (rev 27186)
@@ -263,75 +263,115 @@
}
}
xsettings_registry_notify(registry);
- if (!strncmp(name, "/Xft", 4))
+ if (!strncmp(name, "/Xft", 4) || !strncmp(name, "/Gtk/CursorTheme", 16))
xsettings_registry_store_xrdb(registry);
}
void
xsettings_registry_store_xrdb(XSettingsRegistry *registry)
{
- gchar *cmd;
- FILE *fp;
- gchar *path = xfce_resource_save_location(XFCE_RESOURCE_CONFIG,
- "xfce4" G_DIR_SEPARATOR_S "Xft.xrdb",
- TRUE);
+ gchar *filename;
+ GError *error = NULL;
+ GString *string;
+ gchar *command, *contents;
+ gboolean result = TRUE;
- if (G_LIKELY (path != NULL))
+ /* store the xft properties */
+ filename = xfce_resource_save_location(XFCE_RESOURCE_CONFIG, "xfce4" G_DIR_SEPARATOR_S "Xft.xrdb", TRUE);
+ if (G_LIKELY (filename))
{
-
- if(!g_file_test(path, G_FILE_TEST_IS_REGULAR))
- {
- }
+ /* create file contents */
+ string = g_string_sized_new (80);
+ g_string_append_printf (string, "Xft.antialias: %d\n"
+ "Xft.hinting: %d\n"
+ "Xft.rgba: %s\n",
+ g_value_get_int (&properties[XSETTING_ENTRY_XFT_ANTIALIAS].value),
+ g_value_get_int (&properties[XSETTING_ENTRY_XFT_HINTING].value),
+ g_value_get_string (&properties[XSETTING_ENTRY_XFT_RGBA].value));
+
+ if (g_value_get_int (&properties[XSETTING_ENTRY_XFT_HINTING].value))
+ g_string_append_printf (string, "Xft.hintstyle: %s\n", g_value_get_string (&properties[XSETTING_ENTRY_XFT_HINTSTYLE].value));
+ else
+ string = g_string_append (string, "Xft.hintstyle: hintnone\n");
+
+ if (g_value_get_int (&properties[XSETTING_ENTRY_XFT_DPI].value) > 0)
+ g_string_append_printf (string, "Xft.dpi: %d\n", g_value_get_int (&properties[XSETTING_ENTRY_XFT_DPI].value));
- fp = fopen(path, "w");
- if(fp != NULL)
+ /* try to write the file contents */
+ if (G_LIKELY (g_file_set_contents (filename, string->str, -1, &error)))
{
- fprintf(fp, "Xft.antialias: %d\n", g_value_get_int(&properties[XSETTING_ENTRY_XFT_ANTIALIAS].value));
- fprintf(fp, "Xft.hinting: %d\n", g_value_get_int(&properties[XSETTING_ENTRY_XFT_HINTING].value));
- if(g_value_get_int(&properties[XSETTING_ENTRY_XFT_HINTING].value))
- fprintf(fp, "Xft.hintstyle: %s\n", g_value_get_string(&properties[XSETTING_ENTRY_XFT_HINTSTYLE].value));
- else
- fprintf(fp, "Xft.hintstyle: hintnone\n");
- fprintf(fp, "Xft.rgba: %s\n", g_value_get_string(&properties[XSETTING_ENTRY_XFT_RGBA].value));
- if(g_value_get_int (&properties[XSETTING_ENTRY_XFT_DPI].value) > 0)
- fprintf(fp, "Xft.dpi: %d\n", g_value_get_int(&properties[XSETTING_ENTRY_XFT_DPI].value));
- fclose(fp);
-
- /* run xrdb to merge the new settings */
- cmd = g_strdup_printf("xrdb -nocpp -merge \"%s\"", path);
- g_spawn_command_line_async(cmd, NULL);
- g_free(cmd);
+ /* create command to merge with the x resource database */
+ command = g_strdup_printf ("xrdb -nocpp -merge \"%s\"", filename);
+ result = g_spawn_command_line_async (command, &error);
+ g_free (command);
- if(!g_value_get_int(&properties[XSETTING_ENTRY_XFT_DPI].value)) {
- /* filter out Xft.dpi from xrdb */
- g_spawn_command_line_async("sh -c \"xrdb -query | grep -i -v '^Xft.dpi:' | xrdb\"",
- NULL);
+ /* remove dpi from the database if not set */
+ if (result && g_value_get_int (&properties[XSETTING_ENTRY_XFT_DPI].value) == 0)
+ {
+ command = g_strdup ("sh -c \"xrdb -query | grep -i -v '^Xft.dpi:' | xrdb\"");
+ result = g_spawn_command_line_async (command, &error);
+ g_free (command);
}
}
- g_free(path);
+ else
+ {
+ /* print error */
+ g_critical ("Failed to write to '%s': %s", filename, error->message);
+ g_error_free (error);
+ }
+
+ /* cleanup */
+ g_free (filename);
+ g_string_free (string, TRUE);
+
+ /* leave when there where spawn problems */
+ if (result == FALSE)
+ goto spawn_error;
}
- path = xfce_resource_save_location(XFCE_RESOURCE_CONFIG,
- "xfce4" G_DIR_SEPARATOR_S "Xcursor.xrdb",
- TRUE);
- if (G_LIKELY (path != NULL))
+
+ /* store cursor settings */
+ filename = xfce_resource_save_location(XFCE_RESOURCE_CONFIG, "xfce4" G_DIR_SEPARATOR_S "Xcursor.xrdb", TRUE);
+ if (G_LIKELY (filename))
{
-
- if(!g_file_test(path, G_FILE_TEST_IS_REGULAR))
+ /* build file contents */
+ contents = g_strdup_printf ("Xcursor.theme: %s\n"
+ "Xcursor.theme_core: true\n"
+ "Xcursor.size: %d\n",
+ g_value_get_string (&properties[XSETTING_ENTRY_GTK_CURSORTHEMENAME].value),
+ g_value_get_int (&properties[XSETTING_ENTRY_GTK_CURSORTHEMESIZE].value));
+
+ /* write the contents to the file */
+ if (G_LIKELY (g_file_set_contents (filename, contents, -1, &error)))
{
+ /* create command to merge with the x resource database */
+ command = g_strdup_printf ("xrdb -nocpp -merge \"%s\"", filename);
+ result = g_spawn_command_line_async (command, &error);
+ g_free (command);
}
-
- fp = fopen(path, "w");
- if(fp != NULL)
+ else
{
- fprintf(fp, "Xcursor.theme: %s\n"
- "Xcursor.theme_core: true\n"
- "Xcursor.size: %d\n",
- g_value_get_string (&properties[XSETTING_ENTRY_GTK_CURSORTHEMENAME].value),
- g_value_get_int (&properties[XSETTING_ENTRY_GTK_CURSORTHEMESIZE].value));
- fclose(fp);
+ /* print error */
+ g_critical ("Failed to write to '%s': %s", filename, error->message);
+ g_error_free (error);
}
- g_free(path);
+
+ /* cleanup */
+ g_free (filename);
+ g_free (contents);
+
+ /* leave when there where spawn problems */
+ if (result == FALSE)
+ goto spawn_error;
}
+
+ /* leave */
+ return;
+
+ spawn_error:
+
+ /* print warning */
+ g_critical ("Failed to spawn xrdb: %s", error->message);
+ g_free (error);
}
void
More information about the Xfce4-commits
mailing list