handle xcursor so that we support Xcursor files.
Thu Feb 6 16:43:33 2003 Jonathan Blandford <jrb@redhat.com> * gnome-settings-font.c (load_xcursor_theme): handle xcursor so that we support Xcursor files. * gnome-settings-daemon.c: move gnome_settings_daemon_spawn_with_input here so multiple modules can use it.
This commit is contained in:
parent
e3dd60098a
commit
1f239d9a03
5 changed files with 170 additions and 122 deletions
|
@ -1,3 +1,12 @@
|
|||
Thu Feb 6 16:43:33 2003 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gnome-settings-font.c (load_xcursor_theme): handle xcursor so
|
||||
that we support Xcursor files.
|
||||
|
||||
* gnome-settings-daemon.c: move
|
||||
gnome_settings_daemon_spawn_with_input here so multiple modules
|
||||
can use it.
|
||||
|
||||
Tue Feb 4 17:09:18 2003 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* Release 2.2.0.1
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
#include <libgnome/gnome-init.h>
|
||||
#include <libgnomeui/gnome-ui-init.h>
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "xsettings-manager.h"
|
||||
#include "gnome-settings-daemon.h"
|
||||
|
||||
|
@ -323,3 +329,120 @@ gnome_settings_daemon_new (void)
|
|||
|
||||
return G_OBJECT (daemon);
|
||||
}
|
||||
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
/*
|
||||
* Helper function for spawn_with_input() - wait for a child
|
||||
* to exit.
|
||||
*/
|
||||
gboolean
|
||||
wait_for_child (int pid,
|
||||
int *status)
|
||||
{
|
||||
gint ret;
|
||||
|
||||
again:
|
||||
ret = waitpid (pid, status, 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
goto again;
|
||||
else
|
||||
{
|
||||
g_warning ("Unexpected error in waitpid() (%s)",
|
||||
g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper function for spawn_with_input() - write an entire
|
||||
* string to a fd.
|
||||
*/
|
||||
static gboolean
|
||||
write_all (int fd,
|
||||
const char *buf,
|
||||
gsize to_write)
|
||||
{
|
||||
while (to_write > 0)
|
||||
{
|
||||
gssize count = write (fd, buf, to_write);
|
||||
if (count < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
to_write -= count;
|
||||
buf += count;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_settings_daemon-spawn_with_input:
|
||||
* @argv: command line to run
|
||||
* @input: string to write to the child process.
|
||||
*
|
||||
* Spawns a child process specified by @argv, writes the text in
|
||||
* @input to it, then waits for the child to exit. Any failures
|
||||
* are output through g_warning(); if you wanted to use this in
|
||||
* cases where errors need to be presented to the user, some
|
||||
* modification would be needed.
|
||||
**/
|
||||
void
|
||||
gnome_settings_daemon_spawn_with_input (char **argv,
|
||||
const char *input)
|
||||
{
|
||||
int exit_status;
|
||||
int child_pid;
|
||||
int inpipe;
|
||||
GError *err = NULL;
|
||||
|
||||
if (!g_spawn_async_with_pipes (NULL /* working directory */, argv, NULL /* envp */,
|
||||
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
NULL, NULL, /* child setup and data */
|
||||
&child_pid,
|
||||
&inpipe, NULL, NULL, /* stdin, stdout, stderr */
|
||||
&err))
|
||||
{
|
||||
gchar *command = g_strjoinv (" ", argv);
|
||||
g_warning ("Could not execute %s: %s", command, err->message);
|
||||
g_error_free (err);
|
||||
g_free (command);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (input)
|
||||
{
|
||||
if (!write_all (inpipe, input, strlen (input)))
|
||||
{
|
||||
gchar *command = g_strjoinv (" ", argv);
|
||||
g_warning ("Could not write input to %s", command);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
close (inpipe);
|
||||
}
|
||||
|
||||
wait_for_child (child_pid, &exit_status);
|
||||
|
||||
if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status))
|
||||
{
|
||||
gchar *command = g_strjoinv (" ", argv);
|
||||
g_warning ("Command %s failed", command);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,8 +64,10 @@ struct _GnomeSettingsDaemonClass
|
|||
POA_GNOME_SettingsDaemon__epv epv;
|
||||
};
|
||||
|
||||
GType gnome_settings_daemon_get_type (void);
|
||||
GObject *gnome_settings_daemon_new (void);
|
||||
GType gnome_settings_daemon_get_type (void);
|
||||
GObject *gnome_settings_daemon_new (void);
|
||||
void gnome_settings_daemon_spawn_with_input (char **argv,
|
||||
const char *input);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -11,6 +11,34 @@
|
|||
#include <string.h>
|
||||
|
||||
|
||||
static void
|
||||
load_xcursor_theme (GConfClient *client)
|
||||
{
|
||||
gchar *cursor_theme;
|
||||
gint size;
|
||||
char *add[] = { "xrdb", "-merge", NULL };
|
||||
GString *add_string = g_string_new (NULL);
|
||||
|
||||
cursor_theme = gconf_client_get_string (client,
|
||||
"/desktop/gnome/peripherals/mouse/cursor_theme",
|
||||
NULL);
|
||||
size = gconf_client_get_int (client,
|
||||
"/desktop/gnome/peripherals/mouse/cursor_size",
|
||||
NULL);
|
||||
if (cursor_theme == NULL || size <= 0)
|
||||
return;
|
||||
|
||||
g_string_append_printf (add_string,
|
||||
"Xcursor.theme: %s\n", cursor_theme);
|
||||
g_string_append (add_string, "Xcursor.theme_core: true\n");
|
||||
g_string_append_printf (add_string,
|
||||
"Xcursor.size: %d\n", size);
|
||||
|
||||
gnome_settings_daemon_spawn_with_input (add, add_string->str);
|
||||
|
||||
g_string_free (add_string, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
load_cursor (GConfClient *client)
|
||||
{
|
||||
|
@ -122,7 +150,9 @@ load_cursor (GConfClient *client)
|
|||
|
||||
/* run mkfontdir */
|
||||
mkfontdir_cmd = g_strdup_printf ("mkfontdir %s %s", dir_name, font_dir_name);
|
||||
/* maybe check for error... */
|
||||
/* maybe check for error...
|
||||
* also, it's not going to like that if there are spaces in dir_name/font_dir_name.
|
||||
*/
|
||||
g_spawn_command_line_sync (mkfontdir_cmd, NULL, NULL, NULL, NULL);
|
||||
g_free (mkfontdir_cmd);
|
||||
|
||||
|
@ -167,7 +197,8 @@ load_cursor (GConfClient *client)
|
|||
void
|
||||
gnome_settings_font_init (GConfClient *client)
|
||||
{
|
||||
load_cursor (client);
|
||||
load_xcursor_theme (client);
|
||||
load_cursor (client);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
#include <glib.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "gnome-settings-daemon.h"
|
||||
#include "gnome-settings-xsettings.h"
|
||||
#include "xsettings-manager.h"
|
||||
|
@ -348,118 +343,6 @@ gnome_xft_settings_set_xsettings (GnomeXftSettings *settings)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function for spawn_with_input() - write an entire
|
||||
* string to a fd.
|
||||
*/
|
||||
static gboolean
|
||||
write_all (int fd,
|
||||
const char *buf,
|
||||
gsize to_write)
|
||||
{
|
||||
while (to_write > 0)
|
||||
{
|
||||
gssize count = write (fd, buf, to_write);
|
||||
if (count < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
to_write -= count;
|
||||
buf += count;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function for spawn_with_input() - wait for a child
|
||||
* to exit.
|
||||
*/
|
||||
gboolean
|
||||
wait_for_child (int pid,
|
||||
int *status)
|
||||
{
|
||||
gint ret;
|
||||
|
||||
again:
|
||||
ret = waitpid (pid, status, 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
goto again;
|
||||
else
|
||||
{
|
||||
g_warning ("Unexpected error in waitpid() (%s)",
|
||||
g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* spawn_with_input:
|
||||
* @argv: command line to run
|
||||
* @input: string to write to the child process.
|
||||
*
|
||||
* Spawns a child process specified by @argv, writes the text in
|
||||
* @input to it, then waits for the child to exit. Any failures
|
||||
* are output through g_warning(); if you wanted to use this in
|
||||
* cases where errors need to be presented to the user, some
|
||||
* modification would be needed.
|
||||
**/
|
||||
static void
|
||||
spawn_with_input (char **argv,
|
||||
const char *input)
|
||||
{
|
||||
int exit_status;
|
||||
int child_pid;
|
||||
int inpipe;
|
||||
GError *err = NULL;
|
||||
|
||||
if (!g_spawn_async_with_pipes (NULL /* working directory */, argv, NULL /* envp */,
|
||||
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
NULL, NULL, /* child setup and data */
|
||||
&child_pid,
|
||||
&inpipe, NULL, NULL, /* stdin, stdout, stderr */
|
||||
&err))
|
||||
{
|
||||
gchar *command = g_strjoinv (" ", argv);
|
||||
g_warning ("Could not execute %s: %s", command, err->message);
|
||||
g_error_free (err);
|
||||
g_free (command);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (input)
|
||||
{
|
||||
if (!write_all (inpipe, input, strlen (input)))
|
||||
{
|
||||
gchar *command = g_strjoinv (" ", argv);
|
||||
g_warning ("Could not write input to %s", command);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
close (inpipe);
|
||||
}
|
||||
|
||||
wait_for_child (child_pid, &exit_status);
|
||||
|
||||
if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status))
|
||||
{
|
||||
gchar *command = g_strjoinv (" ", argv);
|
||||
g_warning ("Command %s failed", command);
|
||||
g_free (command);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_xft_settings_set_xresources (GnomeXftSettings *settings)
|
||||
{
|
||||
|
@ -477,7 +360,7 @@ gnome_xft_settings_set_xresources (GnomeXftSettings *settings)
|
|||
g_string_append_printf (add_string,
|
||||
"Xft.rgba: %s\n", settings->rgba);
|
||||
|
||||
spawn_with_input (add, add_string->str);
|
||||
gnome_settings_daemon_spawn_with_input (add, add_string->str);
|
||||
|
||||
g_string_free (add_string, TRUE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue