Add support for bridging WM settings, currently supports

2002-03-04  Anders Carlsson  <andersca@gnu.org>

	* Makefile.am:
	* gnome-settings-daemon.c: (main):
	* gnome-settings-wm.c: (set_number_of_workspaces),
	(set_workspace_names), (wm_callback), (gnome_settings_wm_init),
	(gnome_settings_wm_load):
	* gnome-settings-wm.h:
	Add support for bridging WM settings, currently supports
	_NET_NUMBER_OF_DESKTOPS and _NET_DESKTOP_NAMES.
This commit is contained in:
Anders Carlsson 2002-03-04 08:54:36 +00:00 committed by Anders Carlsson
parent d4d99fea71
commit 0fcd653297
5 changed files with 139 additions and 4 deletions

View file

@ -1,3 +1,14 @@
2002-03-04 Anders Carlsson <andersca@gnu.org>
* Makefile.am:
* gnome-settings-daemon.c: (main):
* gnome-settings-wm.c: (set_number_of_workspaces),
(set_workspace_names), (wm_callback), (gnome_settings_wm_init),
(gnome_settings_wm_load):
* gnome-settings-wm.h:
Add support for bridging WM settings, currently supports
_NET_NUMBER_OF_DESKTOPS and _NET_DESKTOP_NAMES.
Tue Feb 19 23:53:06 2002 Jonathan Blandford <jrb@redhat.com>
* gnome-settings-font.c: set the font path and handle cursors.

View file

@ -15,6 +15,8 @@ gnome2_settings_daemon_SOURCES = \
gnome-settings-background.c \
gnome-settings-xsettings.c \
gnome-settings-xsettings.h \
gnome-settings-wm.c \
gnome-settings-wm.h \
gnome-settings-locate-pointer.c \
gnome-settings-locate-pointer.h \
gnome-settings-sound.c \

View file

@ -41,6 +41,7 @@
#include "gnome-settings-keyboard.h"
#include "gnome-settings-background.h"
#include "gnome-settings-sound.h"
#include "gnome-settings-wm.h"
static GSList *directories = NULL;
XSettingsManager *manager;
@ -143,7 +144,7 @@ main (int argc, char **argv)
if (xsettings_manager_check_running (gdk_display, DefaultScreen (gdk_display)))
{
fprintf (stderr, "You can only run one xsettings manager at a time; exiting");
fprintf (stderr, "You can only run one xsettings manager at a time; exiting\n");
exit (1);
}
@ -153,7 +154,7 @@ main (int argc, char **argv)
terminate_cb, &terminated);
if (!manager)
{
fprintf (stderr, "Could not create xsettings manager!");
fprintf (stderr, "Could not create xsettings manager!\n");
exit (1);
}
}
@ -174,7 +175,8 @@ main (int argc, char **argv)
gnome_settings_keyboard_init (client);
gnome_settings_background_init (client);
gnome_settings_sound_init (client);
gnome_settings_wm_init (client);
for (list = directories; list; list = list->next)
{
GError *error = NULL;
@ -206,7 +208,8 @@ main (int argc, char **argv)
gnome_settings_mouse_load (client);
gnome_settings_sound_load (client);
gnome_settings_background_load (client);
gnome_settings_wm_load (client);
if (!terminated)
gtk_main ();

View file

@ -0,0 +1,86 @@
#include <config.h>
#include "gnome-settings-daemon.h"
#include "gnome-settings-wm.h"
#include <gdk/gdkx.h>
#include <string.h>
static void
set_number_of_workspaces (int workspaces)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.window = GDK_ROOT_WINDOW ();
xev.xclient.send_event = True;
xev.xclient.display = gdk_display;
xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_NUMBER_OF_DESKTOPS");
xev.xclient.format = 32;
xev.xclient.data.l[0] = workspaces;
XSendEvent (gdk_display,
gdk_x11_get_default_root_xwindow (),
False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
}
static void
set_workspace_names (GSList *values)
{
GConfValue *value;
GSList *list;
/* First delete the properties */
XDeleteProperty (gdk_display,
gdk_x11_get_default_root_xwindow (),
gdk_x11_get_xatom_by_name ("_NET_DESKTOP_NAMES"));
for (list = values; list; list = list->next) {
unsigned char *str;
value = list->data;
str = gconf_value_get_string (value);
if (!g_utf8_validate (str, -1, NULL)) {
continue;
}
XChangeProperty (gdk_display,
gdk_x11_get_default_root_xwindow (),
gdk_x11_get_xatom_by_name ("_NET_DESKTOP_NAMES"),
gdk_x11_get_xatom_by_name ("UTF8_STRING"),
8,
PropModeAppend,
str,
strlen (str) + 1);
}
}
static void
wm_callback (GConfEntry *entry)
{
if (!strcmp (entry->key, "/desktop/gnome/applications/window_manager/number_of_workspaces")) {
if (entry->value->type == GCONF_VALUE_INT)
set_number_of_workspaces (gconf_value_get_int (entry->value));
}
else if (!strcmp (entry->key, "/desktop/gnome/applications/window_manager/workspace_names")) {
if (entry->value->type == GCONF_VALUE_LIST &&
gconf_value_get_list_type (entry->value) == GCONF_VALUE_STRING)
set_workspace_names (gconf_value_get_list (entry->value));
}
}
void
gnome_settings_wm_init (GConfClient *client)
{
gnome_settings_daemon_register_callback ("/desktop/gnome/applications/window_manager", wm_callback);
}
void
gnome_settings_wm_load (GConfClient *client)
{
}

View file

@ -0,0 +1,33 @@
/* -*- mode: c; style: linux -*- */
/* gnome-settings-sound.h
*
* Copyright (C) 2002 Anders Carlsson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Author: Anders Carlsson <andersca@gnu.org>
*/
#ifndef __GNOME_SETTINGS_WM_H__
#define __GNOME_SETTINGS_WM_H__
#include <gconf/gconf.h>
void gnome_settings_wm_init (GConfClient *client);
void gnome_settings_wm_load (GConfClient *client);
#endif /* __GNOME_SETTINGS_WM_H__ */