Add XML cflags/libs
2000-08-23 Bradford Hovinen <hovinen@helixcode.com> * capplets/wm-properties/Makefile.am (INCLUDES): (wm_properties_capplet_LDADD): Add XML cflags/libs * capplets/wm-properties/wm-properties-capplet.c (do_get_xml): (do_set_xml): Implement (main): Call do_{get|set}_xml() on --get and --set * capplets/wm-properties/wm-list.c (wm_read_from_xml): (wm_list_read_from_xml): (wm_write_to_xml): (wm_list_write_to_xml): Implement
This commit is contained in:
parent
379d3e137b
commit
f4f9184388
5 changed files with 170 additions and 5 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2000-08-23 Bradford Hovinen <hovinen@helixcode.com>
|
||||||
|
|
||||||
|
* capplets/wm-properties/Makefile.am (INCLUDES):
|
||||||
|
(wm_properties_capplet_LDADD): Add XML cflags/libs
|
||||||
|
|
||||||
|
* capplets/wm-properties/wm-properties-capplet.c (do_get_xml):
|
||||||
|
(do_set_xml): Implement
|
||||||
|
(main): Call do_{get|set}_xml() on --get and --set
|
||||||
|
|
||||||
|
* capplets/wm-properties/wm-list.c (wm_read_from_xml):
|
||||||
|
(wm_list_read_from_xml):
|
||||||
|
(wm_write_to_xml):
|
||||||
|
(wm_list_write_to_xml): Implement
|
||||||
|
|
||||||
2000-08-18 Bradford Hovinen <hovinen@helixcode.com>
|
2000-08-18 Bradford Hovinen <hovinen@helixcode.com>
|
||||||
|
|
||||||
* capplets/keyboard-properties/Makefile.am (INCLUDES):
|
* capplets/keyboard-properties/Makefile.am (INCLUDES):
|
||||||
|
|
|
@ -2,7 +2,8 @@ INCLUDES = -I. -I$(srcdir) \
|
||||||
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
|
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
|
||||||
-I$(srcdir)/../../libcapplet \
|
-I$(srcdir)/../../libcapplet \
|
||||||
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
|
||||||
-I$(includedir) $(GNOME_INCLUDEDIR) $(IMLIB_CFLAGS)
|
-I$(includedir) $(GNOME_INCLUDEDIR) $(IMLIB_CFLAGS) \
|
||||||
|
$(XML_CFLAGS)
|
||||||
|
|
||||||
bin_PROGRAMS = wm-properties-capplet
|
bin_PROGRAMS = wm-properties-capplet
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ wm_properties_capplet_SOURCES = \
|
||||||
wm_properties_capplet_LDADD = \
|
wm_properties_capplet_LDADD = \
|
||||||
../../libcapplet/libcapplet.la \
|
../../libcapplet/libcapplet.la \
|
||||||
$(GNOME_LIBS) $(ORBIT_LIBS) $(GNOMEUI_LIBS) $(GNOME_LIBDIR) $(INTLLIBS) \
|
$(GNOME_LIBS) $(ORBIT_LIBS) $(GNOMEUI_LIBS) $(GNOME_LIBDIR) $(INTLLIBS) \
|
||||||
$(IMLIB_LIBS)
|
$(IMLIB_LIBS) $(GNOME_XML_LIB)
|
||||||
|
|
||||||
EXTRA_DIST = wm-properties.desktop
|
EXTRA_DIST = wm-properties.desktop
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
||||||
/* Copyright (C) 1998 Redhat Software Inc.
|
/* Copyright (C) 1998 Redhat Software Inc.
|
||||||
* Code available under the Gnu GPL.
|
* Code available under the Gnu GPL.
|
||||||
* Authors: Owen Taylor <otaylor@redhat.com>
|
* Authors: Owen Taylor <otaylor@redhat.com>,
|
||||||
|
* Bradford Hovinen <hovinen@helixcode.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -405,3 +406,109 @@ wm_list_get_revert (void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static WindowManager *
|
||||||
|
wm_read_from_xml (xmlNodePtr wm_node)
|
||||||
|
{
|
||||||
|
xmlNodePtr node;
|
||||||
|
WindowManager *wm;
|
||||||
|
gboolean is_current = FALSE;
|
||||||
|
|
||||||
|
if (strcmp (wm_node->name, "window-manager")) return NULL;
|
||||||
|
|
||||||
|
wm = g_new0 (WindowManager, 1);
|
||||||
|
|
||||||
|
for (node = wm_node->childs; node; node = node->next) {
|
||||||
|
if (!strcmp (node->name, "desktop-entry"))
|
||||||
|
wm->dentry =
|
||||||
|
gnome_desktop_entry_load_unconditional
|
||||||
|
(xmlNodeGetContent (node));
|
||||||
|
else if (!strcmp (node->name, "config-exec"))
|
||||||
|
wm->config_exec = xmlNodeGetContent (node);
|
||||||
|
else if (!strcmp (node->name, "config-tryexec"))
|
||||||
|
wm->config_tryexec = xmlNodeGetContent (node);
|
||||||
|
else if (!strcmp (node->name, "session-managed"))
|
||||||
|
wm->session_managed = TRUE;
|
||||||
|
else if (!strcmp (node->name, "is-user"))
|
||||||
|
wm->is_user = TRUE;
|
||||||
|
else if (!strcmp (node->name, "is-current"))
|
||||||
|
is_current = TRUE; /* FIXME: sanity check */
|
||||||
|
}
|
||||||
|
|
||||||
|
wm_check_present (wm);
|
||||||
|
|
||||||
|
if (wm->dentry == NULL ||
|
||||||
|
(wm->config_exec != NULL && is_blank (wm->config_exec)) ||
|
||||||
|
wm->dentry->name == NULL || wm->dentry->exec == NULL ||
|
||||||
|
!(wm->is_user || wm->is_present))
|
||||||
|
{
|
||||||
|
g_free (wm);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_current) current_wm = wm;
|
||||||
|
|
||||||
|
return wm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wm_list_read_from_xml (xmlDocPtr doc)
|
||||||
|
{
|
||||||
|
xmlNodePtr root_node, node;
|
||||||
|
WindowManager *wm;
|
||||||
|
|
||||||
|
root_node = xmlDocGetRootElement (doc);
|
||||||
|
if (strcmp (root_node->name, "wm-prefs")) return;
|
||||||
|
|
||||||
|
for (node = root_node; node; node = node->next) {
|
||||||
|
if (!strcmp (node->name, "window-manager")) {
|
||||||
|
wm = wm_read_from_xml (node);
|
||||||
|
if (wm) window_managers =
|
||||||
|
g_list_insert_sorted
|
||||||
|
(window_managers, wm, wm_compare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static xmlNodePtr
|
||||||
|
wm_write_to_xml (WindowManager *wm)
|
||||||
|
{
|
||||||
|
xmlNodePtr node;
|
||||||
|
|
||||||
|
node = xmlNewNode (NULL, "window-manager");
|
||||||
|
|
||||||
|
xmlNewChild (node, NULL, "desktop-entry", wm->dentry->location);
|
||||||
|
|
||||||
|
if (wm->config_exec != NULL)
|
||||||
|
xmlNewChild (node, NULL, "config-exec", wm->config_exec);
|
||||||
|
|
||||||
|
if (wm->session_managed)
|
||||||
|
xmlNewChild (node, NULL, "session-managed", NULL);
|
||||||
|
|
||||||
|
if (wm->is_user)
|
||||||
|
xmlNewChild (node, NULL, "is-user", NULL);
|
||||||
|
|
||||||
|
if (wm == current_wm)
|
||||||
|
xmlNewChild (node, NULL, "is-current", NULL);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlDocPtr
|
||||||
|
wm_list_write_to_xml (void)
|
||||||
|
{
|
||||||
|
xmlDocPtr doc;
|
||||||
|
xmlNodePtr root_node, node;
|
||||||
|
GList *wm_node;
|
||||||
|
|
||||||
|
doc = xmlNewDoc ("1.0");
|
||||||
|
root_node = xmlNewDocNode (doc, NULL, "wm-prefs", NULL);
|
||||||
|
|
||||||
|
for (wm_node = window_managers; wm_node; wm_node = wm_node->next) {
|
||||||
|
node = wm_write_to_xml ((WindowManager *) wm_node->data);
|
||||||
|
if (node) xmlAddChild (root_node, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlDocSetRootElement (doc, root_node);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <parser.h>
|
||||||
#include "wm-properties.h"
|
#include "wm-properties.h"
|
||||||
#include "capplet-widget.h"
|
#include "capplet-widget.h"
|
||||||
#include "gnome.h"
|
#include "gnome.h"
|
||||||
|
@ -1103,6 +1104,35 @@ wm_setup (void)
|
||||||
update_gui();
|
update_gui();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_get_xml (void)
|
||||||
|
{
|
||||||
|
xmlDocPtr doc;
|
||||||
|
|
||||||
|
doc = wm_list_write_to_xml ();
|
||||||
|
xmlDocDump (stdout, doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void do_set_xml (void)
|
||||||
|
{
|
||||||
|
xmlDocPtr doc;
|
||||||
|
char *buffer;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
while (!feof (stdin)) {
|
||||||
|
if (!len) buffer = g_new (char, 16384);
|
||||||
|
else buffer = g_renew (char, buffer, len + 16384);
|
||||||
|
fread (buffer + len, 1, 16384, stdin);
|
||||||
|
len += 16384;
|
||||||
|
}
|
||||||
|
|
||||||
|
doc = xmlParseMemory (buffer, strlen (buffer));
|
||||||
|
|
||||||
|
init_session ();
|
||||||
|
wm_list_read_from_xml (doc);
|
||||||
|
wm_list_save ();
|
||||||
|
update_session ();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -1156,7 +1186,14 @@ main (int argc, char **argv)
|
||||||
update_session ();
|
update_session ();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else if (init_results == 3) {
|
||||||
|
do_get_xml ();
|
||||||
|
}
|
||||||
|
else if (init_results == 4) {
|
||||||
|
do_set_xml ();
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (selected_wm &&
|
if (selected_wm &&
|
||||||
!selected_wm->session_managed &&
|
!selected_wm->session_managed &&
|
||||||
!wm_is_running()) {
|
!wm_is_running()) {
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
|
||||||
/* Copyright (C) 1998 Redhat Software Inc.
|
/* Copyright (C) 1998 Redhat Software Inc.
|
||||||
* Code available under the Gnu GPL.
|
* Code available under the Gnu GPL.
|
||||||
* Authors: Owen Taylor <otaylor@redhat.com>
|
* Authors: Owen Taylor <otaylor@redhat.com>,
|
||||||
|
* Bradford Hovinen <hovinen@helixcode.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <libgnome/libgnome.h>
|
#include <libgnome/libgnome.h>
|
||||||
|
|
||||||
|
#include <tree.h>
|
||||||
|
|
||||||
typedef struct _WindowManager WindowManager;
|
typedef struct _WindowManager WindowManager;
|
||||||
|
|
||||||
struct _WindowManager {
|
struct _WindowManager {
|
||||||
|
@ -36,6 +39,9 @@ void wm_list_set_current (WindowManager *window_manager);
|
||||||
WindowManager *wm_list_get_current (void);
|
WindowManager *wm_list_get_current (void);
|
||||||
WindowManager *wm_list_get_revert (void);
|
WindowManager *wm_list_get_revert (void);
|
||||||
|
|
||||||
|
void wm_list_read_from_xml (xmlDocPtr doc);
|
||||||
|
xmlDocPtr wm_list_write_to_xml (void);
|
||||||
|
|
||||||
extern GList *window_managers;
|
extern GList *window_managers;
|
||||||
|
|
||||||
/* Management of current window manager */
|
/* Management of current window manager */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue